How to use floppy, CD-ROM and hard disk

You can use a floppy disk drive and an image file.

A real CD-ROM in a host machine can be used on a Windows 2000/XP host. It needs to convert a CD-ROM to image files to use it on a Windows 98/Me host.

When a program is running, you can change a floppy and a CD-ROM image by QEMU monitor. To see monitor, press left Ctrl, left Alt and 2 keys together(Ctrl-Alt-2). To go back to a guest OS, press Ctrl-Alt-1.

When the floppy or CD-ROM image file is in a space-separated path, please use MS-DOS file name path.
For example, C:\Documents and Settings\(your name)\My Documents\qemu\floppy.img is C:\DOCUME~1\(your name)\MYDOCU~1\QEMU\FLOPPY.IMG. It is not case-sensitive. You can see it by dir /x.

[DOS Prompt] dir /x

Please use slash instead of back slash in a QEMU Monitor.
C:\Documents and Settings\(your name)\My Documents ----> C:/DOCUME~1/(your name)/MYDOCU~1
C:\Program Files\Qemu ----> C:/PROGRA~1/QEMU

1. Floppy

You can boot from a floppy disk drive (A:) as follows.

[DOS Prompt] qemu.exe -L .\pc-bios -fda \\.\a: -boot a

You can also use -fda //./a: or -fda "\\.\a:" . Slash only can be used in rxvt.

NOTE: If an access is restricted by local security policy in control panel, you can't use it.

You can make image file from floppy disk on MSYS environment.

$ dd if=//./a: of=./floppy.img

If you use Cygwin, type:

$ dd if=/dev/fd0 of=./floppy.img

There are many converters. Please choose your favorite one.

2. CD-ROM

A real CD-ROM can be used on a Windows 2000/XP host. When a CD-ROM drive is D:, please use \\.\d: or //./d:.

[DOS Prompt] qemu.exe -L . -cdrom //./d:

It boots CD-ROM based OS like Morphix.

[DOS Prompt] qemu.exe -L . -hda win2k.img -cdrom //./d:

It is necessary to make iso image to use CD-ROM on a Windows 98/Me host. If you have a CD-R writing software, you can use it. If you don't have it, you can use mkisofs command in cdrtools. It is ported to Win32 and you can use it as on Linux. Download cdrtools-2.0-win32.bin.zip and put it in PATH directory. If CD-ROM drive is D: , to make cdimage.iso file:

$ mkisofs -r -l -J -o cdimage.iso D:\

Please note that it needs to make a bootable CD-ROM image if you want to boot from CD-ROM. It needs some tricks for each OS.

For Windows, please refer to Bart's site.

3. Hard disk

3.1 Hard disk image

When you use FAT32 file system for your host OS, max file size is 4Gbyte. If there is something wrong, please use dd for windows. You can make hard disk image which is 1500 MB as follows.

$ qemu-img.exe create harddisk.img 1500M

When your host OS is Windows 98/ME, the max size of harddisk image is 1999MB. When your host OS is Windows 2000/XP and use NTFS file system, you can use a file over 4GB.

$ qemu-img.exe create harddisk.img 6G

You can set a hard disk image type qcow which file size grows when it is necessary. You can save a hard disk volume.

$ qemu-img.exe create -f qcow harddisk.qcow 3G

Another tool
dd for windows
http://uranus.it.swin.edu.au/~jn/linux/rawwrite/dd.htm

3.2 Physical hard disk drive

If you have an administrative privilege, a hard disk drive can be used by \\.\PhysicalDriveN (N=0,1,2,...). You can also use slash like //./PhysicalDriveN. It is not case-sensitive. Windows 98/Me isn't supported.

C:\Program Files\Qemu> qemu.exe -L .\bios -hda win2k.img -hdb \\.\PhysicalDrive0
or
C:\Program FIles\Qemu> qemu.exe -L ./bios -hda win2k.img -hdb //./PhysicalDrive0

For example, if the guest OS is Linux, the second partition can be accessed by /dev/hdb2.
It is safe to use as a read-only. Making a file from guest OS to real hard disk isn't recognized immediately. Rebooting a host OS recognized the file. Making a directory from guest OS breaks a host's file system.

There is a case that changes of files in a host OS isn't recognized by a guest OS. Shut down the guest OS, move the file to another directory and boot the guest OS. Then the file is recognized.

Windows 98/Me doesn't recognize NTFS file system. When you use Windows XP on NTFS, Windows 98/Me guest can't see host files.

Please note that if you don't have a multi-boot environment, don't boot from your system hard disk.

C:\Program Files\Qemu> qemu.exe -L .\bios -hda \\.\PhysicalDrive0

It will break your host OS.

3.3 Virtual VFAT

Virtual VFAT enables to access a host directory as a hard disk. When you set fat: in front of a directory name, you can use it as the hard disk. When your directory is myfolder, an example is as follows.

