automount settings

Hello, Usually, when I install new OpenSUSE and make automount of any disk at the pre-installation settings (1), within /mnt dir, all is good (f.e., I have 2 disks and second I mount in /mnt/disc2 at pre-install partition settings).
But when I don’t, my automount doesn’t work even with USB flash drives. (2)
Autofs is installed. All (1) and (2) are same with a clean installation without package changing (Last time I tried it on Leap 15.1 2 times when I changed my SSD).
When I try to mount USB manually, it has only READ permissions (but one time I did it with some trick I forgot now.
And it is not

sudo mount -o remount,rw /partition/identifier /mount/point 

but something maybe like

/dev/sda1 /mnt/usbstick vfat **user**,noauto,noatime,flush 0 0 

I don’t remember and I can’t repeat it now.
Anyway, I think there is a trick of (1) step. Maybe /mnt became special and have other permissions. So, I tried

sudo chown psijic /mnt
sudo chmod 755 /mnt

it helps none.

What is the trick to configure automount properly like it makes step (1)?

Most users would just use the udisks/udev/DE mounting mechanism to detect and auto-mount USB media, but I assume you specifically prefer (or require) traditional root-controlled mounting via a static entry in /etc/fstab?

If you specifically want to use Autofs for “on-demand” mounting, you should read the following reference:
https://doc.opensuse.org/documentation/leap/reference/html/book.opensuse.reference/cha.autofs.html

That requires appropriate configuration of /etc/auto.master (with a reference to auto.foo) and /etc/auto.foo with an appropriate entry as well.

However, for single-user access to USB media the udisks/udev mechanism is preferable IMHO. (Even for installations not using a desktop environment, mount helpers such as udiskie can provide a simple solution for automatic mounting of USB media.)

https://wiki.archlinux.org/index.php/Udisks

for info i found systemd.automount absurdly simply to implement (compared to using autofs directly)

Yes, that’s a good option for “system-level” automounting as well.

Thanks. Actually, I have no preferences except it should be an optimal way. And I think, automount should be available for different users because it’s the right way of a common PC usage.
Now I see, even Krusader’s MountMan can’t see USB devices (but SUSE ImageWriter can).

do you mean something like that?

sudo systemctl SUB_COMMAND autofs

where SUB_COMMAND is one of:
enable - Starts the automounter daemon at boot.

No, systemd.automount…

https://www.freedesktop.org/software/systemd/man/systemd.automount.html

where automount units may either be configured via unit files, or via entries in the /etc/fstab config file

For more info read the manpage…

man systemd.automount

So, for USB flash automounting I need to make a file like that?

/etc/systemd/system/mnt-usb.automount:
[Unit]
Description=USB Flash Drive
What=???
Requires=???
[Automount]
Where=/mnt/usb
TimeoutIdleSec=301
Type=???
Options=rw DirectoryMode=0755

What I need to add? Or it will be 2 files - mount and automount?
And after that I need to run

sudo systemctl daemon-reload

Is it all?

Actually, all you need to do is add a suitable entry in /etc/fstab, and systemd will take care of the “on demand” mounting (creating a systemd unit dynamically at boot).

From ‘man systemd.mount’…

FSTAB

Mount units may either be configured via unit files, or via /etc/fstab (see fstab(5) for details). Mounts listed in /etc/fstab will be converted into native units dynamically at boot and when the configuration of the system manager is reloaded. In general, configuring mount points through /etc/fstab is the preferred approach. See systemd-fstab-generator(8) for details about the conversion.

For example

/dev/sdb1   /mnt/usb     auto     noauto,x-systemd.automount     0 2

However, a unit file can be created manually if desired.

My primary drive is nvme, so I added /dev/sda1 in /etc/fstab and linux mounted EFI catalog with 0 size and no applet pop-up. So, I changed path to /sda and now it looks ok with automounting. I have a KDE applet pop-up, proper files in /mnt/usb and Krusader’s MountMan can see the /dev/sda folder (except it still don’t recognize it as a mounted drive but it’s not a big problem, I think)
Thanks! I can delete /mnt/usb and systemd will autocreate it next time, right?

Hm, I need a root password to unmount the USB drive.
And after that I can’t automount the same drive again.

I can delete /mnt/usb and systemd will autocreate it next time, right?

No, the mount point (directory) needs to exist before the applicable external filesystem can be mounted.

From ‘man 8 mount’…

Non-superuser mounts
Normally, only the superuser can mount filesystems. However, when fstab contains the user option on a line, anybody can mount
the corresponding filesystem.

   Thus, given a line
          /dev/cdrom  /cd  iso9660  ro,user,noauto,unhide
   any user can mount the iso9660 filesystem found on an inserted CDROM using the command:
          mount /cd
   Note that mount is very strict about non-root users and all paths specified on command line are verified before fstab is parsed
   or a helper program is executed. It's strongly recommended to use a valid mountpoint to specify filesystem, otherwise mount may
   fail. For example it's bad idea to use NFS or CIFS source on command line.
   For more details, see fstab(5).  Only the user that mounted a filesystem can unmount it again.  If any user should be  able  to
   unmount  it,  then  use  users  instead  of  user  in the fstab line.  The owner option is similar to the user option, with the
   restriction that the user must be the owner of the special file.  This may be useful e.g. for /dev/fd if a login  script  makes
   the  console  user owner of this device.  The group option is similar, with the restriction that the user must be member of the
   group of the special file.

Does desktop mounting (via udev/udisks2/DE) not work for you? If you remove (or comment out) the fstab entry, then this dynamic mechanism should work in the background instead and allow you to access USB storage media without any additional configuration as I already hinted at back in post #2. Removable-device mounting can be configured in your desktop. For KDE, check out ‘Configure Removable Devices’ in the system tray, or via System Settings > Removable Storage > Removable Devices

hm, I removed the changes in fstab and turned on System Settings > Removable Storage > Removable Devices (2nd and 3rd checkboxes). It doesn’t work now.

Further clarification needed here. Run the following

udisksctl monitor

then attach the USB storage, and observe/capture the output.

udisksctl monitor
Monitoring the udisks daemon. Press Ctrl+C to exit.
**20:28:03.721:** The udisks-daemon is running (name-owner :1.17).
**20:28:11.282:** **Added /org/freedesktop/UDisks2/drives/USB2_2e0_Flash_Disk_100000000000069A**
  **org.freedesktop.UDisks2.Drive:**
    CanPowerOff:                true
    Configuration:              {}
    ConnectionBus:              usb
    Ejectable:                  true
    Id:                         USB2.0-Flash-Disk-100000000000069A
    Media:                       
    MediaAvailable:             true
    MediaChangeDetected:        true
    MediaCompatibility:          
    MediaRemovable:             true
    Model:                      Flash Disk
    Optical:                    false
    OpticalBlank:               false
    OpticalNumAudioTracks:      0
    OpticalNumDataTracks:       0
    OpticalNumSessions:         0
    OpticalNumTracks:           0
    Removable:                  true
    Revision:                   2.50
    RotationRate:               -1
    Seat:                       seat0
    Serial:                     100000000000069A
    SiblingId:                  /sys/devices/pci0000:00/0000:00:01.3/0000:02:00.0/usb1/1-9/1-9:1.0
    Size:                       2121793536
    SortKey:                    01hotplug/1561570091281204
    TimeDetected:               1561570091281204
    TimeMediaDetected:          1561570091281204
    Vendor:                     USB2.0
    WWN:                         
**20:28:11.283:** **Added /org/freedesktop/UDisks2/block_devices/sda**
  **org.freedesktop.UDisks2.Block:**
    Configuration:              ]
    CryptoBackingDevice:        '/'
    Device:                     /dev/sda
    DeviceNumber:               2048
    Drive:                      '/org/freedesktop/UDisks2/drives/USB2_2e0_Flash_Disk_100000000000069A'
    HintAuto:                   true
    HintIconName:                
    HintIgnore:                 false
    HintName:                    
    HintPartitionable:          true
    HintSymbolicIconName:        
    HintSystem:                 false
    Id:                         by-uuid-2016-11-09-10-10-35-00
    IdLabel:                    openSUSE-Leap-42.2-NET-x86_64028
    IdType:                     iso9660
    IdUUID:                     2016-11-09-10-10-35-00
    IdUsage:                    filesystem
    IdVersion:                  Joliet Extension
    MDRaid:                     '/'
    MDRaidMember:               '/'
    PreferredDevice:            /dev/sda
    ReadOnly:                   false
    Size:                       2121793536
    Symlinks:                   /dev/disk/by-id/usb-USB2.0_Flash_Disk_100000000000069A-0:0
                                /dev/disk/by-label/openSUSE-Leap-42.2-NET-x86_64028
                                /dev/disk/by-path/pci-0000:02:00.0-usb-0:9:1.0-scsi-0:0:0:0
                                /dev/disk/by-uuid/2016-11-09-10-10-35-00
  **org.freedesktop.UDisks2.PartitionTable:**
    Type:               dos
