You are not logged in.

#1 2007-01-28 01:36:25

billy
Member
From: Slovenia
Registered: 2006-09-13
Posts: 164

(auto)mounting

I would like to know what are the pros and cons of different mounting programs like autofs, hal, thunar-volman and any other similar program.
I currently use autofs but i noticed that if i dont have the same entries in fstab and in autofs configuration file, the double-click on drive icon in xfce returns an error on opening these drives even if they are already automounted. i need to open thunar seperately and "manually" navigate to mount point...it's a little anoying and time consuming. also my files on usb key got messed up (strange letters, files not working) twice in the last month. not to mention read-only access on usb in thunar on a few ocasions. Don't know if this is autofs problem, but I'm considering a change.
I know that thunar-volman can only be used while running X but i don't mind. i don't often access cd or usb data on consoles ( i guess i wouldn't mind typing mount every once in a while if it happens so tongue). But i also heard that hal takes care of mounting removable media. I would like to hear what you people use and what are your opinions on this applications.

Offline

#2 2007-01-28 10:29:29

Romashka
Forum Fellow
Registered: 2005-12-07
Posts: 1,054

Re: (auto)mounting

I used udev+autofs with Xfce 4.2 for correct mounting of different USB storage devices to their mountpoints.
Gnome's automounting sucks. I get errors when unmounting CDs, it doesn't always remove entries in /media, etc., though USB storage devices mount fine.
I haven't tried Xfce's automounting in 4.4 yet, but they claim that it's better than Gnome's and not buggy.

The reason why I used udev+autofs is that it is the only way that allows to unmount USB storage device after some inactivity period (say, 1 minute) - this allows to mount them with -o async and be more sure in safe unmounting at the same time.
With kernel 2.6.19 now there's a special option for this - flush. This eliminates need in autofs, all can be mounted/unmounted with udev only! But mount program seems to not support this option yet, I guess new util-linux version will support this.

Last edited by Romashka (2007-01-28 10:30:00)


to live is to die

Offline

#3 2007-01-28 20:12:19

Stalwart
Member
From: Latvia, Riga
Registered: 2005-10-18
Posts: 445
Website

Re: (auto)mounting

Romashka wrote:

With kernel 2.6.19 now there's a special option for this - flush. This eliminates need in autofs, all can be mounted/unmounted with udev only! But mount program seems to not support this option yet, I guess new util-linux version will support this.

Can you explain? Sounds cool:D


IRC: Stalwart @ FreeNode
Skype ID: thestalwart
WeeChat-devel nightly packages for i686

Offline

#4 2007-01-28 20:45:59

codemac
Member
From: Cliche Tech Place
Registered: 2005-05-13
Posts: 794
Website

Re: (auto)mounting

I've searched around on google some and haven't found more info.  I'd love to be able to actually have udev mounting stuff automatically in a sane way.

Offline

#5 2007-01-28 20:55:53

iggy
Member
From: Germany, L.E. - Leipzig
Registered: 2004-10-17
Posts: 367

Re: (auto)mounting

codemac wrote:

I've searched around on google some and haven't found more info.  I'd love to be able to actually have udev mounting stuff automatically in a sane way.

me too wink


sorry for my bad english smile

Offline

#6 2007-01-29 01:11:19

lanrat
Member
From: Poland
Registered: 2003-10-28
Posts: 1,274

Re: (auto)mounting

A little more info from the changelog:

Filesystems

FAT: Add "-o flush" mount option for fat for removable media devices (USB flash-based memory devices, MP3 players). Mounting with -o flush tells FAT to write things to disk as quickly as possible. It is like -o sync, but much faster (and not as safe). Think of it like a fast "async" mount (commit)

So it seems it's something between sync and async :-) Note that this is only for FAT.

I still use my udev automounting rules with async:

KERNEL=="sd[b-z]", NAME="%k", SYMLINK+="usbhd-%k", GROUP="users", OPTIONS="last_rule"
ACTION=="add", KERNEL=="sd[b-z][0-9]", SYMLINK+="usbhd-%k", GROUP="users", NAME="%k"
ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/mkdir -p /media/usbhd-%k"
ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/ln -s /media/usbhd-%k /mnt/usbhd-%k"
ACTION=="add", KERNEL=="sd[b-z][0-9]", PROGRAM=="/lib/udev/vol_id -t %N", RESULT=="vfat", RUN+="/bin/mount -t vfat -o rw,noauto,async,dirsync,noexec,nodev,noatime,dmask=000,fmask=111 /dev/%k /media/usbhd-%
k", OPTIONS="last_rule"
ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/mount -t auto -o rw,noauto,async,dirsync,noexec,nodev,noatime /dev/%k /media/usbhd-%k", OPTIONS="last_rule"
ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/rm -f /mnt/usbhd-%k"
ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/umount -l /media/usbhd-%k"
ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/rmdir /media/usbhd-%k", OPTIONS="last_rule"

(my sda is a fixed laptop disk) and they seem to work very well.

When I want to unplug a device I just run sync from the console. This gives the best transfer speed and it's 100% error proof.
If you usually only read from a device you can change async to sync and simply unplug the device after copying a file - but this is much slower for recording large files on a device.

I guess simply changing async to flush for the vfat line would work (if/when this option is supported). It's also very easy (;-)) to customize rules for different devices (for example to mount only mp3 player with flush and external hd with async).

Last edited by lanrat (2007-01-29 01:13:20)

Offline

#7 2007-02-06 20:11:21

lanrat
Member
From: Poland
Registered: 2003-10-28
Posts: 1,274

Re: (auto)mounting

I just made some tests with the "flush" option and... it seems to work :-).
I used this command to mount my 2GB pqi usbstick (1 vfat partition):

