Change external HDD mount behavior - Printable Version +- Forum (http://forum.xbian.org) +-- Forum: Hardware (/forum-7.html) +--- Forum: Peripherals (/forum-27.html) +--- Thread: Change external HDD mount behavior (/thread-3456.html) |
Change external HDD mount behavior - daharn - 23rd Mar, 2016 12:18 AM 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? RE: Change external HDD mount behavior - Nachteule - 23rd Mar, 2016 12:45 AM 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 RE: Change external HDD mount behavior - daharn - 25th Mar, 2016 04:23 AM 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. RE: Change external HDD mount behavior - Nachteule - 25th Mar, 2016 07:35 AM Do never modify existing rules, because they may be overwritten during updates RE: Change external HDD mount behavior - daharn - 25th Mar, 2016 12:29 PM (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. RE: Change external HDD mount behavior - Nachteule - 25th Mar, 2016 11:49 PM 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 RE: Change external HDD mount behavior - daharn - 5th Apr, 2016 12:47 AM 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? RE: Change external HDD mount behavior - Nachteule - 5th Apr, 2016 11:41 PM Install/enable a system logger (syslog[-ng], rsyslog) and look into /var/log/syslog (I'm using rsyslog) RE: Change external HDD mount behavior - Nachteule - 5th Apr, 2016 11:45 PM I don't know what run-parts /etc/usbmount/umount.d does. Maybe there is missing the option '-l' when umounting drive RE: Change external HDD mount behavior - daharn - 12th Sep, 2016 11:35 PM 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? RE: Change external HDD mount behavior - Nachteule - 13th Sep, 2016 03:25 AM (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 RE: Change external HDD mount behavior - daharn - 13th Sep, 2016 09:47 AM (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? RE: Change external HDD mount behavior - Nachteule - 13th Sep, 2016 07:43 PM (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 RE: Change external HDD mount behavior - Nachteule - 29th Dec, 2016 05:20 AM (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 |