Henry Griggs RamblingHomeHomePhoto Gallery Recent TopicsVisit to Australia 2002Sydney house 2002 Circular Quay 2004 Circular Quay 2002 Centrepoint Tower 2004 Oz Birds 2004 Oz Birds 2002 Bridge Climb 2002 Popular TopicsGallbladder removalPhoto of the day HP Calculators Linux/Slackware notes Ripping/burning CDROMs Geek Alaska 2003 UK in 2003 Geek Caribbean 2002 Main TopicsAnneAnne's Crafts Blog Cats Collecting Commentary Credits Events Films Links Linux Michelle Miscellaneous Me Photo Galleries Photo Of The Day Rachael Site Index Travel Us Want List Work NavigationSite MapContactEmail MeSearchAdvanced searchRelated SitesHampton Road EventsHenry's Notes Anne's Site Hampton Roads Aussies Juniper Rowing Club Great Dismal Regatta Virginia Beach Belles Virginia Beach Rowing Club Williamsburg Boat Club |
Burning CDs under Linux9th June 2002 [Linux] I've been able to create data CDs under Linux for a while, and recently learnt how to make audio cds. But there were still some tasks that I didn't know how to do, but were sure could be done. So I did some research. I started with the Sept/Oct 2000 issue of the now-defunct Maximum Linux magazine. I had used this issue ages ago to learn how to setup the cd burner and make data cds. It had a lot of extra information that was now relevant. Then I looked at the CD-Writing-HOWTO that gets installed in /usr/doc/Linux-HOWTOs under Slackware, and is probably somewhere similar for other distributions. And finally, I read the man pages for cdrecord, readcd, cdrdao and cdda2wav. I find man pages easier to read and understand when I have a bit of a background of the topic. So now that I know, the trick is not to forget. And that means I have to write a web page so that I can refer back to it. Setting up a burner[Linux] The essence of doing this is to set your system up for a SCSI cd burner. If you actually have a SCSI cd burner, then your system should work as is. If you have an ATAPI cd burner like most of us, then you have to build a special kernel and fake the SCSI. If you don't know how to build a kernel, it's time to learn. I'll give rough instructions here, but you should investigate further and learn what to do. See your distribution manual, or read the O'Reilly book by Matt Welch Running Linux or use any of the thousands of tutorials that can be found on the Web by doing a Google search.
Determining what SCSI device the burner is[Linux] This is easy. Run "cdrecord -scanbus" as root, and look at the output. There should be enough there to tell you which device the burner is. Here's my output:
root@cerebus:/usr/src/linux/$ cdrecord -scanbus
Cdrecord 1.10 (i686-pc-linux-gnu) Copyright (C) 1995-2001 Jörg Schilling
Linux sg driver version: 3.1.17
Using libscg version 'schily-0.5'
scsibus0:
0,0,0 0) *
0,1,0 1) *
0,2,0 2) 'HP ' 'C5100A ' 'R030' Processor
0,3,0 3) *
0,4,0 4) *
0,5,0 5) *
0,6,0 6) *
0,7,0 7) *
scsibus1:
1,0,0 100) 'SAMSUNG ' 'DVD-ROM SD-612 ' 'ST02' Removable CD-ROM
1,1,0 101) 'YAMAHA ' 'CRW8824E ' '1.00' Removable CD-ROM
1,2,0 102) *
1,3,0 103) *
1,4,0 104) *
1,5,0 105) *
1,6,0 106) *
1,7,0 107) *
This shows I have two SCSI buses. The first one I know is a real SCSI card in my machine, the one that is attached to my Hewlett Packard photo scanner. The second one is the emulation SCSI device. It has two devices on it and that pretty clearly shows me that my Yamaha CD burner, model CRW8824E, is device 1,1,0. So for all examples below, when I want to burn, I use dev=1,1,0. And if I want to read CDs in the DVD drive, I would use device dev=1,0,0. Burning a data cdrom[Linux] This is easy. Like much of cd burning work, it is a two step process:
Step 1 - create an ISO imageThe first step will create a large file containing the files and directory structure that you want on the cdrom. The program to use is mkisofs - MaKe ISO File Structure. If you look at the man page for mkisofs, you'll see that it takes a lot of options. I use a very limited set of the options. Here's the commonest form of what I use. mkisofs -r -o cdimage.iso /home/hgriggs I specify -r to set up the file permissions in the simplest and most useful way on the cdrom. -o is the name of the file that gets created. And at the end I list a directory that contains the file structure I want put on cdrom. When this finishes, I check the ISO image to see that it contains what I expected, by mounting it. This is a feature that I appreciate very much. mount -t iso9660 -o loop cdimage.iso /mnt/dummy and then I can rummage around inside the ISO image and make sure it's all set up correctly before I burn it. Step 2 - burn the ISO image to cdromThe second step is to burn the ISO image to a blank cdrom. cdrecord -v speed=n dev=x,x,x -data cdimage.iso Set the speed to what your burner will take. I usually use 8 because my burner is rated at that. And set the dev= to the correct values for your burner. "cdrecord -scanbus" is your friend. See how to determine your device. Burning an audio cdrom[Linux] This is also easy. Again, this is a two step process, but the first step is very different:
Step 1 - collect sound filesThe first step is what takes me a lot of time. If I am collecting songs from a cd so I can build a compilation cd, then it's no big deal. I use cdparanoia to rip the cds from the original cds. However, I spend a lot of time digitising audio tapes and vinyl. What you ultimately want is raw PCM data. This data is usually wrapped inside a very primitive structure, and the result has a WAV extension and is called a wav file. cdparanoia will create the PCM data and wrap it automatically in the WAV structure. Most recording programs will do the same thing. Getting audio tracks from an audio cdI use cdparanoia to get the tracks off the audio cd. You need to read the man pages of cdparanoia for the fine details. Here's some examples of what I do:
cdparanoia has many more options. Read the man page for how to name the tracks as you go. Getting audio tracks from other sourcesThis is where it gets tricky. You have to produce PCM data that is stereo, 16 bit digital audio, sampled at 44100 Hz. Most of your recording programs will do this. I use yarec for my recording, and use this command line to record a track: yarec -r 44100 -b 16 -c 2 -f -n track01.wav -r sets the sampling rate (44100), -b sets the sample size in bits (16), and -c sets the number of channels (2 for stereo).
Step 2 - burning the tracks to an audio cdcdrecord will create an audio cd for you. I use a command like this: cdrecord -v speed=n dev=x,x,x -pad -audio doors_morrisonhotel.wav doors_lawoman.wav I use -pad because most of the tracks that I create myself from non-cd sources do not have an integral number of blocks (man cdrecord to understand that), -pad will clean that up for me and pad the data. All files specified after -audio are assumed to be audio files. What sort is determined by the extension. I use WAV files, so that works out fine. Ordering the tracksWhen you go to burn your tracks to an audio cd, the tracks will appear on the cd in the order you specify them when you call cdrecord. You can name them one after the other if you like, as I did in the above example, but I find that tedious. I usually rename the tracks so that when I ls the directory, they appear in the order I want them. Take the above example. If I rename the two tracks to be 01_doors_morrisonhotel.wav and 02_doors_lawoman.wav, then I can simply use the cdrecord command: cdrecord -v speed=n dev=x,x,x -pad -audio *.wav Copying a data cdrom[Linux] Copying a cd, data or audio, requires two passes. I reckon that even the slick Windows programs require two passes. False shortcutThere is one short cut method if you have a cd player and a cd burner. You can suck and spit in the one operation with cdrecord -v dev=x,x,x speed=x -isosize /dev/player You have to fill in the numbers for dev=x,x,x, so see above for how to determine the numbers. Set the speed to whatever you normally set it at. /dev/player is the player device. Change that to fit your circumstances. I have used this, but not successfully. I don't think my DVD player is fast enough to keep the data coming in to the burner. Two-pass methodI think it's best to use a two pass method:
Step 1 - getting the data to hard diskI tried a number of different methods of getting the data to hard disk. I used dd, but wasn't happy with the results. Then I tried readcd, a utility that comes with cdrecord. Attempting ddThe first method I tried of getting the data from the cdplayer was with dd. Example: dd if=3D/dev/sr0 of=3Dcdimage I did this and got an error at the very end. However when I mounted the image I had created, it looked fine. "mount -o loop -t iso9660 cdimage /mnt/test". It looked okay, but I didn't trust it, so I don't use this method any more. Using readcdThere is a utility that comes with cdrecord called readcd. This is nice. It gives a nice count of the reading, doesn't give any errors and is my preferred way of sucking a cd to hard disk. readcd dev=x,x,x f=cdimage You have to setup the dev=x,x,x yourself, using "cdrecord -scanbus" to determine what SCSI devices you have. See above. Step 2 - burn to cdThe second step is to burn the image you have created to cdrom with cdrecord. I use
cdrecord -v speed=x dev=x,x,x -data cdimage and that works very nicely. If you want to check your work before you attempt a burn, mount the ISO image with "mount -o loop -t iso9660 cdimage /mnt/test". Then cd to /mnt/test and check that it's all there. If you're happy with the arrangement, umount the image, then burn. Copying an audio cd[Linux] Again, a two pass method is required.
Obviously, the new audio cd will not be an exact bit for bit copy of the original. But it will be close enough. Step 1 - get the audio tracksThere are a number of ways of doing this. cdparanoia will do it. cdda2wav (comes with cdrecord) will also do it. Using cdda2wavI started with cdda2wav. This produces a lot of screen information and seems slow but does a nice job. It will produce audio.inf and cddb files, but I turn these off with -H. cdda2wav -D /dev/sr0 -B -H This will produce a bunch of tracks in the format audio_nn.wav. There are lots of options with this program. One of them is to echo to the soundcard. You can play while you rip. I haven't tried this. Too junky for me. This pair of programs, cdda2wav and cdrecord, work well together. But I'm used to cdparanoia for my ripping, so I thought I would try it too.> Using cdparanoiaCdparanoia was originally based on cdda2wav. It uses similar commands and works just fine. I used cdparanoia -B and the -B is the same as with cdda2wav. However it starts with track0 and gives some weird data for track 0, before getting stuck into the real audio sound on track 1. So it's best to use cdparanoia -B 1- which starts at track 1 and goes to the end. I found that this occasionally shows bad data in the very first read of the cd, but Ctrl-C and restart clears that up. cdparanoia will produce WAV files with a filename format of tracknn.cdda.wav. Again, they are in the right order, ready to be burnt to an audio cd with cdrecord. Interestingly, cdparanoia produces exactly the same size files as cdda2wav does, so either that reflects the common origin, or the PCM data is the same regardless of what extracts it. Step 2 - burn the tracks to cdOnce you have the WAV files in a directory, you can burn the audio cd with cdrecord -v speed=8 dev=1,1,0 -pad -audio /data/mp3/build/*.wav You have to pad the files (-pad) so the WAV files are in the right size for the cd burning. The tracks on the audio cd will be in the normal ls order of the tracks you specify, so name them so they will ls in the correct order and you'll be fine. The output of cdda2wav is already in the right order. If you're making a mix and match type of cd, like a greatest hits, then you rename them to be in the order you want. Summary[Linux] I can now duplicate data and audio cds under Linux. I am unsure if this works with bootable cdroms. This is something I will test later. I am much happier now that I know this. I can write my little scripts and automate a lot of this. There are front ends that do all that for you and I plan on investigating them. However, front ends hide information and I don't like that. If I wanted a GUI front end to hide tricky details, I would be using Windows. Little scripts are much handier. |