MandrakeUser.Org - Your Mandrake-Linux Knowledge Base!


 
 

*DocIndex - Utils & Apps

Handling CD-Images

* What CD-Images Are
* Creating CD-Images
* Mounting CD-Images
* Checking CD-Images
* Burning CD-Images

Related Resources:

CD-Writing HOWTO
CD Writing Tutorial
man cdrecord
man mkisofs

Revision / Modified: Mar. 4, 2002 / Mar. 11, 2002
Author: Gerard Gilbert and Tom Berger

 

Notice that this articles deals with the fundamentals of ISO handling in Linux and does not cover graphical interfaces. This is because all graphical CD burning utilities in Linux are using the same set of command line utilities. Once you understand what they are doing, you will not only be able to handle each graphical program (better), but you will know how to issue a burn command with three or four simple keystrokes.

* What CD-Images Are

CD-Images, commonly referred to as ISO images, are byte per byte copies of CDs. Rather than distributing the content of a CD file by file, these images are exact copies of the ISO9660 file system on a CD (hence the name). This means you only need to handle one file and you don't have to worry about creating a file system on the new CD or making the CD bootable (if the original was bootable, that is). You just burn that image on a new CD and you have an exact copy of the original. As you will see, you don't even need to burn the image onto a CD to access its contents, you can do that right from within your Mandrake Linux system.

iso, raw, cdr, bin, cue, ...

The filename extensions 'iso', 'raw' and 'cdr' all indicate an ISO image which can be handled by the standard 'cdrecord' command.
'bin'/'cue' images, however, seem to be a different kind of animal. First of all, you need a '.cue' file and the corresponding '.bin' file. You can then either burn a CD using cdrdao from your Mandrake Linux CD, or convert this format to a standard .iso file using bchunk, which also comes with Mandrake Linux.

* section index * top

* Creating CD-Images

Creating ISOs consists of two steps: gathering the files you want to put on the image and creating the image from those files.

The first step is pretty simple: create a new directory and put your files in there. The second step is performed using the 'mkisofs' utility, which is part of the 'cdrecord' package:

mkisofs -r -J -o cd_image.iso dir_with_files/

This creates cd_image with the files contained in dir_with_files. The '-r' option enables the so-called 'RockRidge' extensions. These extensions allow for longer than 8 characters file names in Linux and keep the permissions intact. You should always set this, otherwise file names and permissions will be screwed up badly.
The '-J' option enables the so-called 'Joliet' extensions which do the same for Windows (well, apart from the permissions, of course). If you don't use these extensions, the longer file names made possible by RockRidge will be mapped to 8 character file names in Windows. The CD will still work in Windows, but for maximum compatibility, use this option.

If you've got nothing to do on a rainy winter evening, have a read through the 'mkisofs' man page for the rest of the 40 available options ...

* section index * top

* Mounting CD-Images

In order to see what's on an ISO image, you don't have to burn it to a CD. You can open them right from within Linux:

  1. As 'root', create a new directory to mount the image to, e.g. '/mnt/iso':

    mkdir /mnt/iso

  2. Now mount it (also as 'root'):

    mount -o loop,unhide -t iso9660 -r /path/to/cd_image.iso /mnt/iso

    The "-o loop" means use the option that mounts a file as a block device. The "unhide" option shows hidden files. The "-t iso9660" means that the file is in the iso9660 CD-ROM format. The "-r" means to mount read-only.
  3. You can now browse the contents of the image via /mnt/iso like you would do with any other directory.
  4. You unmount the image with

    umount /mnt/iso

By the way, this mechanism allows you to install Mandrake Linux from downloaded ISO images even if you don't have a CD burner (or no CD-Rs at hand). Just place the ISO images together into a new directory (e.g. on a Windows partition), use the 'rawwritewin' tool from the 'dosutils' directory to create a boot floppy from the 'hd.img' floppy image in 'images'. Boot from that floppy and point the installer to the directory where the images are.

* section index * top

* Checking CD-Images

If you've downloaded an ISO image from somewhere else, it is always a good idea to check the image for errors. In fact, you should never use an unchecked image. Errors in ISO images make the files they contain unusable.
The problem with these errors is that they usually do not show up when browsing the CD, they may even only corrupt a small percentage of the files, but as soon as you try to use these files, say to install an operating system, you are bound to encounter the strangest behavior (files missing or applications crashing, system errors, system freeze etc).

This checking is done by comparing MD5 sums. An MD5 sum is sort of a 'digital fingerprint' of a file. The directory from which you downloaded the ISO image from should contain a text file which lists these fingerprints. Download this file (it's just a few bytes) and put it into the same directory as the images. You then run the 'md5sum' command, which is installed by default on Linux systems:

md5sum *.iso

This command computes the MD5 sums of the images you downloaded. It usually takes a few minutes. Now compare the computed values to the numbers listed in the 'md5sum_file' which contains the MD5 sums these images had on the remote server. If they match, everything's OK and you can proceed (you don't have to compare all the numbers, if the first and last four match, the rest should be fine, too).

In order to check if a CD image has been burned correctly to the CD, put the CD into your drive and run

df -k /mnt/cdrom

to get the block count (the number listed under '1k-blocks'). Now umount the CD as 'root' with umount /mnt/cdrom and run this command:

dd if=/dev/cdrom count=block_count bs=1024 | md5sum

Replace block_count with the number you got from the first command. The number you get from this should match the corresponding number in the checksum file you downloaded.
Notice that unmounting the CD is necessary for 'dd' to work correctly. This will however turn off 'supermount' on that drive for the rest of your current session.

(Thanks to doug_s for this bit.)

* section index * top

* Burning CD-Images

The standard tool for burning CDs in Linux is cdrecord. You only use 'cdrdao' for burning audio CDs to get rid of the 2 seconds pause between tracks or to burn cue/bin images.

Burning an image from the hard disk to CD works like this:

cdrecord -v -eject speed=XXdev=x,y,z cd_image.iso

  1. '-v': 'Verbose' switch. This enables the progress indicator. Optional.
  2. '-eject': Eject disk after burning. Optional.
  3. 'speed=XX': Speed factor (i.e. either 4, 8, 12, 16 etc). If you don't know the speed of your CD burner, use '20' (without quotes). 'cdrecord' will automatically adjust this number to the capabilities of your hardware.
  4. 'dev=x,y,z': These three numbers tell 'cdrecord' which device to use. Run

    cdrecord -scanbus

    to find out which to use for yours.

Not that complicated, isn't it? From the wealth of options cdrecord provides, the '-dummy' option provides a sometimes useful functionality: it goes through the whole process without actually burning any data to the disk.

Burning a cue/bin image with cdrdao looks like this

cdrdao write --device 0,3,0 --buffers 64 --eject image.cue

Not much difference to the cdrecord command above. You have to make sure, though, that the cue/bin pair is in the same directory and has the same name (apart from their different extensions, that is).

"What about those three or four key strokes you were talking about at the beginning?" Gee, you are insisting, aren't you? ;-) Well, on my machine, I've defined an alias for the cdrecord command line above in my '.bashrc':

alias biso='cdrecord -v -eject speed=12 dev=0,6,0'

Now all I've to do is type

biso image.iso

and the rest happens all by itself.

* section index * top

 
Legal: All texts on this site are covered by the GNU Free Documentation License. Standard disclaimers of warranty apply. Copyright LSTB (Tom Berger) and Mandrakesoft 1999-2002.