| Server IP : 172.67.201.108 / Your IP : 216.73.216.37 Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5 System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64 User : ec2-user ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /lib/dracut/modules.d/90dm/ |
Upload File : |
#!/usr/bin/sh
_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##*/}" "$final" || return $?
done
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
;;
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
dmsetup -v --noudevsync remove "$devname"
return $?
}
_do_dm_shutdown() {
local ret=0
local final="$1"
local dev
info "Disassembling device-mapper devices"
for dev in /sys/block/dm-*; do
[ -e "${dev}" ] || continue
if [ "x$final" != "x" ]; then
_remove_dm "${dev##*/}" "$final" || ret=$?
else
_remove_dm "${dev##*/}" "$final" > /dev/null 2>&1 || ret=$?
fi
done
if [ "x$final" != "x" ]; then
info "dmsetup ls --tree"
dmsetup ls --tree 2>&1 | vinfo
fi
return $ret
}
if command -v dmsetup > /dev/null \
&& [ "x$(dmsetup status)" != "xNo devices found" ]; then
_do_dm_shutdown "$1"
else
:
fi