--- 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 ...")"