Mt. Rainier Support in Linux
March 8, 2004 -- by A.T. Hun
Last Updated: September 6, 2005
One of the common complaints heard from those considering a switch to Linux is that support for the latest and greatest devices is often lacking. In some cases, that is true. One case where it is not true is in Mount Rainier support for CD-RW drives. Basically, Mount Rainier "provides background formatting and defect management for storage on CD-RW and DVD+RW." In other words, it enables you to use a CD-RW as if it were a big 650 megabyte floppy. Most new CD-RW drives support this standard, but there is precious little support for the standard on the operating system level.
At this point, only Linux offers OS-level support for the Mount Rainier specification. Windows and Mac OS users can use it too, but they will need to run a separate program to access the discs. If I read the changelogs correctly, Mount Rainier support has been in the kernel in some form or another since the 2.4 series. However, full support began with the 2.6.2-rc1 kernel. Linux users can enjoy a feature that Windows users will have to wait until Longhorn for!
Please note: this HOWTO assumes that you have some experience with compiling programs in Linux. Basically, it's nothing more than the ./configure;make;make install three-step. It also assumes that you know how to do some basic system maintenance as root.
A Bit of History
Jens Axboe (who is mainly responsible for getting Mount Rainier support working in the Linux kernel) visited Philips and discussed Mount Rainier before prototype hardware was even available. Philips was kind enough to sponsor both pre- and post-production units for him to test with. That went a long way toward making Mount Rainier in Linux a reality.
What You Will Need
Here are some things you will need in order to get Mount Rainier support working:
- A Mount Rainier-compliant CD-RW drive (note, I have not tried this with DVD+RW but it may work). Check the documentation for your drive to be sure. Most CD-RW drives sold in the past year or so support it. For what it's worth, my drive is an LG GCC-4520B.
- Some high-speed CD-RWs. Mount Rainier will work with 4x discs, but you probably won't be happy with the speed. I bought some Imation 24x discs. Basically, get the fastest discs your drive will support.
- A fully-functional 2.6.2-rc1 (or higher) Linux kernel. I used 188.8.131.52 when writing this HOWTO. Compiling and installing a new kernel is WAY beyond the scope of this article. This article is a good place to start if you are interested.
- A copy of cdmrw.c from Jens Axboe
- A copy of the source for the udftools. I used 1.0.0b3 for this HOWTO.
Compile the Tools
Compile cdmrw with the command
gcc cdmrw.c -o cdmrw -I/usr/src/linux-184.108.40.206/include
(Editor's note: Thanks go out to Chee Hoong Low for the tip about adding the -I switch). Change the location after the -I to reflect your kernel source and location. Copy cdmrw to your favorite place for root's binaries, like /sbin. That should take no time at all. Untar the udftools and compile and install them. You will need to be root to install them. The standard ./configure;make;make install commands worked great for me.
Format the CD-RW
Mount Rainier drives must format the discs before they can be used. You also need to create a UDF filesystem. The cdmrw program and the udftools will enable you to do both things (note: you will need to be root to use them). I will use the device /dev/hdc in all these examples. That will work if your drive is the master on the second IDE channel. Change it as necessary for your system. First, to format the drive. Place a blank CD-RW in the drive, then use this command:
cdmrw -d /dev/hdc -f full
The formating takes place in the background and is handled by the drive itself. If you add the -p option, the program will periodically poll the drive for the status of the format. Sadly, my drive doesn't seem to support that. Just wait until the drive stops. Either that or you can keep issuing the cdmrw -d /dev/hdc command until it says disc is mrw formatted. Next you need to put a UDF filesystem on the disc. This command will do the trick:
mkudffs --media-type=cdrw /dev/hdc
Once that is done your disc is ready to use!
Use the Disc
I made a mount point for it called /mnt/cdmrw and added this line to my /etc/fstab for it:
/dev/hdc /mnt/cdmrw udf noauto,noatime,user,rw 0 0
I've heard that you have to specify the udf filesystem because the "auto" option has a hard time telling the difference between udf and a regular iso9660 filesystem. The "noatime" option helps eliminate unnecessary writes to the disc. Then any user can mount the disc with the mount /mnt/cdmrw command. I noticed that by default only root can write to the disc. So, as root, I issued these two commands:
chmod 777 .
This gives read/write/execute access to all users. After that, you can copy, move, or erase files to your heart's content. The kernel's CD-ROM driver and the drive itself take care of the rest! You should even be able to read the disc on a Windows or Mac OS box which is using a program to provide Mount Rainier support.