Bug 198426

Summary: /etc/mtab is not reliable
Product: [Fedora] Fedora Reporter: Karel Zak <kzak>
Component: initscriptsAssignee: Bill Nottingham <notting>
Status: CLOSED RAWHIDE QA Contact: Brock Organ <borgan>
Severity: medium Docs Contact:
Priority: medium    
Version: 6CC: mitr, rvokal
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 8.38-1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-08-03 00:34:42 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Karel Zak 2006-07-11 11:19:45 UTC
initscripts-8.35/rc.d/init.d/halt:

# Try all file systems other than root and RAM disks, one last time.
mount |  awk '!/( \/ |^\/dev\/root|^\/dev\/ram| \/proc )/ { print $3 }' | sort
-r | \
  while read line; do
    fstab-decode umount -f $line
done

I think the output from mount command should be replaced with /proc/mounts. The
/etc/mtab doesn't contain mountpoints from the "mount --rbind" command. It means
this script doesn't umount all pointpoins.

# mkdir -p /mnt/foo/bar
# mount /dev/dm-1 /mnt/foo/bar

# mkdir -p /mnt/foo2
# mount --rbind /mnt/foo /mnt/foo2

# umount /mnt/foo2
umount: /mnt/foo2: device is busy
umount: /mnt/foo2: device is busy

because:

# mount | grep foo
/dev/dm-1 on /mnt/foo/bar type ext3 (rw)
/mnt/foo on /mnt/foo2 type none (rw,bind)

(note: there is no info about /mnt/foo2/bar in mtab)

# cat /proc/mounts | grep foo
/dev/dm-1 /mnt/foo/bar ext3 rw,data=ordered 0 0
/dev/root /mnt/foo2 ext3 rw,data=ordered 0 0
/dev/dm-1 /mnt/foo2/bar ext3 rw,data=ordered 0 0
          ^^^^^^^^^^^^
you have to umount recursive:

# umount /mnt/foo2/bar
# umount /mnt/foo2

For more datails see bug #194342.

Comment 1 Miloslav Trmač 2006-07-30 03:00:05 UTC
Thanks, changed in CVS.