Linux Know-How provides a collection of introductory texts on often needed Linux skills. |
Home Newbie Guide Some Essential Linux Applications Writing CD-R/Ws | ||
See also: How can I access my CDROM? | ||
Search the VIAS Library | Index | ||
Writing CD-R/WsDisclaimer: Copying copyrighted material is illegal. Do NOT use the instructions below for anything illegal. Writing CDs used to be tricky, but these days I simply use (as root, in X terminal): xcdroast & If it works for you as it works for me, you don't need to read any further.
o All setup has to be done as root. Newer distributions (e.g. RedHat 8.0) may require no setup at all. o Check your boot files if they pass a parameter to the kernel with the information that you have the ide-scsi drive: "hdb=ide-scsi". If required, add to the file /etc/lilo.conf or /boot/grub/grub.conf (depending which boot loader your system uses): the option "hdb-ide-scsi" so that the line looks like this: append="hdb=ide-scsi" #(for /etc/lilo.conf, at the end of the Linux "image" section) kernel /boot/vmlinuz-2.4.7-10 ro root=/dev/hda6 hdb=ide-scsi #(for /boot/grub/grub.conf) Adjust the line above if your CD writer is not "hdb" (second drive on the first IDE interface). It makes your IDE-ATAPI CD-W(R) to be seen on your Linux system as a SCSI device. (It is not really a SCSI device, it is an IDE device, it just pretends to be SCSI.) Run lilo after making any changes to /etc/lilo.conf . Grub does not need re-running.
cd /dev/ ./MAKEDEV loop
lsmod If required, add these two lines at the end of the file /etc/rc.d/rc.local so that the needed kernel modules are automatically loaded on system startup: /sbin/insmod ide-scsi /sbin/insmod loop These two kernel modules are needed for SCSI emulation of IDE drives and to support the loop devices, respectively.
ls -l /dev/cdrom ln -s /dev/scd0 /dev/cdrom #(if required) You may need to do this because "/dev/cdrom" pointed to an IDE device (probably /dev/hdb) but now this changes since your CD-R is going to be in SCSI emulation mode. There is also /dev/cdwriter that you may want to point to /dev/cdrom although it is not necessary on a single CD drive system: ln -s /dev/cdwriter /dev/cdrom
cdrecord -scanbus If it is not installed, download the program "cdrecord" from your favorite Linux software repository (e.g., http://idirect.linuxberg.com/ ). Then install the source code, compile it, install the program, and make symbolic links so that the executable are easy to run (the installation would be much easier if you found a binary *.rpm file): cd /usr/local tar -xvzf /the_path_to_which_you_downloaded/cdrecord-1.6.1.tar.gz ls cd cdrecord-1.6.1 make make install ls /opt/schily/bin/ ln -s /opt/schily/bin/* /usr/local/ The program cdrecord is a spartan, command line utility for writing CD. There are several GUI front ends to it, but they will be useless if the underlying cdrecord does not work properly. My advice: use command line for some time--you get to understand how things work, get flexibility, and reliable results. Then you can install GUI front ends to make CD covers, and make things easier for Windows-educated users on your system.
cdrecord -scanbus
mkisofs -r -o cd_image input_data_directory This makes an International Standard Organization (ISO) standard 9660-type file system containing the files from input_data_directory, but writes the file system to an ordinary file on the hard drive. This output file is an "image" of the new CD which I am creating. The option "-o" indicates that the parameter that follows is the output filename of this image. The option "-r" enables "Rock Ridge" extensions to the ISO protocol so that file attributes are saved, and it sets the file permissions so all the files on the CD are publicly readable (can be read by all user, not only the file owner). The filenames are abbreviated to the "8.3" DOS-type length but, since Linux supports so called "Rock Ridge" extensions to ISO9660, it also writes the full names and all the file permissions as well--this way the new file system is portable across all popular operating systems (DOS, MS Windows, Linux, UNIX, etc)--really convenient to the user. The input data directory can be assembled from different directories and files from all-over your file system using symbolic links (saves harddrive space because the data is not copied), but if you do it you probably want to tell mksiofs to follow symbolic links using the option -f: mkisofs -r -f -o cd_image input_data_directory_containing_symlinks
mount -t iso9660 /dev/loop0 cd_image /mnt/cdrom [now the content of the file should appear in /mnt/cdrom] cd /mnt/cdrom [inspect the file mounted through the loop device] When done with inspection, change your working directory away from the mountpoint and unmount the file: cd umount /mnt/cdrom
cdrecord -v speed=8 dev=0,0,0 -data cd_image The first number in "dev=" stand for the scsi bus number (the first one is 0, second bus is 1, ...), device id on the scsi bus (between 0 and 7), and the scsi lun number (always 0) respectively. You must customize them: the first two numbers can be read in the output from cdrecord -scanbus, the third number is always 0. Make sure to use the correct numbers or you may write to a wrong drive and corrupt your data. The timing of writing to CD-Rs is very important, or an error may occur (the laser cannot be switched on and off at will). Therefore avoid doing intensive tasks during creating a CD, e.g. don't create or erase large files on the hard drive. My old system (RH6.2) will not permit me to start new tasks when using cdrecord . In a similar way, I can burn a CD from an ISO CD image downloaded from the Internet. One source (a Debian FAQ) recommends the following command (as root) to burn the image "binary-i386-1.iso" to a CD: nice --18 cdrecord -eject -v speed=2 dev=0,6,0 -data -pad binary-i386-1.iso This assigns a very high priority ("niceness" of minus 18) to the CD burning task (thus minimizing the possibility of an error).
sox my_file.wav my_file.cdr You don't need to do the conversions manually - cdrecord supports *.wav and *.au directly (it does a conversion from *.wav or *.au to *.cdr "on the fly"). This is very convenient because audio files tend to be large.
If cdparanoia is not installed, download it. The installation from source goes as follows (I use the autocompletion <Tab> shortcut when typing the long filenames): cd /usr/local tar -xvzf /the_path_to_which_you_downloaded/cdparanoia-III-alpha9.6.src.tgz ls cd cdparanoia-III-alpha9.6 ./configure make make install To rip the first track from an audio CD, I can use: cdparanoia 1 which will put the first track from the CD into the wave file "cdda.wav" in the current directory. To rip tracks 1 to 2 from an audio CD to a "raw" file format, I can use: cdparanoia -B -p "1-2" The option -B specifies to use a "batch" mode, so that each track is put into a separate file (this is probably what you want, otherwise all tracks would be placed in one output file). The "-p" option specifies output in raw format. The files are named track1.cdda.raw and track2.cdda.raw . To rip all tracks from an audio CD, each track to a separate *.wav file, while forcing reading speed 4x, I can use: cdparanoia -S 4 -B "1-" Make sure you have sufficient free space on your hard drive. You can use use the space on your DOS partition (if you have dual boot).
cdrecord -v speed=8 dev=0,0,0 -pad -dao -audio track*
To copy a disk to the file "data.bin" (on my harddrive), and the table of contents to the file "toc-file.toc", I can use this command: cdrdao read-cd --device 0,0,0 --buffers 64 --driver generic-mmc-raw --read-raw toc-file.toc To burn the CD from the files I just created, I can use: cdrdao write --device 0,0,0 --buffers 64 --driver generic-mmc --speed 12 toc-file.toc Note on re-writeable CDs. Some stereos will not play re-writeable CDs because of the size of the pits on the CDs. For example, my home stereo (JVC) cannot read re-writable CDs (CD-RW) at all, although it will read write-once disks (CD-Rs). Therefore, re-writable CDs may be good to store data but not audio (unless I plan to play them exclusively on my computer). Mixed-mode CDs (meaning CDs which contain both data and audio, often game CDs) are not a problems, e.g.: [mount the data part of the mixed-mode CD] mount -t iso9660 /dev/cdrom /mnt/cdrom [make an ISO file system from the data on the CD] mkisofs -r -o cd_image /mnt/cdrom [unmount the CD] umount /mnt/cdrom [rip the content of all audio tracks on the CD, except the first track since it is data] cdparanoia -B "2-" [write the data and audio files, piece by piece] cdrecord -v speed=2 dev=0,0,0 -data cd_image -audio track* Most CDs can be copied by first copying all data (for data CDs) or all tracks (for audio CDs) onto the hard drive as described before, but some CDs cannot. For example, these kinds of data (not audio) CDs need to be treated differently: bootable CDs (like Linux installation CD), CDs that require the label, disk with errors, etc. For data CDs, I use these commands to make an exact copy: dd if=/dev/cdrom of=cd_image cdrecord -v speed=2 dev=1,0,0 -data cd_image The dd command copies the input file (if), which in this case is the device /dev/cdrom to the output file (of) which in this example is a file called cd_image (on the hard drive in the current working directory). The second command copies the file cd_image that was created by the dd command onto an empty CD. For data disk with error, you might want to try: dd conv=noerror,notrunc if=/dev/cdrom of=cd_image cdrecord -v speed=2 dev=1,0,0 -data cd_image The option "conv=noerror,notrunc" specifies that the potential read errors are to be ignored, and files not truncated on error. For audio CDs, I use these command to make a copy: [rip the content of all audio tracks on the CD, from track 1 on. The tracks are saved into files in the current directory and named: track01.cdda.wav, track02.cdda.wav, etc.)] cdparanoia -B "1-" [write all the audio files to the CD, one by one. The tracks are separated by a 2 s gap] cdrecord -v speed=2 dev=1,0,0 -audio track* To copy an audio CDS in the most accurate way, man cdrecord recommends doing this: cdda2wav -v255 -D2,0 -B -Owav cdrecord -v dev=2,0 -dao -useinfo *.wav To make an exact copy of mixed mode CDs: [The dd command will output an error message when the the data has ended and audio started. This is expected and OK] dd if=/dev/cdrom of=cd_image [rip the content of all audio tracks on the CD, except the first track since it is data] cdparanoia -B "2-" [Write the data and subsequent audio files, piece by piece] cdrecord -v speed=2 dev=1,0,0 -data cd_image -audio track* Re-writable CDs (CD-RW) are used the same way as regular write-once CDs (CD-R), but you have to blank re-writable disks before you will be able to re-use them, e.g.: cdrecord -v speed=2 dev=1,0,0 blank=fast To see other (more thorough and slower) options for blanking, use: cdrecord blank=help For example this thorough blanking can take 0.5 hour on my system, but is not really necessary unless the old data is confidential: cdrecord dev=0,0,0 blank=disk Again, older stereos often will not play CD-Rs. To simplify writing long commands required by cdrecord (or cdrdao), I may want to define a global alias by placing the following line in the file /etc/bashrc: alias cdrecord="cdrecord -v speed=2 dev=1,0,0" Re-login for the changes in /etc/bashrc to take effect. After creating this alias, I can record a CD using the following shortened command (no need to specify the CD writer speed and device name all the time): cdrecord -audio track*
|
||
Home Newbie Guide Some Essential Linux Applications Writing CD-R/Ws |