My Hackintosh is pretty brittle. Anytime there’s an update I live in fear of it breaking my system. So to that end I found it best to just clone the entire drive so that should something go wrong I can just put the entire clone of my drive back. Since I dual boot I do this in linux, but you could also do it just booting up w/ linux on a usb drive.
To backup and restore my drive I use dd. Here are the commands, obviously you’ll need to figure out which drive for your particular setup.
Restore:
sudo dd if=/dev/sde of=/dev/sda bs=1M conv=noerror,sync status=progress
Make backup:
sudo dd if=/dev/sda of=/dev/sde bs=1M conv=noerror,sync status=progress
Get a list of which disk is sdX to determine your drives.
sudo fdisk -l
On My Linux Box
sda – osx drive
sde – usb backup drive
Notes:
Cloning an entire hard disk
From physical disk /dev/sdX to physical disk /dev/sdY
# dd if=/dev/sdX of=/dev/sdY bs=64K conv=noerror,sync status=progress
This will clone the entire drive, including the MBR (and therefore bootloader), all partitions, UUIDs, and data.
https://wiki.archlinux.org/index.php/disk_cloning
https://www.tonymacx86.com/threads/backup-hackintosh-bootloader-with-dd-terminal.185484/
https://apple.stackexchange.com/questions/46253/what-is-the-best-way-to-clone-a-disk-between-two-macs?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
> sudo dd if=/dev/rdisk0 of=/dev/rdisk2 bs=1m conv=noerror,sync
When dd finishes you may see an error like this:
dd: /dev/rdisk2: short write on character device
dd: /dev/rdisk2: Input/output error
3726+1 records in
3726+1 records out
500107862016 bytes transferred in 14584.393113 secs (34290619 bytes/sec)
That last error message is actually okay. The last block written was a short block because there wasn’t a full 1MB block to copy. No worries.
Now you’ve got a bit-wise perfect clone of your Macintosh HD drive. Reboot your system using the Macintosh HD drive and enjoy your clone!
Option:
If you want to compress the image to a file
https://superuser.com/questions/1097210/clone-only-space-in-use-from-hard-disk
To generate the image:
## dd probably needs sudo here.
dd if=/dev/sdb bs=32M | gzip -c > /foo/bar/my_image.dd.gz
To write the image back:
## dd probably needs sudo here.
gzip -cd < /foo/bar/my_image.dd.gz | dd of=/dev/sdb bs=32M
These commands might be built without dd, with gzip only. I used dd to ensure 32 MiB buffer.
Advantages:
- The resulting file is non-sparse, it needs no special treatment.
- The image size will be reduced even more if the files on your source disk are prone to compression.
Disadvantages:
- It is hard to access the files within the compressed image without full decompression (some FUSE may be useful, although I’m not sure, never tried; consider a squashfs approach).