Support #933
Updated by Daniel Curtis over 6 years ago
This is a guide on virtualizing an ARM based operating system, in this case Arch Linux ARM, on an x86_64 Arch Linux system.
h2. Prepare the environment
* Make sure the system is up to date:
<pre>
pacman -Syu
</pre>
* Install a few dependencies:
<pre>
pacman -S git base-devel
</pre>
h2. Install Arch Linux ARM
* Create a 4GB image and mount it to @~/alarm/root@:
<pre>
mkdir -p ~/alarm/root && cd ~/alarm
dd if=/dev/zero of=./alarm.img bs=8M count=512
mkfs.ext4 alarm.img
sudo mount alarm.img root
</pre>
* Download and install alarm into the image:
<pre>
wget http://archlinuxarm.org/os/ArchLinuxARM-armv7-latest.tar.gz
sudo bsdtar -xpf ArchLinuxARM-armv7-latest.tar.gz -C ./root
sync
</pre>
* Remove the getty systemd unit link to prevent the console from locking up:
<pre>
sudo rm root/etc/systemd/system/getty.target.wants/getty@tty1.service
</pre>
* Copy the kernel and device tree blob out of the image:
<pre>
cp ./root/boot/zImage ./zImage_alarm
cp ./root/boot/dtbs/vexpress-v2p-ca9.dtb ./
</pre>
* Unmount the image so it can be booted from:
<pre>
sudo umount root
</pre>
* With the kernel and rootfs ready, start the VM:
<pre>
qemu-system-arm \
-M vexpress-a9 \
-smp 2 \
-m 1G \
-dtb vexpress-v2p-ca9.dtb \
-kernel zImage_alarm \
-append "root=/dev/mmcblk0 rw roottype=ext4 console=ttyAMA0" \
-drive if=sd,driver=raw,cache=writeback,file=./alarm.img \
-redir tcp:2222::22 \
--nographic
</pre>
* Now log in as *root* with the password *root*.
* The host system also redirects ssh requests on *2222* to the virtualized arch linux arm install.
h2. Resources
* https://medicineyeh.wordpress.com/2016/03/29/buildup-your-arm-image-for-qemu/
* https://wiki.archlinux.org/index.php/QEMU
* https://qemu.weilnetz.de/doc/qemu-doc.html