Difference between revisions of "ISO Images"

From Christoph's Personal Wiki
Jump to: navigation, search
(Burn ISO (image) to a CD)
(devs)
Line 184: Line 184:
 
|}
 
|}
 
</div>
 
</div>
 +
<br clear="all"/>
  
 
==See also==
 
==See also==

Revision as of 21:48, 3 March 2010

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

you can also simulate/test a burn first to make sure everything is good by:

cdrecord dev=0,0 -v -dummy isoimagename.iso

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

Burn ISO (image) to a DVD

growisofs -dvd-compat -Z /dev/hda=foo.iso -speed=16

Misc DVD burning examples

  • Blank (zero-over) a rewritable DVD (note: not required before burning, but erases sensitive data):
growisofs -Z /dev/dvd=/dev/zero
  • Burn a data DVD:
growisofs -dvd-compat -speed=2 -Z /dev/dvd -R -J -pad /path/to/file1 /path/to/file2
  • Burn data file to DVD:
growisofs -Z /dev/dvd -R -J /path/to/file
  • Burn a data backup DVD using more mkisofs commands (note: works on DVD+R and double layer DVD+R DL):
    • Example 1 (note: may not be DOS-compatible because of long file name support, possible leading dot, or multi-dot filenames):
growisofs -speed=8 -Z /dev/dvd -R -J -allow-multidot -allow-leading-dots -l -pad -graft-points "/home/user1=/home/user1"
    • Example 2 (note: write a DVD which MS Windows can read - but not MS-DOS due to the "-l" option and long filenames):
growisofs -dvd-compat speed=2 -Z /dev/dvd -R -J -pad -graft-points "/DirectoryNameA=/home/user1/DirectoryNameA" "/SubDirectoryNameC=/home/user1/DirectoryNameB/SubDirectoryNameC"

Format DVD+RW media

In this example, we will use the dvd+rw-format utility.

  • Syntax:
- usage: /usr/bin/dvd+rw-format [-force[=full]] [-lead-out|-blank[=full]]
         [-ssa[=none|default|max]] /dev/dvd
  • Format: To format a DVD+RW disc, type the following command (replace the device name with yours):
dvd+rw-format -force=full /dev/hdd

It can take several minutes. Here is the output of the command:

* DVD±RW/-RAM format utility by <appro@fy.chalmers.se>, version 6.1.
* 4.7GB DVD+RW media detected.
* formatting
  • Make the UDF filesystem: Once the disc is formatted, you can create the UDF filesystem on the disc:
mkudffs --lvid="dvdrw-backup" --udfrev=0x0150 /dev/hdd

You can add your own options but it's a good thing to use UDF revision 1.50 since it can avoid compatibility problems with several operating systems. Of course, you should change the volume ID. Here is an example of the output of mkudffs:

start=0, blocks=16, type=RESERVED
start=16, blocks=3, type=VRS
start=19, blocks=237, type=USPACE
start=256, blocks=1, type=ANCHOR
start=257, blocks=16, type=PVDS
start=273, blocks=1, type=LVID
start=274, blocks=2294573, type=PSPACE
start=2294847, blocks=1, type=ANCHOR
start=2294848, blocks=239, type=USPACE
start=2295087, blocks=16, type=RVDS
start=2295103, blocks=1, type=ANCHOR
  • Mount the disc and copy the files: The media is now formatted as UDF. Now mount it in read-write (rw) mode. First, create a mount point:
mkdir -p /mnt/dvdrw
mount -t udf -o rw,noatime /dev/hdd /mnt/dvdrw
  • Copy files: You can now write your files in /mnt/dvdrd as you would for any mounted partition of your hard disk. (Note: Be careful not to go over to maximum amount of space available on a DVD {4.7 GB for a simple layer disc}).

For example, if you want to use Partimage to save a partition to the disc, you can type this sort of command:

partimage -z1 save /dev/hda1 /mnt/dvdrw/myimage.pi
  • Use du to check the size of a directory:
du -sh /boot
 100M /boot
  • Umount the disc: Remember to unmount the disc when you are done and run sync to force the data to be physically written:
umount /mnt/dvdrw
sync

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