Sunday, March 18, 2012

How to make a workable copy of a copy-protected CD or DVD using Mac OS X and Terminal

I was digging around looking for an old CD to install in a Windows Virtual machine, and I noticed that some of my older disks were starting to degrade. Since I have plenty of drive space to do so, I decided to make backups of all my old disks as disk images. So I started out where I always have, in OS X's Disk Utility program, which will let you make .dmg files from your disks. I noticed though that certain disks would error out. So I tried several other programs, including the ever-popular Toast. Every program I tried would either hang or error out. So I did some investigating. Here are my results.

Please only use this method to make legal backups of disks that you own. I won't be held responsible for your piracy.

After a lot of reading and experimenting, I believe I've found a good method. The first thing to understand is why certain disks error out and others don't. It seems that game manufacturers will actually intentionally create disks with bad blocks. The bad blocks don't effect the actual operation of the disk, but when an imaging program comes across them, it throws up its arms and decides it can't go on. So clearly the need arises to find a program that will see the errors, take note of them, and soldier on anyway. This is where Terminal comes in. I only have a basic understanding of Terminal and the underlying Unix of OS X, so if you have at least that, then you should be ok following these directions.

Step 1.
Insert the disk. If I really have to tell you any more in this step, you should stop now and ask a techie friend to do this for you.


Step 2. 
Fire up Terminal. It's found in your Utilities folder inside your Applications folder. A faster way to get to it is using Spotlight. Cmd + Space will bring up the search dialog, and then you just start typing. I usually only get to a about "term" before it's popped up at the top of the list. Hit enter and the program will open.

Step 3.
Use the df command to find out the right path for your disk. It should look something like this:


Mini:~ adam$ df

Filesystem     512-blocks       Used   Available Capacity  Mounted on
/dev/disk0s2    975093952  529044976   445536976    55%    /
devfs                 390        390           0   100%    /dev
map -hosts              0          0           0   100%    /net
map auto_home           0          0           0   100%    /home
/dev/disk2s2  34359066544 6882880376 27476186168    21%    /Volumes/Drobo
/dev/disk1s3    976510944  783246128   193264816    81%    /Volumes/Time Machine
/dev/disk3s0      1235568    1235568           0   100%    /Volumes/SC3

Take note of the path of your CD drive and the disk in it. In this case, /dev/disk3s0 (that's a zero)

Step 4.
Unmount your disk 
Mini:~ adam$ diskutil unmountDisk disk3s0
Unmount of all volumes on disk3 was successful

Step 5.
Use dd to clone your disk to a disk image. For copy protected disks, add the conv=noerror flag. If the disk image still won't work right, you may need to add they sync and notrunc flags as well, but all of the disks I've cloned so far haven't needed them. The noerror flag takes note of the errors on the disk, but continues with the cloning process in spite of them. I always name the resulting iso the same as the original volume name. I don't think it matters, but it helps me keep track of them. I've also found that if you just use /dev/disk3 instead of /dev/disk3s0 (or whatever it is for your system), the resulting image may not be usable. One disk I've cloned had no session information attached, and for that I just used /dev/disk3.

Mini:~ adam$ dd conv=noerror if=/dev/disk3s0 of=SC3.iso

With sync and notrunc:
Mini:~ adam$ dd conv=noerror,sync,notrunc if=/dev/disk3s0 of=SC3.iso

This part may take anywhere from a couple minutes, to potentially days, depending on the speed of your computer, your drive, and how many errors are on the disk. SC3, which is the 3rd disk of the original Splinter Cell game, took about 18 hours on my Mac Mini with 8GB Ram and a USB DVD drive, and had thousands of errors. My clone of Jedi Knight disk had 3 errors, and took about 5 minutes.

This is what an error will look like when dd comes across it:

dd: /dev/disk3s0: Input/output error
222870+0 records in
222870+0 records out
456437760 bytes transferred in 388.041972 secs (1176259 bytes/sec)




Step 6.
Mount the image in your virtual machine and test it. If it works, awesome! If it doesn't, go back and try using the sync and notrunc flags. (If it still doesn't work after that, I'm tapped for ideas, sorry.) From the man page for dd, here are descriptions of what each flag does. 

noerror  Do not stop processing on an input error.  When an input error occurs, a diagnostic message followed by the current input and output block counts will be written to the standard error output in the same format as the standard completion message.  If the sync conversion is also specified, any missing input data will be replaced with NUL bytes (or with spaces if a block oriented conversion value was specified) and processed as a normal input buffer.  If the sync conversion is not specified, the input block is omitted from the output.  On input files which are not tapes or pipes, the file offset will be positioned past the block in which the error occurred using lseek(2).

notrunc  Do not truncate the output file.  This will preserve any blocks in the output file not explicitly written by dd.  The notrunc value is not supported for tapes.

sync     Pad every input block to the input buffer size.  Spaces are used for pad bytes if a block oriented conversion value is specified, otherwise NUL bytes are used.


The general idea behind this method is to create a byte for byte, error for error copy of the disk. Many other methods of creating disk images (from what I've read) don't make an exact copy, but a copy reformatted to a certain image format. Some games won't work using these other methods, because they look for certain structures on the disk. I've even come across games that don't contain disk errors that won't work unless cloned using this method.

I hope this is helpful to someone. It is a conglomeration of information taken from a dozen other sites and forums, as well as some independent research and testing. I've tried to be as comprehensive as possible, but if you're still having trouble after following these steps, dig deeper, read man pages, perform very specific Google searches... everything you can to figure out your problem. It's the best way to learn. And hey, if you do find a different way, leave a comment and let me know.

1 comment:

Matt said...

This is good stuff. I've actually been learning about DD in my computer forensics class. It's a pretty handy tool that is found in most flavors of *nix (Unix and all it's various offspring).

http://en.wikipedia.org/wiki/Dd_%28Unix%29

Thanks for the write up!