Change external HDD mount behavior
|
23rd Mar, 2016, 12:18 AM
Post: #1
|
|||
|
|||
Change external HDD mount behavior
Whenever an external HDD is removed uncleanly, kodi plots a warning about it. However, xbian keeps the filesystem mounted (although now empty) to /media/<nameofdrive>. When the drive is now reconnected, it gets mounted to /media/<nameofdrive>1, by this mocking up all library links until either all drives are manually unmounted via shell or xbian is rebooted.
Is there a possibility to unmount disconnected partitions automatically? |
|||
23rd Mar, 2016, 12:45 AM
(This post was last modified: 23rd Mar, 2016 12:45 AM by Nachteule.)
Post: #2
|
|||
|
|||
RE: Change external HDD mount behavior
Yes, the magic word is udev
Use this udev rule (I'm using this rule on all my linux boxes, just tested with RPi2, works as expected) Code: # /etc/udev/rules.d/50-my-media-automount.rules Store this to /etc/udev/rules.d/50-my-media-automount.rules and try again |
|||
25th Mar, 2016, 04:23 AM
Post: #3
|
|||
|
|||
RE: Change external HDD mount behavior
Thanks a lot, the part about clean up seems to be exactly what I am looking for.
However, I would prefer just adding this code snippet to the rules already existing, but can't find anything under /etc/udev. Do you know where the OS gets its instructions regarding the disk handling from when there are no specific rules defined? I just want to make sure I am not overriding anything important. |
|||
25th Mar, 2016, 07:35 AM
Post: #4
|
|||
|
|||
RE: Change external HDD mount behavior
Do never modify existing rules, because they may be overwritten during updates
|
|||
25th Mar, 2016, 12:29 PM
Post: #5
|
|||
|
|||
RE: Change external HDD mount behavior
(25th Mar, 2016 07:35 AM)Nachteule Wrote: Do never modify existing rules, because they may be overwritten during updates You are right of course, let me rephrase that: If I just put the lines about cleaning up into that new udev rule, would it still work? And just to know what are the defaults, I would still like to know where they are defined. |
|||
25th Mar, 2016, 11:49 PM
Post: #6
|
|||
|
|||
RE: Change external HDD mount behavior
Quote:If I just put the lines about cleaning up into that new udev rule, would it still work? If mount procedure mounts device to the same folder: YES, of not: NO. But, testing it out is faster than asking here at the forum Quote:I would still like to know where they are defined The 'default' rules are in package udev and are located in /lib/udev/rules.d |
|||
5th Apr, 2016, 12:47 AM
Post: #7
|
|||
|
|||
RE: Change external HDD mount behavior
I'm sorry, it took me a while until I could look into this again.
I had another closer look at the rules /lib/udev/rules.d and discovered the file usbmount.rules: Code: # set spindown Examining mentioned script /usr/share/usbmount/usbmount, especially the "remove" section I found Code: elif [ "$ACTION" = remove];then Shouldn't this already have done the trick? Or does it not affect my hard drives? Where should I be able to find the corresponding log files? |
|||
5th Apr, 2016, 11:41 PM
Post: #8
|
|||
|
|||
RE: Change external HDD mount behavior
Install/enable a system logger (syslog[-ng], rsyslog) and look into /var/log/syslog (I'm using rsyslog)
|
|||
5th Apr, 2016, 11:45 PM
Post: #9
|
|||
|
|||
RE: Change external HDD mount behavior
I don't know what run-parts /etc/usbmount/umount.d does.
Maybe there is missing the option '-l' when umounting drive |
|||
12th Sep, 2016, 11:35 PM
Post: #10
|
|||
|
|||
RE: Change external HDD mount behavior
I'm sorry for reliving this old topic, but after a long break, I looked into this once more and I might have discovered the reason for the inconsistent behavior in the first place:
Apparently, xbian's implementation of usbmount handles all the mounting and unmounting rather well, EXCEPT when there are whitespaces in the device label! (Yeah, I know, whitespaces in Unix, big no no...) Thats because findmnt would return the target value of a device named "device name" as "device\x20name". the read command then takes this as "devicex20name" and saves it as variable mountpoint. Using the -r option here leaves the \, but won't help either eventually, because the moutpoint and umount commands only work with device\ name or "device name". I have tested this with an USB stick whose mount point was deleted properly when the label contained no white spaces but remained as an empty folder when it did. I suppose, the mast straightforward solution would be piping the device name through some text stream tool to reformat the hex into the corresponding shell escape sequence. Maybe there is a newer version of usbmount available? Or is this one customized anyway? |
|||
13th Sep, 2016, 03:25 AM
Post: #11
|
|||
|
|||
RE: Change external HDD mount behavior
(12th Sep, 2016 11:35 PM)daharn Wrote: I have tested this with an USB stick whose mount point was deleted properly when the label contained no white spaces but remained as an empty folder when it did. There is no newer version and it is not configurable A simple solution could be changing line 273 of file /usr/local/sbin/usbmount to Code: findmnt -S "$DEVNAME" -n -o fstype,target -r | sed 's/\\x20/ /g' | sort -k2r \ This changes \x20 to ' ' Tested it here and it works |
|||
13th Sep, 2016, 09:47 AM
Post: #12
|
|||
|
|||
RE: Change external HDD mount behavior
(13th Sep, 2016 03:25 AM)Nachteule Wrote: A simple solution could be changing line 273 of file /usr/local/sbin/usbmount to Yes, something like that was my idea too, thanks for pointing me right to the script in question. However, changing an sbin probably isn't the "cleanest" way of doing this. Wouldn't survive an update, would it? Should I file an issue/request? |
|||
13th Sep, 2016, 07:43 PM
Post: #13
|
|||
|
|||
RE: Change external HDD mount behavior
(13th Sep, 2016 09:47 AM)daharn Wrote: However, changing an sbin probably isn't the "cleanest" way of doing this. Wouldn't survive an update, would it? Should I file an issue/request? For testing it's ok. But you're right, it wouldn't survive update of package. I'll keep it on mind and will change it in sources later |
|||
29th Dec, 2016, 05:20 AM
Post: #14
|
|||
|
|||
RE: Change external HDD mount behavior
(13th Sep, 2016 07:43 PM)Nachteule Wrote:(13th Sep, 2016 09:47 AM)daharn Wrote: However, changing an sbin probably isn't the "cleanest" way of doing this. Wouldn't survive an update, would it? Should I file an issue/request? Done |
|||
« Next Oldest | Next Newest »
|