Hello,
the scripts to generate a grub.cfg file doesn't find lvm under encrypted
partitions (arch).
Debian has fixed this problem elsewise but it would be nice to have a clean
way detecting such partitions.
I attach a patch to do so with an alternative /etc/grub.d/10_linux file
(cryptgrub2.patch).
Cryptswapgrub2.patch includes also a fix
for hibernation support with encrypted swap-partitions (it includes
every swap device in fstab invoked by the "resume=" command in the kernel
argument list,
so I'm not sure if this hasn't annoying consequences).
Regards,
Alex
--- a/etc/grub.d/10_linux 2011-06-13 07:58:20.000000000 +0200
+++ b/etc/grub.d/10_linux 2011-07-06 19:11:16.058849079 +0200
@@ -58,6 +58,45 @@ if [ "x`${grub_probe} --device ${GRUB_DE
GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
fi
fi
+cryptdetect ()
+{
+#lvm check
+
+if [ -e /sbin/lvs ]; then
+ lvmdevice=$(echo "${linux_root_device_thisversion}" | sed -e "s/-/\//g" -e "s/\/mapper\//\//g")
+ #lvmpath=$(lvs -a --noheadings -o lv_path | grep "$lvmdevice" | sed s/\ //g)
+ lvmname=$(lvs --noheadings -o vg_name $lvmdevice | sed s/\ //g)
+fi
+
+#both events are impossible without cryptsetup
+if [ -e /sbin/cryptsetup ]; then
+#luksdevice check
+ if cryptsetup isLuks ${linux_root_device_thisversion} &> /dev/null; then
+ cryptdevice_tmp="cryptdevice=${linux_root_device_thisversion}"
+ fi
+#lvm below luksdevice check
+#lvmcheck results from above
+ if [ $lvmname ]; then
+ lvmpvlist=$(vgs --noheadings -o pv_name $lvmname | sed s/\ //g)
+ for i in $lvmpvlist
+ do
+ if cryptsetup status $i &> /dev/null; then
+ cryptdevice_tmp="$cryptdevice_tmp cryptdevice=$(cryptsetup status $i | grep "device:" | sed -e "s/device://" -e "s/ //g"):$lvmname" &> /dev/null
+ fi
+ done
+ fi
+fi
+}
+
linux_entry ()
{
@@ -65,6 +104,8 @@ linux_entry ()
version="$2"
recovery="$3"
args="$4"
+ cryptdetect
if [ -n "$5" ] ; then
title="$(gettext_quoted "%s, with Linux %s") $5"
elif ${recovery} ; then
@@ -118,7 +159,7 @@ EOF
message="$(gettext_printf "Loading Linux %s ..." ${version})"
cat << EOF
echo '$message'
- linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
+ linux ${rel_dirname}/${basename} ${cryptdevice_tmp} root=${linux_root_device_thisversion} ro ${args}
EOF
if test -n "${initrd}" ; then
message="$(gettext_printf "Loading initial ramdisk ...")"
--- a/etc/grub.d/10_linux 2011-06-13 07:58:20.000000000 +0200
+++ b/etc/grub.d/10_linux 2011-07-06 19:11:16.058849079 +0200
@@ -58,6 +58,45 @@ if [ "x`${grub_probe} --device ${GRUB_DE
GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}"
fi
fi
+cryptdetect ()
+{
+#lvm check
+
+if [ -e /sbin/lvs ]; then
+ lvmdevice=$(echo "${linux_root_device_thisversion}" | sed -e "s/-/\//g" -e "s/\/mapper\//\//g")
+ #lvmpath=$(lvs -a --noheadings -o lv_path | grep "$lvmdevice" | sed s/\ //g)
+ lvmname=$(lvs --noheadings -o vg_name $lvmdevice | sed s/\ //g)
+fi
+
+#both events are impossible without cryptsetup
+if [ -e /sbin/cryptsetup ]; then
+#luksdevice check
+ if cryptsetup isLuks ${linux_root_device_thisversion} &> /dev/null; then
+ cryptdevice_tmp="cryptdevice=${linux_root_device_thisversion}"
+ fi
+#lvm below luksdevice check
+#lvmcheck results from above
+ if [ $lvmname ]; then
+ lvmpvlist=$(vgs --noheadings -o pv_name $lvmname | sed s/\ //g)
+ for i in $lvmpvlist
+ do
+ if cryptsetup status $i &> /dev/null; then
+ cryptdevice_tmp="$cryptdevice_tmp cryptdevice=$(cryptsetup status $i | grep "device:" | sed -e "s/device://" -e "s/ //g"):$lvmname" &> /dev/null
+ fi
+ done
+ fi
+fi
+}
+
+swapresumedetect()
+{
+ swapdev=""
+ swapdev_tmp=$(grep "swap" /etc/fstab | sed -e "s/ [^ ]\+//g" -e "s/ //g";)
+ if [ swapdev_tmp ]
+ then
+ swapdev="resume=$(echo $swapdev_tmp | sed "s/ / resume=/g")"
+ fi
+}
linux_entry ()
{
@@ -65,6 +104,8 @@ linux_entry ()
version="$2"
recovery="$3"
args="$4"
+ cryptdetect
+ swapresumedetect
if [ -n "$5" ] ; then
title="$(gettext_quoted "%s, with Linux %s") $5"
elif ${recovery} ; then
@@ -118,7 +159,7 @@ EOF
message="$(gettext_printf "Loading Linux %s ..." ${version})"
cat << EOF
echo '$message'
- linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
+ linux ${rel_dirname}/${basename} ${cryptdevice_tmp} ${swapdev} root=${linux_root_device_thisversion} ro ${args}
EOF
if test -n "${initrd}" ; then
message="$(gettext_printf "Loading initial ramdisk ...")"
_______________________________________________
Bug-grub mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-grub