Grub4dos Guide - Experimenting with Grub4dos


To test installing and using Grub4dos without risking any damage to your current operating system, use a Virtual Machine. With the widespread availability of hardware virtualising software, it's a relatively straightforward process to create a hard disk image for testing.

For those comfortable with command line tools, QEMU is a freeware machine emulator ported to Windows. QEMU does not need to be installed and can be used as a portable application - simply unzip the contents of the download to a location of your choice and run from a command prompt. Alternatively use the GUI version - QEMU Manager.

Alternatives to QEMU include -

If enough free hard disk space is available, large image files can be used and the disk image can be partitioned and set up for multibooting.


QEMU Walkthrough - Installing Windows XP

NOTES

Creating a Disk Image

qemu-img.exe help output (from command qemu-img.exe -h)

To create a raw disk image, open a command prompt in the same directory as QEMU and use the following syntax qemu-img.exe create [filename] [size].

To create a 3GB image file (XP.ima) at the root of the C: drive - enter the command
qemu-img.exe create C:/XP.ima 3G

Installing the Guest Operating System

qemu.exe help output (from command qemu.exe -h).

Assuming your CD drive is mounted as "D:", insert the Windows Installation CD into your drive and use the following command to boot from it (change D: to reflect your own CD drive letter if required) -
qemu.exe -L . -m 256 -boot d -cdrom D: -hda C:\XP.ima.

QEMU should boot from the install CD. The disk image can be partitioned and formatted during the XP installation - QEMU is slow in comparison to some of the other software listed above, so the install may take some time.

Once the operating system has been installed, the Guest OS can be started using the following command -
qemu.exe -L . -m 256 -boot c -hda C:\XP.ima.

Sharing Files With The Guest Operating System

Once the guest operating system has been installed, we will need to find a way to share files with it. There are a number of methods for doing so, some are easier to set up than others.

It is also possible to create a network share on the Host OS, and connect to it from the Guest OS, however this is beyond the scope of this guide.


Mount a CD (or CD Image)

Mounting a physical CD drive was covered earlier - simply use the syntax -cdrom [drive:] (where [drive:] is letter allocated to the device).

Alternatively, create a CD image file (.iso) and mount it using the syntax -cdrom [file] (where [file] is the image filename with path - remember to use a forward slash / for the path). To create an .iso image, download the command line tool mkisofs from here. The following is a simple method of using mkisofs -

Now use the command qemu.exe -L . -m 256 -boot c -hda C:\XP.ima -cdrom C:\xp.iso when starting the Guest OS, and all files will be available on the Guest OS CD-ROM drive.


Mount The Guest OS Disk Image

It is possible to mount a disk image on the Host operating system using various tools. To use ImDisk (freeware tool available here), download and install the ImDisk package. Now right click on the image file you want to mount (e.g. C:\XP.ima) and choose option Mount as ImDisk Virtual Disk - this will open a "Mount new virtual disk" window.

As we are mounting a hard disk type image with MBR, we will need to use a file offset. Enter 63 and check Blocks option to mount the first partition on the hard disk image created earlier. You will need to calculate the offset for any other partitions within the image manually. Please note - different disk image formats such as .vmdk might use a different offset value for the first partition.

Select a drive letter (this will be the mount point for the disk image) - the default will be the first available drive. All other options can be left at their default values. When you have finished, click on OK. Open Explorer, the disk should now be mounted as the drive letter selected earlier. If, after installing the operating system, you are prompted to format the disk when accessing it in explorer on the Host OS, then you have used an incorrect offset value for ImDisk.


Mount a Physical Hard Disk

Following is from section 3.6.5.2 of qemu-doc.html -

"Hard disks can be used with the syntax: `\\.\PhysicalDriveN' where N is the drive number (0 is the first hard disk).

WARNING: unless you know what you do, it is better to only make READ-ONLY accesses to the hard disk otherwise you may corrupt your host data (use the `-snapshot' command line so that the modifications are written in a temporary file)."

To use the first hard disk (physical disk (hd0) in grub4dos terms), use command
qemu.exe -L . -m 256 -boot c -hda C:\XP.ima -hdb \\.\PhysicalDrive0 when starting the Guest OS. Please note that backslashes (e.g. \\.\PhysicalDrive0) were used in testing, as recommended in qemu-doc.html. Other sources suggest that forward slashes should be used - e.g. //./PhysicalDrive0. It is not possible to mount individual partitions - only the whole of a hard disk.

During testing a USB flash drive was mounted using the command qemu.exe -L . -m 256 -boot c -hda C:\XP.ima -hdb \\.\PhysicalDrive1. The drive was mounted as a local disk on the Guest OS. Files copied to the drive from the Guest OS were not displayed in Explorer on the Host system until the disk was removed and remounted.