mount can exit 0 (success) when it fails

Bug #1736556 reported by Scott Moser
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
util-linux (Ubuntu)
Confirmed
Low
Unassigned

Bug Description

I'm on softlayer in an official Ubuntu image and 'mount' exits
success even when it fails.

$ cat /etc/cloud/build.info
build_name: server
serial: 20171116

$ cat /etc/fstab
LABEL=cloudimg-rootfs / ext4 defaults,relatime 0 0

# Added by Cloud Image build process
LABEL=cloudimg-bootfs /boot ext3 defaults,relatime 0 0
# CLOUD_IMG: This file was created/modified by the Cloud Image build process
# Mount the metadata disk for cloud-init, if present
LABEL=METADATA /var/lib/cloud/seed/config_drive vfat defaults,nofail 0 0
LABEL=SWAP-xvdb1 none swap sw,comment=cloudconfig 0 2

$ blkid
/dev/xvda1: LABEL="cloudimg-bootfs" UUID="63ea63a7-f64c-493c-90d4-384adc196be9" TYPE="ext3" PARTUUID="3276fc6f-01"
/dev/xvda2: LABEL="cloudimg-rootfs" UUID="82ca1e17-8bc2-4895-96bb-3c39e5863238" TYPE="ext4" PARTUUID="3276fc6f-02"
/dev/xvdh: SEC_TYPE="msdos" LABEL="config-2" UUID="9796-932E" TYPE="vfat"
/dev/xvdb1: LABEL="SWAP-xvdb1" UUID="d51fcca0-6b10-4934-a572-f3898dfd8840" TYPE="swap" PARTUUID="00025cdb-01"

$ whoami
root
$ grep /var/lib/cloud/seed/config_drive /proc/mounts
$ mount /var/lib/cloud/seed/config_drive
$ echo $?
0

## it exited 0 so it should be mounted, but it is not.
$ ls /var/lib/cloud/seed/config_drive
$ grep /var/lib/cloud/seed/config_drive /proc/mounts

## try somewhere else and with /dev/ path. it works.
$ mount /dev/xvdh /mnt
$ echo $?
0
$ grep /mnt /proc/mounts
/dev/xvdh /mnt vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 0 0
$ find /mnt/
/mnt/
/mnt/openstack
/mnt/openstack/latest
/mnt/openstack/latest/meta_data.json
/mnt/openstack/latest/network_data.json
/mnt/openstack/latest/user_data
/mnt/openstack/latest/vendor_data.json

$ journalctl -o short-monotonic --boot --no-pager | pastebinit
http://paste.ubuntu.com/26119983/

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: mount 2.27.1-6ubuntu3.3
ProcVersionSignature: Ubuntu 4.4.0-98.121-generic 4.4.90
Uname: Linux 4.4.0-98-generic x86_64
ApportVersion: 2.20.1-0ubuntu2.12
Architecture: amd64
Date: Tue Dec 5 17:52:14 2017
ProcEnviron:
 TERM=screen
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: util-linux
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Scott Moser (smoser) wrote :
Revision history for this message
Scott Moser (smoser) wrote :

I didn't notice initially but just did. The entry in /etc/fstab is bogus, containing a LABEL=METADATA but the disk here is LABEL=config-v2.

That is clearly broken, but 'mount' should not exit success.

Revision history for this message
Ryan Harper (raharper) wrote :

Can you attach:

  blkid output
  ls -al /dev/disk/by-label
  /proc/mounts

Testing locally on Xenial, and mount always says something isn't found.

% tail -n1 /etc/fstab
LABEL=METADATA /mnt vfat defaults, 0 0
(foudres) ~ % sudo mount -l -vvvv /mnt
mount: can't find LABEL=METADATA

strace of mount shows it consulting blkid for devices with LABEL

Revision history for this message
Scott Moser (smoser) wrote :
Download full text (3.7 KiB)

blkid output was above. and as I said in my first comment the entry in /etc/fstab is wrong.
there is no LABEL=METADATA device. So 'mount' *should* fail, but I would have expected it to exit non-zero.

