Backing Up to Removable Media

The capacity of CDs and DVDs, and the low costs of those media, has made them attractive options as computer backup media. Using tools that commonly come with Linux systems, you can gather files to back up into CD or DVD images and burn those images to the appropriate media.

Command line tools such as mkisofs (for creating CD images) and cdrecord (for burning images to CD or DVD) once provided the most popular interfaces for making backups to CD or DVD. Now there are many graphical front-ends to those tools you could also consider using. For example, GUI tools for mastering and burning CDs/DVDs include K3b (the KDE CD and DVD Kreator) and Nautilus (GNOME’s file manager that offers a CD-burning feature). Other GUI tools for burning CDs include gcombust, X-CD-Roast, and graveman. The commands for creating file system images to back up to CD or DVD, as well as to burn those images, are described in this document.

Creating Backup Images with mkisofs

Most data CDs and DVDs can be accessed on both Windows and Linux systems because they are created using the ISO9660 standard for formatting the information on those discs. Because most modern operating systems need to save more information about files and directories than the basic ISO9660 standard includes, extensions
to that standard were added to contain that information.

Using the mkisofs command, you can back up the file and directory structure from any point in your Linux file system and produce an ISO9660 image. That image can include the following kinds of extensions:

❑ System Use Sharing Protocol (SUSP) are records identified in the Rock Ridge Interchange Protocol. SUSP records can include Unix-style attributes, such as ownership, long file names, and special files (such as character devices and symbolic links).

❑ Joliet directory records store longer file names in a form that makes them usable to Windows systems.

❑ Hierarchical File System (HFS) extensions allow the ISO image to appear as an HFS file system, which is the native file system for Macintosh computers. Likewise, Data and Resource forks can be added in different ways to be read by Macs.

When you set out to create your ISO image, consider where you will ultimately need to access the files you back up using mkisofs (Linux, Windows, or Macs). Once the image is created, it can be used in different ways, the most obvious of which is to burn the image to a CD or DVD.

Besides being useful in producing all or portions of a Linux file system to use on a portable medium, mkisofs is also useful for creating live CDs/DVDs. It does this by adding boot information to the image that can launch a Linux kernel or other operating system, bypassing the computer’s hard drive.

NOTE: Although you can still use the mkisofs command in Ubuntu, mkisofs is now a pointer to genisoimage. The genisoimage command was derived from mkisofs, which was part of the cdrtools package (see http://cdrecord Development of genisoimage is part of the cdrkit project (

Because most Linux users store their personal files in their home directories, a common way to use mkisofs to back up files is to back up everything under the /home directory. Here are some examples of using mkisofs to create an ISO image from all files and directories under the /home directory:

$ cd /tmp

Create basic ISO9660 image
$ sudo mkisofs -o home.iso /home

Add Joliet Rock Ridge extensions
$ sudo mkisofs -o home2.iso -J -R /home

Also add HFS extensions
$ sudo mkisofs -o home3.iso -J -R -hfs /home

With the last command, you will see a warning message like the following:

genisoimage: Warning: no Apple/Unix files will be decoded/mapped

In each of the three examples above, all files and directories beneath the /home directory are added to the ISO image (home.iso). The first example has no extensions, so all file names are converted to DOS-style naming (8.3 characters). The second example uses Joliet and Rock Ridge extensions, so file names and permissions should appear as they did on the original Linux system when you open the ISO on a Linux or Windows system. The last example also makes the files on the image readable from a Mac file system.

NOTE: You can also read Rock Ridge and Joliet extensions on Mac OS X.

You can have multiple sources added to the image. Here are some examples:

Multiple directories/files
$ mkisofs -o home.iso -R -J music/ docs/
giovanni.pdf /var/spool/mail

Graft files on to the image
$ mkisofs -o home.iso -J -R \
-graft-points Pictures/=/usr/share/pixmaps/

The first example above shows various files and directories being combined and placed on the root of the ISO image. The second example grafts the contents of the /var/pics directory into the /home/giovanni/Pictures directory. As a result, on the CD image the /Pictures directory will contain all content from the /usr/share/pixmaps directory.

Adding information into the header of the ISO image can help you identify the contents of that image later. This is especially useful if the image is being saved or distributed online, without a physical disc you can write on. Here are some examples:

Add header info to ISO
$ mkisofs -o /tmp/home.iso -R -J
-publisher “Swan Bay Folk Art Center”
-V “WebBackup”
-A “mkisofs”
-volset “1 of 4 backups, July 30, 2007”

In the example above, -p indicates the preparer ID, which could include a phone number, mailing address, or web site for contacting the preparer of the ISO image. With the option -publisher, you can indicate a 128-character description of the preparer (possibly the company or organization name). The -V indicates the volume ID. Volume ID is important because in many Linux systems this volume ID is used to mount the CD when it is inserted. For example, in the command line shown above, the CD would be mounted on /media/WebBackup in Ubuntu and other Linux systems. The -A option can be used to indicate the application used to create the ISO image. The -volset option can contain a string of information about a set of ISO images.

When you have created your ISO image, and before you burn it to disc, you can check the image and make sure you can access the files it contains. Here are ways to check it out:

Display volume name
$ volname home.iso

Display header information
$ isoinfo -d -i home.iso
CD-ROM is in ISO 9660 format
System id: LINUX
Volume id: WebBackup
Volume set id: All Website material on November 2, 2007
Publisher id: Swan Bay Folk Art Center
Data preparer id:
Application id: mkisofs
Copyright File id:
Abstract File id:
Bibliographic File id:
Volume set size is: 1
Volume set sequence number is: 1
Logical block size is: 2048
Volume size is: 23805
Joliet with UCS level 3 found
Rock Ridge signatures version 1 found

You can see a lot of the information entered on the mkisofs command line when the image was created. If this had been an image that was going to be published, we might also have indicated the locations on the CD of a copyright file (-copyright), abstract file (-abstract), and bibliographic file (-biblio). Provided that the header is okay, you can next try accessing files on the ISO image by mounting it:

Create a mount point
$ sudo mkdir /mnt/myimage

Mount the ISO in loopback
$ sudo mount -o loop home.iso /mnt/myimage

Check the ISO contents
$ ls -l /mnt/myimage

Unmount the image when done
$ sudo umount /mnt/myimage

Besides checking that you can access the files and directories on the ISO, make sure that the date/time stamps, ownership, and permissions are set as you would like. That information might be useful if you need to restore the information at a later date.

Burning Backup Images with cdrecord

The cdrecord command is the most popular Linux command line tool for burning CD and DVD images. After you have created an ISO image (as described earlier) or obtained one otherwise (such as downloading an install CD or live CD from the Internet), cdrecord makes it easy to put that image on a disc.

NOTE: In Linux, cdrecord has been replaced with the wodim command. The wodim command was created from the cdrecord code base and still supports most of the same options. If you run cdrecord, you will actually be running wodim in this Ubuntu release. If you have problems with that utility, contact the CDRkit project (

There is no difference in making a CD or DVD ISO image, aside from the fact that a DVD image can obviously be bigger than a CD image. Check the media you have for their capacities. A CD can typically hold 650MB, 700MB, or 800MB, whereas mini CDs can hold 50MB, 180MB, 185MB, or 193MB. Single-layer DVDs hold 4.7GB, while doublelayer DVDs can hold 8.4GB. Keep in mind, however, that CD/DVD manufacturers list their capacities based on 1000KB per 1MB, instead of 1024KB. Type du –si home.iso to list the size of your ISO, instead of du -sh as you would normally, to check if your ISO will fit on the media you have.

Before you begin burning your image to CD or DVD, check that your drive supports CD/DVD burning and determine the address of the drive. Use the –scanbus option to cdrecord to do that:

In the two examples shown, the first indicates a CD/DVD drive that only supports reading and cannot burn CDs (DVD-ROM and CD-ROM). The second example shows a drive that can burn CDs or DVDs (DVDRW). Insert the medium you want to record on. Assuming your drive can burn the media you have, here are some simple cdrecord commands for burning a CD or DVD images:

Test burn without actually burning
$ cdrecord -dummy home.iso

Burn CD (default settings) in verbose
$ cdrecord -v home.iso

Set specific speed
$ cdrecord -v speed=24 home.iso

Can’t read track so add 15 zeroed sectors
$ cdrecord -pad home.iso

Eject CD/DVD when burn is done
$ cdrecord -eject home.iso

Identify drive by device name (may differ)
$ cdrecord /dev/cdrw home.iso

Identify drive by SCSI name
$ cdrecord dev=0,2,0 home.iso

The cdrecord command can also burn multi-session CDs/DVDs. Here is an example:

Start a multi-burn session
$ cdrecord -multi home.iso

Check the session offset for next burn
$ cdrecord -msinfo
Using /dev/cdrom of unknown capabilities

Create a second ISO to burn
$ mkisofs -J -R -o new.iso \
-C 0,93041 /home/marvin/more Indicate start point and new data for ISO

Burn new data to existing CD
$ cdrecord new.iso

You can use multiple -multi burns until the CD is filled up. For the final burn, don’t use -multi, so that the CD will be closed.

Making and Burning DVDs with growisofs

Using the growisofs command, you can combine the two steps of gathering files into an ISO image (mkisofs) and burning that image to DVD (cdrecord). Besides saving a step, the growisofs command also offers the advantage of keeping a session open by default until you close it, so you don’t need to do anything special for multi-burn sessions.

Here is an example of some growisofs commands for a multi-burn session:

Master and burn to DVD
$ growisofs -Z /dev/dvd -R -J /home/marvin

Add to burn
$ growisofs -Z /dev/dvd -R -J /home/giovanni

Close burn
$ growisofs -M /dev/dvd=/dev/zero

If you want to add options when creating the ISO image, you can simply add mkisofs options to the command line. (For example, see how the -R and -J options are added in the above examples.)

If you want to burn a DVD image using growisofs, you can use the -dvd-compat option. Here’s an example:

Burn an ISO image to DVD
$ growisofs -dvd-compat -Z /dev/dvd=image.iso

The -dvd-compat option can improve compatibility with different DVD drives over some multi-session DVD burning procedures.


About msotela

This blog is for anyone who wants to access the power of a Linux system as a systems administrator or user. You may be a Linux enthusiast, a Linux professional, or possibly a computer professional who is increasingly finding the Windows systems in your data center supplanted by Linux boxes.

Posted on September 23, 2009, in Unix/Linux. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in: 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

%d bloggers like this: