[opensuse] Mount USB HD on plug-in
Hi all. I have 2 external USB HDD's that I use for backup purposes, one of which is used for nightly backups run from cron, the other for ad-hoc backup and general storage use. I have setup udev rules for these drives to create persistent dev symlinks for them and they auto-mount when accessed from dolphin, but I would like them to auto-mount as soon as the system detects that they're plugged in. I know that this used to be possible, and I'm sure it still is; I just don't know which config files I need to create/edit to make it happen under openSuse. Can some kind person please point me in the right direction, either with an example or a link to a web page where I can find the right info? Google hasn't been particularly helpful so far (but maybe I'm just searching for the wrong text). Thanks in advance, -- =================================================== Rodney Baker VK5ZTV rodney.baker@iinet.net.au =================================================== -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Thursday 27 August 2009 09:51:41 Rodney Baker wrote:
Hi all.
I have 2 external USB HDD's that I use for backup purposes, one of which is used for nightly backups run from cron, the other for ad-hoc backup and general storage use.
I have setup udev rules for these drives to create persistent dev symlinks for them and they auto-mount when accessed from dolphin, but I would like them to auto-mount as soon as the system detects that they're plugged in.
I know that this used to be possible, and I'm sure it still is; I just don't know which config files I need to create/edit to make it happen under openSuse.
Can some kind person please point me in the right direction, either with an example or a link to a web page where I can find the right info? Google hasn't been particularly helpful so far (but maybe I'm just searching for the wrong text).
Thanks in advance,
Never mind - found the answer with a custom udev rule and appropriate options in /etc/fstab. They now automount when plugged in and can be unmounted via the device-notifier if necessary. For those interested, here is a new file that I created as /etc/udev/rules.d/98-automount_usb.rules: #run mount -a every time a block device is added/removed. SUBSYSTEM=="block",RUN+="/bin/mount -a" The following rules in /etc/udev/rules.d/ create the symlinks in /dev/ for the 2 USB HDD's: KERNEL=="sd*[0-9]",SYSFS{idVendor}=="152d",SYSFS{idProduct}=="2338",SYMLINK+="backup" KERNEL=="sd*[0-9]",SYSFS{idVendor}=="1058",SYSFS{idProduct}=="1003",SYMLINK+="Elements" Finally, the additional lines in /etc/fstab to specify the mount points: /dev/backup /media/backup ext3 auto,defaults,users 1 2 /dev/Elements /media/Elements ext3 auto,,defaults,users 1 2 The "users" parameter is necessary to allow a user other than the one that mounted the drive (in this case it is either root or udev) to be able to unmount/eject it e.g. to allow safe removal. I hope this helps someone else out - it took a bit of digging to find it but it was worth the effort :-). Cheers, Rodney. -- =================================================== Rodney Baker VK5ZTV rodney.baker@iinet.net.au =================================================== -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Wednesday 26 August 2009 08:13:06 pm Rodney Baker wrote:
Never mind - found the answer with a custom udev rule and appropriate options in /etc/fstab. They now automount when plugged in and can be unmounted via the device-notifier if necessary.
For those interested, here is a new file that I created as /etc/udev/rules.d/98-automount_usb.rules:
#run mount -a every time a block device is added/removed. SUBSYSTEM=="block",RUN+="/bin/mount -a"
The following rules in /etc/udev/rules.d/ create the symlinks in /dev/ for the 2 USB HDD's:
KERNEL=="sd*[0-9]",SYSFS{idVendor}=="152d",SYSFS{idProduct}=="2338",SYMLINK +="backup" KERNEL=="sd*[0-9]",SYSFS{idVendor}=="1058",SYSFS{idProduct}=="1003",SYMLIN K+="Elements"
Finally, the additional lines in /etc/fstab to specify the mount points:
/dev/backup /media/backup ext3 auto,defaults,users 1 2 /dev/Elements /media/Elements ext3 auto,,defaults,users 1 2
The "users" parameter is necessary to allow a user other than the one that mounted the drive (in this case it is either root or udev) to be able to unmount/eject it e.g. to allow safe removal.
Excellent Rodney, I don't know why the usb mounts just "stopped" working, but I have experienced similar problems. I'll give it a try. -- David C. Rankin, J.D.,P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Wed, 2 Sep 2009 17:15:55 David C. Rankin wrote:
On Wednesday 26 August 2009 08:13:06 pm Rodney Baker wrote:
Never mind - found the answer with a custom udev rule and appropriate options in /etc/fstab. They now automount when plugged in and can be unmounted via the device-notifier if necessary.
For those interested, here is a new file that I created as /etc/udev/rules.d/98-automount_usb.rules:
#run mount -a every time a block device is added/removed. SUBSYSTEM=="block",RUN+="/bin/mount -a"
The following rules in /etc/udev/rules.d/ create the symlinks in /dev/ for the 2 USB HDD's:
KERNEL=="sd*[0-9]",SYSFS{idVendor}=="152d",SYSFS{idProduct}=="2338",SYMLI NK +="backup"
KERNEL=="sd*[0-9]",SYSFS{idVendor}=="1058",SYSFS{idProduct}=="1003",SYMLI N K+="Elements"
Finally, the additional lines in /etc/fstab to specify the mount points:
/dev/backup /media/backup ext3 auto,defaults,users 1 2 /dev/Elements /media/Elements ext3 auto,,defaults,users 1 2
The "users" parameter is necessary to allow a user other than the one that mounted the drive (in this case it is either root or udev) to be able to unmount/eject it e.g. to allow safe removal.
Excellent Rodney,
I don't know why the usb mounts just "stopped" working, but I have experienced similar problems. I'll give it a try.
Rereading the quote from my original email I just noticed a couple of things; 1. There is a typo in the second quoted line from /etc/fstab involving an extra comma (but that doesn't prevent it from working). 2. I didn't mention the filename in /etc/udev/rules.d/ nor did I specify where the numeric parameters came from... The 2 lines quoted I put into a new file 59-persistent-storage.rules (but you can name it whatever you like, provided the filename extension is .rules). The numeric parameters you can find from lsusb (with the devices plugged in of course) or via sysfs. There are other parameters you can use in udev rules, as long as you pick something that uniquely identifies each device that you want persistent naming for. This page is useful: http://reactivated.net/udevrules.php Cheers, -- =================================================== Rodney Baker VK5ZTV rodney.baker@iinet.net.au =================================================== -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (2)
-
David C. Rankin
-
Rodney Baker