Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Creating an Image File
- Another way to clone a drive is to create a disk image that you can move around and restore as you would 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
- This command shrinks your backup into an IMG.GZ file, one of the many compression formats Linux can handle.
- Restoring a Drive
- What good are those backups if you can’t use them? When you’re ready to restore a clone, you have two options. If you used the first approach, simply swap the two destinations.
- 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 decrompresses 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.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement