You are not logged in.

#1 2020-10-02 05:11:31

altaway
Member
Registered: 2020-06-04
Posts: 15

[solved, kind of] udev, udisks - change the mountpoint's path

By default (on my system), the default mountpoint is /run/media/$USER/<UUID>. I need it to use PARTLABEL (known as PARTNAME in the udev rules) instead of UUID. How can I do this?

Here is my udev rules file.

# 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}="0" \
, SUBSYSTEM=="block", ENV{PARTNAME}!="", ENV{UDISKS_NAME}="$env{PARTNAME}" \
# , GROUP="storage", MODE:="0664"

GROUP and MODE seem to affect the devices and not their mountpoints. Also, I was told that `UDISKS_NAME` changes the mountpoint's name, but that doesn't work. Can you correct the file?

Last edited by altaway (2020-10-23 16:14:56)

Offline

#2 2020-10-02 06:14:39

solskog
Member
Registered: 2020-09-05
Posts: 407

Re: [solved, kind of] udev, udisks - change the mountpoint's path

Pls use code tags

How about SYMLINK ?

SYMLINK+="/run/media/$USER/$env{PARTLABEL}/$env{PARTNAME}"

Last edited by solskog (2020-10-02 06:19:01)

Offline

#3 2020-10-02 06:32:09

Khere
Member
From: Italy
Registered: 2020-03-04
Posts: 168

Re: [solved, kind of] udev, udisks - change the mountpoint's path


Fan of Giorgio Moroder & Mohammad Ammax enemy

Offline

#4 2020-10-02 07:35:10

altaway
Member
Registered: 2020-06-04
Posts: 15

Re: [solved, kind of] udev, udisks - change the mountpoint's path

solskog wrote:

How about SYMLINK ?

  1. The symlink doesn't show up in the location.

  2. I think the symlink points to the device itself and not its mountpoint.

Offline

#5 2020-10-02 14:21:56

seth
Member
Registered: 2012-09-03
Posts: 49,992

Re: [solved, kind of] udev, udisks - change the mountpoint's path

Please start at the beginning.
Afaiu this isn't about the device names but the moutpoints, what raises the question: how do you mount the device itfp?
(Some automount script, fstab entries, gvfs, …)

udisks will already by default mount to /run/media/$USER/PARTNAME, so if that's not the case for you, we need to figure what changes you made or exotic method you use.
Obviously you'll have to reveal if you're not using Archlinux, because nobody can make an informed statement of derivates or eg. ubuntu reg. this behavior.

Last but not least this might be device specific - if there's no partition label (or a weird filesystem?) udisks can obviously not utilize what doesn't exist. So ensure this is not the cause.

Offline

#6 2020-10-03 02:48:34

altaway
Member
Registered: 2020-06-04
Posts: 15

Re: [solved, kind of] udev, udisks - change the mountpoint's path

seth wrote:

how do you mount the device itfp?

Using the command "udisksctl mount -b <device>"

seth wrote:

udisks will already by default mount to /run/media/$USER/PARTNAME..

It uses UUID, not PARTNAME. I don't think using PARTNAME as default is a good idea, because it may not exist for a few partitions.

seth wrote:

Obviously you'll have to reveal if you're not using Archlinux..

I am on archlinux (up to date). I understand the mess that is the incompatibility among distributions when it comes to things like this (kernel rules, version etc).

I am on UEFI if that helps.

Also, all default (udisks + udev + polkit), except a polkit rule that allows the wheel group to mount or unmount devices without asking for password. And a udev rule shown above.

Last edited by altaway (2020-10-03 03:06:05)

Offline

#7 2020-10-03 05:23:20

solskog
Member
Registered: 2020-09-05
Posts: 407

Re: [solved, kind of] udev, udisks - change the mountpoint's path

When I tried with my kingston usb stick with archiso liveUSB. The default mount path is by-label.

$ udevadm monitor --environment --udev
/dev/disk/by-partuuid/2fbbe9fe-01
/dev/disk/by-uuid/2020-09-01-17-37-13-00 
/dev/disk/by-label/ARCH_202009
/dev/disk/by-path/pci-0000:00:14.0-usb-0:1:1.0-scsi-0:0:0:0-part1
...
# udisksctl mount -b /dev/sdc1
Mounted /dev/sdc1 at /run/media/root/ARCH_202009

