The Linux Page

Mount an ISO file and Burning it to CD-R/DVD-R/BluRay in Linux

An opened laptop optical drive with a literally burned CD disk showing.

Create ISO File to Burn

When creating a CD you use mkisofs (make ISO file system--ISO stands for International Standard Organization, a non-profit organization used to write standard procedures used in business and other places to better organize interoperability between many companies in the world.)

mkisofs -o my-cd.iso directory

The "directory" are all the files you want to write to the ISO file.

Verify Disk Before Burning

Then you should verify that it looks as you expected. This is done by mounting the ISO file:

sudo mount -o loop my-cd.iso /mnt/cd

Assuming the mount works, you can then use ls to see the content of the ISO file:

ls -l /mnt/cd

It should be what you had in your directory before you ran mkisofs.

Make the CD Bootable

Note that if you want to make the CD bootable, you'll need to also add the boot sector to the my-cd.iso file.

Something like this should get you there:

mkisofs -o my-cd.iso -b iso.bin -c boot.cat -no-emul-boot \
        -boot-load-size 4 -boot-info-table directory

This shows how you boot a kernel on the CD. The kernel is in directory. The -b and -c options add the necessary files for the CD to boot properly.

Testing Boot Sector with a VM

If you have a machine that supports VirtualBox (who doesn't now?!) then you should be able to boot your ISO file on a VM without the need to burn a CD.

This can be great economically! Only the CD needs to be capatible with a VM and that may not be as good as a real computer booting from a CD.

Remember too that less and less devices come with a CD drive. We still use them a lot in the medical field to save your data (i.e. a copy of your CT scan, X-Rays, etc. can be given to you on a DVD.)

It is otherwise a bit difficult to check an ISO to see whether the boot sector was properly installed unless you know quite a bit about a CD structure.

Burning the CD

Once you're happy about your CD, you can burn it on your optical device with the cdrecord or wodim command.

Checking Capabilities

First, you may want to determine your device capability as viewed by Linux:

cdrecord -prcap

This one gives us the drive capabilities. The dev=... parameter is useful when you have multiple CD-R/DVD-R drives.

To the minimum you need these to correspond to the type of media you want to write to:

Does write CD-R media
Does read DVD-R media

Then you should see a list of speeds:

Write speed # 0:  8468 kB/s CLV/PCAV (CD  48x, DVD  6x)
Write speed # 1:  7056 kB/s CLV/PCAV (CD  40x, DVD  5x)
Write speed # 2:  5645 kB/s CLV/PCAV (CD  32x, DVD  4x)
Write speed # 3:  4234 kB/s CLV/PCAV (CD  24x, DVD  3x)
Write speed # 4:  2823 kB/s CLV/PCAV (CD  16x, DVD  2x)

Make sure to use a speed your drive knows about so that way cdrecord doesn't choose another one, possibly not what you would like to use.

Now, the speeds indicated by the drive may not match the speeds supported by the media. Some CD-R may accept a speed of 32 maximum, for example. To check the two together, we have another tool called xorriso and we can use:

xorriso -outdev /dev/cdrom -list_speeds

to get such a list. For example, I have a CR-R in my drive and got:

Read speed   :   7056k , 40.0xC
Read speed   :   2940k , 16.7xC
Read speed L :   2940k , 16.7xC
Read speed H :   7056k , 40.0xC
Write speed  :   8468k , 48.0xC
Write speed  :   8467k , 48.0xC
Write speed  :   7056k , 40.0xC
Write speed  :   5645k , 32.0xC
Write speed  :   5644k , 32.0xC
Write speed  :   4234k , 24.0xC
Write speed  :   4233k , 24.0xC
Write speed  :   2823k , 16.0xC
Write speed  :   2822k , 16.0xC
Write speed L:   2822k , 16.0xC
Write speed H:   8468k , 48.0xC

So I can use 16, 24, 32, 40, 48 for the speed=... parameter. So in my case, I can use any speed my drive supports. Great!

Record ISO

Now you can record your ISO file with something like this:

cdrecord dev=/dev/cdrom speed=48 my-cd.iso

If it is your first burn, you probably will have to test different speeds and devices before you get it to work right. I know it took me a little while to get things to work right. If you try to burn too quickly, it is likely to not do a good job and the CD-R won't be readable. So using the smallest speed can be a good idea. It's slower, but safer.

Verifying Media

One way to verify a burn, once cdrecord returns, is to re-read the entire CD-R using the cat command as in:

cat /dev/cdrom verify.iso

The cat command should not fail if the entire CD can be re-read. It will fail in the event part of the CD can't be read back. On some old CD-Drives, it has problems reading the end of the file. The CD may still be working as expected.

Then compare the verify.iso with the original my-cd.iso.

cmp my-cd.iso verify.iso

The two files should be the same.

See also: Mounting a VDI disk on your Host System