Disk Cloning

From Game Research Wiki
Jump to navigation Jump to search

This is a tutorial on how to clone a hard drive.

Tools needed: Linux operating system or Bootable USB linux drive (such as SystemResuceCD)




Check the drive

You will need to check the drive to make sure it's in a state to clone. Check the SMART attributes of the drive to see if any bad sectors have been reported. Also check the file system to make sure there isn't any issues. Checking the file system isn't really required unless you are cloning to a drive that is smaller than the source.

Prepare the drive

If you are cloning to a smaller drive, you will need to shrink your main partition and possibly move partitions so all data is contained withing the boundaries of the new drive. Also make note of how much free space the source drive has. If used space on the partition is greater than the capacity of the drive you are cloning to, you will not be able to clone it. When resizing a partition, specifically a windows partition (NTFS), turn off any fast boot or hibernation settings on the computer before you start. Then test mounting the partition's file system in Linux to see if any errors/warnings come up. If you get a warning about the file system being in an unstable state, you will not be able to resize it until you address this by turning off hibernation (cmd.exe with admin, "powercfg /off") and do a full shutdown of the computer (cmd.exe "shutdown /s /f /t 0"). Within gparted, resize the partition and then move all partitions toward the start of the drive. This could take some time.

Clone the drive

Using terminal, use the following command to start cloning:

dd if=/dev/sdX of=/dev/sdX bs=8096 conv=sync,noerror status=progress

This will clone the drive, sector-by-sector. You may specifiy the amount of sectors you wish to copy but if not, it'll just copy until it it runs out of data to copy or hits the boundary of the target drive.

Make final adjustments

Unless you are cloning to an equal sized drive, you will need to fix the partition. This is mostly aimed at GPT partition layout drives which should be the most common layout now (this tutorial hasn't been updated to take into account older drives with a MBR partition layout). You will need to use gdisk in linux. Start by typing 'gdisk /dev/sdX" in terminal with sdX being replaced with whatever you target drive was. Type 'p' to print details of the disk, then 'v" to verify the disk and list any issues found. At this point, if you wanted to delete any partitions that are said to be located outside the disk boundary, such as if you had recovery partitions you don't want anymore that was at the end of the disk, use 'd' and specify the partition number to remove it. Then use 'p', and 'v' again. Then type 'w" to write changes to disk. The reason for this is that GPT keeps a backup of it's tables at the end of the disk and when you clone to a smaller disk, this will be missing so you typically won't be able to see the partitions till you fix this. Once the backup GPT is written to the disk, the cloning processes is done and drive is ready for use. You should be able to boot from the drive like normal with no boot issues.


if = input device

of = output device

bs = blocksize

count = number of sectors to be copied

conv = additional options sync = keeps LBA synced if unable to read (will fill with zeros on target drive for sector it was unable to read) noerror = will not stop on error

status = progress, shows how much data as been copied so far.


Tips---- (OLD)

When cloning a disk to a smaller device, such as from a HDD to SDD. You will need to fix up the GPT. First make sure partitions you want to move are smaller than target drive by shrinking the partitions. Then clone the drive enough so it keeps all data but might leave other partitions outside of disk boundaries. This is usually fine. If you want to keep all partitions, you will have to move the ones at the end closer to start of disk. This will also require those partitions to be moved to the end of the disk after the clone so you can expand the main partition.

Use gdisk /dev/sdX (X = drive letter in linux) Then P (for print) to print all partitions d follow partition number to delete any partitions that you don't want to keep that may be outside of the partition boundaries. v to verify partitions after all work as been done w to write changes to disk. This will fix the GPT primary table and backup table (at end of disk). This will work with Windows installs as well and should boot right into original OS unless bad sectors were hit.

If the disk is damaged or failing and you are cloning to a drive that is smaller, you will need to clone to a working drive of at least equal size first because resizing may fail in Linux. Windows might work but it's a risk.