This is the first step that i learnt before two years when i learning OS. But inspite of seniors best effort to make us understand i think we understood only half. It was proved when we were trying to run bochs for our final year project. The task was to create the disk images and to install grub in the disk images to boot our kernel. We had a vague idea about the steps that we followed in our second year and finally figured out the right way and understood a lot. Some juniors were also asking us about how to run bochs for the first time. So thought of posting about it.
Creating disk images : The first step would be to create disk images. The utility available with bochs called as bximage can be used to reate disk images. Create a floppy disk image by specifying fd as the disk type and a hard disk image of size 10MB by specifying hd as the disk type while using bximage.
Partitioning the hard disk image : Then the harddisk should be partitioned. For this purpose we use some small linux distributions ike dlxlinux. Using bochs boot with dlxlinux image as the master disk nd the created disk image as the slave. Once dlxlinux is booted use fdisk to partition the slave disk as "fdisk /dev/hdb". Create a new partition and then create ext2 filesystem on the partition using the command mk2efs /dev/hdb1.
Copying the grub files into the disk image: After partitioning the disk image file we should copy the grub files into the image. To do this attach the image file as a loop device and then mount the loop device. These steps will require root previlege
losetup -o 32256 /dev/loop/0 diskimage
mount /dev/loop/0 /mnt/loop
cp /boot/ /mnt/loop/
cp kernel /mnt/loop/boot
Edit the menu.lst file to boot the kernel.
umount /mnt/loop
losetup -d /dev/loop/0
Installing grub in the disk image: After the grub files are copied the next step is to install grub on the hard disk image. This is where the floppy disk image we created earlier comes into use. Attach the floppy disk image as a loop device and use grub-floppy command tocreate bootable floppy disk image. The commands would look like
losetup /dev/loop/0 floppyimage
grub-floppy /dev/loop/0
losetup -d /dev/loop/0
Once the boot floppy image is created edit the bochsrc file to boot from the floppy with our hard disk image as the master disk. Now bochs boots the floppy disk image and u get the grub command prompt. Once the grub command prompt is obtained follow the long established steps of root (hd0,0) and setup (hd0) to install grub on the harddisk image. Now u can test ur own kernel using bochs. Bochs reads its configuration setting from the file bochsrc. This is the file that instructs bochs about the master disk or slave disk or disk to boot etc.
8 comments:
What is meant by bochs?
_____________________
Add your blog here to get more visitors
Check out these links to know what bochs is
http://en.wikipedia.org/wiki/Bochs
http://bochs.sourceforge.net
Great job done dear!!! Keep it up.
This page is very useful, thanx for it. But you can make it even more useful. Like mentioning which os you use to copy grub and where is grub-floppy command (its not present in dlxlinux and dlxlinux use lilo instead grub)
Hey i also like the graphics of your web-page.
ICE
ok...grub and grub-floppy can be found in any of the linux distribution. login as root in any of ur linux distribution and attach the floppy disk image as a loop device using losetup command and then use grub-floppy command to install grub on the loop device u attached. This would install grub on the floppy disk image u created. hope it is clear.
yes!!!
now this page seems to be complete.
nice job on this.
I dont seem to have grub-install present on my system (Fedora Core 6). I do have grub-install and grub but no grub-floppy. Googling produces thousands of matches for 'grub floppy disks' etc but nothing about the command. Any Idea where to get it?
Bochs is good, but i personally find VM to be a better virtual OS on linux (ubuntu). maybe cuz it's more gui. =)
Post a Comment