|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
implement fs-lib, squash a few bugs that were part of det_fs/wrap_fsck
To not pollute dracut-lib.sh, all the fsck related functions were moved
to fs-lib.sh. The functions available are as follows:
- fsck_single
this will detect/verify filesystem, check if it has necessary tools and
check the filesystem respecting additional flags (if any), using
specific "driver" (or falling back to generic one). Currently
available: fsck_drv_{com,xfs,std}. 'com' is used for tools following
typical subset of options/return codes (e.g. ext, jfs), 'std' is used
for "unknown" fs and doesn't assume it can be run non-interactively.
Please see comments around the code for more info.
- fsck_batch
this will check provided list of the devices;
Both of the above functions will fake empty fstab, to make generic fsck
not complain too much (excact devices are always provided on the command
line).
"Known" filesystems currently: ext234, reiser, jfs, xfs
- det_fs
Small bug fixed - as this function is meant to be called in $(), it may
not be verbose.
Current behaviour is:
- if detection is successful, use its result
- if detection is not successful, and filesystem is provided, return
the provided one; otherwise use auto
14 years ago
|
|
|
type det_fs >/dev/null 2>&1 || . /lib/fs-lib.sh
|
|
|
|
|
implement fs-lib, squash a few bugs that were part of det_fs/wrap_fsck
To not pollute dracut-lib.sh, all the fsck related functions were moved
to fs-lib.sh. The functions available are as follows:
- fsck_single
this will detect/verify filesystem, check if it has necessary tools and
check the filesystem respecting additional flags (if any), using
specific "driver" (or falling back to generic one). Currently
available: fsck_drv_{com,xfs,std}. 'com' is used for tools following
typical subset of options/return codes (e.g. ext, jfs), 'std' is used
for "unknown" fs and doesn't assume it can be run non-interactively.
Please see comments around the code for more info.
- fsck_batch
this will check provided list of the devices;
Both of the above functions will fake empty fstab, to make generic fsck
not complain too much (excact devices are always provided on the command
line).
"Known" filesystems currently: ext234, reiser, jfs, xfs
- det_fs
Small bug fixed - as this function is meant to be called in $(), it may
not be verbose.
Current behaviour is:
- if detection is successful, use its result
- if detection is not successful, and filesystem is provided, return
the provided one; otherwise use auto
14 years ago
|
|
|
mount_root() {
|
|
|
|
local _ret
|
|
|
|
local _rflags_ro
|
|
|
|
# sanity - determine/fix fstype
|
implement fs-lib, squash a few bugs that were part of det_fs/wrap_fsck
To not pollute dracut-lib.sh, all the fsck related functions were moved
to fs-lib.sh. The functions available are as follows:
- fsck_single
this will detect/verify filesystem, check if it has necessary tools and
check the filesystem respecting additional flags (if any), using
specific "driver" (or falling back to generic one). Currently
available: fsck_drv_{com,xfs,std}. 'com' is used for tools following
typical subset of options/return codes (e.g. ext, jfs), 'std' is used
for "unknown" fs and doesn't assume it can be run non-interactively.
Please see comments around the code for more info.
- fsck_batch
this will check provided list of the devices;
Both of the above functions will fake empty fstab, to make generic fsck
not complain too much (excact devices are always provided on the command
line).
"Known" filesystems currently: ext234, reiser, jfs, xfs
- det_fs
Small bug fixed - as this function is meant to be called in $(), it may
not be verbose.
Current behaviour is:
- if detection is successful, use its result
- if detection is not successful, and filesystem is provided, return
the provided one; otherwise use auto
14 years ago
|
|
|
rootfs=$(det_fs "${root#block:}" "$fstype")
|
|
|
|
|
|
|
|
journaldev=$(getarg "root.journaldev=")
|
|
|
|
if [ -n "$journaldev" ]; then
|
|
|
|
case "$rootfs" in
|
|
|
|
xfs)
|
|
|
|
rflags="${rflags:+${rflags},}logdev=$journaldev"
|
|
|
|
;;
|
|
|
|
reiserfs)
|
|
|
|
fsckoptions="-j $journaldev $fsckoptions"
|
|
|
|
rflags="${rflags:+${rflags},}jdev=$journaldev"
|
|
|
|
;;
|
|
|
|
*);;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
|
|
|
_rflags_ro="$rflags,ro"
|
|
|
|
_rflags_ro="${_rflags_ro##,}"
|
|
|
|
|
|
|
|
while ! mount -t ${rootfs} -o "$_rflags_ro" "${root#block:}" "$NEWROOT"; do
|
|
|
|
warn "Failed to mount -t ${rootfs} -o $_rflags_ro ${root#block:} $NEWROOT"
|
|
|
|
fsck_ask_err
|
|
|
|
done
|
|
|
|
|
|
|
|
READONLY=
|
|
|
|
fsckoptions=
|
|
|
|
if [ -f "$NEWROOT"/etc/sysconfig/readonly-root ]; then
|
|
|
|
. "$NEWROOT"/etc/sysconfig/readonly-root
|
|
|
|
fi
|
|
|
|
|
|
|
|
if getargbool 0 "readonlyroot=" -y readonlyroot; then
|
|
|
|
READONLY=yes
|
|
|
|
fi
|
|
|
|
|
|
|
|
if getarg noreadonlyroot ; then
|
|
|
|
READONLY=no
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f "$NEWROOT"/fastboot ] || getargbool 0 fastboot ; then
|
|
|
|
fastboot=yes
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! getargbool 0 rd.skipfsck; then
|
|
|
|
if [ -f "$NEWROOT"/fsckoptions ]; then
|
|
|
|
fsckoptions=$(cat "$NEWROOT"/fsckoptions)
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f "$NEWROOT"/forcefsck ] || getargbool 0 forcefsck ; then
|
|
|
|
fsckoptions="-f $fsckoptions"
|
|
|
|
elif [ -f "$NEWROOT"/.autofsck ]; then
|
|
|
|
[ -f "$NEWROOT"/etc/sysconfig/autofsck ] && \
|
|
|
|
. "$NEWROOT"/etc/sysconfig/autofsck
|
|
|
|
if [ "$AUTOFSCK_DEF_CHECK" = "yes" ]; then
|
|
|
|
AUTOFSCK_OPT="$AUTOFSCK_OPT -f"
|
|
|
|
fi
|
|
|
|
if [ -n "$AUTOFSCK_SINGLEUSER" ]; then
|
|
|
|
warn "*** Warning -- the system did not shut down cleanly. "
|
|
|
|
warn "*** Dropping you to a shell; the system will continue"
|
|
|
|
warn "*** when you leave the shell."
|
|
|
|
emergency_shell
|
|
|
|
fi
|
|
|
|
fsckoptions="$AUTOFSCK_OPT $fsckoptions"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
rootopts=
|
|
|
|
if getargbool 1 rd.fstab -d -n rd_NO_FSTAB \
|
|
|
|
&& ! getarg rootflags \
|
|
|
|
&& [ -f "$NEWROOT/etc/fstab" ] \
|
|
|
|
&& ! [ -L "$NEWROOT/etc/fstab" ]; then
|
|
|
|
# if $NEWROOT/etc/fstab contains special mount options for
|
|
|
|
# the root filesystem,
|
|
|
|
# remount it with the proper options
|
|
|
|
rootopts="defaults"
|
|
|
|
while read dev mp fs opts dump fsck || [ -n "$dev" ]; do
|
|
|
|
# skip comments
|
|
|
|
[ "${dev%%#*}" != "$dev" ] && continue
|
|
|
|
|
|
|
|
if [ "$mp" = "/" ]; then
|
|
|
|
# sanity - determine/fix fstype
|
implement fs-lib, squash a few bugs that were part of det_fs/wrap_fsck
To not pollute dracut-lib.sh, all the fsck related functions were moved
to fs-lib.sh. The functions available are as follows:
- fsck_single
this will detect/verify filesystem, check if it has necessary tools and
check the filesystem respecting additional flags (if any), using
specific "driver" (or falling back to generic one). Currently
available: fsck_drv_{com,xfs,std}. 'com' is used for tools following
typical subset of options/return codes (e.g. ext, jfs), 'std' is used
for "unknown" fs and doesn't assume it can be run non-interactively.
Please see comments around the code for more info.
- fsck_batch
this will check provided list of the devices;
Both of the above functions will fake empty fstab, to make generic fsck
not complain too much (excact devices are always provided on the command
line).
"Known" filesystems currently: ext234, reiser, jfs, xfs
- det_fs
Small bug fixed - as this function is meant to be called in $(), it may
not be verbose.
Current behaviour is:
- if detection is successful, use its result
- if detection is not successful, and filesystem is provided, return
the provided one; otherwise use auto
14 years ago
|
|
|
rootfs=$(det_fs "${root#block:}" "$fs")
|
|
|
|
rootopts=$opts
|
|
|
|
rootfsck=$fsck
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done < "$NEWROOT/etc/fstab"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# we want rootflags (rflags) to take precedence so prepend rootopts to
|
|
|
|
# them
|
|
|
|
rflags="${rootopts},${rflags}"
|
|
|
|
rflags="${rflags#,}"
|
|
|
|
rflags="${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 fsck_able "$rootfs" && \
|
|
|
|
[ "$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"
|
implement fs-lib, squash a few bugs that were part of det_fs/wrap_fsck
To not pollute dracut-lib.sh, all the fsck related functions were moved
to fs-lib.sh. The functions available are as follows:
- fsck_single
this will detect/verify filesystem, check if it has necessary tools and
check the filesystem respecting additional flags (if any), using
specific "driver" (or falling back to generic one). Currently
available: fsck_drv_{com,xfs,std}. 'com' is used for tools following
typical subset of options/return codes (e.g. ext, jfs), 'std' is used
for "unknown" fs and doesn't assume it can be run non-interactively.
Please see comments around the code for more info.
- fsck_batch
this will check provided list of the devices;
Both of the above functions will fake empty fstab, to make generic fsck
not complain too much (excact devices are always provided on the command
line).
"Known" filesystems currently: ext234, reiser, jfs, xfs
- det_fs
Small bug fixed - as this function is meant to be called in $(), it may
not be verbose.
Current behaviour is:
- if detection is successful, use its result
- if detection is not successful, and filesystem is provided, return
the provided one; otherwise use auto
14 years ago
|
|
|
_ret=$?
|
|
|
|
ran_fsck=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "${root#block:} $NEWROOT $rootfs ${rflags:-defaults} 0 $rootfsck" >> /etc/fstab
|
|
|
|
|
|
|
|
if ! ismounted "$NEWROOT"; then
|
|
|
|
info "Mounting ${root#block:} with -o ${rflags}"
|
|
|
|
mount "$NEWROOT" 2>&1 | vinfo
|
|
|
|
elif ! are_lists_eq , "$rflags" "$_rflags_ro" defaults; then
|
|
|
|
info "Remounting ${root#block:} with -o ${rflags}"
|
|
|
|
mount -o remount "$NEWROOT" 2>&1 | vinfo
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! getargbool 0 rd.skipfsck; then
|
|
|
|
[ -f "$NEWROOT"/forcefsck ] && rm -f -- "$NEWROOT"/forcefsck 2>/dev/null
|
|
|
|
[ -f "$NEWROOT"/.autofsck ] && rm -f -- "$NEWROOT"/.autofsck 2>/dev/null
|
|
|
|
fi
|
implement fs-lib, squash a few bugs that were part of det_fs/wrap_fsck
To not pollute dracut-lib.sh, all the fsck related functions were moved
to fs-lib.sh. The functions available are as follows:
- fsck_single
this will detect/verify filesystem, check if it has necessary tools and
check the filesystem respecting additional flags (if any), using
specific "driver" (or falling back to generic one). Currently
available: fsck_drv_{com,xfs,std}. 'com' is used for tools following
typical subset of options/return codes (e.g. ext, jfs), 'std' is used
for "unknown" fs and doesn't assume it can be run non-interactively.
Please see comments around the code for more info.
- fsck_batch
this will check provided list of the devices;
Both of the above functions will fake empty fstab, to make generic fsck
not complain too much (excact devices are always provided on the command
line).
"Known" filesystems currently: ext234, reiser, jfs, xfs
- det_fs
Small bug fixed - as this function is meant to be called in $(), it may
not be verbose.
Current behaviour is:
- if detection is successful, use its result
- if detection is not successful, and filesystem is provided, return
the provided one; otherwise use auto
14 years ago
|
|
|
}
|
|
|
|
|
|
|
|
if [ -n "$root" -a -z "${root%%block:*}" ]; then
|
|
|
|
mount_root
|
|
|
|
fi
|