3

I have a Raspberry Pi with Arch Linux and Kodi. I tried to make all config by the new ways of Systemd, that is, by creating Systemd units. For instance, instead of configuring the mount points at boot with the /etc/fstab file, I did it by .mount units.

I made the automounting config with Udisks2 and Polkit.

When I don't unplug the HDD and order the system to reboot, I see that the HDD is mounted in a new directory under /media after every boot. For instance, suppose that before rebooting the HDD was mounted on /media/Untitled. After rebooting it will be (auto)mounted on /media/Untitled1. The next time under /media/Untitled2 and so on. I want it to be mounted always on /media/Untitled.

Maybe, the solution is here, but I don't know.

Edit: I have the following mount units (under /etc/systemd/system directory):

The boot mount unit (boot.mount):

# boot.mount
[Unit]
Description=Boot partition

[Mount]
What=/dev/disk/by-uuid/<BOOT_PART_UUID>
Where=/boot
Type=vfat
Options=defaults

[Install]
WantedBy=multi-user.target

The root (/) mount unit (-.mount):

# -.mount
[Unit]
Description=Root partition

[Mount]
What=/dev/disk/by-uuid/<ROOT_PART_UUID>
Where=/
Type=ext4
Options=noauto,x-systemd.automount

[Install]
WantedBy=multi-user.target

The home mount unit (home.mount):

# home.mount
[Unit]
Description=Home partition

[Mount]
What=/dev/disk/by-uuid/<HOME_PART_UUID>
Where=/home
Type=ext4
Options=noauto,x-systemd.automount

[Install]
WantedBy=multi-user.target

The Polkit rules are (under /etc/polkit-1/rules.d directory):

50-udisks.rules

// 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];
    }
});

(I'm using Udisks2.)

48-shutdown-power-group.rules

// 48-shutdown-power-group.rules
polkit.addRule(function(action, subject) {
    if ((action.id == "org.freedesktop.login1.reboot" ||
        action.id == "org.freedesktop.login1.reboot-multiple-sessions" ||
        action.id == "org.freedesktop.login1.power-off" ||
        action.id == "org.freedesktop.login1.power-off-multiple-sessions" ||
        action.id == "org.freedesktop.login1.suspend" ||
        action.id == "org.freedesktop.login1.suspend-multiple-sessions" ||
        action.id == "org.freedesktop.login1.hibernate" ||
        action.id == "org.freedesktop.login1.hibernate-multiple-sessions") && subject.isInGroup("power"))
    {
        return polkit.Result.YES;
    }
});

The udev rules (under /etc/udev/rules.d directory):

99-udisks2.rules

# 99-udisks2.rules
# 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"
  • Can you add your .mount units and udisks2 config? – Outurnate Sep 30 '17 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.