Don's Pages and my Music

Wednesday, October 14, 2009

Simple CD-ROM & ISO image cookbook.

Simple CD-ROM & ISO image cookbook.

Posted by Steve on Sun 16 Oct 2005 at 15:46

There are many times when you need to work with CD-ROM images (or ISO files) under Linux. This simple cookbook shows you how to accomplish the most common tasks.

Ripping a CD-ROM to an ISO image

Creating backups of CD-ROM images for storage, or to use as installation media for Qemu is a reasonably common task.

If your CD-ROM device is /dev/cdrom you can use the following command to create an ISO image from it:

dd if=/dev/cdrom of=myimage.iso   
Mounting an existing ISO image

If you've made a previous backup of a CD-ROM, or downloaded the ISO image of a new Linux distribution you can mount it to see what is inside the image - before you burn it.

First make sure you have an existing, and empty, directory to mount the image upon:

mkdir -p /mnt/iso   

Now mount the image with the loopback module:

modprobe loop mount -t iso9660 -o loop myimage.iso /mnt/iso   
Modifying an ISO Image

Whilst ISO images are readonly when mounted you can "fake" their writability using the unionfs filesystem driver. This cool module allows you to combine two, or more, directories and present their union in a new location.

Under Debian you can build and use this kernel module by running:

apt-get install module-assistant unionfs-source module-assistant prepare module-assistant build unionfs module-assistant install unionfs insmod unionfs   

Once built and installed you can "merge" the mounted ISO image and another directory by running:

mkdir /mnt/tmp mkdir /mnt/combined mount -t unionfs -o dirs=/mnt/tmp:/mnt/iso none /mnt/combined   

This will give you a directory /mnt/combined containing both the contents of the ISO image you previously mounted in /mnt/iso and the directory /mnt/tmp (which will be empty initially).

Now you can modify the read-only ISO image! Make any additions to the image by modifying the /mnt/combined directory. Instead of modifying the files upon the ISO image though the changes will be saved to the directory /mnt/tmp.

Neat.

Creating an ISO image of a directory

If you have a directory containing files which you'd like to burn to CD-ROM you should first create an ISO image.

Install the appropriate software with:

apt-get install mkisofs   

Then create the actual image with :

mkisofs -o /tmp/output.iso  -J -R /path/to/files   
Burning an ISO image to CD-ROM

If you've created an ISO image you can burn it to your CD-writer using the cdrecord program. Install it with:

apt-get install cdrecord   

Usage is really beyond the scope of this introduction, but in brief you'd first proceed by finding the CD-Writer device upon your system:

root@itchy:~# cdrecord -scanbus ... snip ...         1,0,0   100) 'HDT72251' '6DLAT80         ' 'V43O' Disk         1,1,0   101) *         1,2,0   102) * ... snip ...   

Here we have a device labelled "1,0,0". To write an image to that writer we run:

cdrecord -dev 1,0,0 /tmp/output.iso   
Creating Checksums of Images

When transferring large files such as ISO images you will almost certainly wish to make sure you've not downloaded/uploaded a corrupt file.

In this case you can list the MD5/SHA1 hashes alongside the file. This allows users to verify that their downloads were correct.

To create a checksum of a file run one of:

md5sum filename sha1sum fileName   

Ideally you should post both sums:

skx@itchy:/mnt$ sha1sum /tmp/iso.iso  b9f4f11960b90959e8c1ac736bd89dfa986bfa04  /tmp/iso.iso  skx@itchy:/mnt$ md5sum  /tmp/iso.iso d9866bfa8a52b65c612c74c17710819a  /tmp/iso.iso   

(These two commands are contained within the coreutils package - which should be installed upon all Debian GNU/Linux systems)


Go there...
http://www.debian-administration.org/articles/273

No comments:

Post a Comment