CD Howto
(How to read and write CD's)
© (2004) Pablo Arés, pablo /at/ math.tifr.res.in
How to read CD's
Reading a CD is a simple task. Here are the steps:
- Put the CD in the drive (press the buttom to get the drive open,
put the CD inside and press the buttom again to close the drive).
- Issue the following command:
mount /cdrom
- Now the files on the CD can be access in the /cdrom
directory. You can cd to it and operate as any other normal
directory.
- Just in case you are in the cdrom directory, give the
following command to go back to your home directory:
cd
- Now do:
umount /cdrom
- Finally press the buttom to open the drive or do
eject
- Remove the CD and press the buttom to close the drive.
How to write CD's
Writing a CD is a litte more complex task. There are several things you
have to take into account, and depending on that, you will have to
execute (or not) some of the steps below:
- Is the CD write once (CD-R) or can it be erased (CD-RW)?
- Is there any data in the CD? Or is it empty?
- If there is data, do you want to preserve it, or you do not mind
"overwriting" on it?
Here are the steps. I will write the different options depending on the
possibilities above. I will assume that the files you want to write in
the CD are in a directory called /cdwrite/myfiles. You can make
this directory with the command:
mkdir /cdwrite/myfiles
and then move/copy there the files you want to write in the CD (the
directory /cdwrite is available in the machines with CD writers,
and you can always write in that directory).
- Change directories with
cd /cdwrite
- Put the CD in the drive (see above).
- If your CD has data and you want to preserve it, do the
following:
cdrecord -msinfo dev=0,0,0
That will produce two number, n,m Write them down since you will
need them later.
- If your CD is RW and you want to erase the data, do:
cdrecord blank=gas dev=0,0,0
- Make the "image" to be written in the CD, that is
the file containing all the files you want to write in the CD. The way
to make it depends on whether there is data to be preserved in the CD or
not. Here are the two cases:
- If there is data to be preserved, do the following:
mkisofs -q -R -r -l -J -C n,m -M /dev/scd0 -o /cdwrite/cd.iso /cdwrite/myfiles
Here n,m are the number you got in one the above steps.
- If there is no data, or you do not want to save it, do the
following:
mkisofs -q -R -r -l -J -o /cdwrite/cd.iso /cdwrite/myfiles
- Finally write the cd with the command:
cdrecord -multi dev=0,0,0 -eject -data /cdwrite/cd.iso
- Get the CD from the drive (it will automatically open when the
system finishes writing the CD) and close the drive.
- Erase the files you have created:
rm -fr /cdwrite/myfiles
rm -f /cdwrite/cd.iso