I run Ubuntu Mate 22.04 and I have a USB mass storage device (aka USB-Stick) that is formatted with btrfs. I know it's partition UUID and label and I want it specifically to be mounted with specific mount options. In particular I want to enable file system compression every time I plug it into my computer without having to unmount it and then manually remount it with the terminal.
When I plug it in, I would usually have to do
sudo umount /dev/sdb/
sudo mkdir /media/username/label
sudo mount -t btrfs -o rw,ssd,nosuid,nodev,noatime,space_cache=v2,subvolid=5,subvol=/,uhelper=udisks2,compress=zstd:15,discard=async /dev/disk/by-uuid/<uuid> /media/username/label
sudo chown username:usergroup /media/username/label
which I would like to automate somehow.
How do I do that?
Edit
I tried adding this line to my /etc/fstab as suggested in the comments.
UUID=<uuid> /mnt/<label> btrfs rw,ssd,nosuid,nodev,noatime,space_cache=v2,subvolid=5,subvol=/,uhelper=udisks2,compress=zstd:15,discard=async,nofail 0 2
However this causes the device to not auto-mount anymore when I plug it in. When I mount it, I have to be root. Then it doesn't show up in the devices anymore in my file manager (caja). It also is not user writable by default.
I would like the same behavior as plugging it in normally, just with the options
ssd
, because the device in question is somewhat special and announces itself as rotational when it is not),compress=zstd:15
, because the device is very slow anyway and also somewhat small andnoatime
to preserve the flash drive's lifespan
I want it to mount automatically with those settings, but also is user writable and show up in the file manager.