|
|
@ -1555,8 +1555,8 @@ rootdev_init() {
|
|
|
|
while true
|
|
|
|
while true
|
|
|
|
do
|
|
|
|
do
|
|
|
|
local got_good_root=
|
|
|
|
local got_good_root=
|
|
|
|
while [ "${got_good_root}" != '1' ]
|
|
|
|
while [ "${got_good_root}" != "1" ]; do
|
|
|
|
do
|
|
|
|
|
|
|
|
case "${REAL_ROOT}" in
|
|
|
|
case "${REAL_ROOT}" in
|
|
|
|
LABEL=*|UUID=*)
|
|
|
|
LABEL=*|UUID=*)
|
|
|
|
|
|
|
|
|
|
|
@ -1571,18 +1571,19 @@ rootdev_init() {
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
|
|
# move this cruft into a separate function? do we really need
|
|
|
|
# move this cruft into a separate function? do we really need
|
|
|
|
# the crazy root=ZFS= thing? can't we just detect the fstype?
|
|
|
|
# the crazy root=ZFS= thing? can't we just detect the fstype?
|
|
|
|
ZFS*)
|
|
|
|
ZFS*)
|
|
|
|
if [ "${USE_ZFS}" = '0' ]; then
|
|
|
|
if [ "${USE_ZFS}" = "0" ]; then
|
|
|
|
prompt_user "REAL_ROOT" "root block device"
|
|
|
|
prompt_user "REAL_ROOT" "root block device"
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
ROOT_DEV="${REAL_ROOT#*=}"
|
|
|
|
ROOT_DEV="${REAL_ROOT#*=}"
|
|
|
|
if [ "${ROOT_DEV}" != 'ZFS' ]
|
|
|
|
if [ "${ROOT_DEV}" != "ZFS" ]; then
|
|
|
|
then
|
|
|
|
local ztype=$(zfs get type -o value -H "${ROOT_DEV}")
|
|
|
|
if [ "$(zfs get type -o value -H ${ROOT_DEV})" = 'filesystem' ]
|
|
|
|
if [ "${ztype}" = "filesystem" ]; then
|
|
|
|
then
|
|
|
|
|
|
|
|
got_good_root=1;
|
|
|
|
got_good_root=1;
|
|
|
|
REAL_ROOT=${ROOT_DEV}
|
|
|
|
REAL_ROOT=${ROOT_DEV}
|
|
|
|
ROOTFSTYPE=zfs
|
|
|
|
ROOTFSTYPE=zfs
|
|
|
@ -1594,12 +1595,9 @@ rootdev_init() {
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
else
|
|
|
|
BOOTFS=$(/sbin/zpool list -H -o bootfs)
|
|
|
|
BOOTFS=$(/sbin/zpool list -H -o bootfs)
|
|
|
|
if [ "${BOOTFS}" != '-' ]
|
|
|
|
if [ "${BOOTFS}" != "-" ]; then
|
|
|
|
then
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for i in ${BOOTFS}
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for i in ${BOOTFS}; do
|
|
|
|
zfs get type ${i} > /dev/null
|
|
|
|
zfs get type ${i} > /dev/null
|
|
|
|
retval=$?
|
|
|
|
retval=$?
|
|
|
|
|
|
|
|
|
|
|
@ -1624,19 +1622,17 @@ rootdev_init() {
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
|
|
if [ "${REAL_ROOT}" = '' ]
|
|
|
|
if [ -z "${REAL_ROOT}" ]; then
|
|
|
|
then
|
|
|
|
# No REAL_ROOT determined/specified.
|
|
|
|
# No REAL_ROOT determined/specified. Prompt user for root block device.
|
|
|
|
# Prompt user for root block device.
|
|
|
|
prompt_user "REAL_ROOT" "root block device"
|
|
|
|
prompt_user "REAL_ROOT" "root block device"
|
|
|
|
got_good_root=0
|
|
|
|
got_good_root=0
|
|
|
|
|
|
|
|
|
|
|
|
# Check for a block device or NFS
|
|
|
|
# Check for a block device or NFS
|
|
|
|
elif [ -b "${REAL_ROOT}" ] || is_nfs
|
|
|
|
elif [ -b "${REAL_ROOT}" ] || is_nfs; then
|
|
|
|
then
|
|
|
|
|
|
|
|
got_good_root=1
|
|
|
|
got_good_root=1
|
|
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
else
|
|
|
|
bad_msg "Block device ${REAL_ROOT} is not a valid root device..."
|
|
|
|
bad_msg "${REAL_ROOT} is an invalid root device..."
|
|
|
|
REAL_ROOT=""
|
|
|
|
REAL_ROOT=""
|
|
|
|
got_good_root=0
|
|
|
|
got_good_root=0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
@ -1654,22 +1650,22 @@ rootdev_init() {
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
local fstype=$(get_device_fstype "${REAL_ROOT}")
|
|
|
|
local fstype=$(get_device_fstype "${REAL_ROOT}")
|
|
|
|
good_msg "Initializing ${REAL_ROOT} if needed, detected fstype: ${fstype}"
|
|
|
|
good_msg "Initializing ${REAL_ROOT} if needed"
|
|
|
|
|
|
|
|
good_msg "Detected fstype: ${fstype}"
|
|
|
|
fstype_init "${fstype}"
|
|
|
|
fstype_init "${fstype}"
|
|
|
|
|
|
|
|
|
|
|
|
good_msg "Mounting ${REAL_ROOT} as root..."
|
|
|
|
good_msg "Mounting ${REAL_ROOT} as root..."
|
|
|
|
|
|
|
|
local mount_state=ro
|
|
|
|
# TODO(lxnay): determine if it's possible to move this crufty thing into fstype_init
|
|
|
|
|
|
|
|
if [ "${ROOTFSTYPE}" = 'zfs' ]
|
|
|
|
# TODO(lxnay): determine if it's possible to move this
|
|
|
|
then
|
|
|
|
# crufty thing into fstype_init
|
|
|
|
if [ "$(zfs get -H -o value mountpoint ${REAL_ROOT})" = 'legacy' ]
|
|
|
|
if [ "${ROOTFSTYPE}" = "zfs" ]; then
|
|
|
|
then
|
|
|
|
local zmtype=$(zfs get -H -o value mountpoint "${REAL_ROOT}")
|
|
|
|
MOUNT_STATE=rw
|
|
|
|
if [ "${zmtype}" = "legacy" ]; then
|
|
|
|
|
|
|
|
mount_state=rw
|
|
|
|
else
|
|
|
|
else
|
|
|
|
MOUNT_STATE=rw,zfsutil
|
|
|
|
mount_state=rw,zfsutil
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
|
|
|
|
MOUNT_STATE=ro
|
|
|
|
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Try to mount the device as ${NEW_ROOT}
|
|
|
|
# Try to mount the device as ${NEW_ROOT}
|
|
|
@ -1677,19 +1673,18 @@ rootdev_init() {
|
|
|
|
find_nfs # sets ${?} checked below
|
|
|
|
find_nfs # sets ${?} checked below
|
|
|
|
else
|
|
|
|
else
|
|
|
|
# mount ro so fsck doesn't barf later
|
|
|
|
# mount ro so fsck doesn't barf later
|
|
|
|
if [ "${REAL_ROOTFLAGS}" = '' ]; then
|
|
|
|
local mopts="${mount_state}"
|
|
|
|
good_msg "Using mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE}"
|
|
|
|
[ -n "${REAL_ROOTFLAGS}" ] && \
|
|
|
|
mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE} ${REAL_ROOT} ${NEW_ROOT}
|
|
|
|
mopts="${mopts},${REAL_ROOTFLAGS}"
|
|
|
|
else
|
|
|
|
|
|
|
|
good_msg "Using mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE},${REAL_ROOTFLAGS}"
|
|
|
|
good_msg "Using mount -t ${ROOTFSTYPE} -o ${mopts}"
|
|
|
|
mount -t ${ROOTFSTYPE} -o ${MOUNT_STATE},${REAL_ROOTFLAGS} ${REAL_ROOT} ${NEW_ROOT}
|
|
|
|
mount -t "${ROOTFSTYPE}" -o "${mopts}" \
|
|
|
|
fi
|
|
|
|
"${REAL_ROOT}" "${NEW_ROOT}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# If mount is successful break out of the loop
|
|
|
|
# If mount is successful break out of the loop
|
|
|
|
# else not a good root and start over.
|
|
|
|
# else not a good root and start over.
|
|
|
|
if [ "$?" = '0' ]
|
|
|
|
if [ "${?}" = "0" ]; then
|
|
|
|
then
|
|
|
|
|
|
|
|
# now that the root filesystem is mounted, before
|
|
|
|
# now that the root filesystem is mounted, before
|
|
|
|
# checking the validity of ${NEW_ROOT} and ${REAL_INIT},
|
|
|
|
# checking the validity of ${NEW_ROOT} and ${REAL_INIT},
|
|
|
|
# ensure that ${NEW_ROOT}/etc/initramfs.mounts entries
|
|
|
|
# ensure that ${NEW_ROOT}/etc/initramfs.mounts entries
|
|
|
|