Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Automount (autofs) External Hard Drive (USB)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
DancesWithWords
Guru
Guru


Joined: 29 Jun 2002
Posts: 343
Location: ottawa, canada

PostPosted: Thu Apr 20, 2017 11:34 pm    Post subject: Automount (autofs) External Hard Drive (USB) Reply with quote

Hi,

I set up my system to do backups including auto-mounting of my external USB
hard drive. I followed these instructions https://workaround.org/rsnapshot-and-usb-drives/

everything worked fine until I unplugged my external hard drive. Now it will
no longer auto-mount.

My auto.usbdrive file has:
usbdrive -fstype=auto UUID=234390d3-1b4c-4b03-8476-XXXXXXXXXXXX

My auto.master file has:
/var/autofs/removable /etc/auto.usbdrive –timeout=2,sync,nodev,nosuid

When I look at /var/log/messages I get:
Apr 20 19:24:38 bbox automount[8038]: �
Apr 20 19:24:38 bbox automount[8038]: �
Apr 20 19:24:38 bbox automount[8038]: �

Now remember this did work. I can mount this drive manually but that does
not suit my purposes.

Can you add some insight or suggestions.


=======
DWW


Last edited by DancesWithWords on Sun Apr 30, 2017 9:40 pm; edited 1 time in total
Back to top
View user's profile Send private message
cboldt
l33t
l33t


Joined: 24 Aug 2005
Posts: 843

PostPosted: Fri Apr 21, 2017 12:03 am    Post subject: Reply with quote

I ended up using uam for automatically mounting usb devices. Sometimes it gets stuck if I have failed to umount a device before turning it off or unplugging it. autofs might similarly get stuck.

I run autofs too, but don't use that for mounting usb drives.
Back to top
View user's profile Send private message
DancesWithWords
Guru
Guru


Joined: 29 Jun 2002
Posts: 343
Location: ottawa, canada

PostPosted: Fri Apr 21, 2017 12:08 am    Post subject: Reply with quote

cboldt wrote:
I ended up using uam for automatically mounting usb devices. Sometimes it gets stuck if I have failed to umount a device before turning it off or unplugging it. autofs might similarly get stuck.

I run autofs too, but don't use that for mounting usb drives.


Thanks for the reply. Hopefully someone out there has a solution.

=====
DWW
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 5878

PostPosted: Fri Apr 21, 2017 8:43 pm    Post subject: Reply with quote

There's a similar bug with sshfs mounts not working (and spewing binary to the log) when ld.gold is in use. Does your `ld -v` mention gold by any chance?
Back to top
View user's profile Send private message
DancesWithWords
Guru
Guru


Joined: 29 Jun 2002
Posts: 343
Location: ottawa, canada

PostPosted: Fri Apr 21, 2017 10:15 pm    Post subject: Reply with quote

Ant P. wrote:
There's a similar bug with sshfs mounts not working (and spewing binary to the log) when ld.gold is in use. Does your `ld -v` mention gold by any chance?


No. Nothing like that.


======
DWW
Back to top
View user's profile Send private message
Logicien
Veteran
Veteran


Joined: 16 Sep 2005
Posts: 1369
Location: Montréal

PostPosted: Fri Apr 21, 2017 11:11 pm    Post subject: Reply with quote

Because the Linux kernel can change the device file name of a Usb hard drive on unplug and plugin again, I would ask Udev to do a symbolic link to the drive according to the ID Vendor and ID Product of the Usb drive. Than you can use the symbolic link with Autofs and not it's Linux device file name.
_________________
Paul
Back to top
View user's profile Send private message
DancesWithWords
Guru
Guru


Joined: 29 Jun 2002
Posts: 343
Location: ottawa, canada

PostPosted: Mon Apr 24, 2017 11:48 pm    Post subject: Reply with quote

Logicien wrote:
Because the Linux kernel can change the device file name of a Usb hard drive on unplug and plugin again, I would ask Udev to do a symbolic link to the drive according to the ID Vendor and ID Product of the Usb drive. Than you can use the symbolic link with Autofs and not it's Linux device file name.


I've seen how to do that some where... Can you give me an example or point me to one?

Thanks for this.


====
DWW
Back to top
View user's profile Send private message
apiaio
Apprentice
Apprentice


Joined: 04 Dec 2008
Posts: 211

PostPosted: Tue Apr 25, 2017 8:58 am    Post subject: Reply with quote

Code:
cat /etc/udev/rules.d/40-usbkey.rules
ACTION=="add", KERNEL=="sdc*", SUBSYSTEM=="block", RUN+="/bin/mount /dev/%k"
ACTION=="remove", KERNEL=="sdc*", SUBSYSTEM=="block", RUN+="/bin/umount /dev/%k"
works for me. I dont use autofs
In the part
Quote:
KERNEL=="sdc*"
you will have to use device which is populated in /dev directory during hotplug.
Back to top
View user's profile Send private message
cboldt
l33t
l33t


Joined: 24 Aug 2005
Posts: 843

PostPosted: Tue Apr 25, 2017 11:10 am    Post subject: Reply with quote

Another "plug" for uam - it is nothing more than some scripts that interact with udev actions in a similar fashion to the simple example shared above. A few differences. uam.conf allows mounting to be done by kernel device name (and there is no need to know, in advance, that e.g., 'sdc' will be the device basename), or filesystem label, or UUID, or device serial number. It also allows ignoring certain devices, ostensibly in case they are handled by a different mechanism.

Granted, uam is not as "simple" as the example, but like the example, is "hooked" to only udev.
Back to top
View user's profile Send private message
apiaio
Apprentice
Apprentice


Joined: 04 Dec 2008
Posts: 211

PostPosted: Tue Apr 25, 2017 6:04 pm    Post subject: Reply with quote

You are right that is "hooked" to only udev, but I have been using it for some seven years on two gentoo PC's and never had got stuck as
mentioned above with autofs or uam. I admit that exists better solution.
Even thought it is only hint for DancesWithWords.
Back to top
View user's profile Send private message
Logicien
Veteran
Veteran


Joined: 16 Sep 2005
Posts: 1369
Location: Montréal

PostPosted: Tue Apr 25, 2017 6:32 pm    Post subject: Reply with quote

This is an example to create a symbolic link of a Usb drive to it's Linux device file name with the Udev file /etc/udev/rules.d/00-persistent-usb-names.rules
Code:
KERNEL=="sd*", ATTRS{serial}=="xxxxxxxxxxxxxxxxxxxxxxxx",                 ATTRS{idVendor}=="xxxx", ATTRS{idProduct}=="xxxx" SYMLINK+="xxx%n"


You can get the serial number, the 4 last hexadecimal digits of the idVendor and the idProduct of your Usb drive using
Code:
lsusb -vvv | less

The name of the symbolic link is at your taste. The drive and the partitions if some will appear in /dev after
Code:
udevadm trigger

or after reboot.
_________________
Paul
Back to top
View user's profile Send private message
DancesWithWords
Guru
Guru


Joined: 29 Jun 2002
Posts: 343
Location: ottawa, canada

PostPosted: Wed May 03, 2017 9:43 pm    Post subject: Reply with quote

UPDATE

So interesting fact. Even though I can not manually get my external USB hard drive to mount via autofs. I've learnt that rsnapshot can mount this drive all on its own using autofs.

How this is working I don't know, but it is a win for me. :lol:

If anyone wants to explain this behaviour please be my guest.


====
DWW
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum