Thursday, March 4, 2010

HowTo mount cdrom in linux

SkyHi @ Thursday, March 04, 2010
CD's and DVDs are using iso9660 filesytem. As any other operating system, Linux is also able to read data from standard iso9660 filesystem. Let's see how we can mount CD-ROM or DVD-ROM with use of mount command.
1. Detecting CD-ROM/DVD-ROM drive

If we are not sure which block device is our DVD-ROM or CD-ROM we can find it out by running a following wodim command:

# wodim --devices

If the wodim command is not available on your system make sure that package cdrecord is installed. After running wodim command you should get output similar to one below:

# wodim -devices
wodim: Overview of accessible drives (1 found) :
0 dev='/dev/sdc' rwrw-- : 'TSSTcorp' 'CD/DVDW SH-S183L'

Well, now it's clear that my DVD-ROM drive is know by system as a block device /dev/hdc. Note different systems may behave differently. For example on Debian Linux a user runing wodim command must belong to cdrom group otherwise the wodim command will fail with a following error message:

wodim: No such file or directory.
Cannot open SCSI driver!
For possible targets try 'wodim --devices'
or 'wodim -scanbus'.
For possible transport specifiers try 'wodim
For IDE/ATAPI devices configuration,
see the file README.ATAPI.setup from
the wodim documentation.

2. Testing for iso9660 compatibility

Lets see if my current kernel supports iso9660 filesystem.

# cat /proc/filesystems

This command should report available iso9660 filesystem.
Testing for iso9660 compatibility
3. Creating mount point

Probably there is already mount point on you system. Usually it is /cdrom, /media/cdrom, /media/cdrom0 or /mnt/cdrom . If this not your case create a new mount point now.

# mkdir /media/cdrom0

4. Mounting CD

As a root user issue a command:

# mount -t iso9660 /dev/hdc /media/cdrom0/

Mounting CD using linux
your CD is now mounted as /media/cdrom0/. Navigate to this directory to see its content.
5. Mounting Audio CD's

Sometimes you would like to listen to your favorite music and when you try mount music cd with a command above you can get problems like: mount -t iso9660 /dev/hdc /media/cdrom0/
mount: block device /dev/hdc is write-protected, mounting read-only
mount: wrong fs type, bad option, bad superblock on /dev/hdc,
missing codepage or other error
In some cases useful info is found in syslog - try
dmesg | tail or so

This is because music CD's does not contain standard iso9660 filesystem. In fact the story with music cd's is easier as a story with data CD's with iso9660 filesystem. In order to listen to music CD just insert it into CD-ROM/DVD-ROM drive and fire up you favorite music CD player. Only thing you need to be concern about is whether you have "kdemultimedia-kio-plugins" for KDE or in case of gnome "gnome-media" packages installed which also helps you to browse CD content. In case you would like to see content of music CD just start "KONQUEROR" and enter location:


6. Altering /etc/fstab

To allow users on the system mount CD's or DVD's alter your /etc/fstab and add line similar to the one below:

/dev/hdc /media/cdrom0 iso9660 ro,user,noauto 0 0

7. Unmount and eject CD

There are couple ways how to remove CD/DVD from a drive.

# umout /dev/hdc
# eject

or you can simply run

# eject

If you are unable to unmount, make sure, that you are not in the directory where your DVD-ROM is mounted or that some other application is not using it. If you still have a problem to unmount you DVD-ROM medium you can use fuser command to kill all related processes using your device.

# fuser -mk /dev/hdc
# eject

8. Video