10

I'm trying to mount a device but without success. The strange thing is that the mount command succeeds and return exit code 0, but the device is not mounted. Any idea on why this happens or how to investigate it? Please see the example below:

[root@mymachine ~]# blkid -o list
device         fs_type  label     mount point        UUID
-----------------------------------------------------------------------------------------
/dev/xvda1     xfs                /                  29342a0b-e20f-4676-9ecf-dfdf02ef6683
/dev/xvdy      ext4               /vols/data         72c23c30-2704-42ec-9518-533c182e2b22
/dev/xvdb      swap               <swap>             990ff722-158c-4ad5-963a-0bc9e1e2b17a
/dev/xvdx      ext4               (not mounted)      956b5553-d8b4-4ffe-830c-253e1cb10a2f
[root@mymachine ~]# grep /dev/xvdx /etc/fstab
/dev/xvdx /vols/data5 ext4 defaults 0 0
[root@mymachine ~]# mount -a; echo $?
0
[root@mymachine ~]# blkid -o list
device         fs_type  label     mount point        UUID
-----------------------------------------------------------------------------------------
/dev/xvda1     xfs                /                  29342a0b-e20f-4676-9ecf-dfdf02ef6683
/dev/xvdy      ext4               /vols/data         72c23c30-2704-42ec-9518-533c182e2b22
/dev/xvdb      swap               <swap>             990ff722-158c-4ad5-963a-0bc9e1e2b17a
/dev/xvdx      ext4               (not mounted)      956b5553-d8b4-4ffe-830c-253e1cb10a2f
[root@mymachine ~]# mount /dev/xvdx /vols/data5; echo $?
0
[root@mymachine ~]# blkid -o list
device         fs_type  label     mount point        UUID
-----------------------------------------------------------------------------------------
/dev/xvda1     xfs                /                  29342a0b-e20f-4676-9ecf-dfdf02ef6683
/dev/xvdy      ext4               /vols/data         72c23c30-2704-42ec-9518-533c182e2b22
/dev/xvdb      swap               <swap>             990ff722-158c-4ad5-963a-0bc9e1e2b17a
/dev/xvdx      ext4               (not mounted)      956b5553-d8b4-4ffe-830c-253e1cb10a2f
[root@mymachine ~]#

Full fstab:

[root@mymachine ~]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Mon May  1 18:59:01 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=29342a0b-e20f-4676-9ecf-dfdf02ef6683 /                       xfs     defaults        0 0
/dev/xvdb swap swap defaults,nofail 0 0
/dev/xvdy /vols/data ext4 defaults 0 0
/dev/xvdx /vols/data5 ext4 defaults 0 0
2
  • Thanks! Doesn't seem like it: blkid -o list -c /dev/null ... /dev/xvdx ext4 (not mounted) 956b5553-d8b4-4ffe-830c-253e1cb10a2f [root@mymachine ~]# [root@mymachine ~]# ls -l /vols/data5 total 0
    – yurmix
    Aug 1, 2018 at 22:05
  • Pls show us more /etc/fstab?
    – slm
    Aug 1, 2018 at 22:07

4 Answers 4

15

Normally mount doesn't return 0 if there have been problems. When I had a similar problem, the reason was that systemd unmounted the filesystem immediately after the mount.

You can try strace mount /dev/xvdx /vols/data5 to see the result of the syscall. You can also try mount /dev/xvdx /vols/data5; ls -li /vols/data5 to see whether something is mounted immediately after the mount command.

3
  • 1
    Bingo! Something unmounts the device. Your suggested debugging methods proved it (starting with even the ls command).
    – yurmix
    Aug 1, 2018 at 22:21
  • 5
    @yurmix That something is almost certainly systemd. The developers seem to think that they know better than the actual users, and it will as a result automatically unmount anything for which a mount unit is defined but it thinks the devices needed by that unit are not ready. Aug 2, 2018 at 19:27
  • 2
    the developers have known about this problem for years github.com/systemd/systemd/issues/1741
    – T Nierath
    Jul 9, 2020 at 7:32
9

Further to the accepted answer, which states that something (probably systemd) is unmounting the file system - let me explain in more detail what happened in my case.

It was indeed systemd, as shown by journalctl.

In my scenario, I had this in my fstab

/dev/sda6 /fasthome           ext4    defaults        0       2
/dev/sda7 /mnt/vms  ext4 defaults 0 2

(fasthome, incase you're wondering is a place to do disk intensive stuff without encyprtion).

So when I booted up with an external USB drive plugged in, that became sda and my internal drive became sdb. Clearly these mount points were not going to work, so I corrected them as follows:

/dev/disk/by-uuid/<some uuid> /fasthome ext4 defaults 0 2
/dev/disk/by-uuid/<other uuid> /mnt/vms ext4 defaults 0 2

Then I run mount -a and the command completes, without error, but seemingly they're not mounted. So I try mount /dev/disk/by-uuid ... same thing, and I end up at this question.

Yup it's systemd unmounting them, and in my case it was because previously /fasthome had been attempted to mount to /dev/sda6, systemd is all hung up on that being an inactive device. So although my uuid path symlink correctly points to /dev/sdb6 systemd didn't like what was happening here.

In this particular case, the answer was simply to reboot, so the erroneous device references went away.

I am sure there are 1001 similar yet different circumstances that can lead to this problem, hopefully the detail here will give people a big enough clue for their specific circumstances.

5

It helps to run systemctl daemon-reload, or reboot.

Systemd thinks there is a dependency missing and immediately unmounts the volume.

I found this in https://github.com/systemd/systemd/issues/1741 which was mentioned here in an earlier answer.

3
  • 1
    I think that should be fixed at SystemD, silently failing does not sound like a solution...
    – ajaaskel
    Aug 9, 2021 at 0:22
  • 1
    sudo systemctl daemon-reload allows to mount one time correctly (=useful temporary help), next time still the same problem i.e. it does not fix the root cause of problem.
    – ajaaskel
    Aug 9, 2021 at 0:35
  • 1
    I had a wrong entry in /etc/fstab & this helped after I removed that entry
    – Ayush
    Oct 7, 2021 at 19:06
1

The same happened to me when I forgot to remove old entry in /etc/fstab

That's very irrational behaviour, because fstab entry specified wrong FS type and cli command was corect. The mount command ignored both.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .