CD Tools
Some information on handling CDs under Linux. This includes info on burning CDs. Normally I'd use the excellent k3B, but when in grumbles the command line can be more successful. Further, more detailed, information can be found on this page.
Making an ISO from a Data CD
Below are a couple of ways that you can make an ISO image from a CD.
> dd if=/dev/cdrom of=image.iso
> cat /dev/cdrom > image.iso
Backing up to an ISO
It's quite easy to create an iso
from a directory of files using the
mkisofs
command. The command has a lot of switches for generating various image types.
Below is a quick example for general use.
> mkisofs -v -l -r -J -R -allow-leading-dots -allow-multidot -o image.iso dir
This generates an iso
image called image.iso
that contains the files within the directory
dir
. A brief explanation of the command switches is given in the table below. Take a look at
the man page for fuller descriptions.
Switch | Description |
---|---|
-v | Verbose output |
-l | Allows 31 character filenames |
-r | Sets file uid and gid to 0 and permissions to globally readable |
-J | Generate Joliet extensions. Allow windows to read the CD |
-R | Generate Rock Ridge extensions |
-allow-leading-dots | Allow filenames to start with a dot |
-allow-multidot | Allow filenames to contain more than one dot |
Mounting an ISO
Mounting an ISO image is a very handy trick. You can access the ISO files just like they came from a CD, but the access is a lot quicker because it's coming from your hard disk (If the ISO is on your hard disk!). Note: You need to be root to do this.
First create a directory that you will mount the ISO to.
> mkdir mntDir
Now issue the mount command.
> mount -o loop -t iso9660 image.iso mntDir
When finished, just unmount it.
> umount mntDir
Copying Audio CDs
The tool of choice for copying Audio CDs (on the command line) is cdrdao
.
First use the scanbus
option to find your cd drive(s).
> cdrdao scanbus
You use the following command to do the copy, if you only have one drive it will prompt you
to change the CD. The 'tocFile.toc
' argument specifies where the CD's table of contents file will
be written to.
> cdrdao copy --device ATA:1,0,0 tocFile.toc
It's possible to do the read and write stages separately. Below is the read command, followed by the
write command. Again, 'tocFile.toc
' specifies where the CD's table of contents will be written. The raw
data will be written to a file called 'data.bin'. This can be changed with the --datafile
switch.
> cdrdao read-cd --device ATA:1,0,0 tocFile.toc > cdrdao write --device ATA:1,0,0 --buffers 64 tocFile.toc
A specific driver, rather than using the automated choice, can be specified.
The driver list on the cdrdao
homepage can be used to find the correct driver for your CD drive.
Ripping Audio CDs
There are a whole bunch of programs for ripping audio CDs to mp3
or ogg
files. However most of them are just a graphical front end for cdparanoia
and encoders
like lame
and oggenc
. Personally I prefer a command line based tool, you
get to see more when things go wrong. A particularly nice program is abcde
, A Better CD
Encoder. It is in fact a shell script that controls the mentioned programs, but does other things
like a CDDB look up.
What makes abcde
great is the simple config file you can use to control the
program's operation. With the right settings you can get a set of ogg
files just by
issuing the abcde
command.
> abcde
Here is an example configuration file, ~/.abcde.conf
.
~/.abcde.conf
# ABCDE config file ~/.abcde.conf # Set CDROM device location CDROM=/dev/cdrom2 # Set file output directory OUTPUTDIR=~/tunes/ # Set file output format OUTPUTFORMAT='${ARTISTFILE}/${ALBUMFILE}/${TRACKNUM} ${TRACKFILE}' # Set output type to ogg vorbis OUTPUTTYPE=ogg # Adjust encoding quality OGGENCOPTS='-q 10' # Change the mungefilename function to allow spaces in filenames mungefilename () { echo "$@" | sed s,:,-,g | tr / _ | tr -d \'\"\?\[:cntrl:\] }