INFORMATICS

The Best

creating a disk image

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 

Creating a Disk Image

One of the way to clone a drive is to create a disk image that you can move around and restore as you would do with a bootable USB.

Creating image files allows you to save multiple backups to a single destination, such as a large portable hard drive. Again, this process only requires one command:

dd if=/dev/sdX of=path/to/your-backup.img

To save space, you can have dd compress your backup.

dd if=/dev/sdX | gzip -c > path/to/your-backup.img.gz



Restoring a Drive With dd

First command:

dd if=/dev/sdY of=/dev/sdX

When restoring from an image file, the same concept applies:

dd if=path/to/your-backup.img of=/dev/sdX

If your image file is compressed, then things get a little different. Use this command instead:

gunzip -c /path/to/your-backup.img.gz | dd of=/dev/sdX

To be clear, gunzip is "g unzip," as in the opposite of "g zip." This command decompresses your backup. Then dd replaces the existing drive with this image.

 

Parameters to Consider

You can alter your command by sticking a parameter at the end. By default, dd can take a while to transfer data. You can speed up the process by increasing the block size. Do so by adding bs= at the end.

dd if=/dev/sdX of=/dev/sdY bs=64

This example increases the default block size from 512 bytes to 64 kilobytes.

conv=noerror tells dd to continue despite any errors that occur. The default behavior is to stop, resulting in an incomplete file. Keep in mind that ignoring errors isn't always safe. The resulting file may be corrupted.

conv=sync adds input blocks with zeroes whenever there are any read errors. This way data offsets remain in sync.

You can combine these last two as conv=noerror,sync if you so desire. There is no space after the comma.

Search