You are not logged in.
Sure, you can edit /etc/fstab and mkdir a lot of empty dirs just in case some day a device /dev/sdr7 with jfs/zfs/... is attached through USB.
Sure, you can always fire up the CLI to mount a volume using the right parameters.
Sure you can install GNOME / KDE / thunar-volman to have these things done for you.
I am now at a stage where I want to abandon the GUI and try if I can cut it using openbox, a panel (bmpanel or fbpanel), a filemanager (pcmanfm) and some other lightweight apps. Mostly this works very well and VERY fast, but if I connect a dev via USB, an icon shows on the desktop but I cannot click it unless I mount it manually...
So I looked through the wiki, and autofs is given as a possible solution, but shouldn't HAL and udev be able to do these things on their own? Are there good manuals to set them up correctly so that I can have an automatic volume management with the least possible clutter?
Are there even more basic ways to do this without HAL and udev, because these daemons make the bootprocess rather slow... Step by step I'm trying to get to the core of linux so that one day I'm able to have the same knowledge of it as I have now about windows...
THX!
Zl.
Offline
I have 2 entries in fstab (sda and sda1) with permission to user to mount and rw there
mount /media/key
filesystem is vfat cause thats the only type of keys ever plugged in my box but imo auto will work too
In the really rare cases when i need something more I su and mount it manually
You may make scripts like this
/bin/k+
#!/bin/bash
mount /media/key
/bin/k-
#!/bin/bash
umount /media/key
to shorten the commands
You may add them in the panel too
Offline
I'm doing automounting with pure udev and standard mount command (no fstab entries needed). My rules look like this (/etc/udev/rules.d/010.udev.rules - it's important that it runs as the first rule set):
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"
The most important thing is to properly set sd[X-z] in all rules where X is the first nonfixed hard disk. In my laptop where I'm using these rules I have one hd (/dev/sda) so /dev/sdb is the "lowest" available device name for an usb device.
Also these rules can be further reduced because I'm mounting an usb device in /media and symlink it to /mnt for my convenience only. All media/mnt subdirectories are created dynamically and are deleted on unpluging event.
The first mount rule is designed specifically for vfat (fat32) devices only. It uses flush sync method which gives best performance with maximum data security. Unplugging a device without umounting it first is in this case quite safe (just wait until the led stops blinking and simply unpulg it). Umounting is done later (lazy umount to not confuse applications that might have some files/directories still opened). The second mount rule is for all other filesystems (only general options which should be supported by all of them). It's easy to add more rules for your favourite fs types with special options.
Other parameters can be changed too but don't change %k to other udev parameter because it will most probably not work (it's possible to make it work but it needs more scripting and saving device names in some external file and I wanted only pure udev rules). Also, it's possible to add more scripts (like autobackup) - just search the forums for examples.
I don't know it that's exactly what you're looking for but that's just one way of doing it and it's very "bulletproof" IMHO.
Last edited by lanrat (2008-04-12 20:28:53)
Offline
I use just hal. No automounting, but clicking in thunar cleanly mounts and unmounts usb sticks/external hd to /media. From command line 'pmount /dev/sdb1' (or similar, in package pmount) mounts to /media through hal.
I must admit I like lanrat's solution. But since I have hal running anyway...
Offline
I vote that lanrat adds that to the wiki.
Offline
I vote that lanrat adds that to the wiki.
+1 !
The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...
Offline
I think it's already there.
I use thunar-volman. It's a light weight solution that just works *shrug*.
It's convenient having a thunar window pop up when I plug a flash drive in, as i'm normally using a flash drive to transfer files. Then it's just drag drop.
Offline
I use thunar-volman. It's a light weight solution that just works *shrug*.
It's convenient having a thunar window pop up when I plug a flash drive in, as i'm normally using a flash drive to transfer files. Then it's just drag drop.
The same thing but I don't have anything pop up automatically (I have thunar bound to Win-x so I can start it easily when I need it -- it mounts things automatically though). I also use xfce4-volstatus-icon from AUR which gives me an icon in tray when a removable volume is mounted so I can unmount it easily without starting thunar. I also use notification-daemon-xfce for notifications about whether it is safe to remove stuff (in case something is still needs to be written to a usb stick, for example).
Offline
Yes, it's already in the wiki (on the bottom of the page).
My idea was to have automounting simplified as much as possible and make it "bulletproof" (especially against "bad" updates that can break other automounting solutions from time to time). It's also easy to copy it to other computers (you can simply copy rules file, change sdX if needed and restart udev/box and it works without any other settings).
Since it doesn't need anything else to run it's a good solution for servers without running X/dbus/hal too.
There is a modification described somewhere in the forums that is using similar rules to make automatic backup copies once certain usb device is plugged in - an interesting idea.
Offline
I also use notification-daemon-xfce for notifications about whether it is safe to remove stuff (in case something is still needs to be written to a usb stick, for example).
If you're using vfat on an usb stick then (if possible) you should try changing "async"to "flush" (in fstab or other config) and it'll always be safe to unplug the device (nothing is then stored in the cache but the rw performance is still similar to the async method).
Last edited by lanrat (2008-04-14 05:52:20)
Offline
I'm doing automounting with pure udev and standard mount command
That's what I was looking for! No need for X - all auto-mounted volumes available in init 3!
Very clean solution and again some memory saved because one less program to keep monitoring in the background...
Thx!
Zl.
PS: it is indeed in the wiki - don't know how I missed it!
Offline
Very clean solution and again some memory saved because one less program to keep monitoring in the background...
That sounds a bit paranoid
Does it really make *that* much difference? can you feel it? If so, I'm gonna try that out
Have you Syued today?
Free music for free people! | Earthlings
"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery
Offline
zenlord wrote:Very clean solution and again some memory saved because one less program to keep monitoring in the background...
That sounds a bit paranoid
![]()
Does it really make *that* much difference? can you feel it? If so, I'm gonna try that out
Well, I would like to 'get the hang of linux' and to get it I feel I need to understand the base processes, including udev.
It is so much easier installing thunar-volman and pretend to know how it all works, but if it fails once, you'll see it will be the one time you *really* need the data on that USB-stick and people around you are looking at you, going 'so that is linux, huh? ' )
If in that case it is just between you and udev, you firmly type 'killall udev' (or whatever) in console and people stand in awe for your greatness.
Nah, just rambling: I want to learn more about it and let me control my pc...
Zl.
Offline
Well, I would like to 'get the hang of linux' and to get it I feel I need to understand the base processes, including udev.
It is so much easier installing thunar-volman and pretend to know how it all works, but if it fails once, you'll see it will be the one time you *really* need the data on that USB-stick and people around you are looking at you, going 'so that is linux, huh?
' )
If in that case it is just between you and udev, you firmly type 'killall udev' (or whatever) in console and people stand in awe for your greatness.
Nah, just rambling: I want to learn more about it and let me control my pc...
Zl.
How about HAL? you can do "/etc/rc.d/hal restart", and your friends will stand in awe too
Have you Syued today?
Free music for free people! | Earthlings
"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery
Offline
If you're using vfat on an usb stick then (if possible) you should try changing "async"to "flush" (in fstab or other config) and it'll always be safe to unplug the device (nothing is then stored in the cache but the rw performance is still similar to the async method).
What about wear and tear on the flash drive's lifespan, though?
Offline
It shouldn't be different from the normal usage at least if you're simply copying files on the stick. Flush works like async with manual sync command run at the end of copying process. If you're using async you still have to sync before umount so IMHO it's the same.
Perhaps when you are writing and changing many files on the stick before you want to umount it could be some difference. But it's just easier with flush IMHO. After all it was designed for mobile devices.
Offline
Hi lanrat, I'm trying to use your method but no fs gets mounted, only the symlinks in /dev and directories in /mnt are created. No error message whatsoever in the logs. What can be the problem?
Offline
You do have the necessary fs-packages installed?
Offline
I think so, I can mount it manually.
Offline
I've just solved it. As usual, a pretty stupid error. I used nano for writing the rules and it seems that it introduced an end line character in the middle of the long lines (the ones actually doing the mounting) so udev read these lines as two different lines.
Now it works, and it is a really simple way of automounting. Thanks lanrat!
Offline
Cool :-)
BTW line wrapping is sometimes a PITA but nano -w solves it.
Offline
I have two more questions:
- Can the CDs/DVDs mounted in a similar way? I don't think so because AFAIK no new device nodes are created when a CD is inserted.
- Is there any way to tell conky that a new fs has been mounted so it can be shown? I know that there is variable called if_mounted that checks if a given mountpoint is mounted, but if you use it on a non-existing mountpoint (in this case the mountpoint is created by udev only when a new device is plugged-in) it gives an error message. It can be done creating statically the necessary mountpoints, but then the /mnt directory will be full of empty mountpoints.
Thanks again.
Offline
Unless something has changed since I last checked it a CD/DVD can't be mounted this way. Device nodes are created on the module load not when a cd is inserted. Also it would rather work with "ACTION" attribute I guess (something like ACTION==insert/eject).
Some time ago I was using this tiny utility to automount cdroms. IIRC I had to change "umount" to "eject" in the sources and it worked but it's quite old and not developed anymore.
The second question is interesting but I have no idea how to do that :-) I was using conky a long time ago and I don't know if there is a way to do something similar with the newest version. I guess you could try changing conky config file and reloading it from udev (as another udev rule). But this would require some assumptions (like which user/display to use) and/or more coding. However in theory at least it could be done, I think.
edit: Also if conky can run scripts inside configuration you could try to generate if_mounted commands for the whole collection of /dev/usbhd* or something like this.
Last edited by lanrat (2008-05-26 00:00:55)
Offline
For cd's / dvd's I use an 'auto-fs-line' in fstab. It does the job without any clutter and without the need for extra programs.
Sometimes I have to umount before I can eject though - I think I need to do it with movie DVD's, not with CDROM's.
Zl.
Offline
Well, finally I've switched to the Dark Side, i.e. the easy way. I'm using hal, thunar and thunar-volman. But thanks anyway lanrat, I've learned a bit about udev rules trying your way.
Offline