Simple howto burn and rip cd's

To create iso
Code:
$ mkisofs -o /path/to/output.iso -R -J /path/to/files/you/want/on/cd

to burn cd-r/cd-rw
Code:
$ burncd data /path/to/output.iso fixate

To burn files/directory, to cd without making iso file (thanks to Vermaden @ daemonforums.org)
Code:
$ mkisofs -J -R /path/to/some/file/or/dir | burncd data - fixate

to burn compressed cd:
Code:
$ gunzip -c file.iso.gz | burncd data - fixate

to blank cd-rw
Code:
$ burncd blank

to get cd/dvd image (to get iso from disk)
Code:
$ dd if=/dev/acd0 of=/path/to/disk.iso bs=2048

to burn dvd iso to disk with burncd
Code:
$ burncd dvdrw /paht/to/image.iso

to burn dvd iso to disk with growisofs
Code:
$ growisofs -dvd-compat -Z /dev/cd0=/path/to/image.iso

to burn files to dvd without creating iso
Code:
$ growisofs -Z /dev/cd0 -R -J /some/files

above 2 commands will overwrite content on dvd+-rw disk
no need to blank (so it seams. i tested on my pc)


to append to dvd (must use same options as when creating this dvd)
Code:
$ growisofs -M /dev/cd0 -R -J /some/more/files

