QEMUを利用してx86_64上でubuntu-arm64を動作にチャレンジ
1.概要
ubuntuにはARM64の配布も実施されています。PCはx86_64のCPU搭載機器しか持っていないのでARM64は全く見向きもしていませんでした。しかし、QEMUを利用してx86_64上でubuntu-arm64を動作できると知って、調べてみました。この内容を記述します。
2.詳細
参考資料に沿って作業をします。
実行環境はubuntu-20.04.6で、CPUはAMDの4core、Memory 16GBです。
(a) Install QEMU
(b) Create necessary support files
(c) Fetch the Ubuntu cloud image
(d) Run an emulated ARM64 VM on x86
(e) login
(a) Install QEMU
sudo apt install qemu-system-arm
(b) Create necessary support files
truncate -s 64m varstore.img
truncate -s 64m efi.img
dd if=/usr/share/qemu-efi-aarch64/QEMU_EFI.fd of=efi.img conv=notrunc
(c) Fetch the Ubuntu cloud image
https://cloud-images.ubuntu.com/focal/current/
から下記imgファイルをdownloadします
focal-server-cloudimg-arm64.img
(d) Run an emulated ARM64 VM on x86
sudo qemu-system-aarch64 \
-m 2048 \
-cpu max \
-M virt \
-nographic \
-drive if=pflash,format=raw,file=efi.img,readonly=on \
-drive if=pflash,format=raw,file=varstore.img \
-drive if=none,file=focal-server-cloudimg-arm64.img,id=hd0 \
-device virtio-blk-device,drive=hd0 \
-netdev type=tap,id=net0 \
-device virtio-net-device,netdev=net0
上記コマンドを実行するとubuntu-20.04-arm版を起動できます。
実行速度は遅いです。
login:と表示されますが、login手段がわかりません。
(e) login
参考資料を参照して、cloud-initの設定をします。
-drive if=none,file=cloud.img,id=clouds \
-device virtio-blk-device,drive=cloud
上記2行の追加では不十分でした。1行目を以下のように変えました。
-drive if=none,file=cloud.img,id=clouds,format=raw \
また、memoryを8GBに設定しました
以下の内容になります
sudo qemu-system-aarch64 \
-m 8192 \
-cpu max \
-M virt \
-nographic \
-drive if=pflash,format=raw,file=efi.img,readonly=on \
-drive if=pflash,format=raw,file=varstore.img \
-drive if=none,file=focal-server-cloudimg-arm64.img,id=hd0 \
-device virtio-blk-device,drive=hd0 \
-netdev type=tap,id=net0 \
-device virtio-net-device,netdev=net0 \
-drive if=none,file=cloud.img,id=clouds,format=raw \
-device virtio-blk-device,drive=cloud
また、ubuntu login: と表示されてもloginできません。
cloud-initの処理が終了するのを待つ必要があり、3分ほど待ってloginします。
終了方法はterminalを閉じました。
参考
[外部サイト参照]
・Boot ARM64 virtual machines on QEMU
・UbuntuARMの環境をQEMUでx86 Ubuntu上に用意する
コメント
コメントを投稿