Automomount luks partition with nautilus and special btrfs mount options

I am experimenting with an external usb drive + luks + btrfs filesystem. When I plug this drive into the computer nautilus prompts we for the password and the btrfs filesystem is mounted underneath /run/media/ . That works fine.

But how can I add special btrfs mount options to this process? e.g. compress=zstd:10 ?

Try to run

$ sudo cryptsetup open --type luks /dev/[YOUR_USB_DEVICE] luks-usb
$ sudo mount -t btrfs -o rw,noatime,compress=zstd:10 /dev/mapper/luks-usb /mnt/
$ cd /mnt/

I think the question is “How do I get gnome to automount it with my preferred options?”

Not, “How do I manually mount my external drive every time I connect it?”


Have you tried this?

I solved it with an udev rule.

udisk2 is responsible for mounting usb devices when they are plugged in. It is possible to set mount default options for udisk2 in /etc/udisks2/mount_options.conf. But this is too generic for me. If I set btrfs_defaults on udisk2 level, it will be the default for ALL usb disks with a btrfs filesystem. I am not sure if I want that.

So now I am doing it with a udev rule which is specific to this one usb drive:

ENV{ID_FS_UUID}==“6e08254d-634c-4496-98a8-e248b515fd23”, \

I put this in /etc/udev/rules.d/my-usb-btrfs.rules
and it works

The documentation that helped me:


This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.

I try to reply it, but this topic was closed.

I found that btrfs supports the compression in its properties. (Linux 5.17 or newer)

Check the properties of btrfs:

$ btrfs property get <Your USB path> 

If it shows no compression by default, you can set it to zstd:10

$ btrfs property set <Your USB path>  compression zstd:10

The document: