Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Create an exact duplicate of a CD from the command line UNIX
I've been trying for the longest time to figure out how to make a disk-level duplicate image of a CD from the command line. I know Toast can do it, but I don't own it. Disk Utility's "CD/DVD Master" type files also seem to come up short, for example, on multi-volume CDs or CDs for Windows use.

I've always know this could be done with dd, but never knew the exact options to give it. I still don't know the nuances of filesystems and disk structures, but I ran into this hint that claimed to have the right parameters. The problem is that it didn't tell you what to use for "/path/to/InputFile," and the answer is enough of a nuance that I decided to share it.

The "input file" in this case needs to be the Unix device file for the CD drive that the CD is in, so you need to determine what that actually is. Furthermore, the CD must not be mounted when you do this, and getting the CD in the drive without OS X mounting it is also not necessarily obvious.

This is not rocket science for the Unix seasoned, but I figured it was worth sharing.

Here's the process...

  1. To determine the path to the CD's device file, insert the CD, and let OS X mount it to your desktop.
  2. In Terminal, run the following command, and take a look at the result:

    Spinnaker% df -k /Volumes/*
    Filesystem         1K-blocks     Used   Avail Capacity  Mounted on
    /dev/disk1s0          659122   659122       0   100%    /Volumes/Data_DRNA_100a
    /dev/disk0s3        58474008 49279888 8938120    85%    /
    Spinnaker% 
    Somewhere in there you'll see the CD. Look at the beginning of that line, under "Filesystem" -- that is the name of the device file. Select and copy it. You have to be logged in as an administrator, and provide your password, to do this.

  3. Unmount the CD's volume (without ejecting it :-) like this:
    Spinnaker% sudo umount /dev/disk1s0 
    Password:
    Spinnaker% 
    You should see it disappear from the desktop. Now dd can access the device file.

  4. Run the actual dd command, using the device file as the "/path/to/InputFile". This puts it in your home directory, but you can put it wherever you want:

    Spinnaker% dd if=/dev/disk1s0 of=$HOME/outfile.iso bs=2048
    Spinnaker%
    Note the distinct lack of feedback on whether anything is happening at all, save for your CD spinning up, and this command taking a good 10 minutes to complete before you get your prompt back.
Whether the current Disk Utility has the same flaws as previous ones, I can't comment on, nor have I anything to say on whether the bs=2048 is all it takes for a magic incantation to get this to really do an exact disk-level duplicate.

But but this is how you fill in the "input file" variable in the above referenced hint, and it does create an image file that both OS X and VPC can mount, and VPC will pretend it's an actual CD.

    •    
  • Currently 2.75 / 5
  You rated: 1 / 5 (8 votes cast)
 
[88,995 views]  

Create an exact duplicate of a CD from the command line | 13 comments | Create New Account
Click here to return to the 'Create an exact duplicate of a CD from the command line' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Create an exact duplicate of a CD from the command line
Authored by: mattmend on Jan 15, '04 03:34:44PM

Interesting. I've used Disk Utility to copy many CDs this way, including Windows-only Office XP CDs I was no longer using to give to friends. None of them have reported having trouble with CDs copied via Disk Utility.



[ Reply to This | # ]
Create an exact duplicate of a CD from the command line
Authored by: NetCurl on Jan 15, '04 03:35:00PM

The issue with the line bs=2048 is fairly simple. As you can find in the man page for dd, bs is block size, and superceeds the default Mac OS X block size of 4kb (4096 bytes). The NTFS default block size is 2kb (2048 bytes), and this may lead to problems when CD copying and mounting on Windows machines. CDs for Windows usually have 2kb block sizes, but Mac OS X can handle that and higher.

On CDs, block sizes correspond to data per sector I believe, and Windows adheres more directly with the Yellow Book standard of 2048. ISO CDs have a payload of 2048 bytes accompanied by another 200 or so bytes of header and other information.

Reference:

http://www.emedialive.com/Articles/ReadArticle.aspx?ArticleID=5132&PageNum=2



[ Reply to This | # ]
Create an exact duplicate of a CD from the command line
Authored by: guybrush on Jan 15, '04 04:20:57PM

i use cdrdao:

sudo cdrdao read-cd --device IODVDServices --driver generic-mmc --read-raw --datafile image.iso image.toc

burn it with:

sudo cdrdao write --device IODVDServices --driver generic-mmc image.toc



[ Reply to This | # ]
Create an exact duplicate of a CD from the command line
Authored by: XDave on Jan 15, '04 04:17:05PM

Does anyone know how to create an image that the system recognizes as an actual CD for use in situation where you need the CD in the drive a a key for the app?



[ Reply to This | # ]
Create an exact duplicate of a CD from the command line
Authored by: osxpounder on Jul 08, '04 12:51:22PM

An attempt to do so will likely be hindered by copy protection measures on the CD used as the key -- else, why would the software vendor require the CD as a key?

I don't know much about CD copy protection measures, but I have seen claims on the Internet that many CDs with copy protection use intentional errors of some kind, errors which will hinder a copy program's attempt to make an image of the CD, yet somehow not prevent the CD from functioning properly for its *intended* use.

---
--
osxpounder



[ Reply to This | # ]
Create an exact duplicate of a CD from the command line
Authored by: adrianm on Jan 15, '04 04:29:48PM
On my mac, I often do this:

hdiutil convert /dev/disk3s0 -format UDTO -o imagefile
This will create a master disk image which can be used to burn again.

Presumably this is what Disk Utility does though, so maybe the hints here are better.

[ Reply to This | # ]

Create an exact duplicate of a CD from the command line
Authored by: seanstar on Jul 19, '04 02:38:11PM

the issue I've run into with hdutil convert is that it does just that- it converts. It takes an existing set of files in one filesystem and puts them into an image in another filesystem. This is fine for making isos to be read/burned for Windows, Linux or other common OSs, but not so hot for getting all the nuances of an existing format. I'd imagine dd could be used to directly copy discs that don't even have a filesystem OSX can read (OS/2 HPFS anyone?)



[ Reply to This | # ]
Create an exact duplicate of a CD from the command line
Authored by: silicontrip on Jan 15, '04 09:08:41PM

In the earlier days of OSX you couldn't use umount to unmount disks as this confused the automounter. Instead you should use disktool eg :

disktool -u disk2

you don't need to be root to run the command either, unlike umount.



[ Reply to This | # ]
Create an exact duplicate of a CD from the command line
Authored by: gboudrea on Feb 11, '04 03:19:04PM

[quote]
Note the distinct lack of feedback on whether anything is happening at all, save for your CD spinning up, and this command taking a good 10 minutes to complete before you get your prompt back.
[/quote]
Simply open another Terminal and:
df -h /path/to/image_file.iso

You can then {UP}{ENTER} like crazy until image is done...
This makes a good progess meter! ;)

....gb



[ Reply to This | # ]
Create an exact duplicate of a CD from the command line
Authored by: sjk on Feb 11, '04 06:11:41PM
Or run a (t)csh command loop like:

while (1)
ls -l /path/to/image_file.iso
sleep 5
end

... to display the file's size as it grows.

[ Reply to This | # ]
After "dd" I couldn't reject CD?
Authored by: chiahao on Mar 28, '05 07:35:46AM

After following the intrustions above:

$ df -k /Volumes/*
/dev/disk0s3 58474008 55904412 2313596 96% /
/dev/disk1s0 635870 635870 0 100% /Volumes/Neverhood
/dev/disk0s3 58474008 55904412 2313596 96% /

$ sudo umount /Volumes/(...)

Here's something strange that the CD icon didn't disappear like the description? And once it finished "dd ...", I still couldn't reject the CD!
It says that the device is busy, and even I couldn't mount the device?

I've tried to type "df -k /Volumes/*", but showed that the all mounted device became the same as the label of my only hard disk, like

Filesystem 1K-blocks Used Avail Capacity Mounted on
/dev/disk0s3 58474008 55904412 2313596 96% /
/dev/disk0s3 58474008 55904412 2313596 96% /
/dev/disk0s3 58474008 55904412 2313596 96% /

Could someone help me? Thanks.



[ Reply to This | # ]
After "dd" I couldn't reject CD?
Authored by: returnthis on Oct 28, '05 02:41:25PM

I ran into the same problem

do this:

disktool -r
That will refresh the mount attributes

disktool -e disk1 (or whatever your cd/dvd drive is)

that should get you back to where u want to be



[ Reply to This | # ]
Create an exact duplicate of a CD from the command line
Authored by: susanrm on Oct 07, '06 08:21:22AM

This looks like the perfect solution for me, but unfortunately it didn't work. It ended with an Input/output error. The image was there and the right size, but when I tried to mount it to check it out, it said, "No mountable file systems." It was originally a two-session CD, audio and data.

I tried burning the outfile.iso anyway, and it burned, but it did not mount anything, nor did it show dual sessions in Disk Utility.

One discrepancy was that at Step 2, because it had multiple sessions, the CD showed as multiple filesystems. When I unmounted just /dev/disk1, the whole thing unmounted, so I figured I should just use that. Was that wrong?

Any hints? It would really be great.

Susan



[ Reply to This | # ]