I am trying to run a custom Linux kernel version 2.6.26 on QEMU with a busybox for i386 target but it fails at the end of the kernel booting with these two messages:
No filesystem could mount root, tried: reiserfs ext3 ext2 msdos vfat iso9660
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(1,0)
I don't understand what i am skipping in my work to get into this but the steps i have made is as following:
I downloaded the Linux kernel source from the official site and build it with the following commands
make i386_defconfigmake CC="gcc" -j$(nproc)And I wrote a simple script to build a root file system for the kernel using busybox 1.24.1
The script:
mkdir -p rootfscurr_location=$(pwd)cd rootfsmkdir -p bin boot dev etc lib proc root \sbin media sys tmp var usr etc/init.d \usr/bin usr/sbin usr/libecho "#!/bin/sh"> etc/init.d/rcSecho "PATH=/sbin:/bin:/usr/sbin:/usr/bin">> etc/init.d/rcSecho "export PATH">> etc/init.d/rcSecho "/bin/mount -t proc proc /proc">> etc/init.d/rcSecho "/bin/mount -t sysfs sysfs /sys">> etc/init.d/rcSecho "/sbin/mdev -s">> etc/init.d/rcSecho "/bin/hostname yahiafarghaly">> etc/init.d/rcSecho "/bin/echo ''">> etc/init.d/rcSecho "/bin/echo 'init.d is called!'">> etc/init.d/rcSecho "/bin/echo ''">> etc/init.d/rcSchmod +x etc/init.d/rcStouch etc/group etc/passwd etc/shadow etc/profileecho "root:x:0:"> etc/groupecho "root:x:0:0:root:/root:/bin/sh"> etc/passwdecho "root::10:0:0:0:::"> etc/shadowecho "export PS1='Shell$'"> etc/profileecho "export USER=`id -un`">> etc/profileecho "export HISTSIZE=1000">> etc/profileecho "echo 'Hello Sh !'">> etc/profileecho "echo """>> etc/profilebusybox_ver=1.24.1cd ~/P0/linux_study/busybox/busybox-$busybox_vermake defconfigmake CONFIG_STATIC=y \ CONFIG_EXTRA_CFLAGS="-m32 -march=i386" \ CONFIG_EXTRA_LDFLAGS="-m32" \ CONFIG_PREFIX=$curr_location/rootfs \ CC="gcc" -j$(nproc) installcd $curr_location/rootfsfind -print0 | cpio -0oH newc | gzip -9 > ../rootfs.imgSo now, I have both the kernel and a file system image to have a fully boot to the linux shell.I have used the QEMU command as following:
qemu-system-i386 \ -kernel ./kernel/kernel_image_2.6.26 \ -nographic \ -append "root=/dev/ram init=/sbin/init console=ttyS0 nokaslr" \ -initrd rootfs.img \ -m 512 \ --enable-kvm \ -cpu hostI don't know why QEMU cannot recognize the inital ram disk file. What am i missing ?