I need to burn some files, so I would have more space. I have done this with GUI tools, you just drag and drop, then hit the burn button. After some reading1, it’s fairly simple to do in terminal.

Basically, you create a temporary directory and move files or copy files to it, then use mkisofs to create an ISO from it. You can mount it to check if you are a very careful person, or you can cdrecord it directly.

Here is what I want to do, I want to use symbolic links to include directories which I want to burn. There is a benefit of using symbolic instead of moving files: If temporary directory and files are located in different partitions or hard disks. Symbolic links would better option since the content of files would not need to be moved.

1   Procedure

So the following commands would do what I want:

mkdir ~/tmpdir #
cd ~/tmpdir

# Move files
mv /path/to/foo .

# Or create symbolic link
ln -s /path/to/bar

# Check size, -L option would follow symbolic links
du -shL

# Creating ISO
cd ..
# -f for following symbolic links, -J for Joliet, -r for Rock Ridge
mkisofs -Jrf -V LabelForDisc -o ~/Final.iso tmpdir

# Mount to check, iocharset=utf8 might be necessary if your filenames contain chars other than ISO-8869
sudo mount -t iso9660 -o ro,loop,iocharset=utf8 ~/Final.iso /mnt/cdrom

# Generating list for files ISO
cd /mnt/cdrom
find . | sort > /tmp/listISO
# Generating list for files on disk, -L is for following symbolic links
cd ~/tmpdir
find -L . | sort > /tmp/listDISK

# Checking for files, not size or their contents
diff /tmp/list*

# Burn it, baby!
cdrecord ~/Final.iso

I think it’s pretty clear, isn’t it?

(This is a post for reminding me when I need these steps in the future.)

2   sg module

This is an updated section on 2014-02-07. I have not burned a disc for long time, probably more than a year, and I got the following error:

$ sudo cdrecord -scanbus
Password:
Cdrecord-ProDVD-ProBD-Clone 3.01a16 (x86_64-unknown-linux-gnu) Copyright (C) 1995-2013 Joerg Schilling
cdrecord: No such file or directory. Cannot open '/dev/pg*'. Cannot open or use SCSI driver.
cdrecord: For possible targets try 'cdrecord -scanbus'.
cdrecord: For possible transport specifiers try 'cdrecord dev=help'.

It turns out I now need to load sg module by for /dev/sg0 and /dev/sg1 for my system, even the message says about /dev/pg*:

$ modprobe sg

After the module is loaded and nodes are created, cdrecord is now burning again. It seems udev is no longer automatically loading sg module some time ago. Which is more than fine and even better since I don’t use the drive often, only that I need to remember why I can’t burn and load the module on my own.


[1]http://www.ibm.com/developerworks/linux/library/l-cdburn.html is gone.