diff options
-rw-r--r-- | hooks/encrypt | 68 | ||||
-rw-r--r-- | hooks/lvm2 | 18 | ||||
-rw-r--r-- | install/base | 2 | ||||
-rw-r--r-- | install/dm | 17 | ||||
-rw-r--r-- | install/encrypt | 6 | ||||
-rw-r--r-- | install/lvm2 | 19 | ||||
-rw-r--r-- | mkinitcpio.conf | 5 |
7 files changed, 101 insertions, 34 deletions
diff --git a/hooks/encrypt b/hooks/encrypt index 8b4c80b..bf7bc9f 100644 --- a/hooks/encrypt +++ b/hooks/encrypt @@ -1,17 +1,61 @@ # vim: set ft=sh: +# TODO this one needs some work to work with lots of different +# encryption schemes run_hook () { - echo "" - echo "A password is required to access the root filesystem:" - echo -n "password: " - if /bin/cryptsetup.static isLuks ${root} >/dev/null 2>&1; then - /bin/cryptsetup.static luksOpen ${root} root - else - /bin/cryptsetup create root ${root} - fi + mkdevice () { /bin/mknod "/dev/mapper/control" c ${1} ${2}; } + if [ -e "/sys/class/misc/device-mapper" ]; then + /bin/modprobe -a -q dm-crypt >/dev/null 2>&1 + read dev_t < /sys/class/misc/device-mapper/dev + OLDIFS=$IFS; IFS=: + mkdevice $dev_t + IFS=$OLDIFS - if [ $? != 0 ]; then - echo "ERROR: Password Verification Failed" - exit 1 - fi + if /bin/cryptsetup isLuks ${root} >/dev/null 2>&1; then + echo "" + echo "A password is required to access the root filesystem:" + echo -n "password: " + /bin/cryptsetup luksOpen ${root} root + if [ $? -ne 0 ]; then + err "Password verification failed, aborting..." + exit 1 + else + if [ -e "/dev/mapper/root" ]; then + export root="/dev/mapper/root" + else + err "Password succeeded, but root creation failed, aborting..." + exit 1 + fi + fi + else + do_oldcrypto () + { + exe="/bin/cryptsetup create root ${root}" + [ "x${1}" != "x" ] && exe="$exe --hash \"${1}\"" + [ "x${2}" != "x" ] && exe="$exe --cipher \"${2}\"" + [ "x${3}" != "x" ] && exe="$exe --key-size \"${3}\"" + [ "x${4}" != "x" ] && exe="$exe --offset \"${4}\"" + [ "x${5}" != "x" ] && exe="$exe --skip \"${5}\"" + echo "" + echo "A password is required to access the root filesystem:" + echo -n "password: " + eval "${exe}" + } + msg "Non-LUKS encrypted device found..." + if [ "x${crypto}" != "x" ]; then + do_oldcrypt ${crypto} + if [ $? -ne 0 ]; then + err "Password verification failed, aborting..." + err "Verify parameter format: crypto=hash:cipher:keysize:offset:skip" + exit 1 + else + if [ -e "/dev/mapper/root" ]; then + export root="/dev/mapper/root" + else + err "Password succeeded, but root creation failed, aborting..." + exit 1 + fi + fi + fi + fi } diff --git a/hooks/lvm2 b/hooks/lvm2 new file mode 100644 index 0000000..a1788ce --- /dev/null +++ b/hooks/lvm2 @@ -0,0 +1,18 @@ +# vim:set ft=sh: +run_hook () +{ + mkdevice () { /bin/mknod "/dev/mapper/control" c ${1} ${2}; } + + if [ -e "/sys/class/misc/device-mapper" ]; then + /bin/modprobe -q dm-mod >/dev/null 2>&1 + read dev_t < /sys/class/misc/device-mapper/dev + OLDIFS=$IFS; IFS=: + mkdevice $dev_t + IFS=$OLDIFS + + msg "Scanning logical volumes..." + /bin/lvm vgscan --ignorelockingfailure + msg "Activating logical volumes..." + /bin/lvm vgchange --ignorelockingfailure -ay + fi +} diff --git a/install/base b/install/base index 170df1b..0bb45db 100644 --- a/install/base +++ b/install/base @@ -18,7 +18,7 @@ install () add_file $f /bin/$(basename $f) done - add_file "/lib/initramfs/init" "/init" + add_file "/lib/initcpio/init" "/init" add_file "${CONFIG}" "/config" SCRIPT="" } diff --git a/install/dm b/install/dm deleted file mode 100644 index 7011f5e..0000000 --- a/install/dm +++ /dev/null @@ -1,17 +0,0 @@ -# vim: set ft=sh: - -install () -{ - MODULES=" $(all_modules "/md/" | grep -v "raid")" - BINARIES="" - FILES="" - SCRIPT="UNKNOWN" -} - -help () -{ -cat<<HELPEOF - This hook loads the necessary modules for an device mapper device. - Detection will take place at runtime. -HELPEOF -} diff --git a/install/encrypt b/install/encrypt index e2087e4..d81966b 100644 --- a/install/encrypt +++ b/install/encrypt @@ -2,9 +2,11 @@ install () { - MODULES=" aes-i586 $(find "${MODULEDIR}/kernel/drivers/md" -name dm*.ko) " - BINARIES="cryptsetup.static" + MODULES=" dm-crypt $(all_modules "/crypto/") " + BINARIES="" + add_file "/sbin/cryptsetup.static" "/bin/cryptsetup" FILES="" + SCRIPT="encrypt" } help () diff --git a/install/lvm2 b/install/lvm2 new file mode 100644 index 0000000..c6cacc3 --- /dev/null +++ b/install/lvm2 @@ -0,0 +1,19 @@ +# vim: set ft=sh: + +install () +{ + MODULES=" dm-mod " + BINARIES="" + FILES="" + SCRIPT="lvm2" + + add_dir "/dev/mapper" + add_file "/sbin/lvm.static" "/bin/lvm" +} + +help () +{ +cat<<HELPEOF + This hook loads the necessary modules for an LVM2 root device. +HELPEOF +} diff --git a/mkinitcpio.conf b/mkinitcpio.conf index 9508d60..d248a6c 100644 --- a/mkinitcpio.conf +++ b/mkinitcpio.conf @@ -1,7 +1,8 @@ # vim:set ft=sh #MODULES="piix ide_disk reiserfs" -BINARIES="" +BINARIES="fbxine" FILES="" -HOOKS="base autodetect raid dm" +HOOKS="base autodetect" +# raid dm ide" #HOOKS="base" |