to finalize dvd (slow) (you need this after appending to dvd, to maintain maximal compatibility, it's not 100% necessary)
Code:
$ growisofs -M /dev/cd0=/dev/zero

to format dvd-rw with burncd (slow!)
Code:
$ burncd format dvd-rw

to format dvd+rw with burncd (slow!)
Code:
$ burncd format dvd+rw

To blank dvd-rw (very slow!) (thanks to Vermaden @ daemonforums.org)
Code:
$ growisofs -Z "/dev/cd0=/dev/zero"

to blank dvd+rw (slow)
Code:
dvd+rw-format /dev/cd0

to burn audio cd from wav files
Code:
$ burncd audio file1.wav file2.wav file3.wav fixate

here's simple script that uses mplayer and burncd to burn audio cd's from directory with music files (basically any file that mplayer can play)
Code:
#!/bin/sh
for i in `ls`; do
  rm -f /tmp/cd_track.wav
  mplayer -vo null -vc dummy -af resample=44100 -ao pcm:file=/tmp/cd_track.wav $i
  burncd audio /tmp/cd_track.wav
done
rm -f /tmp/cd_track.wav
burncd audio fixate
exit 0

and here's another simple script to rip audio cd's to mp3
Code:
#!/bin/sh
mkdir /tmp/cd
cd /tmp/cd
cdparanoia -B -d /dev/acd0
for i in `ls *.wav`; do
  lame -m s "$i" -o "$(echo $i | awk '{print substr($0,6,2)}' -).mp3"
  rm -f "$i"
done
echo 'files are in /tmp/cd'
exit 0

you can rip 1 audio track to wav with
Code:
$ cdparanoia -B -d /dev/acd0 1
in this example it'll rip track 1 only
and convert it to mp3 with
Code:
lame -m s audio.wav -o audio.mp3


to attach and mount iso image
Code:
$ mdconfig -a -t vnode -u 0 -f /path/to/image.iso
$ mount -t cd9600 /dev/md0 /mnt


to umount and detach iso image
Code:
$ umount /mnt
$ mdconfig -du 0


To make it all happen you need:

in kernel
Code:
options 	CD9660			# ISO 9660 Filesystem, because you want to read them ;)
device		atapicd		# ATAPI CDROM drives
device		atapicam
device		cd				# nessacery for dvd's
device 		pass
device 		scbus
options		MD_ROOT
device		md
options         UDF

and permission to write to /dev/acd0 /dev/cd0 /dev/pass1

note: The pass device number will also depend on the order that SCSI devices are enumerated by the kernel. To determine exactly which one it is, one can use camcontrol devlist as root [thanks to phoenix @ daemonforums.org]

note, you can't run growisofs using su, you need to do that as user....

here's some part of my /etc/devfs.conf
Code:
own     acd0    root:users
perm    acd0    0660

own     cd0     root:users
perm    cd0     0660

own     pass1   root:users
perm    pass1   0660

own     pass0   root:users
perm    pass0   0660

Here's list of utils you can install to convert from different formats to iso files:
sysutils/iat - converts BIN, MDF, PDI, CDI, NRG, and B5I to ISO
sysutils/nrg2iso - Convert Nero .nrg CD-Image format to ISO
sysutils/ccd2iso - A CloneCD to ISO converter
sysutils/daa2iso - Convert PowerISO DAA files to ISO9660
sysutils/mdf2iso - A Alcohol 120% to ISO converter
sysutils/nrg2iso - Convert Nero .nrg CD-Image format to ISO
sysutils/uif2iso - Convert MagicISO UIF files to ISO9660
sysutils/bchunk - Converts .bin/.cue files to .iso/audio

note: if you have more than one drive, you need to specify which one to use with burncd as well
use -f flag for this
Code:
burncd -f /dev/acd1 data /path/to/image.iso fixate

to use mkisofs you need to install sysutils/cdrtools
to use growisofs you need to install sysutils/dvd+rw-tools

to use cdparanoia you need to install audio/cdparanoia
to use lame you need to install audio/lame
to use mplayer you need to install multimedia/mplayer



resources:
burncd(8)
mkisofs(8)
growisofs(1)

mplayer(1)
cdparanoia(1)

mdconfig(8)

lame(1) , hmm why this is not available in freebsd online manual pages?


UPDATE
To avoid allowing rw access to all pass* devices (thanks to mart), you can do fallowing:
Code:
$ dmesg | grep -i cd0.*target
cd0 at [color="Red"]ata1[/color] bus 0 target 0 lun 0
$ echo 'hint.scbus.0.at="[color="Red"]ata1[/color]"' >> /boot/device.hint
This will make sure that your burner on ata1 (in this case) will be assigned to pass0 always, as long as it's on ata1
now all you have to do is allow only
Code:
own     pass0   root:users
perm    pass0   0660
in /etc/devfs.conf
 
Errmm.. burncd uses the ATAPI (IDE) interface..
So stricly speaking you don't need atapicam and all for that.

atapicam is needed for cdrecord (SCSI) and similar burn programs (nautilus i.e.).
 
You can also do:

mkisofs -o /dev/stdout -R -J /path/to/files/you/want/on/cd | burncd data /dev/stdin fixate
 
SirDice said:
Errmm.. burncd uses the ATAPI (IDE) interface..
So stricly speaking you don't need atapicam and all for that.

atapicam is needed for cdrecord (SCSI) and similar burn programs (nautilus i.e.).

you need atapicam to use growisofs
 
killasmurf86 said:
To make it all happen you need:

in kernel
Code:
options 	CD9660			# ISO 9660 Filesystem, because you want to read them ;)
device		atapicd		# ATAPI CDROM drives
device		atapicam
device		cd				# nessacery for dvd's
device 		pass
device 		scbus
options		MD_ROOT
device		md
options         UDF

and permission to write to /dev/acd0 /dev/cd0 /dev/pass1

note: The pass device number will also depend on the order that SCSI devices are enumerated by the kernel. To determine exactly which one it is, one can use camcontrol devlist as root [thanks to phoenix from daemonforums.org]

note, you can't run growisofs using su, you need to do that as user....

here's some part of my /etc/devfs.conf
Code:
own     acd0    root:users
perm    acd0    0660

own     cd0     root:users
perm    cd0     0660

own     pass1   root:users
perm    pass1   0660

own     pass0   root:users
perm    pass0   0660

Some additions from my own experiences trying to figure this out a few days ago...

1. Recompiling kernels is not required. atapicam can be started via /boot/loader.conf as described in the handbook. It's a personal choice, but avoiding custom kernels makes security updates easier.

2. If you're using a burner connected by USB, then refer to handbook as the setup is much different to the one described here.

3. Device numbers changing. This is a PITA. The enumeration on my machine means that my DVD burner (on IDE via atapicam) is enumerated after my usb drives. This means my DVDs passthrough device (passN) will change, frequently, depending on if I have a USB key inserted or not. I can pass 'pass*' to devfs.conf (or devfs.rules), but that opens up all passthrough devices, hardly ideal. Anyone know of a consistent, secure, way to handle this (fixed to something like a UID, perhaps)?

4. DMA Errors. I can get DVD-R, DVD+RW and DVD+DL disc to burn beautifully with growisofs, but dmesg shows a ton of ata and dma related errors. The errors occur on initializing the device, and when discs are inserted. I'm not at my FreeBSD machine right now, but they appeared related to enabling ata/atapi dma as described in the handbook. I haven't found a solution to these errors yet, but I see similar reports on freebsd mailing lists going back to ~2004. It's possible the errors are unimportant, but I'm wondering if they're also interfering with automounting via hal/thunar-vol-man (which seems broken for me) and/or xfburn (which seems to have issues recognizing and registering DVD media).
 
I use custom kernel and no problems updating to latest security fix...
Well i prefer recompiling everything from sources... haven't tried binary update
 
killasmurf86 said:
I use custom kernel and no problems updating to latest security fix...

I didn't say there would be problems, just that it's easier and probably something best avoided unless you really need to. I'm a firefighter, and have never had a problem with burning buildings, but it doesn't mean I recommend running into them unless it's really necessary :))).

BTW: Some more useful information, in addition to what's already included in the handbook, can be found here: /usr/ports/sysutils/k3b/pkg-message

Now, if someone could post additional info on how to do all this securely, in a consistent manner that survives device reordering, and without all the ata/dma issues, and throw in how to do automounting correctly in xfce I'd be very thankful (hint, hint)...
 
mart said:
Device numbers changing. This is a PITA. The enumeration on my machine means that my DVD burner (on IDE via atapicam) is enumerated after my usb drives. This means my DVDs passthrough device (passN) will change, frequently, depending on if I have a USB key inserted or not. I can pass 'pass*' to devfs.conf (or devfs.rules), but that opens up all passthrough devices, hardly ideal. Anyone know of a consistent, secure, way to handle this (fixed to something like a UID, perhaps)?

Partly solved: I've figured out how to avoid device reordering, which means I can impose more restrictive devfs.conf rules (i.e. permit access to only this specific device, rather than all passthrough devices). It also means I can separate usb thumb drive and dvd burner permissions easily, and it makes scripts a whole lot simpler to write... :)

NOTE: I couldn't find much documentation, so there may be more to this than I've done so far, but the following works great for me...

Code:
1. Discover where your drive is located (in my case cd0)

   [mart@bsddesktop /usr/home/mart]$ dmesg | grep -i cd0.*target
   cd0 at ata3 bus 0 target 0 lun 0

2. Add a device hint to /boot/device.hints (here's mine for reference)

   [mart@bsddesktop /usr/home/mart]$ tail -4 /boot/device.hints 
   # mart:  lock dvdburner (on ata3) to scsi 0
   hint.scbus.0.at="ata3"

3. Tighten up your devfs rules i.e. ensure they're locked to the
   [I]specific[/I] passthrough device [I]only[/I], and to the [I]specific[/I] group [I]only[/I].

4. Reboot

5. Verify its now fixed to scbusN / passN (in my case N=0)

   [mart@bsddesktop /usr/home/mart]$ camcontrol devlist
   <BENQ DVD DD DW1620 B7W9>          at scbus0 target 0 lun 0 (cd0,pass0)
   <USB2.0 CardReader CF RW 0.0>>     at scbus1 target 0 lun 0 (pass1,da0)
   <USB2.0 CardReader Combo 0.0>>     at scbus1 target 0 lun 1 (pass2,da1)
Obviously, use your own info, not mine. Repeat for other devices if necessary.

I still get the

Code:
    acd0: FAILURE - INQUIRY ILLEGAL REQUEST asc=0x24 ascq=0x00
and
Code:
    acd0: FAILURE - READ_BIG timed out
errors. And I still can't get !@$%^$#&* automount functioning properly with xfce... can anyone?
 
Sorry if it's not appropriate topic for mu question, but
is there a way to burn/mount under FreeBSD CD-images produced by ALCOHOL120% (some *.mds & *.mdf files)?
 
Pushrod said:
You can also do:

mkisofs -o /dev/stdout -R -J /path/to/files/you/want/on/cd | burncd data /dev/stdin fixate

it doesn't work on my PC ;(

I removed this from howto for time being
 
Thanks killasmurf86!
I dint know this many options existed for one task.

I was struggling with k3b for a while before posting my question. Unfortunately I still don't know why k3b dint work(it failed even to start). One of the blogs suggested to create a link /dev/cd0 for /dev/acd0 even after which k3b failed to load. Anybody has any idea how to get it to work?
 
you probably need to
Code:
# kldload atapicam
# kldload cd
# kldload pass

and set permissions so you, as user, have rw access to /dev/cdX and /dev/passY

replace X and Y with correct device number
after this you should be able to burn cd/dvd with k3b untill you restart...

to make this permanent read my 1st post at end.... at end there are some tips. I don't say anything about k3b, but if you apply everything mentioned to your system, k3b will work {should}


also you should read comments
 
If you just want a 'backup copy' of your valuable dvd originals there is a port in multimedia called lxdvdrip which is quite useful.

My own attempts at writing dvd's from CLI resulted in a few coasters so I checked out the above. Following the ripping process I noticed that the cli used for growisofs was as follows ;

Code:
growisofs -speed=10 -dvd-compat -use-the-force-luke=dao -Z /dev/cd1 -V DVD_TITLE -dvd-video /tmp/DVD_TITLE
 
Here's a hands free [almost] script for copying audio CD's ~ resulting CD's are correctly identified by CDDB

Code:
#!/bin/sh
echo "Insert audio CD in acd0 and press enter..."
read p
for i in /dev/acd0t* 
do
trackno=`echo $i | cut -d"t" -f2`
dd if=$i of=track${trackno}.cdr bs=2352
done
cdcontrol -f acd0 eject
echo "Insert blank CDR and press enter ..."
read p
burncd -f /dev/acd0 audio *cdr fixate 
cdcontrol -f acd0 eject 
echo "Hit enter to remove temps or Ctrl-C to keep!"
read p
rm track*.cdr
echo "All Done!"

Special thanks to Steve Parker for giving me a hand with this!
 
Most of the examples I've seen for how to use mkisofs assume that what you want to burn to the CD/DVD is everything in and under one or more directories.

But what if I only want to burn *some* of the files in those directories? For example, if I'm doing an incremental backup and only want the files that have recently changed. What techniques do people use in cases like that?

I've considered recreating the directory tree(s) under a backuproot directory, hardlinking the changed files into there, and then giving the backuproot directory as the /path/to/files argument to mkisofs. But I'm wondering if there's a simpler way?

(I tried giving mkisofs the names of the specific files to use, but this flattens the entire hierarchy and leads to naming conflicts.)

Second question: how do you deal with the case where the size of the resulting ISO is bigger than will fit on a DVD?
 
For backup purposes you can also choose to burn a file directly to CD, without creating an ISO 9660 file system(see Handbook 18.6.8 Burning Raw Data CDs),and it is possible to split the big archive into pieces.
For exmaple file archive.tar.gz with size 2G:
Code:
split -b 680m archive.tar.gz [PREFIX]
ls 
archive.tar.gz [PREFIX]aa [PREFIX]ab [PREFIX]ac
then burn all pieces [PREFIX]*,respectively one for disk:
Code:
burncd -f /dev/acd0 -s max data [PREFIX]?? fixate
Now we have backups on 3 CD's.

Recovery:
Copy all CD's from the raw device node to files on hard and concatenate them:
Code:
cp /dev/acd0 path2/file
cat file1 ... file > archive.tar.gz
 
What package delivers burncd? Not available in 13.2 Release, and the man page can't find it either.

It's dead for a long time now:
Code:
commit 256cb4aa441b57e9ad03c267093b9889cad7f258
Author: Alexander Motin <mav@FreeBSD.org>
Date:   Thu Apr 4 09:21:24 2013 +0000

    Remove usr.sbin/burncd, useless after legacy ATA stack removal.
 
Back
Top