$ qemu.exe -L ../pc-bios -hda win2k.img -hdb fat:myfolder

Note: Directory path doesn't work well on Windows. You can set a directory name which is in a directory the program starts. ("myfolder" must be in a directory the program starts.)
It is READ-ONLY. fatrw: prefix doesn't work now.
MS-DOS (Windows 98 boot floppy) can't see files in the directory.

3.4 Sharing files between Windows guest and Windows host

The easiest way to share files between Windows guest and Windows host is to use Windows file sharing.
For more information.

3.5 -snapshot option

If you start the program with -snapshot option, you can make a temporary file for hard disk image and write changes to it. The hard disk image is protected until you commit the changes. For example,

DOS> qemu.exe -L ../pc-bios -hda redhat.img -snapshot
The temporary file is made at C:\Documents and Settings\(your name)\Local Settings\Temp.
The hard disk image can be RAW format.

After you made some change to the hard disk, commit them like this in QEMU monitor.
(qemu) commit hda
If you do not commit the changes and exit the program, the changes will be lost.
If you use two hard disk images, temporary files are made each other.

3.6 Named snapshot

You can use a named temporary file without using -snapshot option.

At first, make the named temporary file by qemu-img.exe. For example, if you use RedHat Linux image, you make the named temporary file redhat-temp.qcow. A format is QCOW or QCOW2.

DOS> qemu-img.exe create -b redhat.img -f qcow redhat-tmp.qcow
After that, you set the temporary file as a hard disk and start QEMU.
DOS> qemu.exe -L ../pc-bios -hda redhat-temp.qcow
Then RedHat Linux will boot.

The changes you made are written to the temporary file so that the base file redhat.img is protected.
If you want to commit the changes to the hard disk, commit them in QEMU monitor.
(qemu) commit hda
A good point is that if you exit QEMU, the change you made is reserved in the temporary file. You can continue to work with it and you can commit them whenever you want.

3.7 VM snapshots

You can use VM snapshots with QCOW2 format on Linux and Windows host.

A combination of QCOW2 and savevm/loadvm enables to save multiple snapshots and restore them.

savevm and loadvm cannot be used with other format except for QCOW2 format.

At first, prepare a QCOW2 format hard disk image. For example, convert an existing image to QCOW2 format.

DOS> qemu-img.exe convert -f raw redhat.img -O qcow2 test.qcow2
Then start the program.
DOS> qemu.exe -L ../pc-bios -hda test.qcow2
Change to QEMU monitor by Ctrl-Alt-2 and save Virtual Machine state.
(qemu) savevm test
(qemu) info snapshots
ID TAG    VM SIZE    DATE                 VM CLOCK
1   test         4M      2006-09-01 12:00:00   00:00:01.000
Then go back to the guest OS by Ctrl-Alt-1 and make a file.
Guest OS$ echo test >test.txt
Guest OS$ ls
test.txt
Press Ctrl-Alt-2 and save VM state by savevm in QEMU monitor.
(qemu) savevm test2
(qemu) info snapshots
ID TAG    VM SIZE    DATE                 VM CLOCK
1   test         4M      2006-09-01 12:00:00   00:00:01.000
2   test2        5M      2006-09-01 12:01:00   00:00:02.000
The you can restore the state which is before you save the file or after you save it.
(qemu) loadvm test
or
(qemu) loadvm 1
You can delete the VM state by delvm.

If you forgot to name the VM state, you can set the state by number.

The guest OS can be started immedidately by -loadvm option.
DOS> qemu.exe -L ../pc-bios -hda test.qcow2 -loadvm test
loadvm/savevm saves a state which is the state of memory and a hard disk.

Note: if you don't save the state and loadvm the state, the changes you made are lost.
If you change the state after loadvm in the middle of the saved list, the state in hard disk will be branched.

4. Executing the program

Please put the floppy, the hard disk and the CD-ROM image in the same directory which has qemu.exe.

$ qemu.exe -L ./ -m 64 -boot a -fda floppy.img -hda harddisk.img -cdrom cdimage.iso

-L : bios location
-m : memory size (Mbyte)
-boot : boot device floppy(a), hard disk(c), CD-ROM(d)
-fda : floppy image
-hda : hard disk image
-cdrom : CD-ROM image

Double hyphen "--" is no more needed.

5. Changing a floppy and a CD-ROM image

To change a floppy and a CD-ROM image, please use QEMU Monitor. To see the Monitor, press Ctrl-Alt-2 keys together. To go back to the guest OS, press Ctrl-Alt-1 keys.

Please use slash instead of back slash in a QEMU Monitor.

For floppy,
(qemu) change fda filename.img
or
(qemu) change fda d:/tmp/yourfile.img

For CD-ROM,
(qemu) eject cdrom
(qemu) change cdrom filename.iso
or
(qemu) eject cdrom
(qemu) change cdrom d:/tmp/yourcdrom.iso

You can see a status of block device.

(qemu) info block


HOME