I noticed just now that '/etc/fstab' has 'nofail' for that line. I removed that, and it fails as you show and as expected. So the issue here is really just 2 things

a.) the Canonical provided image has a bogus and confusing entry in /etc/fstab
b.) mount really should not exit '0' when explicitly asked to mount something even if it has 'nofail'.

heres the info you asked for:

$ mount -l -vvv /var/lib/cloud/seed/config_drive; echo $?
0

$ blkid
/dev/xvda1: LABEL="cloudimg-bootfs" UUID="63ea63a7-f64c-493c-90d4-384adc196be9" TYPE="ext3" PARTUUID="3276fc6f-01"
/dev/xvda2: LABEL="cloudimg-rootfs" UUID="82ca1e17-8bc2-4895-96bb-3c39e5863238" TYPE="ext4" PARTUUID="3276fc6f-02"
/dev/xvdh: SEC_TYPE="msdos" LABEL="config-2" UUID="9796-932E" TYPE="vfat"
/dev/xvdb1: LABEL="SWAP-xvdb1" UUID="d51fcca0-6b10-4934-a572-f3898dfd8840" TYPE="swap" PARTUUID="00025cdb-01"

$ cat /proc/mounts
sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
udev /dev devtmpfs rw,nosuid,relatime,size=483664k,nr_inodes=120916,mode=755 0 0
devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /run tmpfs rw,nosuid,noexec,relatime,size=101204k,mode=755 0 0
/dev/xvda2 / ext4 rw,relatime,data=ordered 0 0
securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0
tmpfs /run/lock tmpfs rw,nosuid,nodev,noexec,relatime,size=5120k 0 0
tmpfs /sys/fs/cgroup tmpfs ro,nosuid,nodev,noexec,mode=755 0 0
cgroup /sys/fs/cgroup/systemd cgroup rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd 0 0
pstore /sys/fs/pstore pstore rw,nosuid,nodev,noexec,relatime 0 0
cgroup /sys/fs/cgroup/blkio cgroup rw,nosuid,nodev,noexec,relatime,blkio 0 0
cgroup /sys/fs/cgroup/cpu,cpuacct cgroup rw,nosuid,nodev,noexec,relatime,cpu,cpuacct 0 0
cgroup /sys/fs/cgroup/cpuset cgroup rw,nosuid,nodev,noexec,relatime,cpuset 0 0
cgroup /sys/fs/cgroup/net_cls,net_prio cgroup rw,nosuid,nodev,noexec,relatime,net_cls,net_prio 0 0
cgroup /sys/fs/cgroup/perf_event cgroup rw,nosuid,nodev,noexec,relatime,perf_event 0 0
cgroup /sys/fs/cgroup/devices cgroup rw,nosuid,nodev,noexec,relatime,devices 0 0
cgroup /sys/fs/cgroup/pids cgroup rw,nosuid,nodev,noexec,relatime,pids 0 0
cgroup /sys/fs/cgroup/memory cgroup rw,nosuid,nodev,noexec,relatime,memory 0 0
cgroup /sys/fs/cgroup/hugetlb cgroup rw,nosuid,nodev,noexec,relatime,hugetlb 0 0
cgroup /sys/fs/cgroup/freezer cgroup rw,nosuid,nodev,noexec,relatime,freezer 0 0
debugfs /sys/kernel/debug debugfs rw,relatime 0 0
systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=37,pgrp=1,timeout=0,minproto=5,maxproto=5,direct 0 0
mqueue /dev/mqueue mqueue rw,relatime 0 0
none /proc/xen xenfs rw,relatime 0 0
fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0
/dev/xvda1 /boot ext3 rw,relatime,data=ordered 0 0
lxcfs /var/lib/lxcfs fuse.lxcfs rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other 0 0...

Read more...

Changed in util-linux (Ubuntu):
status: New → Confirmed
importance: Undecided → Low
Scott Moser (smoser)
summary: - mount can exit (success) when it fails
+ mount can exit 0 (success) when it fails
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.