Linux: How to create an ISO Image from a CD/DVD

[source : http://www.der-eremit.de/linux-how-to-create-an-iso-image-from-a-cddvd/ ]

When I’m talking about ISO Images, I certainly mean 1-to-1 copies of a CD or DVD and NOT a shrinked movie copy. Several ways are leading to Rome, and so it’s just normal that this also the case for creating ISO Images from CD/DVD. I won’t mention all the graphical tools that are out there for doing that job, but instead I would like to show you two methods for the command line.

1. Dump Device
dd is your tool of choice for doing all those nifty imaging things. You can image a CD/DVD/HDD completely or partialy with this nice tool, write images back and so on. dd works blockwise, so you get a real 1-to-1 copy of your source. The only thing you should be aware of are defect sectors on your source media — this will lead to an abort of dd –, and you should really be careful on writing back an image to a device (might overwrite everything, especially nasty when you do this on harddisks).

So how to create an ISO Image with dd? First insert your CD/DVD and ensure that it’s unmounted (Ubuntu for example automounts removable devices), then:

1
2
3
  <span style="color: rgb(194, 12, 185); font-weight: bold;">dd</span>  <span style="color: rgb(0, 120, 0);"><span style="color: rgb(0, 0, 0); font-weight: bold;">if</span></span>=<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>dev<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>dvd <span style="color: rgb(0, 120, 0);">of</span>=dvd.iso <span style="color: rgb(102, 102, 102); font-style: italic;"># for dvd</span><br />  <span style="color: rgb(194, 12, 185); font-weight: bold;">dd</span>  <span style="color: rgb(0, 120, 0);"><span style="color: rgb(0, 0, 0); font-weight: bold;">if</span></span>=<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>dev<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>cdrom <span style="color: rgb(0, 120, 0);">of</span>=cdrom.iso <span style="color: rgb(102, 102, 102); font-style: italic;"># for cdrom</span><br />  <span style="color: rgb(194, 12, 185); font-weight: bold;">dd</span>  <span style="color: rgb(0, 120, 0);"><span style="color: rgb(0, 0, 0); font-weight: bold;">if</span></span>=<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>dev<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>scd0 <span style="color: rgb(0, 120, 0);">of</span>=image.iso <span style="color: rgb(102, 102, 102); font-style: italic;"># if cdrom/dvd is scsi</span>

2. cat
As mentioned above there are several ways to do this job. Sometimes you won’t have dd, or don’t want to use it, or can’t remember of the options: what now? Again a pretty simple solution: cat. Most people are using cat for displaying files, but you can do really nice things with it and of course you can also use it for making ISO Images. Maybe you might wondering now, how can this work? Well, there’s a saying which comes from Unix: Everything is a file. And so, also devices are internally treated as files and files can be read by cat. All what we have to do is: inserting the media, mount it and redirect the output of cat into a file like:

1<br />2<br />3<br />
<span style="color: rgb(194, 12, 185); font-weight: bold;">cat</span>  <span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>dev<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>dvd <span style="color: rgb(0, 0, 0); font-weight: bold;">>></span> dvd.iso <span style="color: rgb(102, 102, 102); font-style: italic;"># for dvd</span><br /><span style="color: rgb(194, 12, 185); font-weight: bold;">cat</span>  <span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>dev<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>cdrom <span style="color: rgb(0, 0, 0); font-weight: bold;">>></span> cdrom.iso <span style="color: rgb(102, 102, 102); font-style: italic;"># for cdrom</span><br /><span style="color: rgb(194, 12, 185); font-weight: bold;">cat</span>  <span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>dev<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>scd0 <span style="color: rgb(0, 0, 0); font-weight: bold;">>></span> image.iso <span style="color: rgb(102, 102, 102); font-style: italic;"># if cdrom/dvd is scsi</span>

Finally, I will show you how you can mount your ISO Image:

1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />
  <span style="color: rgb(102, 102, 102); font-style: italic;"># become root</span><br />  <span style="color: rgb(194, 12, 185); font-weight: bold;">su</span> -<br />  <span style="color: rgb(102, 102, 102); font-style: italic;"># create mount directory (recursively)</span><br />  <span style="color: rgb(194, 12, 185); font-weight: bold;">mkdir</span> <span style="color: rgb(102, 0, 51);">-p</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>path<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>to<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>directory<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>where<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>the<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>iso<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>content<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>should<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>appear<br />  <span style="color: rgb(102, 102, 102); font-style: italic;"># load loopback module, if not already happened. you can check by: lsmod | grep loop</span><br />  modprobe loop<br />  <span style="color: rgb(102, 102, 102); font-style: italic;"># mount iso image as loopback device</span><br />  <span style="color: rgb(194, 12, 185); font-weight: bold;">mount</span> <span style="color: rgb(102, 0, 51);">-o</span> loop <span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>path<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>to<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>iso<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>file<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>image.iso <span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>path<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>to<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>directory<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>where<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>the<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>iso<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>content<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>should<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>appear


Comments

Popular Posts