Imaging Audio CDs using the command line

Alex Santos
4 min readAug 12, 2019

--

Use cdrdao to convert an Audio-CD to a data and toc-file (table of contents file)

A Tool CD?

The goal of this article is to provide a quick overview on how to image an Audio CD to two files on your hard drive by using using a command line interface software package called cdrdao.

To install cdrdao, your operating system may require a package manager be already installed. Most Linux distributions should already have some package manager installed, Mac OS has the App Store but you won’t find cdrdao hosted there for download so you will need to install either MacPorts or Brew and use one of them to download and install cdrdao. I won’t cover installation of these package managers but both are linked where steps for the same are offered.

These process of imaging the disc were executed on a PowerPC Mac running OS X 10.5 but the same steps should apply to other operating systems; FreeBSD, Irix, Linux, Solaris, HP-UX, Win32, OS/2 and Unixware all reportedly work with cdrdao.

Mac OS specifically uses diskutil to modify, verify and repair local disks and it was used to determine the mount point of the Audio CD. You will need to determine what the equivalent tool is for your operating system. Despite this, if you follow along you should get a good idea of the process.

Finally, by the end of this process you will have successfully imaged an Audio CD to a .TOC and .DAT. These files will have been saved to your working directory, likely your home folder, unless you have changed your working directory beforehand. You can then back these files up or burn a new Audio CD, both of which are not covered here either.

So let’s begin …

Insert your Audio CD and enterdiskutil list into the terminal.

In the example below the Audio CD is mounted at/dev/disk3

$ diskutil list
/dev/disk3
#: TYPE NAME SIZE IDENTIFIER
0: CD_partition_scheme Audio CD *530.6 Mi disk3
1: CD_DA 48.2 Mi disk3s1
2: CD_DA 52.4 Mi disk3s2
3: CD_DA 37.2 Mi disk3s3
4: CD_DA 59.9 Mi disk3s4
5: CD_DA 37.7 Mi disk3s5
6: CD_DA 41.9 Mi disk3s6
7: CD_DA 34.5 Mi disk3s7
8: CD_DA 38.8 Mi disk3s8
9: CD_DA 36.8 Mi disk3s9
10: CD_DA 40.4 Mi disk3s10
11: CD_DA 39.2 Mi disk3s11
12: CD_DA 63.6 Mi disk3s12

Next we have to unmount the disc which in this case is /dev/disk3. This is important as cdrdao requires exclusive control over the drive. To ensure exclusivity, close any other apps that might either prevent the disc from unmounting or cause the disc to remount. If the disc is not unmounted or remounts in the middle of the process you will be presented with a message similar to ERROR: scan: ObtainExclusiveAccess failed: -536870187.

so…let’s unmount /dev/disk3

$diskutil unmount /dev/disk3
Volume Audio CD on disk3 unmounted

With the disc now unmounted we need to scan the bus with cdrdao scanbus to obtain the path address of the disc.

$cdrdao scanbus
Cdrdao version 1.2.3 - © Andreas Mueller <andreas@daneb.de>
ERROR: scan: ObtainExclusiveAccess failed: -536870187
ERROR: scan: ObtainExclusiveAccess failed: -536870203
IOService:/MacRISC4PE/ht@0,f2000000/AppleMacRiscHT/pci@5/IOPCI2PCIBridge/firewire@E/AppleFWOHCI/IOFireWireController/IOFireWireDevice@d04ba41705cc50/IOFireWireUnit/IOFireWireSBP2Target/IOFireWireSBP2LUN/com_apple_driver_Oxford_Semi_FW934_DSA/IOSCSIPeripheralDeviceNub/IOSCSIPeripheralDeviceType05/IOBDServices : PIONEER, BD-RW BDR-205, 1.04

I will unpack the gibberish above before we move on.

The first thing to understand is that I have two external and one internal optical drives attached to the Mac. The snippet below represent two optical drives that have no physical disc inserted so they just error out.

ERROR: scan: ObtainExclusiveAccess failed: -536870187
ERROR: scan: ObtainExclusiveAccess failed: -536870203

The rest of the output has the string we need.

IOService:/MacRISC4PE/ht@0,f2000000/AppleMacRiscHT/pci@5/IOPCI2PCIBridge/firewire@E/AppleFWOHCI/IOFireWireController/IOFireWireDevice@d04ba41705cc50/IOFireWireUnit/IOFireWireSBP2Target/IOFireWireSBP2LUN/com_apple_driver_Oxford_Semi_FW934_DSA/IOSCSIPeripheralDeviceNub/IOSCSIPeripheralDeviceType05/IOBDServices : PIONEER, BD-RW BDR-205, 1.04

We don’t need all of it however, we only need the string from IOService to just before the second colon. We will need to copy this portion of the string and apply it to our next command.

IOService:/MacRISC4PE/ht@0,f2000000/AppleMacRiscHT/pci@5/IOPCI2PCIBridge/firewire@E/AppleFWOHCI/IOFireWireController/IOFireWireDevice@d04ba41705cc50/IOFireWireUnit/IOFireWireSBP2Target/IOFireWireSBP2LUN/com_apple_driver_Oxford_Semi_FW934_DSA/IOSCSIPeripheralDeviceNub/IOSCSIPeripheralDeviceType05/IOBDServices

Now that we unmounted the disc and scanned the bus for our string, we will move on to the process of actually imaging the Audio CD.

To do that we type cdrdao read-cd --device "our string in quotes" --with-cddb --datafile test.dat test.toc The command is entered in one line despite what appears to be a line break in the example snipper below. We type this in and hit enter of course. Obviously the path address will differ for your scenario.

$cdrdao read-cd --device “IOService:/MacRISC4PE/ht@0,f2000000/AppleMacRiscHT/pci@5/IOPCI2PCIBridge/firewire@E/AppleFWOHCI/IOFireWireController/IOFireWireDevice@d04ba41705cc50/IOFireWireUnit/IOFireWireSBP2Target/IOFireWireSBP2LUN/com_apple_driver_Oxford_Semi_FW934_DSA/IOSCSIPeripheralDeviceNub/IOSCSIPeripheralDeviceType05/IOBDServices” --with-cddb --datafile test.dat test.toc

Caveats/Gotchas

After unmounting the disc, I noticed that the disc would remount a few moments later. If you see errors when scanning the bus, like ERROR: scan: ObtainExclusiveAccess failed: -536870187 it is possible that the disc simply remounted itself. You may need to consider a tool to temporarily keep the disc unmounted if it keeps mounting before you can complete the commands.

On Macs (PPC and Intel), 10.5+ you may need something like Disk Arbitrator to prevent a disc from mounting. I left a comment with a PPC version of Dsik Arbitrator in case you need it. The latest releases are for contemporary Macs.

References

You can learn more about Audio-CDs and DVD formats here: http://www.herongyang.com/CD-DVD/index.html

--

--