Difference between revisions of "ISO Images"

From Christoph's Personal Wiki
Jump to: navigation, search
(See also)
Line 122: Line 122:
 
*[http://www.tldp.org CD-Writing-HOWTO]
 
*[http://www.tldp.org CD-Writing-HOWTO]
 
*[[cdrtools]] (e.g., [[Cdrtools|mkisofs]])
 
*[[cdrtools]] (e.g., [[Cdrtools|mkisofs]])
 +
*[[CDfs]]
 
*[[Losetup (command)|losetup]]
 
*[[Losetup (command)|losetup]]
 
*[[Dd (command)|dd]]
 
*[[Dd (command)|dd]]

Revision as of 01:37, 21 April 2007

This article will explain how to make ISO images in a Linux environment and various other things you can do with/to ISO images. Everything will be done from the CLI (or command line).

ISO from CD/DVD

To make an ISO from your CD/DVD, place the media in your drive but do not mount it. If it "automounts", unmount it (eg, umount /dev/cdrom).

  • For a DVD:
dd if=/dev/dvd of=dvd.iso
  • For a CD:
dd if=/dev/cdrom of=cd.iso
  • For a CD (as SCSI):
dd if=/dev/scd0 of=cd.iso

also,

cat /dev/cdrecorder >> /home/username/isoimagename.iso

ISO from files on Hard Drive (HDD)

To make an ISO from files on an HDD, create a directory which holds the files you place in your ISO image. Then use the mkisofs command.

  • Example commands:
mkisofs -o /tmp/cd.iso /tmp/directory/

This results in a file called cd.iso in folder /tmp which contains all the files and directories in /tmp/directory/.

mkisofs -o isoimagename.iso -J -r /home/username/directory_for_iso

where -J means use "Joliet" (i.e., generate Joliet directory records in addition to regular iso9660 file names. This is primarily useful when the discs are to be used on Windows-NT or Windows-95 machines). The -r is for the directory and file permissions, user/group IDs, etc.

Burn ISO (image) to a CD

Once you have built your .iso, you can burn this image to a CD using:

cdrecord -v speed=8 dev=ATA:1,1,0 isoimagename.iso 

where the dev parameters can be found by issuing the following as root:

cdrecord -scanbus

Note: You should use 'dev=/dev/hdX' with v2.6 and later kernels. For example, if your CD drive is on /dev/hdc:

cdrecord -v blank=fast -multi -tao -data speed=16 dev=/dev/hdc isoimagename.iso

Mount an ISO image in Linux

It is possible to mount an ISO image in Linux just like any device or file system. This is a convenient way of backing up your CDs and DVDs onto your hard drive and be able to read all of the files on these discs. It is also a good way to check your ISO images before burning them to disc.

  • Step 1: Create a mount point for the ISO:
mkdir /mnt/iso
  • Step 2: Now mount the ISO in the mount point with the following command:
mount myiso.iso /mnt/iso -t iso9660 -o ro,loop=/dev/loop0

where myiso.iso is your ISO file.

You can also place the above mount command in your /etc/fstab file for automatic mounting upon boot up (and as a "permanent" mount).

If you wish to mount more than one ISO image, you can use a different device (e.g. /dev/loop1). By default you have 8 loop devices (loop0 - loop7). You can extend this number up to 255. To do this, you will need to edit your /usr/src/linux/drivers/block/loop.c file and change the following:

#define MAX_LOOP 8

to

#define MAX_LOOP 255

and then rebuild the module. (see here: Linux Loop Devices for details.)

Automount ISO images as user

The above section showed how to mount an ISO as root. However, if you wish to allow users to mount images, you will need to change the procedure a bit.

  • Step 1: Create a soft link to a generic ISO file

Let's say you have an ISO called foo.iso. Create a soft link to this file:

ln -s foo.iso /home/bob/images/my.iso
  • Step 2: Add the following to your /etc/fstab file:
/home/bob/images/my.iso /mnt/iso auto ro,loop=/dev/loop0,user 0 0
  • Step 3: Mount the ISO as user
mount /mnt/iso

That's it!

isotools

Jörg Schilling, author of cdrtools (with mkisofs and cdda2wav) and K3b, has created a utility-pack called isotools. It ships with the following utilities:

  • isodebug
  • isodump
  • isoinfo
  • isovfy

As an example, if you have an ISO called foo.iso, you can view its contents (i.e. files) with this command:

isoinfo -i foo.iso -f -R -J | less

Encrypt CDs/DVDs

mkisofs -r backup | aespipe -e aes256 > backup.iso
modprobe aes         # as root
modprobe cryptoloop  # as root
  • Mount the ISO (see above):
mount -t iso9660 backup.iso /mnt/iso -o loop=/dev/loop0,encryption=aes256
  • Mount the burnt CD/DVD:
mount -t iso9660 /dev/cdrom /mnt/iso -o loop=/dev/loop0,encryption=aes256

See: http://loop-aes.sourceforge.net/

devs

In "dev=ATA:x,y,z", x is 'channel', y is 0 for 'master' and 1 for 'slave', z seems to always be zero (not sure why).

Thus,

devs
IDE Port Master/slave Device cdrecord
1 master /dev/hda "dev=ATA:0,0,0"
1 slave /dev/hdb "dev=ATA:0,1,0"
2 master /dev/hdc "dev=ATA:1,0,0"
2 slave /dev/hdd "dev=ATA:1,1,0"
3 master /dev/hde etc.
3 slave /dev/hdf  
4 master /dev/hdg  
4 slave /dev/hdh  

See also

External links