**20:28:11.329:** **Added /org/freedesktop/UDisks2/block_devices/sda1**
  **org.freedesktop.UDisks2.Block:**
    Configuration:              ]
    CryptoBackingDevice:        '/'
    Device:                     /dev/sda1
    DeviceNumber:               2049
    Drive:                      '/org/freedesktop/UDisks2/drives/USB2_2e0_Flash_Disk_100000000000069A'
    HintAuto:                   true
    HintIconName:                
    HintIgnore:                 true
    HintName:                    
    HintPartitionable:          true
    HintSymbolicIconName:        
    HintSystem:                 false
    Id:                         by-uuid-1E63-B137
    IdLabel:                    openSUSE-Leap-42.2-NET-x86_64028
    IdType:                     vfat
    IdUUID:                     1E63-B137
    IdUsage:                    filesystem
    IdVersion:                  FAT12
    MDRaid:                     '/'
    MDRaidMember:               '/'
    PreferredDevice:            /dev/sda1
    ReadOnly:                   false
    Size:                       3870720
    Symlinks:                   /dev/disk/by-id/usb-USB2.0_Flash_Disk_100000000000069A-0:0-part1
                                /dev/disk/by-label/openSUSE-Leap-42.2-NET-x86_64028
                                /dev/disk/by-partuuid/5d2e2084-01
                                /dev/disk/by-path/pci-0000:02:00.0-usb-0:9:1.0-scsi-0:0:0:0-part1
                                /dev/disk/by-uuid/1E63-B137
  **org.freedesktop.UDisks2.Filesystem:**
    MountPoints:         
  **org.freedesktop.UDisks2.Partition:**
    Flags:              0
    IsContained:        false
    IsContainer:        false
    Name:                
    Number:             1
    Offset:             143360
    Size:               3870720
    Table:              '/org/freedesktop/UDisks2/block_devices/sda'
    Type:               0xef
    UUID:               5d2e2084-01
**20:28:11.354:** **Added /org/freedesktop/UDisks2/block_devices/sda2**
  **org.freedesktop.UDisks2.Block:**
    Configuration:              ]
    CryptoBackingDevice:        '/'
    Device:                     /dev/sda2
    DeviceNumber:               2050
    Drive:                      '/org/freedesktop/UDisks2/drives/USB2_2e0_Flash_Disk_100000000000069A'
    HintAuto:                   true
    HintIconName:                
    HintIgnore:                 true
    HintName:                    
    HintPartitionable:          true
    HintSymbolicIconName:        
    HintSystem:                 false
    Id:                         by-uuid-2016-11-09-10-10-35-00
    IdLabel:                    openSUSE-Leap-42.2-NET-x86_64028
    IdType:                     iso9660
    IdUUID:                     2016-11-09-10-10-35-00
    IdUsage:                    filesystem
    IdVersion:                  Joliet Extension
    MDRaid:                     '/'
    MDRaidMember:               '/'
    PreferredDevice:            /dev/sda2
    ReadOnly:                   false
    Size:                       95600640
    Symlinks:                   /dev/disk/by-id/usb-USB2.0_Flash_Disk_100000000000069A-0:0-part2
                                /dev/disk/by-label/openSUSE-Leap-42.2-NET-x86_64028
                                /dev/disk/by-partuuid/5d2e2084-02
                                /dev/disk/by-path/pci-0000:02:00.0-usb-0:9:1.0-scsi-0:0:0:0-part2
                                /dev/disk/by-uuid/2016-11-09-10-10-35-00
  **org.freedesktop.UDisks2.Filesystem:**
    MountPoints:         
  **org.freedesktop.UDisks2.Partition:**
    Flags:              128
    IsContained:        false
    IsContainer:        false
    Name:                
    Number:             2
    Offset:             4014080
    Size:               95600640
    Table:              '/org/freedesktop/UDisks2/block_devices/sda'
    Type:               0x17
    UUID:               5d2e2084-02


So the shows that the removable media is enumerated as expected. It should mount ok (as you have configured ‘automatic’ mounting AFAIU). Does your desktop notifier not report it as well? It should also show up in Dolphin’s ‘Removable Devices’ panel.

no, nothing happens.

So, I think, configure panel is not worked properly or I need to manually mount the flash drive first time. Or to use console to configure files manually.

So, it works if you mount manually. For example (assuming sda1)…

udisksctl mount --block-device /dev/sda1

If you can mount the USB device partition(s) successfully via udisksctl then we can examine why your desktop is not automating this process as desired.