4

I don't understand the --object-path option in the udisksctl command

I want to unmount an USB thumb drive, but I don't want to have to lookup it's device name (for example /dev/sdb) at each mount. The device name can change across mounts. I want a static way to identify the drive, for example by its partition name or UUID. Does the --object-path service this function?

How do I identify what the --object-path is of a USB thumb drive so I can execute a command such as the following with a partition name that is static across mountings: udisksctl unmount --object-path /media/greg/FD-ext4

1 Answer 1

2

I was looking for the answer to the same question, but there isn't a clear answer because the object seems to be the internal D-Bus object that is created by udisksd (see: https://askubuntu.com/a/633045/49873). This is even more annoying when you have multiple disks mounted and you want to unmount one of them.

My workaround to this is to continue to use the --block-device (or -b) option, but by disk label, e.g. my external backup drive has the label xbackup, so I can mount it as:

$ udisksctl mount -b /dev/disk/by-label/xbackup

Note that this can be confusing if you have multiple drives with the same label. I believe in that scenario the first drive attached to the system retains the label as is, and subsequent devices get a numeric suffix, like xbackup1 (unverified, trying to recall from memory).

3
  • How do you label the encrypted partition? If I tried to use e2label, I got "/dev/sda1 contains a crypto_LUKS file system"
    – josircg
    Sep 12, 2021 at 11:56
  • 1
    @josircg I would imagine you need to do that when you setup the encrypted partition (unix.stackexchange.com/a/538622). I don't know if you can do that on existing LUKS partitions though.
    – suvayu
    Sep 13, 2021 at 21:20
  • 1
    +1; I tried /dev/disk/by-uuid/<the actual UUID of the partition to mount> and it works well for me.
    – sudodus
    Nov 12, 2021 at 19:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .