return 1
}
+grml_match_bootid()
+{
+ path="$1"
+
+ if [ -n "$IGNORE_BOOTID" ] ; then
+ echo " * Ignoring verification of bootid.txt as requested via ignore_bootid.">>/boot.log
+ return 0
+ fi
+
+ if [ -n "$BOOTID" ] && ! [ -r "${path}/conf/bootid.txt" ] ; then
+ echo " * Warning: bootid=... specified but no bootid.txt found on currently requested device.">>/boot.log
+ return 1
+ fi
+
+ [ -r "${path}/conf/bootid.txt" ] || return 0
+
+ bootid_conf=$(cat "${path}/conf/bootid.txt")
+
+ if [ -z "$BOOTID" -a -z "$IGNORE_BOOTID" ]
+ then
+ echo " * Warning: bootid.txt found but ignore_bootid / bootid=.. bootoption missing...">>/boot.log
+ return 1
+ fi
+
+ if [ "$BOOTID" = "$bootid_conf" ]
+ then
+ echo " * Successfully verified /conf/bootid.txt from ISO, continuing... ">>/boot.log
+ else
+ echo " * Warning: BOOTID of ISO does not match. Retrying and continuing search...">>/boot.log
+ return 1
+ fi
+
+ return 0
+}
+
+
matches_uuid ()
{
if [ "${IGNORE_UUID}" ] || [ ! -e /conf/uuid.conf ]
# support for fromiso=.../isofrom=....
if [ -n "$FROMISO" ]
then
- ISO_DEVICE=$(dirname $FROMISO)
+ fs_type="${FROMISO%%:*}"
+ fs_type_auto='1'
+ ISO_DEVICE="${FROMISO}"
+ if echo "${fs_type}" | grep -q '[^[:alnum:]_-]'; then
+ # Not a valid file system name. Treat as part of the
+ # path, and, especially, use autodetection.
+ fs_type=''
+ else
+ # Looks like a file system specification, treat it
+ # like that.
+ fs_type_auto='0'
+ ISO_DEVICE="${ISO_DEVICE#*:}"
+ fi
+ ISO_DEVICE=$(dirname "${ISO_DEVICE}")
if ! [ -b $ISO_DEVICE ]
then
# to support unusual device names like /dev/cciss/c0d0p1
# example an ISO when booting on an ONIE system
if echo "${FROMISO}" | grep -q "\.iso$"
then
- fs_type=$(get_fstype "${FROMISO}")
+ if [ '0' -ne "${fs_type_auto}" ]; then
+ # Autodetect fs type if not overridden.
+ fs_type=$(get_fstype "${FROMISO}")
+ fi
if is_supported_fs ${fs_type}
then
mkdir /run/live/fromiso
- mount -t $fs_type "${FROMISO}" /run/live/fromiso
+ mount -t "${fs_type}" -o 'ro' "${FROMISO}" '/run/live/fromiso'
if [ "$?" != 0 ]
then
- echo "Warning: unable to mount ${FROMISO}." >>/boot.log
+ echo "Warning: unable to mount ${FROMISO} (type ${fs_type})." >>/boot.log
fi
devname="/run/live/fromiso"
fi
echo "Warning: device for bootoption fromiso= ($FROMISO) not found.">>/boot.log
fi
else
- fs_type=$(get_fstype "${ISO_DEVICE}")
+ # Need to extract actual ISO file path later on,
+ # initialize first.
+ iso_name="${FROMISO}"
+
+ if [ '0' -ne "${fs_type_auto}" ]; then
+ # Try to auto-detect file system if not
+ # explicitly provided.
+ fs_type=$(get_fstype "${ISO_DEVICE}")
+ else
+ # Delete file system type override.
+ iso_name="${iso_name#*:}"
+ fi
+ # At this point, the backing device should always be
+ # at the very front, so remove that - leaving only the
+ # ISO file path.
+ iso_name="$(echo "${iso_name}" | sed "s|^${ISO_DEVICE}||")"
if is_supported_fs ${fs_type}
then
mkdir /run/live/fromiso
- mount -t $fs_type "$ISO_DEVICE" /run/live/fromiso
- ISO_NAME="$(echo $FROMISO | sed "s|$ISO_DEVICE||")"
- loopdevname=$(setup_loop "/run/live/fromiso/${ISO_NAME}" "loop" "/sys/block/loop*" "" '')
+ mount -t "${fs_type}" -o 'ro' "$ISO_DEVICE" '/run/live/fromiso'
+ loopdevname=$(setup_loop "/run/live/fromiso/${iso_name}" "loop" "/sys/block/loop*" "" '')
devname="${loopdevname}"
else
- echo "Warning: unable to mount $ISO_DEVICE." >>/boot.log
+ echo "Warning: unable to mount $ISO_DEVICE (type ${fs_type})." >>/boot.log
fi
fi
fi
fi
if is_live_path ${mountpoint} && \
- ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
+ ([ "${skip_uuid_check}" ] || grml_match_bootid ${mountpoint})
then
echo ${mountpoint}
return 0
return 0
fi
done
- elif [ "${fstype}" = "squashfs" -o \
- "${fstype}" = "btrfs" -o \
- "${fstype}" = "ext2" -o \
- "${fstype}" = "ext3" -o \
- "${fstype}" = "ext4" -o \
- "${fstype}" = "jffs2" ]
- then
- # This is an ugly hack situation, the block device has
- # an image directly on it. It's hopefully
- # live-boot, so take it and run with it.
- ln -s "${devname}" "${devname}.${fstype}"
- echo "${devname}.${fstype}"
- return 0
fi
done
fi
# Try to look if it is already supported by the kernel
+ # For ntfs, since user space program ntfs-3g will be used. Check ntfs-3g instead of kernel module.
+ if [ "${fstype}" = "ntfs" ]; then
+ if type ntfs-3g >/dev/null 2>&1; then
+ return 0
+ else
+ return 1
+ fi
+ fi
if grep -q ${fstype} /proc/filesystems
then
return 0
fstype=$(get_fstype "${dev}")
fi
mount -t "${fstype}" -o "${opts}" "${dev}" "${mountp}" || \
- ( echo "SKIPPING: Cannot mount ${dev} on ${mountp}, fstype=${fstype}, options=${opts}" > boot.log && return 0 )
+ ( echo "SKIPPING: Cannot mount ${dev} on ${mountp}, fstype=${fstype}, options=${opts}" >> boot.log && return 0 )
fi
}
then
mount_opts="ro,noatime"
fi
- if mount -t "${fstype}" -o "${mount_opts}" "${device}" "${backing}" >/dev/null
+ if mount -t "${fstype}" -o "${mount_opts}" "${device}" "${backing}" >/dev/null 2>&1
then
echo ${backing}
return 0
# + a workdir to become mounted
# + workdir and upperdir to reside under the same mount
# + workdir and upperdir to be in separate directories
- mkdir "${unionrw}/rw"
- mkdir "${unionrw}/work"
+ mkdir -p "${unionrw}/rw"
+ mkdir -p "${unionrw}/work"
unionmountopts="-o noatime,lowerdir=${unionro},upperdir=${unionrw}/rw,workdir=${unionrw}/work"
;;
esac