これは日々の作業を通して学んだことや毎日の生活で気づいたことをを記録しておく備忘録である。
HTML ファイル生成日時: 2025/02/19 17:13:34.229 (台灣標準時)
NVMM と QEMU を使って NetBSD-10.1 (amd64) を動かす方法を記録しておくでござる。
qemu-img コマンドを使って virtual disk を準備するでござる。
# cd /vm # mkdir netbsd_04 # cd netbsd_04 # qemu-img create -f qcow2 netbsd_04.qcow2 128G Formatting 'netbsd_04.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=137438953472 lazy_refcounts=off refcount_bits=16 # ls -lF total 196 -rw-r--r-- 1 root wheel 198656 Feb 6 00:49 netbsd_04.qcow2 # chmod 600 netbsd_04.qcow2 # ls -lF netbsd_04.qcow2 -rw------- 1 root wheel 198656 Feb 6 00:49 netbsd_04.qcow2 # file netbsd_04.qcow2 netbsd_04.qcow2: QEMU QCOW Image (v3), 137438953472 bytes (v3), 137438953472 bytes
NetBSD-10.1 のインストール用のイメージファイルをダウンロードするでござる。
# wget http://nycdn.netbsd.org/pub/NetBSD-daily/netbsd-10-llvm/202502020850Z/images/NetBSD-10.1_STABLE-amd64.iso # ls -lF total 635428 -rw-r--r-- 1 daisuke wheel 650274816 Feb 2 22:48 NetBSD-10.1_STABLE-amd64.iso -rw-r--r-- 1 root wheel 198656 Feb 6 00:49 netbsd_04.qcow2
ゲスト OS が、通信できるように bridge を準備するでござる。
# /sbin/ifconfig tap3 create # /sbin/ifconfig tap3 up # /sbin/ifconfig tap3 descr "NetBSD VM 04" # /sbin/ifconfig bridge0 create # /sbin/ifconfig bridge0 up # /sbin/ifconfig bridge0 descr "Bridge for VMs" # /sbin/brconfig bridge0 add tap3 add wm0
tap と bridge ができたかどうか確認するでござる。
# ifconfig tap3 tap3: flags=0x8943
mtu 1500 ec_capabilities=0x5 ec_enabled=0x1 description: "NetBSD VM 04" address: f2:0b:a4:c1:10:d8 status: no carrier inet6 fe80::f00b:a4ff:fec1:10d8%tap3/64 flags 0x8 scopeid 0x6 # ifconfig bridge0 bridge0: flags=0x41 mtu 1500 description: "Bridge for VMs" status: active
以下のスクリプトを準備するでござる。
# cat netbsd_04_install.sh /usr/pkg/bin/qemu-system-x86_64 \ -accel nvmm \ -cpu max -smp cpus=1 -m 2G \ -display none \ -cdrom /vm/netbsd_04/NetBSD-10.1_STABLE-amd64.iso \ -drive file=/vm/netbsd_04/netbsd_04.qcow2,if=none,id=hd0,cache=directsync \ -device virtio-blk-pci,drive=hd0 \ -object rng-random,filename=/dev/urandom,id=viornd0 \ -device virtio-rng-pci,rng=viornd0 \ -netdev tap,id=tap3,ifname=tap3,script=no -device virtio-net-pci,netdev=tap3,mac=12:34:56:78:90:03 \ -spice addr=localhost,port=55903,ipv4=on,disable-ticketing=on,seamless-migration=on
上のスクリプトを実行するでござる。
# sh netbsd_04_install.sh
また、 spicy コマンドを使って SPICE でゲスト OS に接続するでござる。
% spicy -p 55903
そして、 spicy の表示する画面を見て、通常通りに NetBSD をインストール すればよいでござる。
![]() |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
インストールが完了したら、 halt して、仮想機械を止めるでござる。
ゲスト OS の起動のために、以下のようなスクリプトを作っておくでござる。
# cat netbsd_04_start.sh /usr/pkg/bin/qemu-system-x86_64 \ -accel nvmm \ -cpu max -smp cpus=2 -m 4G \ -display none \ -drive file=/vm/netbsd_04/netbsd_04.qcow2,if=none,id=hd0,cache=directsync \ -device virtio-blk-pci,drive=hd0 \ -object rng-random,filename=/dev/urandom,id=viornd0 \ -device virtio-rng-pci,rng=viornd0 \ -netdev tap,id=tap3,ifname=tap3,script=no -device virtio-net-pci,netdev=tap3,mac=52:54:00:ab:cd:ef \ -spice addr=localhost,port=55903,ipv4=on,disable-ticketing=on,seamless-migration=on -daemonize
スクリプトを実行するでござる。
# sh netbsd_04_start.sh
spicy コマンドを使って、起動した仮想機械を操作すればよいでござる。
% spicy -p 55903
![]() |
---|
![]() |