Working With CD-ROM Drives

Like any modern operating system, Ubuntu comes pre-loaded with tools for working with CD/DVD drives, including tools for working with re-writable discs.

This article covers some useful topics for working with CD-ROM drives.

Note that most of these instructions are for the command line, and assume that your CD drive is /dev/cdrom — if that's not the case, on your system, you'll have to modify the commands accordingly.

How to Load/Unload a CD/DVD

If you've heard people talk about “mounting and unmounting volumes,” when talking about Linux or Unix, you might be worried that using CDs or DVDs will be a cumbersome process. However, in Ubuntu loading and unloading a CD or DVD is done the same as you're probably used to in Windows. Simply put the disc in your drive, and Ubuntu will see that it's there, and act appropriately. It will create an icon on your desktop, for accessing the disc, and, depending on what type of disc it is, will launch an appropriate application for dealing with it. (e.g. it may launch your default music player, if it's an audio CD, or launch your default movie player, if it's a DVD.)

When you're done using the CD/DVD, just like in Windows, you can simply eject the disc from the drive. (The icon that had been created on the desktop will disappear.) Or, if you wish, you can right-click on the icon on the desktop, and choose Eject.

How to Erase a CD-RW/DVD-RW

If you have a rewritable disc, CD or DVD, you can erase it at the command line, by entering the following commands:

$ sudo umount /dev/cdrom
$ cdrecord dev=/dev/cdrom blank=fast

ISO Files

There is a special type of file, called an ISO File, which is an image of a CD or DVD. (You can read more about ISO files on the wikipedia page.)

ISO files are handy for creating backups of your CDs/DVDs, or for distributing CDs/DVDs on the internet. For example, Ubuntu's installation CD can be downloaded from their website, as an ISO file.

How to Create an ISO Image of a CD/DVD

The easiest way to create an .iso file from a disc is to simply right-click the disc's icon on the desktop, and choose Copy Disk from the menu. Ubuntu will bring up a utility to copy the disc; in the Copy Disk To drop-down, choose File image. You can then choose a name and location for the .iso file you want to create.

If you have a DVD or data CD for which you'd like to make an image, you can also do it from the command line, by entering the following commands. Substitute the name of the file you want to create for file.iso.

$ sudo umount /dev/cdrom
$ dd if=/dev/cdrom of=file.iso bs=1024

How to Create an ISO Image From the File System

You can create an ISO file without having an actual disc; you can simply choose a folder on your system which represents the ISO image to be created, and use the mkisofs command to create it.

Simply enter this command, substituting the name of the file you want to create for file.iso, and the full path of the folder for /location_of_folder/.

$ mkisofs -o file.iso /location_of_folder/

How to Burn an ISO Image to a CD/DVD

Simply right-click the .iso file, and choose Write to Disc->Write.

Mounting an ISO Image Without Burning It

You can actually mount an ISO image in the file system, as if it were on a CD or DVD, without actually burning it. This is the same effect as burning it to a disc and then putting the disc in your CD-ROM drive, except that you don't need to waste a disc.

This doesn't seem to work for audio CDs; only data CDs, or DVDs.

To Mount

To mount the image, enter the following commands, where, again, you would substitute the name of the file instead of file.iso.

$ sudo mkdir /media/iso
$ sudo modprobe loop
$ sudo mount file.iso /media/iso/ -t iso9660 -o loop

You now have your .iso file “mounted” on the file system, and can access it like any drive. There should even be an icon on the desktop, named “iso.” If the .iso file is an image of a data CD/DVD, all you have to do is navigate to it like any other drive/folder on the system.

If the .iso file is an image of a DVD or a music CD, however, Ubuntu won't treat it quite like a normal disc — that is, when you mount it, Ubuntu won't automatically launch your DVD or CD player. You'll have to do that yourself.

For example, on my system, I use Totem to watch DVDs. In order to use Totem to view an .iso image, I'd use this command:

$ totem /media/iso

And I use Rhythmbox to listen to audio CDs, so in order to use that to listen to an audio CD, I'd enter:

$ rhythmbox /media/iso

You might use different applications to watch DVDs or listen to audio CDs; in that case, you'll have to examine the application's help to figure out how to launch it from the command line, and whether you'll have to do anything special to launch a mounted .iso image like this.

Some applications might even be able to read the .iso file directly, without having to mount it.

To Unmount

When you're finished with the “disc” you mounted, simply enter the following command, to un-mount it.

$ sudo umount /media/iso/

If you mounted the image to a different location from /media/iso/ then you'll have to enter that location here.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.