CD Burning on Linux using the command line

Copyright © 2005 - Angelo Bertolli

Note: Depending on your system, you might need to be root to perform some of these commands. Play it safe and only become root when you need to.

(1) Find out which device you should reference as the burner by using cdrecord. In my examples the device will be 2,0,0
cdrecord -scanbus

(2) Make ISO9660 file system with Rock Ridge (Unix) and Joliet (MS) extensions (use -f to follow soft links). This is for creating your first session, see the part about adding sessions if you want to burn to the same CD more than once.
mkisofs -R -J -o cdimage.iso data_directory/

(3) Burn the ISO image on the CDR (choose a speed). You must use -multi unless this is the last session/track you will add to the disk (see later for multiple sessions). The -eject option is optional and only ejects the CD when it is done. If you leave out speed=# then it will try to determine the fastest speed on its own. Note that the speed for CDR and CDRW can be different, but 4 is a safe number to choose for both.
cdrecord -v -multi -eject speed=16 dev=2,0,0 cdimage.iso

Multiple Sessions

You will need some information about where the other sessions "left off" on the CD, so that you may add another session. In my example, this command returns 113633,121133
cdrecord dev=2,0,0 -msinfo

Instead of (2) above, you will need to construct the CD image in a special way so you do not lose any data that is in previous sessions. In my example, my burner is /dev/cdrom1
mkisofs -o session2.iso -C 113633,121133 -M /dev/cdrom1 -R -J more_data/

Burn the new session to the CD just like in (3)
cdrecord -v -multi -eject speed=16 dev=2,0,0 session2.iso

Need More Help?

man mkisofs
man cdrecord

Code Reference

cdrecord -scanbus
mkisofs -R -J -o cdimage.iso data_directory/
cdrecord -v -multi -eject speed=16 dev=2,0,0 cdimage.iso

cdrecord dev=2,0,0 -msinfo
mkisofs -o session2.iso -C 113633,121133 -M /dev/cdrom1 -R -J more_data/
cdrecord -v -multi -eject speed=16 dev=2,0,0 session2.iso

DVD Burning Quickie

Burning DVDs is almost just as easy. The thing to watch out for are filesystems that don't allow very large files. To get around this, we split the iso into 1 GB chunks:
mkisofs -R -J -split-output -o iso_directory/dvdimage data_directory/

This will create a collection of files starting with "dvdimage" in the iso_directory/ which you can use to burn using dvdrecord:
dvdrecord -v -multi -eject speed=1 dev=2,0,0 iso_directory/dvdimage*

Note: There is a -dvd-video option for mkisofs if you are planning on making your own video DVDs