Some notes on how to clone a hard drive
October 2, 2017
Described below are some directions on cloning a bootable hard drive.
These directions worked for cloning a windows 7 boot drive to a blank hard drive.
The software tools required for this operation are:
Parted Magic 8.1 (bootable) (from 2013, this is a version of linux)
Bart's P.E. (bootable) (a version of windows XP)
For this example we used the following hard drives:
the source drive: 30 Gb hard drive containing windows 7
the target drive: 120 Gb blank SSD
First wipe, and format the target drive using Parted Magic (linux):
- with the PC turned off, attach the target drive.
- boot up using the Parted Magic bootable CD
- use the partition tool within Parted Magic to wipe the target drive, and format to: ntfs
- turn off the PC
Then attach the source drive and reboot into Parted Magic (linux). The PC should now have these attached as hard drives:
Leave the drives unmounted.
Use: Parted Magic Mount to make sure that the drives are unmounted.
To clone the drives and copy the contents from the source drive to the target drive
> dd if=/dev/sdb1 of=/dev/sda1 bs=4096 conv=sync,noerror &
if=/dev/sdb1 refers to the source drive, the data to be copied from.
of=/dev/sda1 refers to the target drive where data is to be written.
bs=4096 ... or ... bs=BYTES, read and write up to BYTES bytes at a time (default: 512),
conv=sync,noerror ... convert the file, and make sure it doesn't stop if it encounters any errors,
The dd command refers to the DD statement found in IBM's Job Control Language (JCL),
Accidentally reversing the input and output drives, that is, mistakenly setting the "if=" drive as the target,
Open a second xterm and find the process ID of the dd command (use top):
If, for example the PID of dd is:
dd pid = 4655
then issue the following command to the first xterm (the one running dd) to get output feedback from the dd command within the xterm:
> watch -n 10 kill -USR1 4655
The above will output the progress of the dd command every 10 seconds.
After the cloning procedure, the new hard drive will still need to have its master boot record fixed, the drive marked as bootable and its partition adjusted.
Continuing, turn off the PC, remove the old source drive (30 Gb, hard drive containing windows 7) then attach the cloned target drive (120 Gb, formerly blank hard drive now containing windows 7) as though it were to be the boot drive.
Then boot up using Bart's P.E. windows XP cd.
Within Bart's PE we will fix the master boot record (mbr) of the new drive. From here we'll call it the new C: boot drive.
Use the mbr tools from here: mbrfix.zip
Within Bart's P.E. desktop:
- open up A43 file management utility
- unzip the files from the mbrfix.zip, then copy them over to the new C: boot drive,
C:\temp\mbrfix_files Mbrfix.exe, and Mbrfix64.exe
- from within the A43 file management utility open up a DOS box:
>> tools >> OpenDOSwindow
- from: C:\temp\mbrfix_files run:
mbrfix /drive 0 listpartitions
mbrfix /drive 0 fixmbr /yes
mbrfix /drive 0 /partition 1 setactivepartition
Now we should see that the drive's Boot partition is set to YES:
mbrfix /drive 0 listpartitions
The new drive may fail to boot up:
- try to fix this with the windows 7 boot up DVD.
- then choose: Repair your computer
After cloning the drive and booting it up, ms' windows explorer may show a smaller size than what the drive actually should be. This can happen if the source drive is smaller than the target drive.
Use diskpart to extend the hard drive's space:
- open a DOS box and run:
- then from within the diskpart program issue these command:
> list volume (get a list with volume #, use this # in the next command).
The above should extend the drive's hard drive space to use its full capacity.