IgnorantGuru's Blog

Linux software, news, and tips

Script: bic

«Downloads

Download Links: download bicview sourceverify
Description: Burns a folder tree or ISO image to CD or DVD
Recommended For: Linux
Tested On: Arch Linux
Current Version: 0.9.2
Requires: inotifywait sudo cdrtools dvd+rw-tools eject
Related: mountiso
License: GNU GPL v3     * SEE DISCLAIMER *
Bugs/Requests: SourceForge Tracker or Arch Linux Forum Thread

Contents

Overview


UPDATE: The copy of bic provided here is outdated and may not work at all without adjustments – it is provided for reference only. Also, bic’s functionality has been incorporated into the new Burn Tools SpaceFM plugin.

Fed up with GUI burning apps that were buggy and didn’t do what I wanted, I wrote bic to quickly burn a folder of files or an ISO image to disc. This script is best considered as a starting point for making your own custom burn script, rather than a script that is going to do everything you want without some changes. At the very least, you will need to set your drive and folder preferences at the top of the script. You may also want to modify some of the options passed to the burn commands in the script.

Currently, bic auto-detects media type, burns single-session data CDs and DVDs, copies CDs and DVDs, checks disc integrity using on-disc MD5 sums or against an existing folder/ISO, and creates snapshots of disc contents. bic lets you use your preferred file manager to build the contents of your disc.

bic --help

Usage: bic [OPTIONS] [SPEC]
Burns files/links in folder SPEC to CD or DVD
Burns isoimage SPEC to CD or DVD
OPTIONS
--size                   monitor SPEC folder size and sums (Ctrl-C to quit)
--sizeonly               monitor SPEC folder size (Ctrl-C to quit)
--burn                   burn to current media (auto-detected)
--cd     --cdr           burn to CDR      [ 16x ]
--cdrw                   burn to CDRW     [ 4x ]
--dvd    --dvdr          burn to DVDR     [ 4x ]
--dvdrw                  burn to DVDRW    [ 2x ]
--dvddl  --dl            burn to DVDR DL  [ 2x ]
--speed ##               override default burn speed
-V VOLNAME               volume name (32 char max)
--copy                   copy disc (no SPEC)
                         (must also include burn option eg --cd )
--copykeep SPEC          copy disc and keep ISO file SPEC
                         (can be used without burn)
--check [SPEC]           check disc integrity
                         (optional SPEC to compare ISO or tree)
--snap                   write snapshot of disc contents to
                         ~/snapshots/
