Difference between revisions of "ISO Images"

From Christoph's Personal Wiki
Jump to: navigation, search
Line 1: Line 1:
 
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 [[:Category:Linux Command Line Tools|command line]]).
 
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 [[:Category:Linux Command Line Tools|command line]]).
  
== ISO from CD/DVD ==
+
==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, <tt>umount /dev/cdrom</tt>).
 
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, <tt>umount /dev/cdrom</tt>).
  
* For a DVD:
+
*For a DVD:
 
<pre>dd if=/dev/dvd of=dvd.iso</pre>
 
<pre>dd if=/dev/dvd of=dvd.iso</pre>
* For a CD:
+
*For a CD:
 
<pre>dd if=/dev/cdrom of=cd.iso</pre>
 
<pre>dd if=/dev/cdrom of=cd.iso</pre>
* For a CD (as SCSI):
+
*For a CD (as SCSI):
 
<pre>dd if=/dev/scd0 of=cd.iso</pre>
 
<pre>dd if=/dev/scd0 of=cd.iso</pre>
  
Line 14: Line 14:
 
  cat /dev/cdrecorder >> /home/username/isoimagename.iso
 
  cat /dev/cdrecorder >> /home/username/isoimagename.iso
  
== ISO from files on Hard Drive (HDD) ==
+
==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 <tt>mkisofs</tt> command.
 
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 <tt>mkisofs</tt> command.
  
* Example commands:
+
*Example commands:
 
  mkisofs -o /tmp/cd.iso /tmp/directory/
 
  mkisofs -o /tmp/cd.iso /tmp/directory/
 
This results in a file called <code>cd.iso</code> in folder <code>/tmp</code> which contains all the files and directories in <code>/tmp/directory/</code>.
 
This results in a file called <code>cd.iso</code> in folder <code>/tmp</code> which contains all the files and directories in <code>/tmp/directory/</code>.
Line 24: Line 24:
 
where <code>-J</code> 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 <code>-r</code> is for the directory and file permissions, user/group IDs, etc.
 
where <code>-J</code> 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 <code>-r</code> is for the directory and file permissions, user/group IDs, etc.
  
== Burn ISO (image) to a CD ==
+
==Burn ISO (image) to a CD==
 
Once you have built your <code>.iso</code>, you can burn this image to a CD using:
 
Once you have built your <code>.iso</code>, you can burn this image to a CD using:
 
  cdrecord -v speed=8 dev=ATA:1,1,0 isoimagename.iso  
 
  cdrecord -v speed=8 dev=ATA:1,1,0 isoimagename.iso  
Line 30: Line 30:
 
  cdrecord -scanbus
 
  cdrecord -scanbus
  
== Mount an ISO image in Linux ==
+
==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.
 
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:
+
*Step 1: Create a mount point for the ISO:
 
  mkdir /mnt/iso
 
  mkdir /mnt/iso
  
* Step 2: Now mount the ISO in the mount point with the following command:
+
*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
 
  mount myiso.iso /mnt/iso -t iso9660 -o ro,loop=/dev/loop0
 
where <code>myiso.iso</code> is your ISO file.
 
where <code>myiso.iso</code> is your ISO file.
Line 48: Line 48:
 
and then rebuild the module. (see here: [http://www.geocities.com/rlcomp_1999/loop.html Linux Loop Devices] for details.)
 
and then rebuild the module. (see here: [http://www.geocities.com/rlcomp_1999/loop.html Linux Loop Devices] for details.)
  
== See also ==
+
==devs==
* [http://www.tldp.org CD-Writing-HOWTO]
+
In "<code>dev=ATA:x,y,z</code>", <code>x</code> is 'channel', <code>y</code> is <code>0</code> for 'master' and <code>1</code> for 'slave', <code>z</code> seems to always be zero (not sure why).
* [[cdrtools]] (e.g., [[Cdrtools|mkisofs]])
+
 
* [[Losetup (command)|losetup]]
+
Thus,
* [[Dd (command)|dd]]
+
<div style="float:left; margin:0px 20px 20px 0px;">
 +
{| align="center" style="border: 1px solid #999; background-color:#FFFFFF"
 +
|-
 +
! colspan="4" bgcolor="#EFEFEF" | '''devs'''
 +
|-align="center" bgcolor="#1188ee"
 +
!IDE Port
 +
!Master/slave
 +
!Device
 +
!<tt>cdrecord</tt>
 +
|- align="left"
 +
|1 || master || <code>/dev/hda</code> || "<code>dev=ATA:0,0,0</code>"
 +
|--bgcolor="#eeeeee"
 +
|1 || slave || <code>/dev/hdb</code> || "<code>dev=ATA:0,1,0</code>"
 +
|- align="left"
 +
|2 || master || <code>/dev/hdc</code> || "<code>dev=ATA:1,0,0</code>"
 +
|--bgcolor="#eeeeee"
 +
|2 || slave || <code>/dev/hdd</code> || "<code>dev=ATA:1,1,0</code>"
 +
|- align="left"
 +
|3 || master || <code>/dev/hde</code> || etc.
 +
|--bgcolor="#eeeeee"
 +
|3 || slave || <code>/dev/hdf</code> || &nbsp;
 +
|- align="left"
 +
|4 || master || <code>/dev/hdg</code> || &nbsp;
 +
|--bgcolor="#eeeeee"
 +
|4 || slave || <code>/dev/hdh</code> || &nbsp;
 +
|}
 +
</div>
 +
 
 +
==See also==
 +
*[http://www.tldp.org CD-Writing-HOWTO]
 +
*[[cdrtools]] (e.g., [[Cdrtools|mkisofs]])
 +
*[[Losetup (command)|losetup]]
 +
*[[Dd (command)|dd]]
 +
 
 +
==External links==
 +
*[http://www.troubleshooters.com/linux/cdrw.htm Installing Your ATAPI CDRW Drive in Linux]
  
 
[[Category:Linux Command Line Tools]]
 
[[Category:Linux Command Line Tools]]

Revision as of 02:21, 27 March 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

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.)

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