1

I have a number of disk partitions, which are represented by icons in the GUI. Something like this:

Media-icon

When I double-click on this icon, the partition got mounted. Or I can right-click on this icon and get a three-line menu with operations Open/Mount Volume/Properties.

My questions - where can I find an actual command line text, which is executed during this operation? Can I modify/adjust this line for my needs?

Raffa
  • 32,237
HEKTO
  • 555
  • 1
  • 8
  • 24

1 Answers1

1

Where can I find an actual command line text, which is executed during this operation?

What you want should look like this:

udisksctl mount -b /dev/sdxy

Can I modify/adjust this line for my needs?

Yes, see man udisksctl.

Notice on Ubuntu, this is handled by udisks and usually tracked/managed by gvfsd.

However modifying the default behavior of those daemons/services is not recommended and you should, instead, consider using udisksctl as a command in your custom script/shortcut for mounting/unmounting filesystems actions or adding udev rules for actions other than mounting/unmounting filesystems.

That said, ...

What do you want to achieve?

Is it, for example, to set read-only ro mount option as the default for "all" automatically mounted media? ...

Refer to /etc/udisks2/mount_options.conf.example and create/edit /etc/udisks2/mount_options.conf to look like this:

[defaults]
# # common options, applied to any filesystem, always merged with specific filesystem type options
defaults=ro
allow=exec,noexec,nodev,nosuid,atime,noatime,nodiratime,ro,rw,sync,dirsync,noload
... or is it, for example, to set read-only ro mount option as the default for "a specific" automatically mounted media/disk/partition? ...

Hove a look at /dev/disk/by-* in order to identify your target media/disk/partition device and use that as follows ...

Refer to /etc/udisks2/mount_options.conf.example and create/edit /etc/udisks2/mount_options.conf to look like this:

[/dev/disk/by-partuuid/30ea9e87-01]
# # Options, applied to a specific partition by partition uuid
defaults=ro
allow=exec,noexec,nodev,nosuid,atime,noatime,nodiratime,ro,rw,sync,dirsync,noload
... or do you prefer "a more portable, independent and powerful" media/disk/partition mounting/unmounting way? ...

See Different behaviour of bash script in udev

Raffa
  • 32,237
  • Thank you! So, where exactly should I add mounting options, for example - ro? – HEKTO Jan 12 '24 at 00:09
  • @HEKTO You're welcome ... That would be udisksctl mount -o ro -b /dev/sdxy – Raffa Jan 12 '24 at 11:18
  • I meant - in what configuration file should I add this option? The only UDisks config file I've found on my box is /etc/udisks2/mount_options.conf. Is it the correct one? – HEKTO Jan 12 '24 at 22:50
  • 1
    @HEKTO Please, see the edit ... This is beginning to look more like an XY problem :-) – Raffa Jan 13 '24 at 10:18
  • No, the ro option is not X for me, it's just an example... I asked about how the mounting works and how to configure it - in case I double-click an icon in GUI. I had no idea about udisks... Anyway, your answer became very useful, and I'm accepting it – HEKTO Jan 13 '24 at 19:02