You are not logged in.

#1 2015-05-30 04:06:04

gnox
Member
Registered: 2013-05-18
Posts: 91

Reboot changes mounted USB ext.drive directory to root owner

Hi,

I configured Arch with udisks2 to automount USB's when I plugged them in and to be mounted as shared, according to wiki :

/etc/udev/rules.d/99-udisks2.conf

# UDISKS_FILESYSTEM_SHARED
# ==1: mount filesystem to a shared directory (/media/VolumeName)
# ==0: mount filesystem to a private directory (/run/media/$USER/VolumeName)
# See udisks(8)
ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{UDISKS_FILESYSTEM_SHARED}="1"

/etc/polkit-1/rules.d/50-udisks.rules

polkit.addRule(function(action, subject) {
  var YES = polkit.Result.YES;
  var permission = {
    // only required for udisks1:
    "org.freedesktop.udisks.filesystem-mount": YES,
    "org.freedesktop.udisks.filesystem-mount-system-internal": YES,
    "org.freedesktop.udisks.luks-unlock": YES,
    "org.freedesktop.udisks.drive-eject": YES,
    "org.freedesktop.udisks.drive-detach": YES,
    // only required for udisks2:
    "org.freedesktop.udisks2.filesystem-mount": YES,
    "org.freedesktop.udisks2.filesystem-mount-system": YES,
    "org.freedesktop.udisks2.encrypted-unlock": YES,
    "org.freedesktop.udisks2.eject-media": YES,
    "org.freedesktop.udisks2.power-off-drive": YES,
    // required for udisks2 if using udiskie from another seat (e.g. systemd):
    "org.freedesktop.udisks2.filesystem-mount-other-seat": YES,
    "org.freedesktop.udisks2.encrypted-unlock-other-seat": YES,
    "org.freedesktop.udisks2.eject-media-other-seat": YES,
    "org.freedesktop.udisks2.power-off-drive-other-seat": YES
  };
  if (subject.isInGroup("storage")) {
    return permission[action.id];
  }
});

When I connect a USB ext.drive, it is mounted to /media/<Label USB> in this case "Hitachi", with my user as owner, how it is supposed to work, I can access read/delete etc everything ok at this part.

➜  /media  ls -lrth
total 8.0K
drwxrwxrwx 6 gnox   gnox   4.0K May 29 15:28 Hitachi

But if I reboot the machine with the drive mounted  the directory appears now as root owner, and the USB is mapped to a new directory <Label>1 with the correct owner or is not recognized at all, I assume because it cannot use the one that is with root permissions.

[root@arch media]# ls -lrth
total 8.0K
drwxrwxrwx 6 gnox   gnox   4.0K May 29 15:28 Hitachi1
drwx------ 2 root root 4.0K May 29 21:57 Hitachi

I can't find what could be the cause, Looks like is doing a clean unmount at reboot, journalctl shows this :

May 29 21:57:35 arch systemd[1]: Unmounting /media/Hitachi...
May 29 21:57:35 arch systemd[1]: Unmounted /media/Hitachi.

This is when I plug again the usb when is not recognized

May 29 21:58:10 arch udisksd[659]: udisks daemon version 2.1.5 starting
May 29 21:58:10 arch udisksd[659]: Acquired the name org.freedesktop.UDisks2 on the system message bus
May 29 21:58:10 arch dbus[476]: [system] Activating via systemd: service name='org.freedesktop.UDisks2' unit='udisks2.service'
May 29 22:04:07 arch udisksd[659]: Mounted /dev/sdb1 at /media/Hitachi1 on behalf of uid 1000

But then at start either is not recognized the USB or is mounted in a new folder, I cant figure out in what moment is changed to root the original directory or why it didnt was removed as the unmount does,  any ideas what else can I check?? ..

The USB is formatted as ext3 and I changed the owner to my local user (gnox/gnox) after the format.

These are my services

# systemctl -t service
UNIT                                                LOAD   ACTIVE SUB     DESCRIPTION
avahi-daemon.service                                loaded active running Avahi mDNS/DNS-SD Stack
bumblebeed.service                                  loaded active running Bumblebee C Daemon
dbus.service                                        loaded active running D-Bus System Message Bus
geoclue.service                                     loaded active running Location Lookup Service
kmod-static-nodes.service                           loaded active exited  Create list of required static device nodes for the curren
ntpd.service                                        loaded active running Network Time Service
polkit.service                                      loaded active running Authorization Manager
razerd.service                                      loaded active running Razer device state daemon
rtkit-daemon.service                                loaded active running RealtimeKit Scheduling Policy Service
sddm.service                                        loaded active running Simple Desktop Display Manager
systemd-backlight@backlight:intel_backlight.service loaded active exited  Load/Save Screen Backlight Brightness of backlight:intel_b
systemd-binfmt.service                              loaded active exited  Set Up Additional Binary Formats
systemd-journal-flush.service                       loaded active exited  Flush Journal to Persistent Storage
systemd-journald.service                            loaded active running Journal Service
systemd-logind.service                              loaded active running Login Service
systemd-modules-load.service                        loaded active exited  Load Kernel Modules
systemd-random-seed.service                         loaded active exited  Load/Save Random Seed
systemd-readahead-collect.service                   loaded active exited  Collect Read-Ahead Data
systemd-readahead-replay.service                    loaded active exited  Replay Read-Ahead Data
systemd-remount-fs.service                          loaded active exited  Remount Root and Kernel File Systems
systemd-rfkill@rfkill0.service                      loaded active exited  Load/Save RF Kill Switch Status of rfkill0
systemd-rfkill@rfkill1.service                      loaded active exited  Load/Save RF Kill Switch Status of rfkill1
systemd-rfkill@rfkill2.service                      loaded active exited  Load/Save RF Kill Switch Status of rfkill2
systemd-sysctl.service                              loaded active exited  Apply Kernel Variables
systemd-tmpfiles-setup-dev.service                  loaded active exited  Create Static Device Nodes in /dev
systemd-tmpfiles-setup.service                      loaded active exited  Create Volatile Files and Directories
systemd-udev-trigger.service                        loaded active exited  udev Coldplug all Devices
systemd-udevd.service                               loaded active running udev Kernel Device Manager
systemd-update-utmp.service                         loaded active exited  Update UTMP about System Boot/Shutdown
systemd-user-sessions.service                       loaded active exited  Permit User Sessions
systemd-vconsole-setup.service                      loaded active exited  Setup Virtual Console
thermald.service                                    loaded active running Thermal Daemon Service
udisks2.service                                     loaded active running Disk Manager
unbound.service                                     loaded active running Unbound DNS Resolver
upower.service                                      loaded active running Daemon for power management
user@1000.service                                   loaded active running User Manager for UID 1000
user@996.service                                    loaded active running User Manager for UID 996
wicd.service                                        loaded active running Wicd a wireless and wired network manager for Linux
wpa_supplicant.service                              loaded active running WPA supplicant

Offline

#2 2015-09-19 20:52:43

stellarpower
Member
Registered: 2015-09-19
Posts: 1

Re: Reboot changes mounted USB ext.drive directory to root owner

Can confirm the same here. I can unmount and remount the drive and the folder disappears correctly when unmounting. However on rebooting, the old folder remains. https://discourse.osmc.tv/t/directories … dia/1362/4 seems to suggest that /media should be completely wiped at poweroff, however as you mention it may be a problem with unclean unmounting at poweroff. For now I shall be searching to add a shutdown hook to unmount everything in /media correctly.

Offline

Board footer

Powered by FluxBB