[arch-general] umount usb stick via udev
Dear arch users, I managed to mount my usb stick automatically via udev rules (hal isn't running). However, if I unplug the stick while thunar is open, the umount command hangs. After that I can't even reboot. But if I close thunar before unplugging the stick umount works fine. Here is my udev rule: SUBSYSTEMS=="usb", ATTRS{serial}=="07A10809D5B952B9", KERNEL=="sd*", SYMLINK+="unistick%n" SUBSYSTEMS=="usb", ATTRS{serial}=="07A10809D5B952B9", KERNEL=="sd*", ACTION=="add", RUN+="/usr/bin/sudo -u benjamin /bin/mount /media/unistick" SUBSYSTEMS=="usb", ATTRS{serial}=="07A10809D5B952B9", KERNEL=="sd*", ACTION=="remove", RUN+="umount /media/unistick" And here is the corresponding line of fstab: /dev/unistick1 /media/unistick vfat rw,noauto,user,utf8,noatime 0 0 Thanks for any help, Benjamin
Am 07.10.2010 17:18, schrieb Benjamin Sambale:
I managed to mount my usb stick automatically via udev rules (hal isn't running). However, if I unplug the stick while thunar is open, the umount command hangs. After that I can't even reboot. But if I close thunar before unplugging the stick umount works fine.
Automatic umounting is neither intended nor safe. The reason is obvious: To guarantee data consistency and proper functionality of the operating system, the file system has to be removed _before_ the underlying device is. This obviously cannot happen automatically.
Am 07.10.2010 17:32, schrieb Thomas Bächler:
Am 07.10.2010 17:18, schrieb Benjamin Sambale:
I managed to mount my usb stick automatically via udev rules (hal isn't running). However, if I unplug the stick while thunar is open, the umount command hangs. After that I can't even reboot. But if I close thunar before unplugging the stick umount works fine. Automatic umounting is neither intended nor safe. The reason is obvious: To guarantee data consistency and proper functionality of the operating system, the file system has to be removed _before_ the underlying device is. This obviously cannot happen automatically.
Thanks for the reply. I know that unplugging the stick before umounting is kind of "unsafe". However, I never had problems with this and of course I do not unplug while files are get written. By the way the udev page on archwiki also suggests umounting in a udev rule. Finally, as I wrote before everything works if I close thunar before. And using hal it works in all cases anyway. So, I'm still grateful for further hints.
Hi Benjamin, Excerpts from Benjamin Sambale's message of Thu, 07 Oct 2010 19:08 +0200:
Am 07.10.2010 17:32, schrieb Thomas Bächler:
I managed to mount my usb stick automatically via udev rules (hal isn't running). However, if I unplug the stick while thunar is open, the umount command hangs. After that I can't even reboot. But if I close thunar before unplugging the stick umount works fine. Automatic umounting is neither intended nor safe. The reason is obvious: To guarantee data consistency and proper functionality of
Am 07.10.2010 17:18, schrieb Benjamin Sambale: the operating system, the file system has to be removed _before_ the underlying device is. This obviously cannot happen automatically.
Thanks for the reply. I know that unplugging the stick before umounting is kind of "unsafe". However, I never had problems with this and of course I do not unplug while files are get written. By the way the udev page on archwiki also suggests umounting in a udev rule. Finally, as I wrote before everything works if I close thunar before. And using hal it works in all cases anyway. So, I'm still grateful for further hints.
Thunar depends on HAL, so probably it is not correct to use it without HAL, and the following is from http://thunar.xfce.org "Use the correct HAL property to determine whether a given volume or device requires eject" Cheers, Sergey
On Thu, 2010-10-07 at 12:00 -0600, Sergey Manucharian wrote:
Thunar depends on HAL, so probably it is not correct to use it without HAL, and the following is from http://thunar.xfce.org "Use the correct HAL property to determine whether a given volume or device requires eject"
It can be used without hal, but not in the way that you can unplug a device without unmounting it. There's some technological difference between unplugging with and without hal. With hal: - device mounted - thunar open - device ejected without unmount - hal receives uevents and knows the device is dead - hal tells thunar that device is dead - thunar (and other hal or udisks-enabled programs) tries to close all references to the mountpoint - hal unmounts the dead device Now if you do that without hal, the point where hal detects that the device is dead and thunar getting to know that has to be done by yourself. If you forget that, you're screwed.
On 17:18 Thu 07 Oct , Benjamin Sambale wrote:
Dear arch users,
I managed to mount my usb stick automatically via udev rules (hal isn't running). However, if I unplug the stick while thunar is open, the umount command hangs. After that I can't even reboot. But if I close thunar before unplugging the stick umount works fine. Here is my udev rule:
SUBSYSTEMS=="usb", ATTRS{serial}=="07A10809D5B952B9", KERNEL=="sd*", SYMLINK+="unistick%n" SUBSYSTEMS=="usb", ATTRS{serial}=="07A10809D5B952B9", KERNEL=="sd*", ACTION=="add", RUN+="/usr/bin/sudo -u benjamin /bin/mount /media/unistick" SUBSYSTEMS=="usb", ATTRS{serial}=="07A10809D5B952B9", KERNEL=="sd*", ACTION=="remove", RUN+="umount /media/unistick"
And here is the corresponding line of fstab:
/dev/unistick1 /media/unistick vfat rw,noauto,user,utf8,noatime 0 0
Thanks for any help, Benjamin
use -l(lazy) option to umount --
On Thu, Oct 7, 2010 at 10:18 AM, Benjamin Sambale <bsambale@gmx.de> wrote:
Dear arch users,
I managed to mount my usb stick automatically via udev rules (hal isn't running). However, if > I unplug the stick while thunar is open, the umount command hangs. After that I can't even reboot. But if I close thunar before unplugging the stick umount works fine. Here is my udev rule:
SUBSYSTEMS=="usb", ATTRS{serial}=="07A10809D5B952B9", KERNEL=="sd*", SYMLINK+="unistick%n" SUBSYSTEMS=="usb", ATTRS{serial}=="07A10809D5B952B9", KERNEL=="sd*", ACTION=="add", RUN+="/usr/bin/sudo -u benjamin /bin/mount /media/unistick" SUBSYSTEMS=="usb", ATTRS{serial}=="07A10809D5B952B9", KERNEL=="sd*", ACTION=="remove", RUN+="umount /media/unistick"
And here is the corresponding line of fstab:
/dev/unistick1 /media/unistick vfat rw,noauto,user,utf8,noatime 0 0
Thanks for any help, Benjamin
you could maybe look into autofs, since it can automatically unmount the device after a period of inactivity, and automatically remount when activity starts again. C Anthony
participants (6)
-
Benjamin Sambale
-
C Anthony Risinger
-
Fess
-
Jan de Groot
-
Sergey Manucharian
-
Thomas Bächler