Working with CDs and ISO Images

The increasing use of virtual machines to host systems means that you will often need to work with ISO images rather than real CDs.

There are programs with more user-friendly graphical interfaces, but the following commands will show you how to create an image from a CD or DVD, mount it, and when necessary copy it back onto a physical CD using the command line.

Obviously before copying a CD or DVD you need to ensure that you are legally allowed to do so.

Copying a CD to an ISO image

Simply dump the contents of the device direct from the CD/DVD to an .ISO file.

$ dd if=/dev/cdrom of=cdimage.iso 

In some cases you will need to specify the block size explicitly in order to create a usable image. Normally the block size on a CD will be 2048 bytes, but some operating systems including VMS use 512 byte block sizes.

$ dd if=/dev/cdrom of=cdimage.iso bs=2048 
141824+0 records in
141824+0 records out
290455552 bytes (290 MB) copied, 73.0457 s, 4.0 MB/s

Mounting an ISO image

To mount a CD or a CD image you need to be logged in as root. Using the loopback option, allows you to mount a CD image.

$ su 
# mount -o loop cdimage.iso /mnt 
# ls /mnt
autorun.inf          dists                g2ldr	  
install.386          pics                 README.mirrors.html
README.txt           win32-loader.ini     css
doc                  g2ldr.mbr            isolinux
pool                 README.mirrors.txt   setup.exe
debian               firmware             install
md5sum.txt           README.html          README.source

Erasing CD-RW media

To erase a CD-RW disk form he command line use the following command, don’t forget to dismount the disk first.

$ umount /dev/cdrw 
$ wodim dev=/dev/cdrw blank=fast -eject 

To overwrite the previous contents you can use the following option instead of fast but this will take much longer.

$ wodim dev=/dev/cdrw blank=all -eject

Writing an ISO image to CD

This similar to the command used to erase a CD-RW disk but instead of telling the system to blank the disk, you specify the name of the ISO image file to write to the device.

$ wodim dev=/dev/cdrom cdimage.iso
wodim: No write mode specified.
wodim: Assuming -tao mode.

Device type    : Removable CD-ROM
Version        : 0
Response Format: 2
Capabilities   : 
Vendor_info    : 'LITE-ON '
Identification : 'COMBO SOHC-4832K'
Revision       : 'OQK8'
Device seems to be: Generic mmc2 DVD-ROM.
Using generic SCSI-3/mmc   CD-R/CD-RW driver (mmc_cdr).

This entry was posted in Linux. Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s