Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save franzflasch/132139b8ba798066394e62b3f7532f7a to your computer and use it in GitHub Desktop.
Save franzflasch/132139b8ba798066394e62b3f7532f7a to your computer and use it in GitHub Desktop.
Howto qemu-arm with busybox linux and shared folder

Install dependencies

apt-get install gcc-arm-linux-gnueabihf qemu

Prepare work directory

mkdir qemu-arm-sandbox && cd qemu-arm-sandbox

Download and unzip linux

wget <link_to_kernel_tar_file> && tar xvf <linux_tar_file>

Download and unzip busybox

wget <link_to_busybox_tar_file> && tar xvf <busybox_tar_file>

Build linux kernel

cd <linux_dir>
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- defconfig

Now enter menuconfig and adapt kernel config file

add all 9p virtio related configs

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig

Build kernel

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j8

Build busybox

cd <busybox_dir>
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- defconfing

Adapt busybox config

Busybox Settings ==> Build Options SELECT Build BusyBox as a static binary(no shared libs)

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig

Build busybox

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- install

Prepare some files

cd _install
mkdir proc sys dev etc etc/init.d

Create etc/init.d/rcS file and enter the following shell code

#!/bin/sh
mount -t proc none /proc
mount -t sysfs none /sys
/sbin/mdev -s

Make the file executable

chmod +x etc/init.d/rcS  

create cpio rootfs

find . | cpio -o --format=newc > ../rootfs.img

Now you're ready to go:

cd back to qemu-arm-sandbox

qemu-system-arm -m 256 -M virt -kernel <linux_dir>/arch/arm/boot/zImage -initrd <busybox_dir>/rootfs.img -nographic -append "console=ttyAMA0 root=/dev/ram rdinit=/sbin/init" -virtfs local,path=<host_path_to_share>,security_model=passthrough,mount_tag=host_share

Now in the guest shell mount the shared folder

mkdir -p /mnt/host_share && mount -t 9p -o trans=virtio host_share /mnt/host_share -oversion=9p2000.L
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment