Local Information Back |
The following is a list of instructions to write a CD using linux. Most of the information found here is directly from the CD-Writing mini-HOWTO (by Winfried Trumper).
Writing of a CD under Linux is done in 2 steps:
Step 1: Creating an iso9660 filesystem:
Before any storage medium (e.g. floppy disk, harddisk or CD) can be used, it must get a filesystem. This filesystem is responsible for organising and incorporating the files that should be stored on the medium.
Well, the writable CDs are only writable once, so if we would write an empty filesystem to them they would get formatted - but remain completely empty.
So what we need is a tool that creates the filesystem while copying the files to the CD. The common file system for CD-ROMS for PC's is known as the iso9660 filesystem. To create an image of this file system, we use the mkisofs command as follows:
% mkisofs -r -o cdimage storage
This command has put the entire input "storage" hierarchy in the output file "cdimage" in the form of an iso9660 filesystem.
The option '-r' sets the permissions of all files to be public readable on the CD and enables Rock Ridge extensions. That is what one usually wants and use of this option is recommended until you now what you're doing (hint: without '-r' the mount-point gets the permissions of "storage"!).
Sometimes, all the directories or the files that you want to put on CDs are not in one tree. In this instance, you may want to make a directory containing a symbolic link to the trees you want to include. In order for mkisofs to follow symbolic links, you must specify the -f flag.
To create a symbolic link called pumpkins in the directory storage to the directory /usr/pumpkins in storage, use the following command (assuming that you are currently in the directory storage):
% ln -s /usr/pumpkins pumpkins
Limitations of the iso9660 filesystem are:
Step 2a: Paranoia Check
Now that we have an image of the directory that we want to write to our CD, we might want to verify that mkisofs has created the filesystem correctly. We can employ a loopback device to mount the above mkisofs created file to insure that the directory layout of the CD-image is okay. We use the following command to do this:
% mount -t iso9660 -o ro,loop=/dev/loop0 cdimage /loop
You should see the directories and files inside `storage' in the directory /loop if all went well. After you are satisfied you should unmount /loop as:
% umount /loop
At the time of writing this documentation, only root was able to invoke this command.
Step 2b: Write the image to the CD
If there are no problems with the CD-image, we can now write to a CD using the cdrecord utility. When writing a CD-recordable just type on lamprey:
% cdrecord -v dev=0,0 speed=2 cdimage
on acara, for a writeable CD use the following:
% cdrecord -v dev=0,1,0 speed=8 cdimage
and for a rewritable CD on acara use
% cdrecord -v dev=0,1,0 speed=4 cdimage
For this to work, you have to be logged in on lamprey, however, you do not have to be root. The speed option corresponds to the writing speed of our CD (2X). It is possible to write at 2X speed over the network, eg. your cdimage does not have to be on the lamprey disk. `cdimage' is, of course, the name of our CD-image created by mkisofs). -v lets you see the writing progress.
If you are writing to a CD-rewritable, you have to erase the disk prior to reuse. To do so type
% cdrecord dev=0,0 speed=2 blank=all
This took ~40 minutes when I tested it, but it works. You can try one of the
other "blank" options listed below. If any work and are faster, then let me know.
Other options are: ================== blank=all To blank the full CD blank=fast Minimal blank, erasing the PMA, the TOC and the pregap. blank=track To blank a track blank=session To blank the last session blank=help To see some more options
I think you may be able to blank from within the burning command, eg:
% cdrecord dev=0,0 blank=fast speed=2 cdimage
But haven't tried that yet
mkisofs -o session1.cdimage -R session1 cdrecord -v speed=2 dev=0,0 -eject -multi session1.cdimage
This first creates a session1.cdimage file with all the data in the session1 directory. Next the data in the session1.cdimage file is written to the disk and then cdrecord appends ~20Mb of padding. When cdrecord starts writing the padding, it will print a line "Fixating..." (you may need the -v flag as given above to see this). The fixation step takes 1 to 3 minutes. Next type:
cdrecord -msinfo dev=0,0This prints out something like: 0,18099
The first number is always zero, the second varies depending on how much data has already been written to the CD. Write these numbers down. Next type:
mkisofs -o session2.cdimage -R -C 0,18099 -M session1.cdimage session2This creates a session2.cdimage file appropriate for appending after the previously written session1.cdimage. To burn it on the CD type:
cdrecord -v speed=2 dev=0,0 -eject -multi session2.cdimageThis will write the second session followed by another fixation. When I repeated the "cdrecord -msinfo dev=0,0" command the output was:18099,31275 I expect that these are the numbers you would give to the -C mkisofs flag when creating a third session.
Note that the procedure above deviates from the description in the original documentation. However, when following the official procedure it never worked and the steps above did.
Note! Make sure nothing is mounted on /mnt/cdrw, or else cdrecord will not work.