2022年1月9日 星期日

GNS3 Micro Core Linux (Tiny Core Linux) qcow2

GNS3 Micro Core Linux (Tiny Core Linux 13.0) 的 qcow2

問題所在

  1. 在 GNS3 VPCS 的 MAC address 起始值是固定的,如果有兩個 GNS3 在同一個 LAN 環境下,在 VPCS 互通的情況下,會有問題。
  2. 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]

前置準備

  1. 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
  2. 至 QEMU website (https://www.qemu.org/download/#windows)下載 Windows 64bit 安裝檔 qemu-w64-setup-20220831.exe
  3. 執行安裝檔
  4. 將安裝後路徑加入使用者環境變數 PATH

產生 qcow2 on Windows 10

A. 利用 QEMU (on Windows 10)產生qcow2

  1. 產生 Micro Core Linux qcow2 檔案
    qemu-img create -f qcow2 Core-13.qcow2 128M
    qemu-img create -f qcow2 Core64-13.qcow2 128M
  2. 將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
  3. 執行從iso安裝Micro Core Linux至影像檔
  4. 測試產生的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

  1. 新增虛擬機
    類型: Linux
    版本: Linux 2.6/3.x/4.x (32/64-bit)
    記憶體: 128MB
    立即建立虛擬機
    檔案位置: Core64-13.vdi
    檔案大小: 64MB
    硬碟類型: VDI
    動態分配
    建立
  2. 設定虛機
    儲存裝置:加入光碟影像檔CorePure64-13.0.iso,並調整Core-13.vdi至IDE
  3. 執行從iso安裝Micro Core Linux至影像檔
  4. 測試產生的Core64-13.vdi
    設定虛機: 移除光碟影像檔
    開啟虛機,正常運作後,關閉虛機

B-2. 利用qemu-img將vdi轉換為qcow2

  1. qemu-img convert -f vdi -O qcow2 Core64-13.dvi Core64-13.qcow2

從iso安裝Micro Core Linux至影像檔

  1. Micro Core Linux開機後下載安裝程式
    tce-load -wic tc-install
  2. 執行安裝程式
    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
  3. 安裝完畢後關機
    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 38400
DEFAULT core
LABEL core
KERNEL /tce/boot/vmlinuz
INITRD /tce/boot/core.gz
APPEND 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

cd /opt
mkdir tmp
cd tmp
zcat /mnt/sda1/tce/boot/core.gz | sudo cpio -i -H newc -d
vi etc/inittab
---自動登入serial console,人工登入tty console (tc)---
# /sbin/getty respawn shell invocations for selected ttys.
ttyS0::respawn:/sbin/getty -nl /sbin/autologin 38400 ttyS0
tty1::respawn:/sbin/getty -L 38400 tty1
---

修改etc/security,將 # ttyS0 行首的註解去除,允許serial登入console

vi etc/securetty
---
# For people with serial port consoles
ttyS0
---

刪除 core.gz (corepure64.gz),並以重新打包的 core.gz (corepure64.gz)替代

rm /mnt/sda1/tce/boot/core.gz
find|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

使用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

2022年1月5日 星期三

Microsoft Automatic Update trusted CTL

 Microsoft Automatic Update URL for trusted CTL

  1. The computer requires HTTP (TCP port 80) access and name resolution (TCP and UDP port 53) ability to contact ctldl.windowsupdate.com.
  2. Currently all the downloaded files require approximately 1.5 MB of space.