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 -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. Something like this:

cdrecord dev=/dev/cdrom speed=52 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.

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