summaryrefslogtreecommitdiffstats
path: root/modules.d/90dm
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xmodules.d/90dm/dm-shutdown.sh34
-rwxr-xr-xmodules.d/90dmsquash-live/dmsquash-live-root.sh51
2 files changed, 54 insertions, 31 deletions
diff --git a/modules.d/90dm/dm-shutdown.sh b/modules.d/90dm/dm-shutdown.sh
index bd7134a..93b62bb 100755
--- a/modules.d/90dm/dm-shutdown.sh
+++ b/modules.d/90dm/dm-shutdown.sh
@@ -2,26 +2,40 @@
_remove_dm() {
local dev="$1"
+ local final="$2"
local s
local devname
for s in /sys/block/"${dev}"/holders/dm-*; do
[ -e "${s}" ] || continue
- _remove_dm "${s##*/}"
+ _remove_dm "${s##*/}" "$final" || return $?
done
- # multipath devices might have MD devices on top,
- # which are removed after this script. So do not
- # remove those to avoid spurious errors
+
+ read -r devname < /sys/block/"${dev}"/dm/name
case $(cat /sys/block/"${dev}"/dm/uuid) in
mpath-*)
+ # multipath devices might have MD devices on top,
+ # which are removed after this script. So do not
+ # remove those to avoid spurious errors
return 0
;;
- *)
- read -r devname < /sys/block/"${dev}"/dm/name
- dmsetup -v --noudevsync remove "$devname" || return $?
+ CRYPT-*)
+ if command -v systemd-cryptsetup > /dev/null; then
+ DM_DISABLE_UDEV=true SYSTEMD_LOG_LEVEL=debug systemd-cryptsetup detach "$devname" && return 0
+ elif command -v cryptsetup > /dev/null; then
+ DM_DISABLE_UDEV=true cryptsetup close --debug "$devname" && return 0
+ else
+ dmsetup -v --noudevsync remove "$devname"
+ return $?
+ fi
+
+ # try using plain dmsetup if we're on the final attempt.
+ [ -z "$final" ] && return 1
;;
esac
- return 0
+
+ dmsetup -v --noudevsync remove "$devname"
+ return $?
}
_do_dm_shutdown() {
@@ -33,9 +47,9 @@ _do_dm_shutdown() {
for dev in /sys/block/dm-*; do
[ -e "${dev}" ] || continue
if [ "x$final" != "x" ]; then
- _remove_dm "${dev##*/}" || ret=$?
+ _remove_dm "${dev##*/}" "$final" || ret=$?
else
- _remove_dm "${dev##*/}" > /dev/null 2>&1 || ret=$?
+ _remove_dm "${dev##*/}" "$final" > /dev/null 2>&1 || ret=$?
fi
done
if [ "x$final" != "x" ]; then
diff --git a/modules.d/90dmsquash-live/dmsquash-live-root.sh b/modules.d/90dmsquash-live/dmsquash-live-root.sh
index e808339..4518852 100755
--- a/modules.d/90dmsquash-live/dmsquash-live-root.sh
+++ b/modules.d/90dmsquash-live/dmsquash-live-root.sh
@@ -59,27 +59,34 @@ get_check_dev() {
echo "$_udevinfo" | grep "DEVNAME=" | sed 's/DEVNAME=//'
}
-# Find the right device to run check on
-check_dev=$(get_check_dev "$livedev")
-# CD/DVD media check
-[ -b "$check_dev" ] && fs=$(det_fs "$check_dev")
-if [ "$fs" = "iso9660" -o "$fs" = "udf" ]; then
- check="yes"
-fi
-getarg rd.live.check -d check || check=""
-if [ -n "$check" ]; then
- type plymouth > /dev/null 2>&1 && plymouth --hide-splash
- if [ -n "$DRACUT_SYSTEMD" ]; then
- p=$(dev_unit_name "$check_dev")
- systemctl start checkisomd5@"${p}".service
- else
- checkisomd5 --verbose "$check_dev"
+# Check ISO checksum only if we have a path to a block device (or just its name
+# without '/dev'). In other words, in this context, we perform the check only
+# if the given $livedev is not a filesystem file image.
+if [ ! -f "$livedev" ]; then
+ # Find the right device to run check on
+ check_dev=$(get_check_dev "$livedev")
+ # CD/DVD media check
+ [ -b "$check_dev" ] && fs=$(det_fs "$check_dev")
+ if [ "$fs" = "iso9660" -o "$fs" = "udf" ]; then
+ check="yes"
fi
- if [ $? -eq 1 ]; then
- die "CD check failed!"
- exit 1
+ getarg rd.live.check -d check || check=""
+ if [ -n "$check" ]; then
+ type plymouth > /dev/null 2>&1 && plymouth --hide-splash
+ if [ -n "$DRACUT_SYSTEMD" ]; then
+ p=$(dev_unit_name "$check_dev")
+ systemctl start checkisomd5@"${p}".service
+ else
+ checkisomd5 --verbose "$check_dev"
+ fi
+ if [ $? -eq 1 ]; then
+ warn "Media check failed! We do not recommend using this medium. System will halt in 12 hours"
+ sleep 43200
+ die "Media check failed!"
+ exit 1
+ fi
+ type plymouth > /dev/null 2>&1 && plymouth --show-splash
fi
- type plymouth > /dev/null 2>&1 && plymouth --show-splash
fi
ln -s "$livedev" /run/initramfs/livedev
@@ -109,7 +116,7 @@ if [ -f "$livedev" ]; then
auto) die "cannot mount live image (unknown filesystem type)" ;;
*) FSIMG=$livedev ;;
esac
- [ -e /sys/fs/"$fstype" ] || modprobe "$fstype"
+ load_fstype "$fstype"
else
livedev_fstype=$(det_fs "$livedev")
if [ "$livedev_fstype" = "squashfs" ]; then
@@ -143,6 +150,8 @@ do_live_overlay() {
if [ -z "$pathspec" -o "$pathspec" = "auto" ]; then
pathspec="/${live_dir}/overlay-$l-$u"
+ elif ! str_starts "$pathspec" "/"; then
+ pathspec=/"${pathspec}"
fi
devspec=${overlay%%:*}
@@ -296,7 +305,7 @@ do_live_overlay() {
dmsetup message /dev/mapper/live-overlay-pool 0 "create_thin 0"
# Create a snapshot of the base image
- echo 0 "$sz" thin /dev/mapper/live-overlay-pool 0 "$base" | dmsetup create live-rw
+ echo 0 "$thin_data_sz" thin /dev/mapper/live-overlay-pool 0 "$base" | dmsetup create live-rw
elif [ -z "$overlayfs" ]; then
echo 0 "$sz" snapshot "$base" "$over" PO 8 | dmsetup create live-rw
fi