--snapfind SEARCHTEXT    grep for SEARCHTEXT in
                         ~/snapshots/*
--reload                 reload tray

WARNING: RW discs are automatically overwritten!

Current Drive: /dev/scd0 (growisofs) aka /dev/sg3 (cdrecord)

Installation Instructions


Follow the standard Script Installation Instructions.

Also, before running bic, install required packages using your package manager.
On Arch Linux (also see cdrkit note below):

pacman -S inotifywait sudo dvd+rw-tools eject

Or on *ubuntu (this installs cdrkit, not the genuine cdrtools – see below):

sudo apt-get install inotifywait cdrtools dvd+rw-tools eject

IMPORTANT:
For political rather than technical reasons, most repositories do not contain the genuine version of cdrtools, but a replacement called cdrkit (wodim). cdrtools files are replaced by links to wodim in /usr/bin. cdrkit is a broken and very poorly maintained fork of cdrtools which causes many burning problems for users. I highly recommend you install the genuine version of cdrtools from cdrecord.berlios.de. (Additional info on the controversy)

To change to the genuine cdrtools on Arch Linux:
First, obtain and build cdrtools from the AUR. Note: You may not be able to install it with yaourt or packer due to package conflicts – just build the package…

wget http://aur.archlinux.org/packages/cdrtools/cdrtools/PKGBUILD
wget http://aur.archlinux.org/packages/cdrtools/cdrtools/cdrtools.install
makepkg -s
pacman -Rd cdrkit
pacman -U cdrtools-xxxxxxx.pkg.tar.xz  # whatever pkg makepkg built above

 

Finally, for password-less ISO mounts, installing mountiso is recommended.

Configuring bic


Open bic (/usr/local/bin/bic ?) in a text editor as root and edit the “User Defaults” section at the top. bic needs to know your DVD drive (eg /dev/scd0), the SCSI name for your DVD drive (eg /dev/sg3 for cdrecord), and the folder where discs are auto-mounted on your system (eg /media/dvd). There are several other options you can set as well.

Tip: You may need to make /dev/scd0 and /dev/sg3 (or whatever your drive is called) owned by root:optical, and then add your user to the optical group to avoid permission errors. For example:

sudo chown root:optical /dev/scd0 /dev/sg3
sudo usermod -aG optical myuser

(Your drive designations may vary. Log your user out and back in or reboot for the group change to take effect.)

In order for integrity checking and snapshots to work properly, your DVD drive should automount when a disc is inserted or reloaded. autofs is one tool you can consider for automounting. If it does not auto-mount, the check may fail. In that case you can mount the disc manually and run a check again.

bic currently supports only one DVD/CD drive, although you can modify this.

Building Your Disc Content

First, create a folder which will contain your disc content – “/tmp/buildtree” is used in this example. Then, open a terminal window and run this command:

bic --size /tmp/buildtree

Leave that terminal window open, and in your file manager add files and folders to /tmp/buildtree. You can also place links to files and folders in /tmp/buildtree – it is not necessary to copy large files. In the terminal window where bic is running, it will display the current size of the build tree in MB, and will also report that it is calculating MD5 sums of the files you add. bic will add a file called “.checksum.md5.gz” to /tmp/buildtree (which it can later use to check disc integrity). (If you don’t want any md5sums calculated until you’re ready to burn, use ––sizeonly instead.)

Depending on whether you are burning a CD or DVD, you will not want more than 700MB or 4470MB in /tmp/buildtree.

When you are done creating your disc contents, return to the terminal window where bic is running and press Ctrl-C to quit.

Note: It is not necessary to use “bic ––size” – it is merely a convenience to show you the total size of the files you add and to calculate the MD5 sums in advance.

Burning, Checking, and Snapshot

Next, issue the appropriate command to bic to burn and check your disc. When burning a folder to disc, you will also be prompted to save a snapshot of the disc contents. You can use these snapshots to search the contents of your CDs without inserting them.

Example burn commands:

# To auto-detect the media type (CDR, DVDR, etc), burn /tmp/buildtree, and check:
bic --burn /tmp/buildtree

# If auto-detection doesn't work, you can always specify the kind of disc...
# To burn /tmp/buildtree to a CDR and check:
bic --cd /tmp/buildtree

# To burn /tmp/buildtree to a DVDRW and check:
bic --dvdrw /tmp/buildtree

# To burn an ISO file and check:
bic --burn /downloads/example.iso

# To burn a disc specifying a volume name and custom burn speed:
bic -V "ThisVolume" --speed 12 --burn /tmp/buildtree

(To perform checks of ISO files, you may be prompted for your root password so the ISO file can be mounted. If you have mountiso installed in your path, bic will use this for password-less ISO mounts.)

If bic doesn’t succeed, study the error messages. You may need to modify commands in the script for your purposes. The good news is once you get it properly configured, it should keep working reliably.

Other Functions


# Check any disc burned with bic (except from ISO or copied):
bic --check

# Or, you can compare disc contents against any folder:
bic --check /tmp/buildtree

# Or, if a disc is burned from ISO:
bic --check /downloads/example.iso

# To copy a CD and burn the copy:
bic --copy --burn

# To copy a CD and burn the copy, keeping the ISO file:
bic --copykeep --burn /tmp/keepthis.iso

# To create an ISO file from a disc without burning a copy:
bic --copykeep /tmp/keepthis.iso

# To save a text file snapshot of disc contents:
bic --snap

# To reload the tray and then save a snapshot of disc contents:
bic --reload --snap

# To search your snapshots for the file example.txt:
bic --snapfind "example.txt"