Cloning/imaging drives/disks to file then restoring using cat command (Mac OS X example – should work in Linux as well)

Posted: September 30, 2017 in Linux
Tags: , , , , ,

Warning: Command line utilities tend to be simple but very powerful i.e. typing incorrect commands (especially the directions of < and > below) can result in your source drive being wiped out – suggest to back up important files before proceeding. Proceed with instructions below at your own risk.

Do following in an OS X terminal

1) Determine source/destination drives/disks;

mount

2) Unmount partition

diskutil unmount /Volume/XXXXXXX

3) Clone/image partition to file (assumes /dev/disk1 is source). Note: this can take some time depending on read/write speeds of drives;

sudo su -i
cat /dev/disk1|gzip -c9 > ./filename.cat.gz

4) Restore image to partition (assumes /dev/disk1 is destination and drive is unmounted). Note: this can take some time depending on write speeds of drives;

sudo su -i
gzcat ./filename.cat.gz > /dev/disk1

Above was tested using in OS X 10.12. You may get “unexpected end of file” / “uncompress failed” errors but nevertheless the commands work.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s