From Christoph's Personal Wiki
Jump to: navigation, search

CDfs is a virtual Linux file system that provides access to individual data and audio tracks on compact discs. A compact disc mounted with the "cdfs" driver appears as a collection of files, each representing a single track. It supports the following track types:

  • Red Book audio: Appears as a CDA file; reading from it will start the media player reading from the tracks. The CDA files aren't actual music files, they are 'shortcuts' to the invisible tracks on the audio CD.
  • White Book video: Appears as a playable MPEG-1 file containing audio and video streams.
  • Yellow Book data:
    • Apple HFS: Appears as a mountable HFS file system image (sans partition table).
    • ISO 9660: Each session appears as a mountable ISO image file.
    • El Torito boot image: Appears as a floppy image file.

Cdfs is not included in the mainline Linux kernel, but is distributed instead as a series of kernel patches.

On other Unices and operating systems such as Windows, cdfs can be the name of the ISO 9660 file system driver.


Note: Most of the following is taken directly from the official website (with modifications).

  • If you mount the CD with the cdfs file system, you get the two sessions as files:
mount -t cdfs -o ro /dev/cdrom /mnt/cdfs
ls -l /mnt/cdfs
  total 33389
  -r--r--r-- 1 root root 33503232 2007-04-20 19:36 sessions_1-1.iso
  -r--r--r-- 1 root root 34121728 2007-04-20 19:36 sessions_1-2.iso
  • These files can then be mounted loop back:
mount -t iso9660 -o loop /cdfs/sessions_1-1.iso /mnt/loop1
mount -t iso9660 -o loop /cdfs/sessions_1-2.iso /mnt/loop2

and the file a can be accessed in both sessions

ls -l /mnt/loop1
  total 9889
  -r-xr-xr-x 1 root root 10104236 2007-04-20 17:34 a
ls -l /mnt/loop2
  total 2
  -r-xr-xr-x 1 root root 2 2007-04-20 19:16 a
  -r-xr-xr-x 1 root root 2 2007-04-20 19:19 b

The file system also allows you to access data on faulty multi session disks, e.g. disk with multiple single sessions instead of a multi session (for instance created with mkisofs without the proper -C parameters).

  • track-?.wav: an audio file. The file starts with a WAV-header and can be copied or played (by copying it to the audio device), e.g.:
mount -t cdfs -o ro /dev/cdrom /mnt/cdfs
ls -l /mnt/cdfs
  total 0
  -r--r--r-- 1 root root 42973392 2007-04-20 18:01 track-1.wav
  -r--r--r-- 1 root root 65164512 2007-04-20 18:01 track-2.wav
  -r--r--r-- 1 root root 71743056 2007-04-20 18:01 track-3.wav
  -r--r--r-- 1 root root 66940272 2007-04-20 18:01 track-4.wav
sox /mnt/cdfs/track-1.wav -t ossdsp /dev/dsp 


Note: The following is an example.

cat /proc/cdfs
  [cdfs   2.6.19]
  CD (discid=XXXXXXXX) contains 10 tracks:

  Track  1: audio track (track-01.wav), [       0 -   20987], length= 4:39
  Track  2: audio track (track-02.wav), [   20988 -   39988], length= 4:13

See also

External links