Creating images or things from images with terminal


Terminal 'man dd'

I'm forever forgetting how to use dd even though I've researched it, Ruben has explained it a couple of times, and I've created a few bootable USBs using dd and my favourite guide to creating a bootable USB.

Yesterday while trying to create a disk image, I found this nice tutorial on "Macintosh How To", but I thought I might create just a little note here of my own.

Insert whatever it is you're using, whether it is a USB or a CD/DVD and open Terminal. If you just want a list of the current devices, and know what you're looking for, run:

diskutil list

If you have entered a CD/DVD though, you can run the following to give specifically the information of the CD/DVD:

drutil status

The /dev/diskN portion, where N is the number you found out previously, determines the device node and is the important part, and one that should be noted. Unmount before you do anything, to make sure it's not in use.

diskutil unmountDisk /dev/diskN

I don't really understand 'Disk Utility.app' so I don't use it..

Then finally you can follow with the dd command, though depending on what you're doing can be a bit confusing since I have people telling me one thing when I'm trying to do another. Haha, I guess I just didn't explain it well enough then.

To make an image of a disk/volume and output it onto another mounted volume (not using the device node though.. since I'm not trying to overwrite everything on it?). It's important to give the name of the output file.. (file.extension below). Might need to sudo it.

dd if=/dev/diskN of=/Volumes/VolumeName/file.extension bs=2048

Or to put an image onto a disk/volume, maybe so that you can use it to boot:

dd if=/path/to/downloaded/file.extension of=/dev/diskN bs=1024

The Ubuntu tutorial uses /dev/rdisk, and says this might be faster. Might be worth trying. It also uses 1m/1M instead. Anyway, there'll be a short message when it's done (records in, records out, bytes transferred).

You can remount the disk/volume or eject it:

diskutil mountDisk /dev/diskN
diskutil eject /dev/diskN

Phew. So maybe I won't need to search through Google next time I forget.