Setting up a CD/DVD burner under FreeBSD
Installing the ATAPI/CAM Driver
If like me, you purchased one of those <$100 LiteOn IDE DVD burners, then you will most likely want to setup ATAPI/CAM before you go any further. This driver allows ATAPI devices (CD-ROM, CD-RW, DVD drives etc...) to be accessed through the SCSI subsystem, and so allows the use of applications like sysutils/cdrdao or cdrecord.
Add the following lines to your kernel:
device atapicam device scbus device cd device pass
For completeness, device ata needs to be in your kernel, but chances are, it's already there or you wouldn't even be booting.
Then rebuild, install your new kernel, and reboot your machine. During the boot process, your burner should show up, like so:
The drive could now be accessed via the /dev/cd0 device name, for example to mount a CD-ROM on /cdrom, just type the following:
# mount -t cd9660 /dev/cd0 /cdrom
Before we go much farther, it is worth mentioning how to setup /etc/devfs.conf correctly so that you don't have to be root to do all of this. I have added the following lines to /etc/devfs.conf:
# Commonly used by many ports link acd0 cdrom link acd0 dvd perm acd0 0660 perm cd0 0660 perm pass0 0660 perm pass1 0660 perm pass2 0660 perm pass3 0660 perm xpt0 0666
In addition, in /etc/group, I added myself to the operator group so that I have group permissions to execute the above devices. These updates won't be effective until you reboot. However, you can make these changes by hand and they will stick then if you made the above changes.
Installing the Software
You will want to install the following ports. I'll cover what each does later on.
/usr/ports/sysutils/cdrtools /usr/ports/sysutils/dvd+rw-tools /usr/ports/sysutils/vobcopy /usr/ports/multimedia/mplayer
To create a plain vanilla ISO9660 from a directory on your disk, do the following: (Remember that you can only save files with 8.3 chars file length, eight chars for the file name and three for the filetype).
# mkisofs -o cd.iso cd_dir
For an ISO9660 DVD with Joliet we do this: (Supports up to 31 chars in filename, most likely will only work on Windows).
# mkisofs -o cd.iso -J cd_dir
For an ISO9660 DVD with Joliet and Rock Ridge extension: (As I've understood this -J (Joliet) makes the DVD able to use filenames with up to 31 chars length, -r (Rock Ridge) do it for the *NIX systems. -l do so the disc actually use 31 character filenames).
# mkisofs -o cd.iso -J -r -l cd_dir
Checking your Setup
You can run the following command to get the SCSI address of the burner.
[tethys]:[10:55am]:[/home/rnejdl] > camcontrol devlist
So 1,0,0 will be the SCSI address to use with cdrecord(1) and other SCSI application.
growisofs was originally designed as a frontend to mkisofs to facilitate appending of data to ISO9660 volumes residing on random-access media such as DVD+RW, DVD-RAM, plain files, hard disk partitions. In otherwords, the growisofs does everything that mkisofs does and more. If you have your ISO image, you can use growisofs to burn directly to DVD as follows:
# growisofs -dvd-compat -speed=4 -Z /dev/cd0=image.iso
Of course you don't have to create an ISO file/image to be able to burn. We could just have passed the directory and other options to growisofs (as you probably remember growisofs is a frontend to mkisofs) and added a few flags for burning:
# growisofs -Z /dev/cd0 -r -J -speed=4 /folder/to/ Executing 'builtin_dd if=image.iso of=/dev/pass0 obs=32k seek=0' 16154624/3688857600 ( 0.4%) @3.4x, remaining 22:44 26902528/3688857600 ( 0.7%) @2.3x, remaining 20:25 ...
Now if all went well we've gotten a new DVD disc with content. Everything worked well for me the first time and I hope everything went as well for you.
Burncd is the utility you use in FreeBSD if you have an atapi cdrom (or dvd) drive. It's fairly simple to use and almost every CDRom drive built after 1999 is support by it. Here's an example where I am burning the DragonFlyBSD cdrom to disc:
[tethys]:[10:45am]:[/home/rnejdl] > burncd -f /dev/acd0 data dfbsd-LATEST-GCC3.iso fixate
With rewritable CD's, you will need to erase them first. There are two methods of erasing, blank and erase. Blank is by far the quicker method and can be executed as follows:
[tethys]:[7:25pm]:[/home/rnejdl] > burncd -f /dev/acd0 blank blanking CD - 99 % done next writeable LBA 0 writing from file 5.2-CURRENT-20040809-SESNAP.iso size 243328 KB written this track 243328 KB (100%) total 243328 KB [tethys]:[7:33pm]:[/home/rnejdl] >
Then, to burn to the rewritable CD:
[tethys]:[7:33pm]:[/home/rnejdl] > burncd -f /dev/acd0 data 5.2-CURRENT-20040809-SESNAP.iso fixate next writeable LBA 121816 writing from file 5.2-CURRENT-20040809-SESNAP.iso size 243328 KB written this track 243328 KB (100%) total 243328 KB [tethys]:[7:43pm]:[/home/rnejdl]
CDRecord is the cd burning utility you use if you have a scsi drive or if you have atapicam setup correctly (as listed above). To start, you should make sure that cdrecord sees your cd burner:
[tethys]:[11:02am]:[/home/rnejdl] > cdrecord -scanbus Cdrecord 2.00.3 (i386-unknown-freebsd5.2.1) Copyright (C) 1995-2002 Jörg Schilling Using libscg version 'schily-0.7' scsibus1: 1,0,0 100) 'LITE-ON ' 'DVDRW LDW-451S ' 'GSB6' Removable CD-ROM 1,1,0 101) * 1,2,0 102) * 1,3,0 103) * 1,4,0 104) * 1,5,0 105) * 1,6,0 106) * 1,7,0 107) * [tethys]:[11:20am]:[/home/rnejdl] >
In this case, my nifty Lite-On DVD burner is on 1,0,0. Remember this, or if you are lazy like me, set it as an environmental variable. My CD burner can handle 24 speed writes, so I'm setting that as well:
setenv CDR_SPEED 24 setenv CDR_DEVICE 1,0,0
While cdrecord has many options, basic usage is even simpler than burncd. Burning an ISO 9660 image is done with:
# cdrecord dev=device imagefile.iso
Vobcopy is a simple program (at least simple in usage) that copies the contents of a DVD to your harddrive. This is useful is you want to copy a DVD or create a DIVX of one. Very simply, you mount the DVD rom and then run the program:
[tethys]:[10:45am]:[/home/rnejdl] > mount /cdrom [tethys]:[10:45am]:[/home/rnejdl] > vobcopy /cdrom ... Lots of stuff here ...
Vobcopy will create a directory that's the name of the DVD you copied into your current working directory.
Although mplayer is most commonly used just for playing media files, it also has the nice ability to take as input a set of vob files (which you obtained above) and to process them into an avi that you could burn into a VCD. Here's what the command line options would look like to do convert the raw .vob files into divx's. This command line is a bit complex so I am writing this doc to remember this stuff for me.
cat *.vob | mencoder -o mymovie.avi \ -oac mp3lame -lameopts br=192:vbr=2 \ -ovc lavc -lavcopts vcodec=mpeg4:vhq:keyint=250 -vop pp lb -
If you want to learn more about the specific mencoder flags, you should consult the mencoder man file. For example, if you want to encode in divx 3 instead, you can use vcodec=msmpeg4. Use this if you want to be able to play the video back on older players. Finally try playing back the movie using mplayer, after it's done encoding. You may also, want to try using other video players, such as xine. In order, to test whether or not playback works properly in other players.
What if "I dont have 5.0 gigs of free harddrive space!" you ask. Dont worry all is not lost, you can completely forget about vobcopy and use mplayer to rip and encode directly from the dvd. To do this though, you need to make sure mplayer is compiled with "WITH_DVD=YES", otherwise mplayer wont know how to talk to the dvd player. This farther knocks down the time it takes to rip and encode since no temporary files are created on the harddrive. The only down side of this is you are still limited by the speed of your dvd drive, and you wont have the original mpeg2 files laying around for high quality playback. However, for most people with limited drive space keeping the original mpeg2 files around is impractical anyways.
mencoder -dvd 1 -oac mp3lame -lameopts br=192:vbr=2 \ -ovc lavc -lavcopts vcodec=msmpeg4:vhq:keyint=250 \ -o output.avi -vop pp lb
I actually have not had to burn an audio CD yet from FreeBSD. To get the contents of an audio CD into an MP3 file, I use with /usr/ports/audio/grip or KAudioCreator. These programs offer nice GUI's, CDDB polling, and automatic playlist automation.
My CD burning and ripping were rather slow and painful at times. I found that in FreeBSD, to be safe, they do not enable DMA transfers to ATAPI drives by default. Trust me, you probably want to do this if you have any sort of modern drive. Simply add these lines to /boot/loader.conf:
This page was created in 0.00112 seconds
Comments and Questions
Last modified: May 28 2007.