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