And when I repartitioned same usb stick without a label, The mountpath is instead by-uuid.

$ udevadm monitor --environment --udev
/dev/disk/by-partuuid/00028ff1-01
/dev/disk/by-uuid/596a81de-a1c8-44a2-9fef-83bd7c0d19fe
/dev/disk/by-path/pci-0000:00:14.0-usb-0:1:1.0-scsi-0:0:0:0-part1
...
# udisksctl mount -b /dev/sdc1
Mounted /dev/sdc1 at /run/media/root/596a81de-a1c8-44a2-9fef-83bd7c0d19fe

Last edited by solskog (2020-10-03 05:45:21)

Offline

#8 2020-10-03 06:10:26

seth
Member
Registered: 2012-09-03
Posts: 49,992

Re: [solved, kind of] udev, udisks - change the mountpoint's path

Yup.

seth wrote:

Last but not least this might be device specific - if there's no partition label (or a weird filesystem?) udisks can obviously not utilize what doesn't exist. So ensure this is not the cause.

Unfortunately the OP didn't address this in his reply.

Offline

#9 2020-10-03 07:24:38

altaway
Member
Registered: 2020-06-04
Posts: 15

Re: [solved, kind of] udev, udisks - change the mountpoint's path

solskog wrote:

When I tried with my kingston usb stick with archiso liveUSB. The default mount path is by-label.
And when I repartitioned same usb stick without a label, The mountpath is instead by-uuid.

Okay, that's interesting. Here's my case.
1. I am using a partition which is part of the internal drive and not  something like a usb stick.
2. udisksctl uses UUID even though PARTLABEL exists.

Offline

#10 2020-10-03 07:30:08

seth
Member
Registered: 2012-09-03
Posts: 49,992

Re: [solved, kind of] udev, udisks - change the mountpoint's path

lsblk -f
cat /etc/fstab

Offline

#11 2020-10-03 07:57:10

altaway
Member
Registered: 2020-06-04
Posts: 15

Re: [solved, kind of] udev, udisks - change the mountpoint's path

lsblk -pf

NAME             FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINT
/dev/nvme0n1
|-/dev/nvme0n1p1 vfat   FAT32       14C0-B491                             508.9M     0% /efi
|-/dev/nvme0n1p2 ext4   1.0         c6277c7a-ea9b-4e1c-ae1b-ce20f66baafc    4.4G    91% /home
|-/dev/nvme0n1p3 swap   1           da88b0da-8315-499b-860b-4b65a3312842                [SWAP]
|-/dev/nvme0n1p4 ext4   1.0         2bd9b6e2-fc8f-4dea-9cb8-6018c7f72059   12.7G    68% /
`-/dev/nvme0n1p5 ext4   1.0         7fec946b-334b-47d5-a35b-b8c2e761ddfb

cgdisk /dev/nvme0n1

Part. #     Size        Partition Type            Partition Name
----------------------------------------------------------------
            1007.0 KiB  free space
   1        512.0 MiB   EFI system partition      EFI System Partition
   2        121.0 GiB   Linux /home               home
   3        5.0 GiB     Linux swap                swap
            512 bytes   free space
   4        50.2 GiB    Linux x86-64 root (/)     archlinux
            201.8 GiB   free space
   5        98.5 GiB    Linux filesystem          virt-pool
            327.5 KiB   free space

cat /etc/fstab

# /dev/nvme0n1p4
UUID=2bd9b6e2-fc8f-4dea-9cb8-6018c7f72059	/         	ext4      	rw,relatime	0 1

# /dev/nvme0n1p1
UUID=14C0-B491      	/efi      	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro	0 2

gparted
gparted.png
The device/partition I was trying to mount - /dev/nvme0n1p5
The mountpoint udisks is giving -  /run/media/$USER/7fec946b-334b-47d5-a35b-b8c2e761ddfb
The mountpoint I needed - /run/media/$USER/virt-pool

Last edited by altaway (2020-10-03 08:07:09)

Offline

#12 2020-10-03 08:03:57

seth
Member
Registered: 2012-09-03
Posts: 49,992

Re: [solved, kind of] udev, udisks - change the mountpoint's path

Label the partition in the FS and see what happens, https://wiki.archlinux.org/index.php/Pe … g#by-label

Offline

#13 2020-10-03 08:15:06

altaway
Member
Registered: 2020-06-04
Posts: 15

Re: [solved, kind of] udev, udisks - change the mountpoint's path

seth wrote:

Label the partition in the FS and see what happens, https://wiki.archlinux.org/index.php/Pe … g#by-label

Thanks, it works now. So label and partlabel are not the same thing. That was the source of confusion. I'll try to see if I can make udisks use partlabel itself using udev's rules.

I just found out that udisks has its own set of rules (seperate from udev). I'll post something if I find it relevant.

Last edited by altaway (2020-10-03 08:19:28)

Offline

#14 2020-10-03 18:27:37

altaway
Member
Registered: 2020-06-04
Posts: 15

Re: [solved, kind of] udev, udisks - change the mountpoint's path

Alright, I went through the documentation a bit thoroughly. udisks has a configuration file at (/etc/udisks2/mount_options.conf). The file has some information (regarding defaults and other things). Also, the options were dependent on the filesystem which was being mounted. I think filesystems like ntfs don't store information like the uid, gid and the mode bits in the inodes. So mount provides special options for the sake of compatibility (default - owner=root,group=root,mode=0777). ext filesystems don't have the need to change this information though mount options because the inodes already have the information. So to change the group and permissions of the mountpoint, you mount the partition first, then change it just like you change it for a directory.  If you are trying to mount an NTFS filesystem instead, you put gid=<GID> in the mount options.

Regarding the path, udisks uses LABEL if it exists and UUID otherwise. I haven't yet found out how to make udisks use PARTLABEL instead.

I am insisting on PARTLABEL because the LABEL is stored in the corresponding partition whereas PARTLABEL is stored in the gpt itself and there are a few cases where it feels less cumbersome to not disturb the partition. For example, if an acquaintance gives you a usb stick, giving it a PARTLABEL doesn't affect the usb stick itself, whereas giving it a LABEL does (the same label is going to show in everyone's systems for the usb stick, partlabel doesn't leave your computer).

At the same time, it doesn't make sense for the gpt to hold the partlabel of a random external usb stick, so I don't really know. Maybe I should stick to LABEL.

Last edited by altaway (2020-10-03 18:37:21)

Offline

#15 2020-10-03 22:10:03

GaKu999
Member
From: US/Eastern
Registered: 2020-06-21
Posts: 696

Re: [solved, kind of] udev, udisks - change the mountpoint's path

altaway wrote:

I am insisting on PARTLABEL because the LABEL is stored in the corresponding partition whereas PARTLABEL is stored in the gpt itself and there are a few cases where it feels less cumbersome to not disturb the partition. For example, if an acquaintance gives you a usb stick, giving it a PARTLABEL doesn't affect the usb stick itself, whereas giving it a LABEL does (the same label is going to show in everyone's systems for the usb stick, partlabel doesn't leave your computer).

Everyone will see the PARTLABEL the same as a LABEL, and in more complex cases live LVM you won't be able to deal with a PARTLABEL at all, or you meant something else?

Example:

...normal
$ blkid /dev/sda2
/dev/sda2: SEC_TYPE="msdos" LABEL_FATBOOT="ESP" LABEL="ESP" UUID="AA91-A2DC" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="ESP" PARTUUID="860eab53-8ff6-ed47-99b9-2d5cd271ba56"
...LVM
$ blkid /dev/sda4
/dev/sda4: UUID="kGlh5b-7rL5-a6IH-BKOp-d3zm-6Q43-kwV347" TYPE="LVM2_member" PARTLABEL="DISTROS" PARTUUID="9bff0e37-647e-454c-86c0-e3284c46c742"
..Inside the LVM
$ blkid /dev/os/archlinux 
/dev/os/archlinux: LABEL="ARCHLINUX" UUID="40d72e0a-da07-4f4d-8883-75ab4687dc0d" BLOCK_SIZE="4096" TYPE="ext4"

PARTLABEL it's better intended to identify a partition itself, but for a filesystem, the label it's a better approach since it gives a "human" identification to the filesystem, aside from the UUID.
Anyways, you are free do follow your own path for this, since it's not written in stone.


My reposSome snippets

Heisenberg might have been here.

Offline

Board footer

Powered by FluxBB