umountroot cannot handle fuse host mounts

Bug #186114 reported by Agostino Russo
2
Affects Status Importance Assigned to Milestone
Wubi
Fix Committed
Medium
Unassigned
sysvinit (Ubuntu)
Fix Released
Undecided
Evan

Bug Description

Binary package hint: sysvinit

If root is loopmounted the host mount will be handled by the initrd and will not show up in fstab
Hence explicit DEV and TYPE are required. For fuse mounted hosts the TYPE in /proc/mounts is
fusblk so we need to rely on vol_id first to get the real filesystem type.

Following is the proposed code that should replace remount_ro within umountroot. We first
try to remount as usual and if that fails, we try to use explicit DEV and TYPE.

remount_ro () {
# ntfs-3g in hardy does not allow remounts (v 1.1120, gutsy v 1.913), and does not take -n why?
# use sed instead of awk: sed -n "\:^/[^ ]* $MTPT :p" /proc/mounts
 echo remounting $1
 local MTPT=$1
 [ "$VERBOSE" = no ] || log_action_begin_msg "Mounting $MTPT filesystem read-only"
 MOUNT_FORCE_OPT=
 [ "$(uname -s)" = "GNU/kFreeBSD" ] && MOUNT_FORCE_OPT=-f
 # This:
 # mount -n -o remount,ro /
 # will act on a bind mount of / if there is one.
 # See #339023 and the comment in checkroot.sh
 mount $MOUNT_FORCE_OPT -n -o remount,ro -t dummytype dummydev $MTPT 2>/dev/null \
 || mount $MOUNT_FORCE_OPT -n -o remount,ro dummydev $MTPT 2>/dev/null \
 || mount $MOUNT_FORCE_OPT -n -o remount,ro $MTPT 2>/dev/null
 ES=$?
 if [ $ES != 0 ]; then
  local MOUNT="$(sed -n "\:^/[^ ]* $MTPT :p" /proc/mounts)"
  local DEV=${MOUNT%% *}
  local TYPE=$(/lib/udev/vol_id -t $DEV 2> /dev/null)
  if [ -z "$TYPE" ]; then
   TYPE=${MOUNT#* $MTPT }
   TYPE=${TYPE%% *}
  fi
  mount $MOUNT_FORCE_OPT -n -o remount,ro -t $TYPE $DEV $MTPT 2>/dev/null || \
  mount $MOUNT_FORCE_OPT -o remount,ro -t $TYPE $DEV $MTPT
  ES=$?
 fi
 [ "$VERBOSE" = no ] || log_action_end_msg $ES
}

Tags: wubi
Agostino Russo (ago)
Changed in sysvinit:
assignee: nobody → evand
Revision history for this message
Agostino Russo (ago) wrote :
Changed in wubi:
importance: Undecided → Medium
status: New → Confirmed
Revision history for this message
Agostino Russo (ago) wrote :

Diff vs current hardy umountroot

Changed in wubi:
status: Confirmed → Fix Committed
Revision history for this message
Agostino Russo (ago) wrote :

In order for the host device to be remounted ro it is also necessary that any loopdevice it contains is also ro, I am not aware of any way to change the ro/rw status of loopdevices after they are created, save maybe "blockdev --setro" (thanks to Colin Watson for the tip!).

Revision history for this message
Agostino Russo (ago) wrote :

something along the lines of:

for d in /dev/loop*; do
    blockdev --setro "$d" || true;
done

Revision history for this message
Agostino Russo (ago) wrote :

New diff, should also try to set loopdevices ro

Revision history for this message
Agostino Russo (ago) wrote :
Revision history for this message
Agostino Russo (ago) wrote :
Evan (ev)
Changed in sysvinit (Ubuntu):
status: New → Fix Released
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.