local v
while [ $# -gt 0 ]; do
case $1 in
- rw|ro);;
defaults);;
*)
v="$v,${1}";;
# the root filesystem,
# remount it with the proper options
rootopts="defaults"
- while read dev mp fs opts rest; do
+ while read dev mp fs opts dump fsck; do
# skip comments
[ "${dev%%#*}" != "$dev" ] && continue
# sanity - determine/fix fstype
rootfs=$(det_fs "${root#block:}" "$fs")
rootopts=$opts
+ rootfsck=$fsck
break
fi
done < "$NEWROOT/etc/fstab"
# we want rootflags (rflags) to take precedence so prepend rootopts to
# them; rflags is guaranteed to not be empty
- rflags="${rootopts:+"${rootopts},"}${rflags}"
+ rflags="${rootopts:+${rootopts},}${rflags}"
# backslashes are treated as escape character in fstab
# esc_root=$(echo ${root#block:} | sed 's,\\,\\\\,g')
# printf '%s %s %s %s 1 1 \n' "$esc_root" "$NEWROOT" "$rootfs" "$rflags" >/etc/fstab
ran_fsck=0
- if [ -z "$fastboot" -a "$READONLY" != "yes" ] && \
- ! strstr "${rflags},${rootopts}" _netdev && \
+ if [ "$rootfsck" != "0" -a -z "$fastboot" -a "$READONLY" != "yes" ] && \
+ ! strstr "${rflags}" _netdev && \
! getargbool 0 rd.skipfsck; then
- umount "$NEWROOT"
fsck_single "${root#block:}" "$rootfs" "$rflags" "$fsckoptions"
_ret=$?
[ $_ret -ne 255 ] && echo $_ret >/run/initramfs/root-fsck
ran_fsck=1
fi
- if [ -n "$rootopts" -o "$ran_fsck" = "1" ]; then
- info "Remounting ${root#block:} with -o ${rflags}"
- umount "$NEWROOT" &>/dev/null
- mount -t "$rootfs" -o "$rflags" "${root#block:}" "$NEWROOT" 2>&1 | vinfo
- fi
+ echo "${root#block:} $NEWROOT $rootfs ${rflags:-defaults} 0 $rootfsck" >> /etc/fstab
+
+ info "Remounting ${root#block:} with -o ${rflags}"
+ mount -o remount "$NEWROOT" 2>&1 | vinfo
[ -f "$NEWROOT"/forcefsck ] && rm -f "$NEWROOT"/forcefsck 2>/dev/null
[ -f "$NEWROOT"/.autofsck ] && rm -f "$NEWROOT"/.autofsck 2>/dev/null
_dev="/dev/disk/by-uuid/${_dev#UUID=}"
;;
esac
+ if strstr "$_opts" "subvol=" && \
+ [ "${root#block:}" -ef $_dev ]
+ [ -n "$rflags" ]; then
+ # for btrfs subvolumes we have to mount /usr with the same rflags
+ _opts="${_opts:+${_opts},}${rflags}"
+ elif getarg ro; then
+ # if "ro" is specified, we want /usr to be readonly, too
+ _opts="${_opts:+${_opts},}ro"
+ fi
echo "$_dev ${NEWROOT}${_mp} $_fs ${_opts} $_freq $_passno"
_usr_found="1"
break
root=$(getarg root=)
if rflags="$(getarg rootflags=)"; then
- getarg rw && rflags="${rflags},rw" || rflags="${rflags},ro"
+ getarg rw && rflags="${rflags},rw"
+ getarg ro && rflags="${rflags},ro"
else
- getarg rw && rflags=rw || rflags=ro
+ getarg rw && rflags=rw
+ getarg ro && rflags=ro
fi
fstype="$(getarg rootfstype=)"