HOEKSTRA.CO.UK

So, you downloaded a torrent expecting a nice AVI- or MPG-file for instant-action AV entertainment, and all you got was a big .bin file and a funny little .cue file? Here's the Linux-way of how to extract the content from them:

Overview

.bin and .cue files are binary and metadata file tuples for storing optical storage data in its rawest form. More on this type of raw data type in Wikipedia.

Solutions

There at least 3 approaches available for making this type of file usable:

  • Use the bin2iso utility
  • Use the bchunk utility
  • Use the cdemu kernel module

Use the bin2iso utility

# emerge bin2iso
  • Create an iso image file from your .bin and .cue pair by just specifying the .cue file:
# bin2iso myfile.cue

This creates the output file myfile-01.iso from your myfile.bin and also obliterates the myfile.bin file.

  • Mount the resulting .iso file in, say, the /mnt/image directory:
# mkdir /mnt/image
# mount -o loop -t iso9660 myfile-01.iso /mnt/image
# ls /mnt/image

... and collect your files from the /mnt/image directory.

Use the bchunk utility

  • Download and install the bchunk utility from http://he.fi/bchunk or install it on a Gentoo-based Linux as follows:
# emerge bchunk
  • Create an iso image file (example: outfile.iso, but don't specify the .iso extension) from your .bin and .cue pair (example: infile.bin and infile.cue)
# bchunk infile.bin infile.cue outfile

This creates the output file outfile.iso, which you can mount.

  • Mount the resulting .iso file in, say, the /mnt/image directory:
# mkdir /mnt/image
# mount -o loop -t iso9660 outfile.iso /mnt/image
# ls /mnt/image

Use the cdemu kernel module

Note that release cdemu-0.8  does not work from Kernel 2.6.17 onwards.

  • Ensure that your current linux kernel points to your kernel source code directory via the /usr/src/linux symbolic link:
# uname -a
Linux dappy 2.6.20-gentoo-r1 #1 PREEMPT Thu Mar 8 18:41:41 GMT 2007 i686 AMD Athlon(tm) XP 1700+ AuthenticAMD GNU/Linux
# ls -l /usr/src
lrwxrwxrwx  1 root root   23 Jun 11 10:55 linux -> linux-2.6.20-gentoo-r1/
drwxr-xr-x 20 root root 1328 Mar 13 18:27 linux-2.6.20-gentoo-r1
# emerge cdemu
  • Install the module in your kernel
# modprobe cdemu
  • Check to see if the modules was successfully installed:

A cdemu device should have been created in your /dev directory:

# ls /dev/cdemu*
/dev/cdemu0
/dev/cdemu1
. . .
/dev/cdemu8

You can also check if it was loaded with the command:

# lsmod
Module                  Size  Used by
cdemu                  11532 0
. . .
  • Mount the .cue file as follows - this pulls in the .bin file:

# cdemu 0 infile.cue

# mount /dev/cdemu0 /mnt/cdrom