GNS3 Micro Core Linux (Tiny Core Linux 13.0) 的 qcow2
問題所在
- 在 GNS3 VPCS 的 MAC address 起始值是固定的,如果有兩個 GNS3 在同一個 LAN 環境下,在 VPCS 互通的情況下,會有問題。
- There is a serious bug in Tiny Core Linux 12.0, the traceroute program does not work as expected. The bug has been resolved in Tiny Core Linux 13.0. [updated:2/5/2022]
前置準備
- Go to Tiny Core Linux website (http://tinycorelinux.net/downloads.html) download Core x86 Release Files Core-13.1.iso, or click Other Ports (http://tinycorelinux.net/ports.html) to download CorePure64-13.1.iso
- 至 QEMU website (https://www.qemu.org/download/#windows)下載 Windows 64bit 安裝檔 qemu-w64-setup-20220831.exe
- 執行安裝檔
- 將安裝後路徑加入使用者環境變數 PATH
產生 qcow2 on Windows 10
A. 利用 QEMU (on Windows 10)產生qcow2
- 產生 Micro Core Linux qcow2 檔案
qemu-img create -f qcow2 Core-13.qcow2 128M
qemu-img create -f qcow2 Core64-13.qcow2 128M - 將Micro Core Linux載入qcow2影像檔並開機
qemu-system-i386 -hda Core-13.qcow2 -cdrom Core-13.1.iso -boot d -m 128
qemu-system-x86_64 -hda Core64-13.qcow2 -cdrom CorePure64-13.1.iso -boot d -m 256 - 執行從iso安裝Micro Core Linux至影像檔
- 測試產生的qcow2影像檔
qemu-system-i386 -hda Core-13.qcow2 -m 128
qemu-system-x86_64 -hda Core64-13.qcow2 -m 128
B-1. 利用Vriturlbox (on Window 10)產生vdi
- 新增虛擬機
類型: Linux
版本: Linux 2.6/3.x/4.x (32/64-bit)
記憶體: 128MB
立即建立虛擬機
檔案位置: Core64-13.vdi
檔案大小: 64MB
硬碟類型: VDI
動態分配
建立 - 設定虛機
儲存裝置:加入光碟影像檔CorePure64-13.0.iso,並調整Core-13.vdi至IDE - 執行從iso安裝Micro Core Linux至影像檔
- 測試產生的Core64-13.vdi
設定虛機: 移除光碟影像檔
開啟虛機,正常運作後,關閉虛機
B-2. 利用qemu-img將vdi轉換為qcow2
- qemu-img convert -f vdi -O qcow2 Core64-13.dvi Core64-13.qcow2
從iso安裝Micro Core Linux至影像檔
- Micro Core Linux開機後下載安裝程式
tce-load -wic tc-install - 執行安裝程式
sudo tc-install.sh
boot from [C]drom: c
Install type [F]rugal: f
Target 1. Whole Disk: 1
Disk for corepure64 2.sda: 2
Install a bootloader: y
Install Extensions:
Formatting Option 3.ext4: 3
Boot options:
Continue: y - 安裝完畢後關機
sudo halt
將Console轉導至serial port (ttyS0)
因GNS3使用serial來連接VM,必須讓Micro Core Linux將console轉導至serial port
A. Method 1
修改/opt/bootsync.sh加入/sbin/getty 38400 ttyS0
sudo vi /opt/bootsync.sh
---
/usr/bin/sethostname box
/sbin/getty 38400 ttyS0 &
/opt/bootlocal.sh &
---
filetool.sh -b
完成Micro Core Linux的qcow2影像檔
B. Method 2
修改extlinux.conf,設定開機訊息顯示在serial console,在首行加入SERIAL 0 38400,並在末行尾加入console=ttyS0,38400
cd /mnt/sda1/tce/boot/extlinux
vi extlinux.conf---SERIAL 0 38400DEFAULT coreLABEL coreKERNEL /tce/boot/vmlinuzINITRD /tce/boot/core.gzAPPEND quiet waitusb=5:UUID="..." tce=UUID="..." console=ttyS0,38400 tz=GMT+8 nodhcp---
設定可從serial console登入,需修改/mnt/sda1/tce/boot/core.gz (corepure64.gz) 中的etc/inittab及etc/security
在etc/inittab
加入自動登入serial console
ttyS0::respawn:/sbin/getty -nl /sbin/autologin 38400 ttyS0
修改自動登入
tty1::respawn:/sbin/getty -nl /sbin/autologin 38400 tty1
為人工登入 (tc)
tty1::respawn:/sbin/getty -L 38400 tty1
加入自動登入serial console
ttyS0::respawn:/sbin/getty -nl /sbin/autologin 38400 ttyS0
修改自動登入
tty1::respawn:/sbin/getty -nl /sbin/autologin 38400 tty1
為人工登入 (tc)
tty1::respawn:/sbin/getty -L 38400 tty1
cd /optmkdir tmpcd tmpzcat /mnt/sda1/tce/boot/core.gz | sudo cpio -i -H newc -dvi etc/inittab---自動登入serial console,人工登入tty console (tc)---# /sbin/getty respawn shell invocations for selected ttys.ttyS0::respawn:/sbin/getty -nl /sbin/autologin 38400 ttyS0tty1::respawn:/sbin/getty -L 38400 tty1---
修改etc/security,將 # ttyS0 行首的註解去除,允許serial登入console
vi etc/securetty---# For people with serial port consolesttyS0---
刪除 core.gz (corepure64.gz),並以重新打包的 core.gz (corepure64.gz)替代
rm /mnt/sda1/tce/boot/core.gzfind|sudo cpio -o -H newc | gzip -2 > /mnt/sda1/tce/boot/core.gz
關機即可得到qcow2影像檔
虛機使用serial連線console
使用QEMU
qemu-system-i386 "Core-13.qcow2" -m 128 -serial telnet:localhost:12345,server,nowait
qemu-system-x86_64 "Core64-13.qcow2" -m 128 -serial telnet:localhost:12345,server,nowait
qemu-system-x86_64 "Core64-13.qcow2" -m 128 -serial telnet:localhost:12345,server,nowait
使用VirtualBox
虛機設定->序列埠->序列埠1->啟用序列埠
連接埠模式: TCP
連線到現有管線端/通訊埠: 不勾選
路徑/位址: 12345 (輸入通訊部號碼)
連線serial console
啟用虛機後,即可使用 telnet localhost:12345連接serail console
QEMU模擬器無法輸入非小寫字母的解決方式
請使用左方的shift鍵。(右方shift無效)
如果qemu中無法使用shift key,則可利用qemu monitor (用Ctrl+Alt+2切換)搭配sendkey來送出非小寫英文字母
- sendkey shift-S
- sendkey esc
- sendkey shift-semicolon
- sendkey shift-1
沒有留言:
張貼留言