Alpine
, Virtual Machine
, QEMU
, bootstrap
, aarch64
$ dd if=/dev/zero of=~/qemu-images/simple-alpine.img bs=8M count=16
16+0 records in
16+0 records out
134217728 bytes (134 MB, 128 MiB) copied, 0.086382 s, 1.6 GB/s
$ fdisk -l ~/qemu-images/simple-alpine.img
Disk /home/zack/qemu-images/simple-alpine.img: 128 MiB, 134217728 bytes, 262144 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x7ac31012
Device Boot Start End Sectors Size Id Type
/home/zack/qemu-images/simple-alpine.img1 * 2048 206847 204800 100M b W95 FAT32
/home/zack/qemu-images/simple-alpine.img2 206848 262143 55296 27M 83 Linux
$ mkfs.vfat -v --offset=2048 ~/qemu-images/simple-alpine.img $((100*1024*1024/1024))
$ mkfs.ext4 -E offset=$((512*206848)) ~/qemu-images/simple-alpine.img
Download the NETBOOT image from Alpine's download. And, decompress it.
Here is another place to download https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/aarch64/netboot/
$ qemu-system-aarch64 \
-smp 2 \
-M virt \
-cpu cortex-a57 \
-m 1G \
-kernel ~/alpine-image/temp/boot/vmlinuz-lts \
-initrd ~/alpine-image/temp/boot/initramfs-lts \
--append "console=ttyAMA0 ip=dhcp alpine_repo=http://dl-cdn.alpinelinux.org/alpine/latest-stable/main/ modloop=http://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/aarch64/netboot/modloop-lts" \
-hda ~/qemu-images/simple-alpine.img \
-serial stdio
# mount -t ext4 /dev/vda2 /mnt/
/mnt/
# apk add apk-tools-static
# apk.static
--arch $(uname -m) \
-X http://dl-cdn.alpinelinux.org/alpine/latest-stable/main/ \
-U \
--allow-untrusted \
--root /mnt/ \
--initdb add alpine-base
ttyAMA0::respawn:/sbin/getty -L 0 ttyAMA0 vt100
into /mnt/etc/inittab
to get the VM's serial tty/etc/fstab
# cat /mnt/etc/fstab
/dev/vda2 / ext4 rw,relatime 0 0
/dev/vda1 /boot vfat rw,relatime 0 0
# mkdir /mnt/boot
ββββ# cat /mnt/etc/network/interfaces
ββββauto eth0
ββββiface eth0 inet dhcp
ββββ# echo "alpine-arm64" > /mnt/etc/hostname
ββββ# chroot /mnt/
ββββ# rc-update add networking
$ qemu-system-aarch64 \
-smp 2 \
-M virt \
-cpu cortex-a57 \
-m 1G \
-kernel ~/linux-stable/arch/arm64/boot/Image \
--append "console=ttyAMA0 root=/dev/vda2 rw rootfstype=ext4" \
-hda ~/qemu-images/simple-alpine.img \
-serial stdio