February 11, 2004 Edition

By Jorge Castro (mailto:jorge@whiprush.org), Kyle Rankin (mailto:greenfly@greenfly.org)

 

KDE and OpenOffice.org

Welcome back to another edition of Linux.Ars. We had to take a week off, so you can stop deluging us with all your flames (note: we don't get much fan mail). This week we're going to catch you up to the latest Linux news, and then look at autofs. While desktop utopia (http://arstechnica.com/etc/linux/2003/linux.ars-12242003.html) is close, autofs can help tide you over, and can be used in other flexible ways. So mount yourself in a chair and read on.

 

KDE 3.2 is released

After over a year in development and with 10,000 bugs resolved during that time, kde.org has released (http://www.kde.org/announcements/announce-3.2.php) version 3.2 of their award-winning desktop, KDE. This is the first major release to incorporate improvements from Apple's Safari (http://www.apple.com/safari/) product into KHTML, the browsing component of Konqueror. While the detailed changelog (http://www.kde.org/announcements/changelogs/changelog3_1_5to3_2.php) is deceptively small, the performance improvements alone are impressive.

Pick up the release from download.kde.org (http://download.kde.org/download.php?url=stable/3.2/). Watch the front page of Ars for a more detailed look at KDE (hint hint). KDE fans should also take a peek at the OpenOffice.org KDE Integration Project (http://kde.openoffice.org/).

 

It's getting faster

Speaking of OpenOffice.org, we've been kicking the tires around the latest developer build (http://download.openoffice.org/680/index.html), and our biggest complaint, startup performance, has been dramatically improved. We're still waiting for the aesthetic improvements from Ximian (http://ooo.ximian.com/) to make it upstream, however.

You can scan the timetable (http://development.openoffice.org/releases/OOo_2_0_timetable.html) for the 2.0 release and glean future features, as well as track the progress of the project. Given the recent efforts by KDE and GNOME to integrate with OpenOffice.org, the 2.0 release looks like it could bring some much-needed consistency to the Linux desktop.

 

The 2.6-based distros cometh

The Linux kernel 2.6 has been out for a few months now. While advanced users have been taking the plunge, many people choose to let their distribution integrate the kernel and do all the hard work for them. Those of you that are still being conservative with regards to 2.6 (nothing wrong with that) can check out these web performance benchmarks (http://www-106.ibm.com/developerworks/linux/library/l-web26/index.html?ca=dgr-lnxw07KernelCompare) from IBM to get an idea of improvements. Mandrake Linux 10 (http://www.mandrakelinux.com/en/100beta.php3) is already on its second beta; we expect it to be the first major distribution to ship with 2.6 out of the box. We've been critical (http://arstechnica.com/etc/linux/2003/linux.ars-10302003.html) of Mandrake in the past, but it looks like they have a plan (http://www.mandrakelinux.com/en/pr-releaseprocess.php3) to satisfy those that need to bleed, and those that need stability. Kudos.

The granddaddy of boot-from-CD distributions, Knoppix, is also nearing 2.6. The Knoppix C't Edition (http://knoppix.net/forum/viewtopic.php?t=7985&sid=962de987092a4f7bdbf1de9bd929d2ae) is available, and should give Knoppix fans a hint of what is coming up in the next version. Make sure you read the thread so you can get it to boot into 2.6

The Fedora Core 2 schedule has been updated (http://fedora.redhat.com/participate/schedule/) after a slight delay. Test-1 is due on February 12, so have your torrents standing by. There will be three betas in all. Though disabled for test1, Fedora will be the first major distribution to support SELinux (http://www.nsa.gov/selinux/) out of the box. Those looking for more information on how to get SELinux running on an existing machine can check out SELinux for Distributions (http://selinux.sourceforge.net/) for more information.

Since we're taking a tour of distributions, Debian Sid users can check out the beginnings of UserLinux (http://userlinux.com/cgi-bin/wiki.pl?Installing_UserLinux). Right now it is just a meta-package recommending certain combinations of packages from Debian itself, but the project is off to a good start. There's no shortage of work for Bruce and Co., so consider signing up to the list (http://lists.userlinux.com/cgi-bin/mailman/listinfo/discuss) and lending a hand. Since Gentoo users pick their kernel right on install, there's a comprehensive (http://forums.gentoo.org/viewtopic.php?t=70838) thread on the Gentoo forums on migrating to 2.6.

 

TTT: Tools, Tips and Tweaks

 

Setting up autofs

When trying to figure out the best way to set up my removable USB drive, I stumbled upon autofs. Not only was it an excellent solution for the USB drive I started setting it up to manage other mount points on my system after realizing its potential, and configurability. Autofs allows us to mount filesystems automatically, this includes any mount point, including remote ssh and ftp hosts. Here, I will discuss everything I did to set it up, and how you can use autofs to automate access.

What is it?

Autofs it is a kernel option that lets you automatically mount filesystems to your computer when you access them, and then automatically unmount them when they are no longer used. For some basics, you can read the Quick autofs Tutorial (http://www.linuxhq.com/lg/issue24/nielsen.html). For some more-detailed setup information check out the Autofs HOWTO (http://www.linux-consulting.com/Amd_AutoFS/autofs.html).

Why use it?

To illustrate some of the simple niceties of autofs, here is an example of reading the contents of a CD-ROM, and ejecting it, pre- and post-autofs.

Before autofs:
 
*insert CD into drive
mount /cdrom
*do what you need to do
umount /cdrom
*remove CD from drive
 
With autofs:
 
*insert CD into drive
*do what you need to do
*remove CD from drive

Upon accessing the /cdrom directory, autofs automatically mounted it for me, and when I pressed the eject button (or waited for the timeout) it automatically unmounted it. This is a fairly straightforward example, but it presents a lot of possibilities. For instance, you can set up SMB and NFS mounts that only mount as you access them, then umount later. Or, as in my USB drive example, mount the USB drive only when you access it, then quickly unmount it when you aren't using it, so it will be safe to remove.

Set up

First, install autofs. The autofs how-to linked above covers this; in my case all that was necessary was to make sure autofs support was enabled in my kernel. I then ran apt-get install autofs in Debian, which installs all the necessary files and sets up a default /etc/auto.master file and a few default configurations, auto.net and auto.misc. Those scripts are a good starting point; those and man 5 autofs will clue you into some of the basic configuration you can do. After we have autofs installed, we'll set up local removable drives.

Removable drives

We'll begin by adding a line to our /etc/auto.master file. This file keeps track of where the autofs filesystems will be eventually mounted, along with pointing to the specific configuration file (or script, I'll get to that later) for it to read from, and then a column for any other options you would like to add. Here's the line I added for my removable drives:

/var/autofs/removable   /etc/auto.removable     --timeout=2

This line tells autofs to create a new directory under /var/autofs/removable, to then read from /etc/auto.removable to find out about any mountpoints that might exist under there, and then to timeout (and therefore umount the filesystem) after 2 seconds of idling. The 2-second idling isn't as important for CD-ROMs as it is for USB drives, so if you want your CDROM to have a longer timeout, just create a new configuration file for it, and a new line in auto.master. You may also add extra options to be passed to the mount command in this column, options which will be applied to any mountpoint listed under this directory.

With /etc/auto.master edited, I then created a new autofs configuration file, called auto.removable, and put it in /etc. The file looks like the following:

cdrom   -fstype=iso9660,ro,sync,nodev,nosuid    :/dev/cdrom
floppy          -fstype=auto,sync,nodev,nosuid          :/dev/fd0
USBdrive        -fstype=vfat,uid=1002,gid=1002,umask=002        :/dev/sda1

The first column is the name of the directory mount point I want to use, so these lines would automount their devices when /var/autofs/removable/cdrom, /var/autofs/removable/floppy, and /var/autofs/removable/USBdrive were accessed, respectively. The second column sets up any mounting options you want to use for these individual filesystems, separated by commas. The third column is to list what device you wish to mount. IMPORTANT: if you are not listing an NFS mount, you need to prepend a colon to the beginning of the device, so /dev/cdrom becomes :/dev/cdrom.

Once you create this file, simply restart autofs with /etc/init.d/autofs restart. Note, you only have to restart autofs when you edit /etc/auto.master. You can edit any of the other configuration files on the fly how you like, and won't have to restart autofs for the changes to take effect.

With these settings in place, I put the Fedora Core 1 CD in my CD-ROM, and typed ls:

greenfly@clover:~$ ls /var/autofs/removable/
greenfly@clover:~$ ls /var/autofs/removable/cdrom
Fedora                RPM-GPG-KEY                 TRANS.TBL
GPL                   RPM-GPG-KEY-beta            autorun
README                RPM-GPG-KEY-fedora          dosutils
README-Accessibility  RPM-GPG-KEY-fedora-rawhide  eula.txt
RELEASE-NOTES         RPM-GPG-KEY-fedora-test     images
RELEASE-NOTES.html    RPM-GPG-KEY-rawhide         isolinux
greenfly@clover:~$ ls /var/autofs/removable/
cdrom
greenfly@clover:~$ ls /var/autofs/removable/

Notice that the CD-ROM directory didn't exist in /var/autofs/removable until I actually tried to access it. Then it only existed until it timed out, which, with my configuration, is 2 seconds, and then it unmounted. You can also check /var/log/syslog to watch autofs work:

Jan 27 10:05:41 clover automount[31302]: attempting to mount entry /var/autofs/removable/cdrom 
Jan 27 10:05:41 clover automount[5729]: lookup(file): looking up cdrom 
Jan 27 10:05:41 clover automount[5729]: lookup(file): cdrom -> -fstype=iso9660,ro,sync,nodev,nosuid :/dev/cdrom 
Jan 27 10:05:41 clover automount[5729]: parse(sun): expanded entry: -fstype=iso9660,ro,sync,nodev,nosuid :/dev/cdrom 
Jan 27 10:05:41 clover automount[5729]: parse(sun): dequote("fstype=iso9660,ro,sync,nodev,nosuid") -> fstype=iso9660,ro,sync,nodev,nosuid 
Jan 27 10:05:41 clover automount[5729]: parse(sun): gathered options: fstype=iso9660,ro,sync,nodev,nosuid 
Jan 27 10:05:41 clover automount[5729]: parse(sun): dequote("/dev/cdrom") -> /dev/cdrom 
Jan 27 10:05:41 clover automount[5729]: parse(sun): core of entry: options=fstype=iso9660,ro,sync,nodev,nosuid, loc=/dev/cdrom 
Jan 27 10:05:41 clover automount[5729]: parse(sun): mounting root /var/autofs/removable, mountpoint cdrom, what /dev/cdrom, fstype iso9660, options ro,sync,nodev,nosuid 
Jan 27 10:05:41 clover automount[5729]: do_mount /dev/cdrom /var/autofs/removable/cdrom type iso9660 options ro,sync,nodev,nosuid using module generic 
Jan 27 10:05:41 clover automount[5729]: mount(generic): calling mkdir_path /var/autofs/removable/cdrom 
Jan 27 10:05:41 clover automount[5729]: mount(generic): calling mount -t iso9660 -s -o ro,sync,nodev,nosuid /dev/cdrom /var/autofs/removable/cdrom 
Jan 27 10:05:43 clover kernel: ISO 9660 Extensions: Microsoft Joliet Level 3 
Jan 27 10:05:43 clover kernel: ISO 9660 Extensions: RRIP_1991A 
Jan 27 10:05:43 clover automount[5729]: mount(generic): mounted /dev/cdrom type iso9660 on /var/autofs/removable/cdrom 
Jan 27 10:05:46 clover automount[5747]: running expiration on path /var/autofs/removable/cdrom 
Jan 27 10:05:46 clover automount[5747]: expired /var/autofs/removable/cdrom

I have highlighted a few lines of interest. You can see autofs detect the access of /var/autofs/removable/cdrom, then watch it mount the filesystem, and seconds later, watch it time out and expire the mount point.

 

Beyond local filesystems

Autofs can manage basically any filesystem that you could normally mount by hand. This means you can use it to manage your NFS and ssh mounts. To do this, I added another line to my /etc/auto.master for smb connections:

/var/autofs/smb /etc/auto.smb   --timeout=60

And then created the /etc/auto.smb file:

backup  -fstype=smbfs,username=joey,password=hacktheplanet,uid=1000,gid=1000://gibson/backup
html    -fstype=smbfs,username=joey,password=hacktheplanet,uid=1000,gid=1000://gibson/html
mp3     -fstype=smbfs,guest,uid=1000,gid=1000://gibson/mp3

This file sets up three mount points, /var/autofs/smb/backup, /var/autofs/smb/html, and /var/autofs/smb/mp3, respectively. Notice that I specify the mountpoints with a colon first, and then the normal //servername/share syntax used for smb. With this set up, I then restart autofs, and:

greenfly@clover:~$ ls /var/autofs/smb/
greenfly@clover:~$ ls /var/autofs/smb/backup
010901 rawtext
0211ay.jpg
1.40.2.zip
1.42.3.zip
2003 Web Analysis.xls
...
url_200210.txt
url_200210.xls
url_200211.txt
various_artists
greenfly@clover:~$ ls /var/autofs/smb/      
backup
greenfly@clover:~$ ls /var/autofs/smb/

Again the mountpoint isn't created until I try to access it, then it mounts the smb share, and finally times out a minute later:

 

Jan 27 10:34:36 clover automount[31336]: attempting to mount entry /var/autofs/smb/backup 
Jan 27 10:34:36 clover automount[8930]: lookup(file): looking up backup 
Jan 27 10:34:36 clover automount[8930]: lookup(file): backup -> -fstype=smbfs,username=joey,password=hacktheplanet,uid=1000,gid=1000^I://gibson/backup 
Jan 27 10:34:36 clover automount[8930]: parse(sun): expanded entry: -fstype=smbfs,username=joey,password=hacktheplanet,uid=1000,gid=1000^I://gibson/backup 
Jan 27 10:34:36 clover automount[8930]: parse(sun): dequote("fstype=smbfs,username=joey,password=hacktheplanet,uid=1000,gid=1000") -> fstype=smbfs,username=joey,password=hacktheplanet,uid=1000,gid=1000 
Jan 27 10:34:36 clover automount[8930]: parse(sun): gathered options: fstype=smbfs,username=joey,password=hacktheplanet,uid=1000,gid=1000 
Jan 27 10:34:36 clover automount[8930]: parse(sun): dequote("//gibson/backup") -> //gibson/backup 
Jan 27 10:34:36 clover automount[8930]: parse(sun): core of entry: options=fstype=smbfs,username=joey,password=hacktheplanet,uid=1000,gid=1000, loc=//gibson/backup 
Jan 27 10:34:36 clover automount[8930]: parse(sun): mounting root /var/autofs/smb, mountpoint backup, what //gibson/backup, fstype smbfs, options username=joey,password=hacktheplanet,uid=1000,gid=1000 
Jan 27 10:34:36 clover automount[8930]: do_mount //gibson/backup /var/autofs/smb/backup type smbfs options username=joey,password=hacktheplanet,uid=1000,gid=1000 using module generic 
Jan 27 10:34:36 clover automount[8930]: mount(generic): calling mkdir_path /var/autofs/smb/backup 
Jan 27 10:34:36 clover automount[8930]: mount(generic): calling mount -t smbfs -s -o username=joey,password=hacktheplanet,uid=1000,gid=1000 //gibson/backup /var/autofs/smb/backup 
Jan 27 10:34:37 clover automount[8930]: mount(generic): mounted //gibson/backup type smbfs on /var/autofs/smb/backup 
Jan 27 10:35:44 clover automount[9058]: running expiration on path /var/autofs/smb/backup 
Jan 27 10:35:44 clover automount[9058]: expired /var/autofs/smb/backup

It works in essentially same way that mounting the CD-ROM worked, only with different mount options. If you just want basic autofs mounting to work with your removable devices and network shares, this is really all you need to do. Now, if you want to push the envelope . . .

Dynamic ftp and ssh mounts with autofs and lufs

One of the things that actually inspired me to write the smb browsing script is the similar scripting that the lufs project (http://lufs.sourceforge.net/) has included for autofs. LUFS lets you mount remote ftp and ssh servers as though they were NFS or SMB fileservers on your filesystem. With their autofs tools you can simply browse around your filesystem with strategically-named folders and browse ftp.kernel.org, or even your own ssh or ftp servers.

The setup

Okay, so the first thing to do, is to install and setup lufs on your system. This will vary per distribution, but is straightforward. You will be able to use lufsmount and lufsmount to mount and umount remote ftp and ssh filesystems. Read the manpages for those respective commands for more information on how to run them manually.

Configuring lufs with autofs

Mounting things manually? That's not why we are using autofs! So, how do we get autofs and lufs to work together? It's actually rather easy, and just requires two extra entries in your /etc/auto.master file:

/var/autofs/ssh /usr/bin/auto.sshfs     uid=1000,gid=1000,--timeout=30
/var/autofs/ftp /usr/bin/auto.ftpfs     uid=1000,gid=1000,--timeout=30

Notice I added some extra options to pass along to mount, so that any remote filesystem I mount would have the UID of my current user (if you had multiple users you wanted to have access you could always create a group for them all and then just use the gid= option.) At this point I simply restart autofs and browse to /var/autofs/ftp:

greenfly@clover:~$ ls /var/autofs/ftp
greenfly@clover:~$ ls /var/autofs/ftp/ftp.kernel.org/pub/linux/kernel/v2.6/
ChangeLog-2.6.0           linux-2.6.1.tar.bz2       patch-2.6.0.sign
ChangeLog-2.6.1           linux-2.6.1.tar.bz2.sign  patch-2.6.1.bz2
LATEST-IS-2.6.1           linux-2.6.1.tar.gz        patch-2.6.1.bz2.sign
README-2.6                linux-2.6.1.tar.gz.sign   patch-2.6.1.gz
linux-2.6.0.tar.bz2       linux-2.6.1.tar.sign      patch-2.6.1.gz.sign
linux-2.6.0.tar.bz2.sign  patch-2.6.0.bz2           patch-2.6.1.sign
linux-2.6.0.tar.gz        patch-2.6.0.bz2.sign      pre-releases
linux-2.6.0.tar.gz.sign   patch-2.6.0.gz            snapshots
linux-2.6.0.tar.sign      patch-2.6.0.gz.sign       testing
greenfly@clover:~$ ls /var/autofs/ftp
ftp.kernel.org
greenfly@clover:~$ ls /var/autofs/ftp

Once again, notice that the directory doesn't exist until you actually access it, then autofs creates it. You can treat this like any other mounted network filesystem and copy files to your local system. With the ftp and ssh modules, you can also specify user:pass@foo.com under the /var/autofs/ftp/ directory if you don't want to log in as anonymous.

SSH mounting works basically the same was as ftp, except that everything works best if already have set up passwordless ssh logins with rsa keys for your root user. I just copied over my public root rsa key to any remote ssh server I wanted to connect to, confirmed that I could ssh to the server without requiring a password, and then I could simply browse to /var/autofs/ssh/user@server/ to connect.

One caveat, the LUFS project is still in the experimental stage, so don't be surprised if everything doesn't work exactly as stably as other network filesystems. I have noticed some caching issues when running vim on a file for minutes at a time, with file writes not always going through perfectly. For filesystem copying though, it should work fairly well.

Conclusion

So, at this point I have been using autofs for a bit, and have done a few things to make it easier to manage. For one, the /var/autofs directory structure was getting annoying, so I created symlinks under /mnt to various autofs directories. For instance, you can run something like ln -s /var/autofs/ftp/ftp.kernel.org /mnt/ftp.kernel.org and ftp.kernel.org will only be mounted when you access /mnt/ftp.kernel.org/. This works even though the directory doesn't yet exist under /var/autofs/ftp.

You can use this to create many different symlinks for different ssh or smb accounts. I even ended up deleting my /cdrom directory, and replacing it with a symlink to /var/autofs/removable/cdrom, and created quick access to my arslinux account by ln -s /var/autofs/ssh/greenfly@arslinux.com/home/greenfly /mnt/arslinux. I also created quick access to the kernel and xfs ftp dirs by ln -s /var/autofs/ftp/ftp.kernel.org/pub/linux/kernel /mnt/kernel and ln -s /var/autofs/ftp/oss.sgi.com/projects/xfs /mnt/xfs respectively.

 

Cool app of the Week

Media players have a notorious reputation on every platform. Regardless of established User Interface Guidelines, they seem to go out of their way to disregard such guidelines and shoot for "trendy" skins and user interfaces. Oftentimes the result is a shoddy UI reminiscent of a 1975 Kenwood, complete with wood trim. The Open Source Community has been listening to such criticism (http://www.livejournal.com/users/jwz/123070.html), and today we have plenty of choices when it comes to usable media players.

Two major players dominate the Linux landscape, Mplayer (http://www.mplayer.hu/) and Xine (http://www.xine.org/). For this week we're going to look at a front-end to the Xine libraries, called Totem (http://www.hadess.net/totem.php3). Though Totem is eventually going to use the GStreamer (http://www.gstreamer.net/) framework, users can use the program today with the proven Xine backend.

Before we look at Totem itself, we need to clarify the state of video in Linux. Given the current state of software patent and copyright issues around the world, and specifically in the U.S., Totem has to come crippled out of the box as a media player with most distributions. While it will play Quicktime, Divx, Real Media, Windows Media, DVD Video, VCD, and MP3s; generally speaking it doesn't come that way when it is first installed. Until these issues are straightened out, most U.S. users will have to resort to the "non-U.S." or "non-free" sections of their distributions to get the full Totem experience.

Missing image
Totem.png
Description

A UI we can all appreciate (Run to the hills)

The View menu brings a "Take screenshot" feature that will take a PNG snapshot of the currently playing video. The video controls can be hidden via the menu or by simply hitting "h". Fullscreen support is also supported via "f" or the corresponding menu item. Users with multiple displays will appreciate Totem's ability to fullscreen on an entire monitor without interfering with the other displays. The fullscreen mode itself is unobtrusive, providing a "minimode" set of controls on the bottom left corner of the screen and an "Exit Fullscreen" button on the top right of the screen when the mouse is moved. Users with a scrollwheel can scroll up and down on the video window to fast forward and rewind in real-time, though the jogging is not as smooth as with Mplayer-based players.

Totem can also play audio files. When you cue up your list of MP3s/WAVs/Oggs/WMVs, it provides an OpenGL-accelerated goom visualization while they are playing. Though not a replacement for more capable music players, Totem fits in as a "listen to just one track" player.