This presentation demonstrates the process to create a new Qemu usable virtual disk capable of self boot using the popular Grub boot loader. Grub in turn can boot other kernels placed on the disk file system. The steps are applicable only for a GNU/Linux System. All tools used are readily available on all popular linux distros in use.
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Installing grub on virtual hard disk images
1. Installing grub on virtual hard disks Sukhvinder Singh http://www.linkedin.com/in/s0001 sukh.chauhan@gmail.com 30 Aug 2010
2. Steps This presentation demonstrates the process to create a new Qemu usable virtual disk capable of self boot using the popular Grub boot loader. Grub in turn can boot other kernels placed on the disk file system. The steps are applicable only for a GNU/Linux System. All tools used are readily available on all popular linuxdistros in use. To demonstrate we’ll take ubuntu-desktop as the reference test platform.
3. Create a disk image Create a disk image. You may create a file named disk.img, containing 40320 blocks ( a block has a standard size of 512 bytes). This results in a disk image of size 20643840 bytes ( = 21 MB). The size used is only for demonstration purposes. You may use a different size based on your requirement. 40320 blocks x 512 bytes/block = 20643840 bytes (21 MB) $ dd if=/dev/zero of=disk.img count=40320 40320+0 records in 40320+0 records out 20643840 bytes (21 MB) copied, 0.175132 s, 118 MB/s
4. Create a partition on the disk image Expert command (m for help): m Command action b move beginning of data in a partition c change number of cylinders (=40) d print the raw data in the partition table e list extended partitions f fix partition order g create an IRIX (SGI) partition table h change number of heads (=16) i change the disk identifier m print this menu p print the partition table q quit without saving changes r return to main menu s change number of sectors/track (=63) v verify the partition table w write table to disk and exit Use fdisk to create a partition on the disk image. Set CHS (Cylinder-Head-Sectors) geometry of the disk Create a primary partition Set the OS identifier for the partition to 83 (Linux) Calculate CHS: The number of sectors in a cylinder is fixed to 63 ( a popular constant ), S = 63 Taking heads to an arbitrary value of 16, H=16 (another popular constant) C * H * S = Number of blocks = 40320 C * 16 * 63 = 40320 C = 40 ; H = 16 ; S = 63
5.
6. Create a file system Format the disk and create an ext2 filesystem on the image $ mkfs.ext2 /dev/loop0 Mount the image Mount the disk image to a directory on the local filesystem $ mount /dev/loop0 /mnt Detach the loopback device $ losetup –d /dev/loop0
9. Boot using Qemu The following command will bring up the Qemu window and boot from the new disk.img. $ qemu –hda disk.img –m 128 The grub boot code on the disk.img boots to stage2 and brings up a grub command prompt. grub > If you have placed a multiboot specification compliant kernel (for ex. linux kernel 2.6.* ) on the disk.img filesystem under /boot directory, the following command will bring up the kernel. grub> kernel /boot/kernel.bin grub> boot
10. For more information, contact:Sukhvinder Singhhttp://www.linkedin.com/in/s0001sukh.chauhan@gmail.com