As hard drives and networks grow, maintaining good backups without going bananas becomes more of a challenge. A good tool to add to your backup kit is a CD writer. Even when a CD-R/RW is too small for a complete backup scheme, it comes in handy for smaller, specialized uses. Part 1 of this two-part series will tell how to use CD writers in Linux, while Part 2 will cover automating backups with scripts using tools like tar and rsync.
CD writers have dropped in price enough to make sense as CD-ROM drive replacements. Because restoring from a CD is fast and easy, I like using CD-R/RWs to backup server configurations and to backup the data of users with sensitive, mission-critical information. CDs can be read on any computer, whereas restoring from tape is a complicated process, to say the least. Users who can be trusted to manage their own CD backups make life a little easier for the overworked sysadmin.
Consider long-term archiving. Because CD-ROMs are nearly universal, CD-Rs make sense for longer-term storage. Of course 5.25″ floppy disks were nearly universal once upon a time as well, proving there are no guarantees!
You’ve probably heard that CD-RWs are not readable in all drives. Any modern CD drive should have multiread capability, which is easy enough to test. DVD drives are especially precise and should be able to read any disk. If you have an important disk that has been damaged, try reading it in a DVD drive.
I recommend using either SCSI or IDE/ATAPI interfaces, while avoiding parallel port and USB. Parallel port burners are a pain no matter what operating system they are on. You’ll need the 2.4.18 kernel or later of Linux for good USB support, and even then I’m not convinced that USB would be fast enough for regular use. And while Firewire sounds marvelous, it can be especially tricky to get functioning properly (if you can make it work, let me know and you can star in a future article). Newer drives are best; any drive over 3 years old is suspect, as there’s been considerable improvement in the technology over the last few years.
SCSI Emulation
ATAPI drives need to use the ide-scsi pseudo device driver. Most modern Linux distributions have this compiled into the kernel. Search your system for the ide-scsi kernel module:
$ locate ide-scsi.o
/lib/modules/2.4.19/kernel/drivers/scsi/ide-scsi.o
If it is not present, the kernel needs to be recompiled. See Resources for more information.
Your particular flavor of Linux may have nice graphical config tools to set up ide-scsi. All that is necessary is a minor edit of two files: /etc/modules.conf (in Debian /etc/modules) and your bootloader, GRUB or LILO. These two lines appear in my /etc/modules:
ide-cd ignore=”hdb hdc”
ide-scsi
By default, the IDE subsystem claims all ATA devices for its own. The “ignore” line enables the SCSI subsystem to grab both my CD-RW and CD-ROM. If you want to copy CDs, both drives will need to use the ide-scsi pseudo device driver. If you don’t want to enable SCSI emulation on your CD-ROM, another way to copy a CD is to mount the drive and copy all the files,
Add the following to the end of lilo.conf:
append=”hdb=ide-scsi”
append=”hdc=ide-scsi”
Next, add this line to /etc/grub.conf or to the “kernel” line in Debian /boot/grub/menu.lst:
hdb=scsi hdc=scsi
Be sure to use the correct hdn designation for your drives.
GUI/ No GUI
There are many GUI programs for CD writing in Linux: X-CD-Roast, gcombust, KonCD, Gnome Toaster, and eroaster, just to name a few. All are graphical front ends for the three core CD writing programs: cdroaster, mkisofs, and cdrdao (and sometimes cdparanoia as well for ripping music tracks). cdrdao, “disk-at-once”, is primarily for writing audio tracks. It also enables copying-on-the-fly and writing mixed mode disks. We’ll stick to data recording in this article.
Understanding cdroaster and mkisofs has three benefits: the GUI programs will be more understandable, you’ll have the option of burning disks without running X, and you’ll find these tools have more options than most of the GUI front-ends.
Burning Disks
Burning a disk is a two-step process. First create an ISO9660 image, then burn the image to disk. mkisofs creates filesystems, while cdrecord controls the actual writing to disk.
$ mkisofs -o monday_backup.iso -JRVv /home/carla/
-o specifies the backup filename
-J use Joliet naming records, for Windows compatibility
-R Rock Ridge naming conventions for preserving filename length and cases, for UNIX/Linux
-V Volume ID- this is the disk name that shows up in Windows Explorer
-v verbose, for a running commentary as the image is created
Test The Image
Mount the image to verify everything is OK and to lessen the risk of creating a coaster:
# mount -t iso9660 -o ro,loop=/dev/loop0 monday_backup.iso /cdrom
This mounts it in the /cdrom directory, and if the image is error-free, all the files and directories you selected should appear.
Now that you have a nice ISO image, find the SCSI device address of your CD writer, as root:
# cdrecord -scanbus
Cdrecord 1.10 (i686-pc-linux-gnu) Copyright (C) 1995-2001 Jvrg Schilling
Linux sg driver version: 3.1.24
Using libscg version ‘schily-0.5’
scsibus0:
0,0,0 0) ‘TOSHIBA ‘ ‘DVD-ROM SD-M1202’ ‘1020’ Removable CD-ROM
0,1,0 1) ‘LITE-ON ‘ ‘LTR-24102B ‘ ‘5S54’ Removable CD-ROM
0,2,0 2) *
0,3,0 3) *
0,4,0 4) *
0,5,0 5) *
0,6,0 6) *
0,7,0 7) *
Burn, Baby
# cdrecord -v -eject speed=8 dev=0,1,0 monday_backup.iso
-v verbose
-eject eject when finished
-speed write speed
-dev device number from cdrecord -scanbus
And finally, enter the name of the image being burned.
To perform a quick erase on a CD-RW, which erases only the Table of Contents (TOC) and the Program Memory Area (PMA), type:
# cdrecord –dev=0,1,0 –blank=fast
To completely erase a disk, type:
# cdrecord –dev=0,1,0 –blank=all
Next week we’ll dig more deeply into command options, automating CD backups, and restoring data from a CD.