VMware Communities
SethWilsonMD
Contributor
Contributor

My experience using dd to create vmdk ("convert" dd to vmdk)

I am switching to a new laptop. My old laptop has an 80GB hard drive with Microsoft Windows XP Pro SP3 installed. I have Ubuntu 10.04 LTS installed on a USB drive. The USB drive has a Linux partition and a FAT32 partition. I booted the laptop using the USB drive, opened up a terminal window, cd to the directory on the FAT32 partition where I wanted the image files stored, and then issued these commands:

$ su

# dd if=/dev/sda | split -a 3 -b 1G -d - wilsons_laptop_

I used View / Device information in GParted to display the drive geometry (Heads: 255; Sectors/track: 63; Cylinders: 9729; Total sectors: 156296385).

I installed VMWare Player on my new laptop. I used it to create a new virtual machine called wilsons_laptop (install OS later, Microsoft Windows XP Professional, 2GB max drive size, split into multiple files). I copied the dd files to the folder it created and renamed them to have a ".dd" extension (not necessary, just my preference). Then I made the following changes to the wilsons_laptop.vmdk disk descriptor file:

1. Changed createType="twoGbMaxExtentSparse" to createType="twoGbMaxExtentFlat" under #Disk DescriptorFile

2. Commented out the existing SPARSE entries and added entries under # Extent description for all of the .dd files (be sure to include the 0 offset value at the end of the line--it is not present on SPARSE entries but it is required for FLAT entries):

RW 2097152 FLAT "wilsons_laptop_000.dd" 0
RW 2097152 FLAT "wilsons_laptop_001.dd" 0
RW 2097152 FLAT "wilsons_laptop_002.dd" 0

[etc.]

RW 2097152 FLAT "wilsons_laptop_072.dd" 0
RW 2097152 FLAT "wilsons_laptop_073.dd" 0
RW 1107137 FLAT "wilsons_laptop_074.dd" 0

3. I changed the value of the drive geometry options to match the geometry of the laptop hard drive:

ddb.geometry.cylinders = "9729"
ddb.geometry.heads = "255"
ddb.geometry.sectors = "63"

I booted into Safe Mode to start, but never ran into any trouble starting up the virtual machine at all. I installed the VMWare Tools as prompted. Everything seems to be working fine. VMWare is a great application.

The only problem I had was that originally I forgot to include the 0 at the end of the extent entries. This caused VMWare Player to report the error "Error while powering on: The file specified is not a virtual disk."

I found a description of the vdmk entries (VMWare Virtual Disks Virtual Disk Format 1.1) here:

http://www.vmware.com/app/vmdk/?src=vmdk

0 Kudos
3 Replies
vfalcao
Contributor
Contributor

SethWilsonMD,

your post was great !

I almost solved my problem. I'd like to know how to clone a single partition, say, /dev/sda2, instead of the whole disk ( /dev/sda ).

Is that possible ?

0 Kudos
WoodyZ
Immortal
Immortal

I'd like to know how to clone a single partition, say, /dev/sda2, instead of the whole disk ( /dev/sda ).

Is that possible ?

Of course you can image just a given partition.  Just specify the partition as in, if=/dev/sda(n)  where "(n)" is the partition as in: if=/dev/sda1

0 Kudos
SethWilsonMD
Contributor
Contributor

Make a backup now.

I think so, but you are not going to be able to just copy a bootable partition and have it start right up. For starters, you are going to need the boot sector, or at least a boot sector. Once you have the boot sector, then you are going to need to change the partition information in the boot sector to match the drive architecture you are trying to create. You are probably going to have to do some math to determine the right number of cylinders, sectors, and heads. You might also need more than just the boot sector to have things line up correctly, i.e. some empty space between the boot sector and the first partition.

I plan . . . eventually . . . to delete information I do not need off of my single partition, defragment the drive, use a partition tool of some kind to shrink the partition (I had one partition that took up the entire disk), and then change the vmware architecture and knock a big chunk off the end of the drive. The OS (Windows XP) might freak out if a 80GB hard drive suddenly becomes a 30GB drive, but I doubt I will have much of a problem with VMware.

Now, make a backup.

Good luck!

0 Kudos