0

I'm trying to automount external usb hdd to my freshly installed Debian 9 box. I'm trying to achieve that with simple udev rule and simply not able to do that. This rule works on my old Debian 6 system without any problem. So rule is created in /etc/udev/rules.d/11-externalusb.rules

Rule from my old system:

SUBSYSTEMS=="block", ENV{ID_FS_LABEL}=="wdext1", RUN+="/bin/mount /dev/disk/by-label/wdext1"

/etc/fstab entry:

/dev/disk/by-label/wdext1 /mnt/hdd ext4 defaults,noauto 0 0

In Debian 9 this approach doesn't work at all:/ I see the following in the logs: EXT4-fs (sdb1): mounted filesystem with ordered data mode. Opts: (null) but I can't see any mounts created. I've searched internet, found some other examples and made another very simple rule:

KERNEL!="sd[b-z][0-9]", GOTO="media_by_label_auto_mount_end"

ACTION=="add", RUN+="/bin/mount /dev/sdb1 /mnt/hdd1"`

LABEL="media_by_label_auto_mount_end"

This rule does not work too:/ journalctl says the following:

Mar 23 20:12:48 uranas kernel: sd 6:0:0:0: [sdb] 2930272256 512-byte logical blocks: (1.50 TB/1.36 TiB)
Mar 23 20:12:48 uranas kernel: sd 6:0:0:0: [sdb] Test WP failed, assume Write Enabled
Mar 23 20:12:48 uranas kernel: sd 6:0:0:0: [sdb] Asking for cache data failed
Mar 23 20:12:48 uranas kernel: sd 6:0:0:0: [sdb] Assuming drive cache: write through
Mar 23 20:12:48 uranas kernel:  sdb: sdb1
Mar 23 20:12:48 uranas kernel: sd 6:0:0:0: [sdb] Attached SCSI disk
Mar 23 20:12:48 uranas kernel: EXT4-fs (sdb1): mounted filesystem with ordered data mode. Opts: (null)

But I can't see any mounts:/ If I try to run fsck on /dev/sdb1 it complains that the device is in use. So as for now I completely lost what am I doing wrong. Can anyone help me to automount this usb hdd via udev rule. Thanks.

  • The mount succeeded. You should put efforts on why you can't see the mount. What command did you try, to actually see the mount? Did you try mount or df for example ? – A.B Mar 24 '18 at 15:51
  • Tried mount, tired to enter /mnt/hdd1 directory, no joy. I was able to automount my hdd via fstab entry, which was able to mount disk on boot time, but I want to find what is going on with udev:/ – Rimvydas Mar 24 '18 at 16:45
  • what's the output of df /mnt/hdd1 after the the log tells "mounted" ? – A.B Mar 24 '18 at 17:12
  • Output is very strange:/ df /mnt/hdd1 Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda2 470992144 11581872 435415496 3% / – Rimvydas Mar 24 '18 at 19:41
  • Unless there are other namespaces involved (containers...) I have no idea, so I can't help anymore – A.B Mar 24 '18 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.