Create and Restore Disk Images on macOS

Disk Utility may be a powerful GUI tools, but sometimes having a manual control is more assuring. I believe disk images are one such issue. If you happen to be working with headless disk images, say for your raspberry pi projects, it’s more recommended (due to its swiftness and control) to use command line interfaces.

To create a disk image from a drive:

  1. Run the following command, and look for the volume path of your drive.
diskutil list
  1. Replace the bracketed part with the volume path and run the command.
diskutil unmountDisk [Volume Path]
  1. Replace the bracketed part with the volume path and the desired name and path for a disk image file, and run the command.
sudo dd if=[Volume Path] of=[Path to Disk Image file].img

To restore a disk image to a drive:

  1. Run the following command to find a volume path to the disk.
diskutil list
  1. Replace the bracketed part with the volume path and run the command.
diskutil unmountDisk [Volume Path]
  1. (optional) You can format the disk before going ahead. Replace the bracketed part with the volume path and run the command.
sudo newfs_msdos -F 32 [Volume Path]
  1. Replace the former bracketed part with the path to the disk image by simply drag and drop, and latter with the volume path. And run the command.
sudo dd if=[Path to Disk Image file] of=[Volume Path]

Let me know if there is any issues or questions.

Leave a comment