科技新知

不知道大家最近有沒有在考慮使用國産OS,如果有,大家又是怎樣做初步測試的呢?

筆者之前一直都笨笨的從ISO開始安裝,所以每試不同的版本,都要從零開始。不但重複,OS安裝階段的複制過程也是很耗時的。但其實國産OS,大部份都有qcow2的格式,我們若只是本地測試的話,其實可以利用qcow2來做快速VM生成。

阿里aliyun

之前筆者有介紹過ubuntu的multipass,若你想試用的國産OS就是阿里aliyun,只要你有ubuntu,就可以快速跑起來。

但如果沒有ubuntu,只要有qemu(多平台),也是可以的。

qemu-system-x86_64  \\
  -cpu host -machine type=q35,accel=kvm -m 2048 \\
  -nographic \\
  -snapshot \\
  -netdev id=net00,type=user,hostfwd=tcp::2222-:22 \\
  -device virtio-net-pci,netdev=net00 \\
  -drive if=virtio,format=qcow2,file=aliyun_3_x64_20G_nocloud_alibase_20251215.qcow2 \\
  -drive if=virtio,format=raw,file=seed.img

上述指令中的qcow2和seed.img,階為官方網站可以下載的。預設帳號 alinux 密碼 aliyun。

seed.img是用於cloud-init的,就是初始化VM所用。第二次開機時,就不需要再使用seed.img

qemu-system-x86_64  \\
  -cpu host -machine type=q35,accel=kvm -m 2048 \\
  -nographic \\
  -snapshot \\
  -netdev id=net00,type=user,hostfwd=tcp::2222-:22 \\
  -device virtio-net-pci,netdev=net00 \\
  -drive if=virtio,format=qcow2,file=aliyun_3_x64_20G_nocloud_alibase_20251215.qcow2

華為OpenEuler

同樣地,我們也是用qemu可以跑起OpenEuler,只是它沒有seed.img(不支持cloud init),所以直接跑起就好。

qemu-system-x86_64  \\
  -cpu host -machine type=q35,accel=kvm -m 2048 \\
  -nographic \\
  -netdev id=net00,type=user,hostfwd=tcp::2222-:22 \\
  -device virtio-net-pci,netdev=net00 \\
  -drive if=virtio,format=qcow2,file=openEuler-24.03-LTS-SP3-x86_64.qcow2

預設帳號 root 密碼 openEuler12#$

第二次開機,指令也是一樣。

龙蜥AnolisOS

方式也一樣。

qemu-system-x86_64  \\
  -cpu host -machine type=q35,accel=kvm -m 2048 \\
  -nographic \\
  -netdev id=net00,type=user,hostfwd=tcp::2222-:22 \\
  -device virtio-net-pci,netdev=net00 \\
  -drive if=virtio,format=qcow2,file=AnolisOS-8.10-x86_64-ANCK.qcow2

預設帳號 anuser 密碼 anolisos

總結

如果只是要體驗一下國産OS,Qemu快速起VM就足夠。但Qemu本身只有NAT網絡,想要做VM之間的通訊,需要大量的學習成本。

馬交野