2

When I want to use a USB disk on my desktop, I insert the disk and mount it manually, for example:

mount /dev/sdb1 /mnt/usb

I know that I can specify mount options with -o, such as

mount -o nodev,noexec,nosuid /dev/sdb1 /mnt/usb

But is there a way to set default options for all USB disks? (so that I don't have to type it manually every time)

Martin Vegter
  • 358
  • 75
  • 236
  • 411

1 Answers1

4

In attempting to ascertain whether this is a duplicate of the U&L Q&A asked by @Ramesh I came across this Ask Fedora Q&A titled: udisks default mount options. One of the answer to that Q&A said the following:

excerpt - https://ask.fedoraproject.org/en/question/9957/udisks-default-mount-options/?answer=23126#post-id-23126

I've had a similar discussion in bugzilla. Basically mount options are hard-coded in udisk but if you add a device in fstab, it will mount with the options and at the mount point specified in fstab.

Too bad there is no way to override in udisks2

So it would seem your options are to either setup entries in /etc/fstab for your removable media, or attempt to use udisks, which will make use of it's own unconfigurable default options, or make use of the ones that you'd have to define in /etc/fstab.

slm
  • 369,824
  • using /etc/fstab has two problems: 1) I don't know what filesystem the disk will have (it could be fat or ext4). I am not sure whether i can leave taht out in fstab. 2) I think, I cannot use wildcards in fstab, i.e. /dev/disk/by-path/pci-*-usb* – Martin Vegter Sep 14 '14 at 18:34
  • @MartinVegter - correct you'd have to know these things ahead of time in /etc/fstab. – slm Sep 14 '14 at 19:25
  • @MartinVegter - do you care if the devices are automatically mounted w/ those options when the device becomes present? – slm Sep 14 '14 at 19:33
  • not automatically. I am happy to mount them manually, I just don't want to have to type the long options every time. – Martin Vegter Sep 14 '14 at 19:49
  • @MartinVegter - what about these methods? http://unix.stackexchange.com/questions/134797/how-to-automatically-mount-an-usb-device-on-plugin-time-on-an-already-running-sy/134903#134903 – slm Sep 14 '14 at 20:14
  • the methods are for automount. I don't need automount. – Martin Vegter Sep 14 '14 at 22:22
  • is there any way to change the defaults options. Where are they defined? – Martin Vegter Sep 14 '14 at 22:23
  • @MartinVegter - the methods can be setup to identify the devices but not perform the actual automounts, as in my A. – slm Sep 14 '14 at 23:09
  • is there a way to mount all devices which are not specifically listed in /etc/fstab with options nodev,noexec,nosuid ? i.e. changing the defaults. – Martin Vegter Sep 14 '14 at 23:43