Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Why does df query /usb? It was mounted on /dev/sdb1, but that device is now absent, had been properly unmounted. There was an entry for /usb in /etc/mtab, but I deleted it. When I attach a usb device, it gets /dev/sdc, so the system thinks /dev/sdb isn't available.
There might be interesting information in the message buffer, for example
Code:
dmesg | grep -C 4 sdb
A reboot should fix that anyway.
Edit: partprobe and partx could be useful tools here as well. Perhaps the kernel thinks that one of the sdb partitions is still in use and needs to be told that this is not so. partx allows editing the kernel's copy of the partition table.
Last edited by berndbausch; 03-15-2020 at 10:45 PM.
for me that means: the system thinks /usb is still available, was not properly detached. As it was mentioned a reboot should help. Also you need to give more details if it [will] happen again.
You may find additional info in /var/log (about all the events related to it, like mount/umount/eject...)
If I remember well manual editing of /etc/mtab is pointless, but it may depend on your OS.
There might be interesting information in the message buffer, for example
Code:
dmesg | grep -C 4 sdb
returns a slew of errors. It seems that although umount /usb returned no errors to stderr it failed and recorded errors in logs.
Quote:
Originally Posted by berndbausch
A reboot should fix that anyway.
Yes. I didn't ask for a fix. I asked what df was consulting that made it query /usb. Perhaps a cached version of /etc/mtab? What can I make it do so that it doesn't?
Quote:
Originally Posted by berndbausch
Perhaps the kernel thinks that one of the sdb partitions is still in use and needs to be told that this is not so.
I asked how to tell the kernel that no sdb partition is in use.
Quote:
Originally Posted by berndbausch
partx allows editing the kernel's copy of the partition table.
partx tells me /dev/sdb isn't.
Quote:
Originally Posted by pan64
for me that means: the system thinks /usb is still available, was not properly detached.
So I think. I asked what df consulted.
Quote:
Originally Posted by pan64
As it was mentioned a reboot should help.
I didn't ask for help.
Quote:
Originally Posted by pan64
Also you need to give more details if it [will] happen again.
You may find additional info in /var/log (about all the events related to it, like mount/umount/eject...)
It's happening now.
Quote:
Originally Posted by pan64
If I remember well manual editing of /etc/mtab is pointless, but it may depend on your OS.
Are you sure about that? mtab is a "virtual" file, actually generated when you want to read it, editing it is just pointless. But its "implementation"/behavior depends on the OS.
Traditionally /etc/mtab is a file created in parallel to the kernel memory, and df looked at it.
In Linux /proc/mounts is an ASCII representation of the kernel memory.
Recent distos make /etc/mtab a symlink to /proc/mounts. (Check with ls -l)
Then is is quite clear: the mount and df commands must use /proc/mounts.
Are you sure about that? mtab is a "virtual" file, actually generated when you want to read it, editing it is just pointless. But its "implementation"/behavior depends on the OS.
Quote:
Originally Posted by MadeInGermany
Traditionally /etc/mtab is a file created in parallel to the kernel memory, and df looked at it.
I have occasional problems with flash drives umounting without complaint but the kernel thinking they're still mounted, reserving the device, e.g., /dev/sdb I have cleared them sometimes by editing /etc/mtab.
Quote:
Originally Posted by MadeInGermany
In Linux /proc/mounts is an ASCII representation of the kernel memory.
/proc/mounts is what I was looking for, thanks.
Quote:
Originally Posted by MadeInGermany
Recent distos make /etc/mtab a symlink to /proc/mounts. (Check with ls -l)
Not the latest Slackware. I can cat them both simultaneously, see the differences, though mtab seems to be a subset of mounts.
Quote:
Originally Posted by MadeInGermany
Then is is quite clear: the mount and df commands must use /proc/mounts.
mount doesn't report /usb being mounted when df complains that it can't query it.
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803
Rep:
Quote:
Originally Posted by RandomTroll
When I run df, I get Why does df query /usb? It was mounted on /dev/sdb1, but that device is now absent, had been properly unmounted. There was an entry for /usb in /etc/mtab, but I deleted it. When I attach a usb device, it gets /dev/sdc, so the system thinks /dev/sdb isn't available.
I'm not sure if it'll make your USB problem go away but you should at least be able to find out what "df" is looking at to find the USB device by running:
Code:
strace df
Sorry... I don't have any phantom USB devices lingering on my system or I'd post some strace output as an example.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.