Bug 1271848 - mount -a doesn't catch a typo in /etc/fstab and a typo in /etc/fstab can make a system not reboot properly
mount -a doesn't catch a typo in /etc/fstab and a typo in /etc/fstab can make...
Status: CLOSED NEXTRELEASE
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: util-linux-ng (Show other bugs)
6.8
Unspecified Unspecified
medium Severity medium
: rc
: ---
Assigned To: Karel Zak
qe-baseos-daemons
:
Depends On:
Blocks: 1269194 1271850
  Show dependency treegraph
 
Reported: 2015-10-14 17:19 EDT by Dave Sullivan
Modified: 2017-04-25 08:05 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1271850 (view as bug list)
Environment:
Last Closed: 2017-04-25 08:05:19 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Dave Sullivan 2015-10-14 17:19:50 EDT
Description of problem:

Systems booted and was appearing to do an fsck but was failing because of the args past in via /etc/fstab

/ partition referenced in /etc/fstab looked like this (note the -e)

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

#
# /etc/fstab
# Created by anaconda on Fri Jan  7 15:10:37 2011
#
# 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
#
-e/dev/mapper/rootvg-rootlv /                       ext4    defaults        1 1
UUID=1d960796-c08d-4a0d-926f-3cf3c193ebd2 /boot                   ext4    defaults        1 2
/dev/mapper/rootvg-tmplv /tmp                    ext4    defaults        1 2
/dev/mapper/rootvg-varlv /var                    ext4    defaults        1 2
/dev/mapper/rootvg-crashlv /var/crash              ext4    defaults        1 2
/dev/mapper/rootvg-swaplv swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/md0	        /data		ext4	defaults,nodiratime,noatime,barrier=0	0 0

Notice how mount -a doesn't recognize an issue

[root@seaking ~]# mount -a
[root@seaking ~]#

Now if I add a space after -e an issue is recognized.

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

#
# /etc/fstab
# Created by anaconda on Fri Jan  7 15:10:37 2011
#
# 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
#
-e /dev/mapper/rootvg-rootlv /                       ext4    defaults        1 1
UUID=1d960796-c08d-4a0d-926f-3cf3c193ebd2 /boot                   ext4    defaults        1 2
/dev/mapper/rootvg-tmplv /tmp                    ext4    defaults        1 2
/dev/mapper/rootvg-varlv /var                    ext4    defaults        1 2
/dev/mapper/rootvg-crashlv /var/crash              ext4    defaults        1 2
/dev/mapper/rootvg-swaplv swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/md0	        /data		ext4	defaults,nodiratime,noatime,barrier=0	0 0

[root@seaking ~]# mount -a
[mntent]: line 9 in /etc/fstab is bad

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:

mount -a
echo $? returns 0 


Expected results:

mount -a should be able to catch the noted typo above


Additional info:

[root@seaking ~]# for fs in $(awk '!/^#/ {print $1}' /etc/fstab) ; do mount -fv ${fs} >/dev/null || echo ${fs} ; done
mount: invalid option -- 'e'
Usage: mount -V                 : print version
       mount -h                 : print this help
       mount                    : list mounted filesystems
       mount -l                 : idem, including volume labels
So far the informational part. Next the mounting.
The command is `mount [-t fstype] something somewhere'.
Details found in /etc/fstab may be omitted.
       mount -a [-t|-O] ...     : mount all stuff from /etc/fstab
       mount device             : mount device at the known place
       mount directory          : mount known device here
       mount -t type dev dir    : ordinary mount command
Note that one does not really mount a device, one mounts
a filesystem (of the given type) found on the device.
One can also mount an already visible directory tree elsewhere:
       mount --bind olddir newdir
or move a subtree:
       mount --move olddir newdir
One can change the type of mount containing the directory dir:
       mount --make-shared dir
       mount --make-slave dir
       mount --make-private dir
       mount --make-unbindable dir
One can change the type of all the mounts in a mount subtree
containing the directory dir:
       mount --make-rshared dir
       mount --make-rslave dir
       mount --make-rprivate dir
       mount --make-runbindable dir
A device can be given by name, say /dev/hda1 or /dev/cdrom,
or by label, using  -L label  or by uuid, using  -U uuid .
Other options: [-nfFrsvw] [-o options] [-p passwdfd].
For many more details, say  man 8 mount .
-e/dev/mapper/rootvg-rootlv
mount: according to mtab, /dev/sdb1 is already mounted on /boot

UUID=1d960796-c08d-4a0d-926f-3cf3c193ebd2
mount: according to mtab, /dev/mapper/rootvg-tmplv is already mounted on /tmp

/dev/mapper/rootvg-tmplv
mount: according to mtab, /dev/mapper/rootvg-varlv is already mounted on /var

/dev/mapper/rootvg-varlv
mount: according to mtab, /dev/mapper/rootvg-crashlv is already mounted on /var/crash

/dev/mapper/rootvg-crashlv
mount: according to mtab, /dev/mapper/rootvg-swaplv is already mounted on swap

/dev/mapper/rootvg-swaplv
mount: according to mtab, tmpfs is already mounted on /dev/shm

tmpfs
mount: according to mtab, devpts is already mounted on /dev/pts

devpts
mount: according to mtab, sysfs is already mounted on /sys

sysfs
mount: according to mtab, proc is already mounted on /proc

proc
mount: according to mtab, /dev/md0 is already mounted on /data

/dev/md0
Comment 3 Karel Zak 2015-10-15 05:40:19 EDT
(In reply to Dave Sullivan from comment #0)
> [root@seaking ~]# mount -a
> [mntent]: line 9 in /etc/fstab is bad

...

> Expected results:
> mount -a should be able to catch the noted typo above

What do you mean with "catch"? It reports the malformed line and the line is ignored. What else do you expect?

Maybe the return code should be 64 ("some mounted") rather than zero.

The basic "mount -a" feature is to be optimistic and continue working if possible. It's unwanted to stop when something is wrong with fstab (

Note that in RHEL7 we use systemd instead of "mount -a" and systemd is more pedantic and many users hate it.
Comment 4 Dave Sullivan 2015-10-15 09:13:17 EDT
The first example with -e/dev/mapper/rootvg-rootlv /                       ext4    defaults        1 1

It doesn't catch the malformed line and returns 0.

I think it's fine to have it continue just think with above example knowing that fsck will bail on the -e this should be addressed and especially if customers were thinking a mount -a test before reboot would catch any fstab problems.

Wasn't really sure how on boot fstab is addressed relative to mount -a.

Just know we were past grub which had identified the root device, noticed the fs needed fsck and we got some bogus fsck fail error with -e due to the typo.  So I know on rhel6 fsck was trying to fsck, and assume some like mount -a reads the whole thing after pivot_root.
Comment 5 Karel Zak 2017-01-06 06:30:31 EST
Note that (based on this BZ report) findmnt since v2.29 supports --verify to check fstab parsability and usability. 

It's available for Fedora 25. For more details see
http://karelzak.blogspot.cz/2016/10/util-linux-v229-whats-new.html
Comment 7 Karel Zak 2017-04-25 08:05:19 EDT
CLOSING; for RHEL8 we will be available "findmnt --verify"; for RHEL6 it seems overkill to backport this feature or try to improve the fstab parser.

Note You need to log in before you can comment on or make changes to this bug.