storaged-project / udisks

The UDisks project provides a daemon, tools and libraries to access and manipulate disks, storage devices and technologies.
http://storaged.org/doc/udisks2-api/latest/
Other
339 stars 142 forks source link

[Request] How do I mount multiple partitions in external disk #1301

Open clustor opened 1 month ago

clustor commented 1 month ago

When I insert a USB drive that has VFAT and EXT4 partitions in Ubuntu, I always see only the first partition mounted. I added a 'udev' rule to mount second partition with SUBSYSTEM=="block" ACTION=="add", KERNEL=="sda5", ENV{ID_FS_LABEL}=="Backup-Linux", RUN+="/usr/bin/udisksctl mount -b /dev/%k" but it fails with exit code 1.

I would like to mount both VFAT and EXT4 partitions. It's not clear to me how selects that first partition be mounted. Any help will be appreciated?

vojtechtrefny commented 1 month ago

udisks itself doesn't automount devices, it just tells your DE there is a new devices detected and it then tells udisks to mount them so whether a device will be mounted depends on your DE configuration (for example in KDE this is configurable in Disks & Cameras → Device Auto-Mount).

It is possible that we don't correctly inform about all devices, check udisksctl info -b /dev/sda5, especially whether HintSystem and HintIgnore are set to false.

I added a 'udev' rule to mount second partition

udev runs in a separate namespace and manually running mount (or udisksctl) doesn't work from udev rules.

tbzatek commented 1 month ago

The correct way is to set udev attributes UDISKS_AUTO, UDISKS_IGNORE and UDISKS_SYSTEM (depending on what you're trying to achieve) - see man udisks(8).