My machine at uni has an ATAPI CD burner.
acd0: CD-RW <SONY CD-RW CRX140E> at ata1-slave using PIO4
I've never had a CD-R before so it took me a while and a bit of help from
freebsd-questions@freebsd.org to work out how to use it. This is what I've worked out so far...
You can mount a CD in ISO9660 format just as you would in a regular reader.
mount -t cd9660 /dev/acd0c /mnt/acd0
You can create a disk image of a CD using dd(1). You have to get the block size right though (2048B - thanks to Dave Leimbach).
dd bs=2048 if=/dev/acd0c of=chomsky.img
You can mount such a disk image using the vn device if you have it configured in your kernel. You need a line such as:
pseudo-device vn
in your kernel config. If you are unsure then refer to the excellent instructions in the FreeBSD Handbook. Once you have done that use vnconfig and mount.
vnconfig -c /dev/vn0c chomsky.img
mount -t cd9660 /dev/vn0c /mnt/vn0c
Once you have finished unmount the image and unconfigure the vn device.
umount /dev/vn0c
vnconfig -u /dev/vn0c
I'm not sure about non ISO9660 data...I have only tried one CD (HFS+ format) so far and dd(1) stops with an I/O error at block 49966.
You can play audio CDs as per a normal reader using cdcontrol(1) et al.
cdcontrol -f /dev/acd0c
You can make a disk image using dd(1). You have to get the block size right though (2352B thanks to Graywane). NB I don't know how to get an image (correctly) back to an audio CD yet...
dd bs=2352 if=/dev/acd0c of=42.img
You can grab the audio tracks as WAV files using dagrab from the ports collection.
dagrab -a -v
These WAV files can be converted to CD Audio files using sox, also from the ports collection.
Assuming you have a C based shell, to use
sox
to do the WAV -> CD Audio conversion, you can type...(> is the prompt)
> foreach i (*.wav)
foreach? echo $i to $i:r.raw
foreach? sox $i $i:r.raw
foreach? end
Under FreeBSD 5 and later versions of FreeBSD 4 there are device files
representing each track and you can read the audio data as CD Audio by using
dd
and these devices (rather than needing to use the
dagrab
and
sox
method). If you are using devfs
you automatically have the exact number of track devices needed for the current
CD - non-devfs systems may need to make use of
MAKEDEV.
Once you have the correct number of track devices, again assuming a C based
shell:
> foreach i ( /dev/acd0t* )
foreach? echo $i
foreach? dd bs=2352 if=$i of=track`basename $i | sed -E 's/acd0t([0-9]+)/\1/g'`.raw
foreach? end
Images can be burnt with burncd(8). I'm not sure what happens if you get the speed argument wrong so check your burners capabilites before starting.
burncd -f /dev/acd0c -s 8 data chomsky.img fixate
If you don't have an image (but instead a directory structure) you can use the makecdfs script found in /usr/share/examples/worm/. Read the script for usage instructions.
You can burn audio files with burncd(8).
burncd -f /dev/acd0c -s 8 audio track*.raw fixate
Thanks to the wonders of shell globbing burncd(8) will burn the audio tracks in the correct order.
2 seconds of banding will be put between each track - to avoid that (so to
produce a CD with a continuous sound ala Sgt. Pepper's) you need to use what is
known as Dist At Once mode (DAO) - alas I haven't worked that one out yet
(update - burncd(8) now has
a -d argument to use DAO mode). In the days before -d
you could read the audio CD with dd(1) and
burn the image as one audio track and the new CD would have all the audio but
no track information (i.e. CD players say you have only 1 (albeit quite long)
track).
Mark Slingo just wrote to me to remind me about burning from CD to CD. I haven't tried it as I didn't have 2 drives and now I don't even have 1 burner however he tells me it works well.
cat /dev/acd0c | burncd -f /dev/acd1c -s 4 data - fixate
This reads from acd0 and writes to acd1 without requiring you to make a disk image. This would be much faster and take less disk space. Why use cat(1) as opposed to dd(1)? I don't know. One caveat is this probably only works if acd0 reads faster than acd1 writes - probably the normal situation for most people with 2 drives.