1. Platform Virtualization
(i386)
for kernel booting, debugging and testing
Requirements
Linux machine (Virtual or Real)
Qemu, busybox, initramfs, kernel
packages : build-essential, libncurses5-dev, vnc4server
2. Installations
Qemu: is a generic and open source machine emulator and virtualizer.
http://wiki.qemu.org
Method 1:
Install a virtualbox virtual manager to run ubuntu 12.04 in windows 7. Then updated the ubuntu
packages , means the initial updates. Then installed qemu ,
# sudo apt-get install qemu
after installation check whether the qemu is installed correctly, run the command,
# qemu-system-i386
popup a black qemu windows shows some no disk found notification.
Fig 1 : Qemu window
3. Method 2:
Download the latest qemu source from http://wiki.qemu.org. Extract the source and install
# tar xf qemu-1.2.0.tar.bz2
# cd qemu-1.2.0.tar.bz2
# sudo ./configure --target-list=i386-softmmu
# sudo make
# sudo make install
Check the qemu working, run command
# qemu-system-i386
popup a black qemu windows shows some no disk found notification [Fig. 1].
Fig 2 : working qemu window of a custom kernel
4. Busybox: The Swiss Army Knife of Embedded Linux
http://busybox.net
Download latest busybox tar from the website and extract it.
#tar xf busybox-1.20.2.tar.bz2
#cd busybox-1.20.2
#make allnoconfig
#make menuconfig
Select appropriate options in menuconfig.
busybox settings -> build options -> static binary[essential]
coreutils -> enable cat, touch, chmod, chroot, cp, echo, ln, ls, mkdir, mknod,
pwd, rm, rmdir
console utils -> clear
editor -> vi
find -> find, grep
init -> poweroff, init [essential]
linux system utils -> mdev, mount[essential]
network utils -> ping, arp, httpd, ifconfig
shells -> ash, choose which shell is aliased to sh & bash name[essential]
save the configuration.
#make
#make install
make install command copies the binaries generated to _install directory.
5. initramfs: is a root filesystem which is embedded into the kernel and loaded at an early stage
of the boot process.
Create a main directory initramfs
#mkdir initramfs
#cd initramfs
Create a basic folder structure
#mkdir -pv bin lib dev etc mnt/root proc root sbin sys
Copy some default device nodes to device directory
#sudo cp -va /dev/{null,console,tty} dev
Now copy the busybox binaries in _install directory into initramfs.
#cd busybox-1.20.2
#sudo cp -avR _install/* ../initramfs
Fig 3 : busybox copy to initramfs
6. Create a init script in initramfs directory
#cd initramfs
#sudo gedit init
Fig 4: init script
Change the permission settings of init script to executable
#sudo chmod +x init
Fig 5 : initramfs folder structure
8. Kernel: Linux is a clone of the operating system Unix, written from scratch by Linus
Torvalds with assistance from a loosely-knit team of hackers across the Net.
http://www.kernel.org/
Download a stable kernel and untar it,
Fig 7 : Kernel.org
# tar xf linux-2.6.34.tar.bz2
# cd linux-2.6.34
# make allnoconfig
# make menuconfig
select appropriate options.
general setup -> initial RAM filesystem and RAM disk support
-> initramfs source [/home/premjith/linux_qemu/initramfs]
Bus options -> PCI support
ELF Format/Emulation -> Kernel support ELF binaries
Networking Support [y] -> Networking options
->packet socket
->unix domain socket
9. -> TCP/IP networking
Device drivers -> ATA
-> Network device support
File systems -> second extended FS support
-> ext3
Kernel hacking -> kernel debugging
-> compile the kernel with debug info
Fig 8 : kernel configuration
save the configuration and run make
# make
It generates a bzImage of kernel in arch/x86/boot/
10. Virtual booting of kernel image in Qemu
#qemu-system-i386 -kernel linux-2.6.34/arch/x86/boot/bzImage
Fig 9 : final qemu window