| Grabber Softwares : Enhance Your Computing |
CD Writing With Linux A step-by-step guide to mastering CD-ROMs under Linux This months PC Quest CD-ROM was mastered entirely in Linux, using tools that are part of this CD-ROM and those that are freely available on the Net. CD writing is not anything new to Linux, and almost all CD writers and ReWriters are supported. We used an external Yamaha CRW4260 ReWritable drive, connected via an Adaptec 2940 SCSI adapter. Writing a CD-ROM is a two-stage process. The first process consists of collecting data and replicating the CD directory structure on a hard disk, the CD image. The second process consists of burning the image onto a CD recordable disk. As the Red Hat installation section of the PCQ CD-ROM required the use of long file names, we used the standard ISO9660 format with Rockridge extensions, which enables UNIX systems to see long file names. The Rockridge extension format generates long filenames from the standard ISO9660 8.3 format by creating a file TRANS.TBL in each directory of the CD-ROM. The TRANS.TBL file is a simple text file that stores both the 8.3 and long file name of each file in the directory. To operating systems such as DOS and Win 95, only the standard 8.3 file name is visible.
Unlike standard SCSI CD-ROMs, CD recordable drives are treated as Generic SCSI devices, and hence need special support in the kernel built-in for them. If youre using Red Hat Linux, then the required support is already built-in and available as a module called sg. The first thing to check is whether your CD-ROM drive is recognized at the boot time. You should see a message something like (as in our case):
Here the CD-ROM has been identified as device sr0 on SCSI BUS0, SCSI ID 1, LUN 0. Its a good idea to keep these parameters in mind, as you will probably need them later on (You dont have to reboot to check them, just type dmesg | less, and you can examine you system bootlog. If generic SCSI or loopback devices are not to be included in the /dev/ directory, you will have to create those devices yourself.
Now you need to load the SCSI generic device driver. If you are running RED HAT, type insmod sg. If it doesnt work, or you are not running RED HAT, then you will need to recompile your kernel to include SCSI device support. Also check that you have loop device support (as shown below) as well. If not, you will have to compile that in as well. To make sure that all is well with your set-up, type cat /proc/devices The output should be similar to this: Character Devices:
If you see all the correct devices in the list, you are ready to create your CD-ROM. Creating the CD-ROM image To create a standard ISO9660 filesystem image, you have to use the mkisofs tool. It has support for various CD-ROM formats including audio, VCD, multi-session, CD Extra, and bootable disks (Using the El Torito format). Though it is possible to write the CD-ROM without actually writing a raw ISO9660 image, doing so allows you to view and test the CD-ROM before it is actually written. This is generally considered safer as any interruptions in the data pipeline caused by a slow system or network interruption can be fatal. In fact, to be on the safer side, you should disable all network traffic from your computer, and even unplug the network cable. We first created the raw image using mkisosf from the directory tree /cddata/May_PCQ onto, a separate hard disk mounted on /image using the command: mkisofs -r -K -b misc/instimage/initrd.img -c misc/instimage/boot.cat -A PCQ_MAY98 -o /image/image.iso /cddata/May_PCQ This creates a Rockridge extensions enabled (-r) bootable CD-ROM (-b) using the file initrd.img as the boot image, and boot.cat as the boot catalog (-c). The image is written to the file /image/image.iso using the directory tree /CD-ROMdata/May_PCQ. The next step consists of mounting the raw image as an ISO9660 filesystem to check that all is well. Simply create a mount point, say /tmp/test and mount
the image by issuing the command: mount -t iso9660 -o ro,loop=/dev/loop0
/image/image.iso To verify that all paths and filenames are correct, you should be able to examine the contents of the CD-ROM image like any other mounted partition. Writing the CD-ROM The final part is actually writing the CD-ROM. There are several CD writing tools available, the most popular being cdwrite, cdrecord, and the X-based Xcdroast. Xcdroast is based on cdwrite, which does not yet implement multi-session capabilities, so we decided to use cdrecord. It is available as a rpm package from any rpm resource such as ftp.redhat.com. Cdrecord is a simple command line utility, and works with any generic CD writer. However, you have to specify the SCSI device by its SCSI ID and LUN, so dig out the information you obtained at boot time. You can also simply type ./cdrecord-scanbus. This will give you the SCSI bus, ID, and LUN of your SCSI devices. In our case, we had the configuration Bus=0, SCSI Id=1, LUN=0. Its a good idea to do a dummy run to see whether your system is fast enough to write data to the CD-ROM at the required rate. CD writers are not kind to data interruptions, so dont even dream of doing this over a NFS mounted drive. cdrecord -v -dummy dev=0,1,0 speed=4 /image/image.iso This runs the entire burning process, with the laser turned off! The speed=4 parameter is for a 4X drive. You should generally experiment with different speed settings to obtain the best results. Once you are convinced that all is well, go ahead and repeat the process without the -dummy option. It should take approximately 16 minutes to write a 600 MB disk at 4x writing speed. |
Gopal Y Upadhyaya
Grabber Softwares