Remember when creating CDs, the root of the CD is relative to the created directory; in this case, cdimage. Once you have your files in this directory, you are ready to create the iso9660 image using the mkisofs command. To create the basic image, use the following command:
mkisofs -r -o cdimage.iso cdimage
The -r option ensures the image contains additional file description data by way of the Rock Ridge protocol, preserving the original file name and setting permissions optimally for CD-ROMs such that read/execute permissions become global, write permissions are cleared, and special mode bits are also cleared since they do not apply on CD-ROMs. The -o option designates the output file (cdimage.iso). The last value is the directory in which the files are located.
Many commercially manufactured Linux CDs, such as Red Hat, are bootable. This isn't difficult to do using the “El Torito” standard. Most newer BIOSes today support the bootable CD feature, and most bootable CDs for the PC are based on El Torito. El Torito makes your CD appear as a floppy, and thus your BIOS can boot it.
If you want a bootable CD, you'll need a 1.44MB boot image intended for a boot floppy. In our distribution example, we could use the boot image used for installation. For distribution_b, the name of the boot image is boot.img. The process by which we make a CD bootable takes place in the creation of the iso9660 image (International Organization for Standardization specification for compact disk read-only memory). Thus, before we create our image, we need to create a directory inside of cdimage to hold the boot image; a directory called boot would work fine. So, we place the image boot.img into cdimage/boot and create the iso9660 image by executing the following command:
mkisofs -r -b boot/boot.img -c boot/boot.cat -o\ cdimage.iso cdimage
Here we have two new options, both of which are used to make the CD bootable. The -b option is followed by the name of the boot image to be booted. Note that the file is relative to the root of the CD. The -c option is followed by the name of the boot catalog required by El Torito; this file is automatically created by mkisofs. Only the more recent versions of mkisofs allow for the automatic creation of the boot catalog; older versions require you to create it yourself.
Before actually burning the CD, take a look at your image layout by mounting it. This is done using a loopback device, so this must be supported in the kernel. The following command will mount your image:
mount -r -t iso9660 -o loop cdimage.iso /mnt
Once you've created your image, bootable or not, you are ready for the final process of burning it onto the CD using either cdrecord or cdwrite. Take the following into consideration before you start:
Make sure the computer isn't experiencing any excessive vibrations.
Make sure the image is on a local hard drive.
Make sure the load on your system isn't too high.
Keeping these three things in mind will help prevent errors during the write process. The CD writer can be put through a test process that won't actually write, but will simulate the entire process. This is done by adding the -dummy option for cdrecord and the -y option for cdwrite. Now all that is left is inserting a blank CD and executing the command that matches your choice of writer.
cdrecord -eject -v -isosize speed=2 dev=0,0\ cdimage.iso cdwrite -ev --device /dev/??? -s 2 cdimage.isoThe first two options for both utilities are eject and verbose. Thus, the CD will eject after the burning process is finished, and the program will run in verbose mode. The option -isosize for cdrecord limits the size of the CD to the size of the iso9660 image. The options speed=2 and -s 2 indicate the speed at which to write to the CD; in this case, the 2 means at 2x. Finally, the options --device, dev=0,0 and /dev/??? set the target device, where /dev/??? should be your CD-R (i.e., /dev/scd0) and 0,0 stands for the SCSI ID and bus in that order.
If all worked out well, congratulations. You now have a full-fledged, iso9660 CD. You can make a CD with other formats just as well. The utility mkhybrid, included with mkisofs, can make images of Joliet and HFS format. It is also possible to make a CD with the EXT2 file system format. Have fun burning!
Alex Withers has been using Linux since 1.1.59. He is currently studying computer science at Gonzaga University and can be reached at email@example.com.
- Machine Learning Everywhere
- Smoothwall Express
- Bash Shell Script: Building a Better March Madness Bracket
- Own Your DNS Data
- Simple Server Hardening
- From vs. to + for Microsoft and Linux
- Understanding OpenStack's Success
- The Weather Outside Is Frightful (Or Is It?)
- Ensono M.O.
- Understanding Firewalld in Multi-Zone Configurations