7.7 Using FTP service 7.9 Foreign Image Formats Including QEMU and VMware
Simics User's Guide  /  II Feature Overview  /  7 Moving Data in and out of the Simulation  / 

7.8 Importing a Real Disk into Simics

It is possible to create an image by copying data from a real disk. If the disk to be copied contains an operating system, you must have at least two operating systems on the machine, since the partition that should be copied should not be in use or mounted.

Before making a copy of a disk, some information about the disk should be gathered:

On Linux, these numbers can be obtained using the fdisk utility. You can choose to make a copy of the whole disk or just a partition of the disk using the dd utility. Example:

dd if=/dev/hdb of=hdb_disk.img


On Windows, you can use the System Information application to find the information under Components/Storage/Disks. You have to select the Advanced setting from the View menu. If you have Cygwin (http://www.cygwin.com) installed, you can use the dd utility to create the image, provided that the correct entries in the /dev file system are created. To access the first hard drive (/dev/hda):

mkdir -p /dev/hda
mount -s -b '\\.\PHYSICALDRIVE0' /dev/hda

You can also mount a specific drive letter:

mkdir -p /dev/fd0
mount -s -b '\\.\A:' /dev/fd0

or

mkdir -p /dev/hda1
mount -s -b '\\.\C:' /dev/hda1

Cygwin's mount program creates persistent mounts (they are stored in the registry), so you will only need to set these things up once. The -b option to mount ensures that no CR/LF conversions are made. See the Cygwin documentation for further details on how to use the mount command.

On Windows hosts without Cygwin, a third-party program can be used to create the disk images. See figure 1 for more details.

Note: To save space, you may want to compress the disk image using the craff utility. See section 7.2.8.
The next step is to prepare the target configuration so it can use the new disk. For x86 targets, the dredd machine has a $disk_files parameter that can be set to a list of files to use in the image object of the boot disk, and also $disk_size that specifies the size of that disk.
$disk_size = 1056964608
$disk_files = [["hdb_disk.img", "ro", 0, 1056964608, 0]]

For other machines, that do not have these parameters, attributes in the disk object and its corresponding image objects have to be set instead.

Make sure to set the $disk_size correctly to reflect the size of the disk that has been copied. If only a partition has been copied, the offset where the partition starts, and the size of the partition, should be set in the file list. If the whole disk has been copied, the offset is zero and the size should be the size of the whole disk. Several partitions can be combined to form the complete disk, as described in section 7.2.7.

For an x86 machine, the system component will automatically set the BIOS geometry for the C: disk. It can also be set manually:

simics> system_cmp0.cmos-hd C 1023 16 63

7.7 Using FTP service 7.9 Foreign Image Formats Including QEMU and VMware