Xfce Forum

Sub domains
 

You are not logged in.

#1 2021-02-16 16:36:35

jody
Member
Registered: 2015-01-26
Posts: 9

[SOLVED] Strange automount behaviour

Hi
I have a computer with a SSD drive (/dev/sda) and a secondary data disk (/dev/sdb)

When i plug in a USB stick, a directory /mnt/usb1 is created and the stick is mounted there. When the stick is properly removed (umount) the directory is deleted.
This is ok and it is done by the udev rule "/etc/udev/rules.d/10-automount-usb.rules" (which i did not write):

KERNEL=="sd[c-z]", NAME="%k", SYMLINK+="usb%m", GROUP="users", OPTIONS="last_rule"
ACTION=="add", KERNEL=="sd[b-z][0-9]", SYMLINK+="usb%n", GROUP="users", NAME="%k"
ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/mkdir -p /mnt/usb%n"
ACTION=="add", KERNEL=="sd[b-z][0-9]", PROGRAM=="/lib/udev/vol_id -t %N", RESULT=="vfat", RUN+="/bin/mount -t vfat -o rw,noauto,flush,quiet,nodev,nosuid,noexec,noatime,dmask=000,fmask=111 /dev/%k /mnt/usb%n", OPTIONS="last_rule"
ACTION=="add", KERNEL=="sd[b-z][0-9]", RUN+="/bin/mount -t auto -o rw,noauto,sync,dirsync,noexec,nodev,noatime /dev/%k /mnt/usb%n", OPTIONS="last_rule"
ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/umount -l /mnt/usb%n"
ACTION=="remove", KERNEL=="sd[b-z][0-9]", RUN+="/bin/rmdir /mnt/usb%n", OPTIONS="last_rule"[

But:

1. When the directory /mnt/usb1 exists at boot time (if the stick was not removed properly, or if the direcory has been created manually), after the booting, /dev/sdb1 is mounted to both /data (as determined in /etc/fstab) and to /mnt/usb1! My /etc/fstab makes no mention on /mnt/usb1. And i don't see why the rules would apply to /dev/usb only when the directory is present, but not when the directory does not exist.

2. When i reboot the computer with the USB stick (/dev/sdc) plugged in, i end up with the following mounts:
   /dev/sdb1 -> /data
   /dev/sdb1 -> /mnt/usb1
   /dev/sdc1 -> /mnt/usb1
  (again a bad mount of /dev/sdb)

3, When i completely unmount /dev/sdb, and the run "fsck /dev/sdb" this fails (ext2fs_open2: Bad magic number in super-block ), and after that, usb1 is mounted to /mnt/usb1 again.

The behaviour described in points 1 - 3 are 100% reproducible, and seems to be faulty.
While i like automounting of USB sticks, i don't like normal disks being treated like sticks.

Is there a way to change the udev rules that real hard-disks are not automounted to /mnt/usbX?
Or does the faulty behaviour have an other cause?

Last edited by jody (2021-02-17 07:44:07)

Offline

#2 2021-02-16 17:52:53

ToZ
Moderator
From: Canada
Registered: 2011-06-02
Posts: 7,415

Re: [SOLVED] Strange automount behaviour

Not sure if its this, but on quick inspection, all of your udev rules apply also to sdb devices:

sd[b-z][0-9]

The first line in your udev rule actually starts with sdc:

sd[c-z]

Does changing all of the "sd[b-z][0-9]" strings to "sd[c-z][0-9]" make a difference? You might need to reboot.

Also, what does your /etc/fstab look like?

Offline

#3 2021-02-17 07:35:25

jody
Member
Registered: 2015-01-26
Posts: 9

Re: [SOLVED] Strange automount behaviour

ToZ - that totally made a difference!
All strange behaviour i observed before has gone away. Thanks!

My /etc/fstab:
----
# /dev/sda1
UUID=7713-76EE                        /boot/efi    vfat        defaults,noatime    1 2
# /dev/sda2
UUID=32f1ded2-e850-4a6b-9ff6-04d3f072fb36        none        swap        sw            0 0
# /dev/sda3
UUID=e4a9b1b8-8a90-494f-b89c-eb7838c9435d        /        ext4        noatime            0 1
# /dev/sdb1
UUID=924ce722-fd7e-435b-b998-fe6caf3a3ed9        /data        ext4        defaults,noatime      1 2
----

Offline

Board footer

Powered by FluxBB