You are not logged in.

#1 2014-11-02 02:12:44

Malvineous
Member
From: Brisbane, Australia
Registered: 2011-02-03
Posts: 195
Website

[SOLVED] Mounted USB stick immediately unmounts itself - why?

Hi all,

I thought I was unable to mount a USB stick, however it does actually mount but then it gets immediately unmounted by something:

# mount /dev/sdd1 /mnt
# ls /mnt
<empty folder>
# umount /mnt
umount: /mnt: not mounted

# mount /dev/sdd1 /mnt && ls /mnt
<contents of USB stick>
# ls /mnt
<empty folder>

Somehow the USB stick is getting automatically *unmounted* almost immediately after I mount it!

I don't have any automounts enabled, so I'm not sure why this would happen.  If I make a different folder (e.g. /root/test) and mount it there then it sticks, it is only the /mnt folder that gets automatically unmounted.

Any idea what's going on?  I've never seen this happen before, and last time I tried this (a week or two ago) it worked fine.

Last edited by Malvineous (2015-03-15 01:15:16)

Offline

#2 2014-11-02 04:19:29

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,662

Re: [SOLVED] Mounted USB stick immediately unmounts itself - why?

Anything interesting at the end of the journal or in the output of dmesg after you do this?


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#3 2014-11-02 07:03:47

Malvineous
Member
From: Brisbane, Australia
Registered: 2011-02-03
Posts: 195
Website

Re: [SOLVED] Mounted USB stick immediately unmounts itself - why?

Nope, nothing at all.  Only messages relate to the insertion of the USB stick, nothing else appears when I mount it.  Can't see any processes running that look like they might have something to do with mounting/unmounting, and no udev rules mention the device or mount point.

I did have the mount point listed in /etc/fstab with a different device name, but commenting out that line didn't change anything.

Really weird.

Offline

#4 2014-11-02 09:07:10

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,019

Re: [SOLVED] Mounted USB stick immediately unmounts itself - why?

Maybe "lsof /mnt" would show something.

Offline

#5 2014-11-02 09:43:58

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: [SOLVED] Mounted USB stick immediately unmounts itself - why?

Use "mount -v" (i.e. "verbose") to get some feedback - it's most likely not being mounted.

Immediately after running that mount command, run:

echo $?

To see the return code. It should be 0.

This is where a sensible prompt comes in handy, to get indication of whether the command failed, e.g.:

export PS1="\[\e[36;1m\]pc-\[\e[33;1m\]\u:\[\e[34;1m\]\w\`if [ \$? = 0 ]; then echo -e '\[\e[01;32m\]$'; else echo -e '\[\e[01;31m\]$'; fi\`\[\e[0m\] "

Also, mounting to /mnt is very weird - you should be mounting a directory *inside* /mnt.

Offline

#6 2014-11-02 09:46:19

Vain
Member
Registered: 2008-10-19
Posts: 183

Re: [SOLVED] Mounted USB stick immediately unmounts itself - why?

Malvineous wrote:

I did have the mount point listed in /etc/fstab with a different device name, but commenting out that line didn't change anything.

I made the same “mistake”. Try running “systemctl status mnt.mount” and see which device the output refers to. For me, it still listed the old device name. Hence, when you mount it, systemd tries to find the (old) device—which it can’t—and thus unmounts your device immediately.

I was too lazy/annoyed to find out how to solve this properly. I rebooted my system. roll

Offline

#7 2014-11-02 12:36:32

Malvineous
Member
From: Brisbane, Australia
Registered: 2011-02-03
Posts: 195
Website

Re: [SOLVED] Mounted USB stick immediately unmounts itself - why?

brebs wrote:

Use "mount -v" (i.e. "verbose") to get some feedback - it's most likely not being mounted.

Like I said in my first post, if you run "ls" immediately after the mount then you can see the contents of the USB stick, so it's definitely getting mounted, but waiting only a few hundred milliseconds after the mount reveals it has been unmounted again.  What is causing the unmount is unknown.

brebs wrote:

Immediately after running that mount command, run:

echo $?

To see the return code. It should be 0.

Yes it is zero, because the mount command succeeds.  "ls" wouldn't be able to list the files on the USB stick if the mount failed.  It is something else that is unmounting the folder mere milliseconds after it is successfully mounted, but I don't know where else to look to find out what it could be.

brebs wrote:

Also, mounting to /mnt is very weird - you should be mounting a directory *inside* /mnt.

I am mounting inside /mnt, I just used /mnt as an example to keep things simple.

Vain wrote:

I made the same “mistake”. Try running “systemctl status mnt.mount” and see which device the output refers to. For me, it still listed the old device name. Hence, when you mount it, systemd tries to find the (old) device—which it can’t—and thus unmounts your device immediately.

I was too lazy/annoyed to find out how to solve this properly. I rebooted my system. roll

Interesting idea!  Unfortunately I have nothing listed for this particular mount point.  The only *.mount services on my system are the ones that are mounted at boot (e.g. srv.mount for /srv).  I have the "noauto" option against this mount point in fstab (as USB sticks aren't normally attached to my system when I boot) so sensibly enough I don't seem to have a mount service running for this particular mount point.

Offline

#8 2014-11-02 13:04:19

Vain
Member
Registered: 2008-10-19
Posts: 183

Re: [SOLVED] Mounted USB stick immediately unmounts itself - why?

Malvineous wrote:

Interesting idea!  Unfortunately I have nothing listed for this particular mount point.  The only *.mount services on my system are the ones that are mounted at boot (e.g. srv.mount for /srv).  I have the "noauto" option against this mount point in fstab (as USB sticks aren't normally attached to my system when I boot) so sensibly enough I don't seem to have a mount service running for this particular mount point.

Yeah, I’ve been using “noauto” as well. I guess systemd creates those units on the fly at some point. “systemctl | grep mount” might reveal unexpected mount units.

Offline

#9 2014-11-06 06:25:35

Malvineous
Member
From: Brisbane, Australia
Registered: 2011-02-03
Posts: 195
Website

Re: [SOLVED] Mounted USB stick immediately unmounts itself - why?

Yeah "systemctl | grep mount" was how I found the instance for /srv, but there's nothing for my /mnt folder.  So weird.  Guess the only way to resolve it once and for all is to debug the kernel and break on the unmount() call and see which process is calling it :-S

Offline

#10 2015-03-15 01:14:56

Malvineous
Member
From: Brisbane, Australia
Registered: 2011-02-03
Posts: 195
Website

Re: [SOLVED] Mounted USB stick immediately unmounts itself - why?

Turns out this is systemd forcing active mounts to match what's in /etc/fstab.

Removing the mount point from /etc/fstab should work, but in my case I was able to add multiple entries for each device (via UUID) that I wanted to appear at the mount point.  Running "systemctl daemon-reload" then picked up the changes and it didn't automatically unmount the devices any more.

I have to say I've not been terribly fond of systemd so far (nothing against the idea, just the implementation is too cryptic), but this silly design decision is enough for me to start actively disliking it...

Offline

Board footer

Powered by FluxBB