16/12/2008

Console CD burning

This was originally part of the last post, but I got stuck in an increasingly off-topic quagmire. I'm not a console zealot, but if some quick one-liner in a shell means I don't have to fire up a big GUI, I'm all for it. CD copying and ISO burning are prime candidates. You need wodim/cdrtools and cdrdao for this, which are probably installed by default as K3b depends on them. cdrtools users, replace wodim with cdrecord (see below).
Copy an audio CD:
I found an old summary of cdrtools here, but note that the device syntax (--device 0,1,0) is obsolete on some systems and might cause trouble.
The hard way:
$ wodim --devices
$ cdrdao copy --source-device /dev/scd0 --device /dev/scd1 --buffers 64 --speed 24
The wodim output ought to give you a hint what to use for the --source-device and --device options (for single-device copying, omit --source-device). Without the --speed option, cdrdao is supposed to use the "highest possible speed", which turned out to be 4.
The easy way (see this excellent ubuntuforums post):
Edit /etc/cdrdao.conf.
#---- cdrdao.conf ----#
write_buffers: 128
write_device: "/dev/scd1"
write_driver: "generic-mmc"
read_device: "/dev/scd0"
read_driver: "generic-mmc"
read_paranoia_mode: 3
write_speed: 24
Change write_speed and write_buffers to suit your CD writer and expendable RAM.
Copy with:
$ cdrdao copy
For an on-the-fly copy, add the --on-the-fly option. This ought to work also with data CDs, alternatively to the solution below.
Burn an ISO file:
Save your default burning options to /etc/wodim.conf
#---- wodim.conf ----#
CDR_DEVICE=/dev/scd0
CDR_SPEED=24
CDR_FIFOSIZE=128m
Change to suit your burner and expendable RAM.
The one-liner:
$ wodim <isofile>.iso
Copy a data CD (wodim):
Dump the unmounted CD to an image:
$ dd if=/dev/scd0 of=myiso.iso
Some people also recommend cat /dev/scd0 > myiso.iso.
Then burn with wodim.
To fulfil my one-liner criterion, a shell script might be useful. This is for just one drive, adapt for two:
#!/bin/bash
sudo umount /media/Disk
wait 2 # to ensure drive is ready
echo "Dumping..."
dd if=/dev/scd0 of=/tmp/myiso.iso
eject /dev/scd0
read -p "Insert CD-R. Press any key to continue... " -n1 -s
sudo umount /media/Disk
wait 2
echo "Burning..."
wodim /tmp/myiso.iso
rm -f /tmp/myiso.iso
Replace your default CD automount behind the umount statements, and your source drive for /dev/scd0. Save as /usr/bin/copydatacd, make executable
$ chmod a+x /usr/bin/copydatacd
Use with sudo copydatacd (umount needs sudo)
Note: This doesn't work with audio CDs, because they don't have a mountable file system.

Caveats: cdrtools/cdrkit has been a license battleground for years. openSuSE uses the cdrkit fork of cdrtools, (wodim, genisoimage, icedax), but issues a compatibility package symlinking cdrecord, mkisofs, cdda2wav from cdrtools. If you have cdrtools, replace the commands.
There is some confusion about the location of the config files, which don't exist by default. According to this change log, they were changed on SuSE from /etc/default/<commandname> to /etc/<commandname>.conf around 2004. I didn't check for other distros and use the latter version throughout. According to the cdrdao man page, both versions are accepted, but /etc/cdrdao.conf has precendence.

No comments: