Score:0

`findmnt` and `ls` still see a physically disconnected external storage drive

in flag

Here is an /etc/fstab record example of one of the mounts as per x-systemd.automount and other goodies:

UUID=XXXX-XXXX /media/XXXX-XXXX auto noauto,nofail,nouser,uid=root,gid=users,umask=007,X-mount.mkdir,x-systemd.automount,x-systemd.device-timeout=1,x-systemd.idle-timeout=60 0 2

Currently this external exFAT-formatted drive is physically disconnected from the PC, but I still get the following surprises

$ ls /media
ls: cannot access '/media/XXXX-XXXX': No such device

and

$ findmnt /media/XXXX-XXXX
TARGET           SOURCE    FSTYPE OPTIONS
/media/XXXX-XXXX systemd-1 autofs rw,relatime,fd=55,pgrp=1,timeout=60,minproto=5,maxproto=5,direct,pipe_ino=24590

This obviously fools other software, which might potentially be using findmnt to determine whether the mount is up, to believe that the storage drive is actually mounted and to proceed with further actions.

How do I make sure that when the drive is physically disconnected, it is no longer considered by the Linux system?

djdomi avatar
za flag
seems to me tgat media is still mounted?
in flag
@djdomi, it's not, the record you see just reflects `fstab` and `systemd` relation. There is no actual mount in either `mount`, `df`, `lsblk`, etc.
djdomi avatar
za flag
did you tried `eject` or `udisks --detach /dev/sdX` or `udisksctl power-off -b /dev/sdb`in reference to [this post](https://unix.stackexchange.com/questions/35508/eject-usb-drives-eject-command/129282)
in flag
@djdomi, the problem with this is that there is no device to begin with. The device is gone and that's exactly what `ls` complains about for instance. `lsblk` also does not provide any insight. Of course I remember what was the name of the device and I tried to enter it manually in `eject` command, what naturally results in `eject: /dev/sdd: not found mountpoint or device with the given name` error message.
djdomi avatar
za flag
UUID=XXXX-XXXX /media/XXXX-XXXX is the X anomized?
in flag
@djdomi, yup, in reality letters are different, but that's irrelevant here.
djdomi avatar
za flag
why do you do this? is that a secret?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.