Skip to content

Instantly share code, notes, and snippets.

@0x4248
Last active July 20, 2023 14:02
Show Gist options
  • Save 0x4248/10bb33875cc690bb297279d5c8ad08e8 to your computer and use it in GitHub Desktop.
Save 0x4248/10bb33875cc690bb297279d5c8ad08e8 to your computer and use it in GitHub Desktop.
How to test Linux in qemu using busybox

Download linux

Download busybox

cd into linux

run:

make defconfig
make -j 24

Then cd to busybox run:

make defconfig
make
make install
mkdir -pv _install/{etc,proc,sys,dev}
sudo mknod -m 600 _install/dev/console c 5 1
sudo mknod -m 666 _install/dev/null c 1 3
sudo mknod -m 660 _install/dev/ram b 1 0
cd _install

Then create a init file

Then run:

find -print0 | cpio -0oH newc | gzip -9 > ~/initramfs.cpio.gz

Then cd to the linux folder

qemu-system-x86_64 -kernel arch/x86/boot/bzImage -initrd ~/initramfs.cpio.gz --append "root=/dev/ram init=/init console=ttyS0" -nographic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment