Custom Kernel and CD Burning


Building a Custom Kernel
CD Burning

Building a Custom Kernel

Building a custom kernel is very useful for fine tuning your system, and adding support for new devices. It is a very powerful tool, yet is easy to wield.

cd /usr/src/sys/i386/conf

If you have an architecture other than i386, cd there instead (you are most likely running on i386 if you're migrating from windows). This directory holds your kernel configuration files. You will notice a file named GENERIC. This is the file that holds the configuration for the generic FreeBSD kernel. We don't want to mess with that one, in case we want to base other kernels off of it, or if we want to rebuild it. As root:

cp GENERIC NEWKER

You can rename NEWKER to whatever you want, just as long as its something that lets you know what kernel configuration this is.

vi NEWKER

This is where you get to modifying your kernel. If you know your hardware, you can comment out lines you know you don't need. If you want USB2 support (who doesn't?) add this line:

device ehci

If you want to be neat about it, put this under your USB support section. If you want CD Burning with ATA/ATAPI drives (which is probably what you have) make sure you have these four lines (some may already be present, just uncomment them by removing the pound sign, if it is there).

device atapicam
device scbus
device cd
device pass

The rest of the configuring can be done at will by you. If you're not sure about something, leave it in, as it won't hurt, it'll just make your boot time a bit slower (not much). When you're done with vi type:

/usr/sbin/config NEWKER

At the end it will spit out a directory, cd there, and issue three commands:

cd ../compile/NEWKER
make depend
make
make install

Now your new kernel is installed at /boot/kernel Your old kernel is now at /boot/kernel.old FreeBSD is kind enough to save your old kernel configuration, but it only saves the most recent one. In other words, if you ever want to go back to the old default kernel, you'll want to save it elsewhere. It's also possible to boot off of a different kernel, so I backup the default kernel in case something ever goes wrong and I need it. In order to do so let's do this.

cd /boot
cp -r kernel.old kernel.generic

It's redundant to have two of the same kernel, but it doesn't matter, because the next time you build a custom kernel you will overwrite kernel.old. Now when you reboot you should be in the new environment. You can now enjoy fast USB2 transfers, and CD burning. In case something goes wrong, you can boot off of your old kernel. At the FreeBSD startup screen, choose the "6. Escape to loader prompt" option before the 10 seconds ends. (This is option "6." in 5.4-RELEASE. If you're running a different version, it might be in a different place on the menu but you WILL have this option!) Then:

unload
boot /boot/kernel.generic/kernel

That will have you boot off of the generic kernel. Now you can fix the problem with your new kernel. For the time being however, you should (only if you're fixing your new kernel):

mv -f /boot/kernel /boot/kernel.bad
cp -r /boot/kernel.generic /boot/kernel

CD Burning

Make sure you've gone through the section on building a custom kernel first, and have built in support for ATA/ATAPI CD burners before continuing. In order to burn cd's at a somewhat reasonable speed, you need to add two lines to /boot/loader.conf (as root of course):

hw.ata.ata_dma="1"
hw.ata.atapi_dma="1"

Now we need to install a CD-burning application. At a bare minimum (i.e. command-line only), you'll need to install cdrtools and cdrdao. However, most people prefer a graphical CD-burning program. If you want a graphical CD-burning program (most people do), skip ahead. Otherwise, continue with the following steps.

It is quite possible to burn CDs without installing any graphical programs to do the job. However, we do need to install the following two applications in order to be able to burn CDs. (Even if you plan to install a graphical burning program later, there's no harm in installing these apps because they're most likely dependencies of any graphical program you might install).

cd /usr/ports/sysutils/cdrtools
make install clean

This will install cdrecord and mkisofs, which allow you to burn CDs and create .iso files, along with multiple other command-line CD-related utilities.

cd /usr/ports/sysutils/cdrdao
make install clean

This will install cdrdao, which allows you to burn CDs using disk-at-once mode (which we'll need if we want to properly record audio CDs).

Once you have these two packages installed, you do not need to install anything else in order to complete our setup. Simply skip the next step about installing K3B and follow the remaining directions on this page to complete your setup of CD-burning.

Although there are many graphical CD-burning applications to choose from, allow us to recommend K3B, a rather large (but extremely capable) graphical CD-Burning application.

whereis k3b
cd /usr/ports/sysutils/k3b
make install clean

At this point we should be able to burn CDs as root. However, if we want our user to be able to burn CDs, we have to change some permissions:

cd /usr/local/bin
chmod 4711 cdrdao cdrecord

Now we have to add a few lines to /etc/devfs.conf:

vi /etc/devfs.conf

Now add these lines:

perm xpt0 0666
perm pass0 0666
perm pass1 0666

It is my understanding that you need a number of pass entries equal to the number of cd-roms you have. When I had only pass0 then just my DVD-ROM showed up, but once I had pass1 added, then I could also access my CD-RW just fine. Now reboot and we should be ready to burn CDs.

As a final note, we have not included information on the usage of K3B because we believe most users are familiar with the basics of creating a CD with a graphical CD-Burning application. K3B is a pretty straight-forward application to use, but that doesn't mean that it is the only CD-Burning application out there. We have simply had the most luck with it to date and for that reason list it on this page. Do not feel compelled to use it just because we do.

If you are interested in command-line CD/DVD-Burning, we have a separate page here which deals with that topic.