Testing and running the Kernel with QEMU is nice, it is faster for developing but it is not what we want. We want to run things in real hardware.
#mtools
echo "drive c: file="`pwd`/bootable.img" partition=1" > ~/.mtoolsrc
#create an image
dd if=/dev/zero of=bootable.img count=088704 bs=512
mpartition -I c:
mpartition -c -t 88 -h 16 -s 63 c:
mformat c:
mmd c:/boot
mmd c:/boot/grub
#copy grub bootloader
mcopy grub/grub-0.94-i386-pc/boot/grub/stage1 c:/boot/grub
mcopy grub/grub-0.94-i386-pc/boot/grub/stage2 c:/boot/grub
mcopy grub/grub-0.94-i386-pc/boot/grub/fat_stage1_5 c:/boot/grub
#grub
echo "(hd0) bootable.img" > bmap
printf "geometry (hd0) 88 16 63 n root (hd0,0) n setup (hd0)n" | /usr/sbin/grub --device-map=bmap --batch
#copy menu.lst to bootable.img
mcopy menu.lst c:/boot/grub/
mcopy kernel.bin c:/boot/grub/
We can test this image using qemu like this
qemu -hda bootable.img
Then, the image can be burned into a pendrive using ‘dd’ or ‘usb-imagewriter’
- sudo apt-get install usb-imagewriter (in order to install the GUI Tool)
- sudo dd if=bootable.img of=/dev/sdX (where sdX is the pendrive location into /dev)