mount -t vfat -o rw,noauto,flush,dirsync,noexec,nodev,noatime,dmask=000,fmask=111 /dev/sdb1 /mnt/temp

Then I copied some 800 MB file from the disk to the stick using standard mc copy option.
The stick has nice led which blinks when something is transferred from or to the stick so I know if there is any real activity.
The file was copied quite quickly (mc showed ~15MB/sec). So far there was no difference between flush and async.
But after mc showed 100% the led was still blinking and mc was waiting until it stopped blinking. This is a difference.
With async it just finishes with 100% and the led stops blinking. You have to run "sync" command then the led is blinking again for some time and the rest of the file is being written to the stick (if you don't do this you risk data damage).
With the flush option running sync command does nothing.

I'll change my automounting udev rules to these

KERNEL=="sd[b-z]", NAME:="%k", SYMLINK+="usbhd-%k", GROUP:="users", OPTIONS="last_rule"
ACTION=="add", KERNEL=="sd[b-z][0-9]", SYMLINK+="usbhd-%k", GROUP:="users", NAME:="%k"
ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/mkdir -p /media/usbhd-%k"
ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/ln -s /media/usbhd-%k /mnt/usbhd-%k"
ACTION=="add", KERNEL=="sd[b-z][0-9]", PROGRAM=="/lib/udev/vol_id -t %N", RESULT=="vfat", RUN+="/bin/mount -t vfat -o rw,noauto,flush,dirsync,noexec,nodev,noatime,dmask=000,fmask=111 /dev/%k /media/usbhd-%k", OPTIONS="last_rule"
ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/mount -t auto -o rw,noauto,async,dirsync,noexec,nodev,noatime /dev/%k /media/usbhd-%k", OPTIONS="last_rule"
ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/rm -f /mnt/usbhd-%k"
ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/umount -l /media/usbhd-%k"
ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/rmdir /media/usbhd-%k", OPTIONS="last_rule"

(I keep them in /etc/udev/rules/010.udev.rules) and see how it works for more devices.

So far it looks quite cool. You still have fast data transfer and you don't need to do anything, just unplug the stick and it should be safe.

Last edited by lanrat (2007-02-06 20:23:17)

Offline

#8 2007-04-12 23:27:08

kozaki
Member
From: London >. < Paris
Registered: 2005-06-13
Posts: 671
Website

Re: (auto)mounting

Interesting +++
I also experimented the 'flush' option on a 1GB usb stick with success so far.

Now i(ve got a question.
lanrat, AFAIK your udev customised rule takes care of every external usb device you (un)plug. But what about mounting the devices on mount point from its name ?
e.g. all my usb devices have named partitions, therefore /etc/disk/by-label/[name] dev nodes. And they are mounted on corresponding /media/[name] thanks to fstab lines.

Would it be feasable to edit/expand your Udev rule for it to do this, plus automatically (un)mounting the devices ?


Seeded last month: Arch 50 gig, derivatives 1 gig
Desktop @3.3GHz 8 gig RAM, linux-ck
laptop #1 Atom 2 gig RAM, Arch linux stock i686 (6H w/ 6yrs old battery smile) #2: ARM Tegra K1, 4 gig RAM, ChrOS
Atom Z520 2 gig RAM, OMV (Debian 7) kernel 3.16 bpo on SDHC | PGP Key: 0xFF0157D9

Offline

#9 2007-04-13 11:53:33

lanrat
Member
From: Poland
Registered: 2003-10-28
Posts: 1,274

Re: (auto)mounting

I already tried that. It's tempting but there's one problem. You can use label or any other information from /sys when you plug-in your device. But it doesn't work on unplugging event because this information (about label) is already unavailable (the device is already unplugged and sys information is destroyed when action=remove rule starts). Only kernel name for a device is still working at this moment (I mean %k = sdX etc.). If you use any other udev %variable it will return an empty string and it will prevent both proper umounting and directory removal.

I still think it's possible to do it. Only, you need additional external scripts and some kind of a database (a text file should be fine too - BTW these rules currently don't need fstab at all) where you can write label to kernel device name mappings which would be still available to the udev scipt after the device is unplugged.

As I'm a KISS lover (and lazy :-)) I can live with the current naming scheme (usbhd-sda..). I'm using only a few usb devices and usually only one at a time so I don't have good motivation to produce more advanced scripts :-) Besides, that's already a job of more advanced and specialized software.

Offline

Board footer

Powered by FluxBB