From fc786924009b1b6287a7e83d2ece6b82f780093e Mon Sep 17 00:00:00 2001 From: Benjamin Schieder Date: Tue, 25 Apr 2006 17:05:36 +0000 Subject: [PATCH] Benjamin Schieder: Automatically adjust Device-Mapper (encrypted filesystem) configuration Create a mechanism to automatically recreate the initrd if necessary Changes: mechanism is now in initrd itself, not in an init script WARNING: This is still untested! Please wait for a comment from me :) [2006031713044803603] (https://www.rocklinux.net/submaster) git-svn-id: http://www.rocklinux.org/svn/rock-linux/trunk@7539 c5f82cb5-29bc-0310-9cd0-bff59a50e3bc --- package/base/device-mapper/etc_conf_dm_initrd_dm | 6 ++++-- package/base/device-mapper/etc_stone.d_mod_dm.sh | 2 ++ package/base/rockinitrd/init | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/package/base/device-mapper/etc_conf_dm_initrd_dm b/package/base/device-mapper/etc_conf_dm_initrd_dm index 0903c692f..feb7b9be8 100644 --- a/package/base/device-mapper/etc_conf_dm_initrd_dm +++ b/package/base/device-mapper/etc_conf_dm_initrd_dm @@ -100,7 +100,8 @@ while read device mountpoint status ; do fi [ "${mountpoint}" == "/" ] && rootfsmounted=1 echo "done" - echo "Remember to change the status of ${device} to encrypted using stone." + sed -e "s,^${device}\(.*\)encrypt,${device}\\1encrypted," -i /root/etc/conf/dm/mounts + recreateinitrd=1 echo "Press enter to continue" read < /dev/console continue @@ -186,7 +187,8 @@ while read device mountpoint status ; do fi [ "${mountpoint}" == "/" ] && rootfsmounted=1 echo "done" - echo "Remember to change the status of ${device} to 'plain' using stone." + sed -e "s,^${device}\(.*\)decrypt,${device}\\1plain," -i /root/etc/conf/dm/mounts + recreateinitrd=1 echo "Press enter to continue" read < /dev/console continue diff --git a/package/base/device-mapper/etc_stone.d_mod_dm.sh b/package/base/device-mapper/etc_stone.d_mod_dm.sh index 2e17b7fca..cd4db2c30 100644 --- a/package/base/device-mapper/etc_stone.d_mod_dm.sh +++ b/package/base/device-mapper/etc_stone.d_mod_dm.sh @@ -119,5 +119,7 @@ modprobe $x # added by mod_dm [ -e "/sbin/fsck.${fs}" ] && echo "/sbin/fsck.${fs} /sbin/fsck.${fs}" done < <( mount ) | sort | uniq >>/etc/conf/initrd/initrd_dm echo "/sbin/fsck /sbin/fsck" >>/etc/conf/initrd/initrd_dm + + mkinitrd } diff --git a/package/base/rockinitrd/init b/package/base/rockinitrd/init index c51813b92..0cd3aea96 100644 --- a/package/base/rockinitrd/init +++ b/package/base/rockinitrd/init @@ -50,6 +50,7 @@ PATH="/sbin:/usr/sbin:/bin/:/usr/bin" rootfs="" rootfsmounted=0 +recreateinitrd=0 mount -n -t tmpfs tmpfs /tmp || echo "Can't mount tmpfs!" mount -n -t proc proc /proc || echo "Can't mount procfs!" @@ -107,4 +108,8 @@ killall udevd # additional programs can be applied (like persistent storage, et alas) emit_udev_events +if [ "${recreateinitrd}" != "0" ] ; then + echo "Recreating initrd" + chroot . /sbin/mkinitrd < /dev/console > /dev/console 2>&1 +fi exec chroot . $real_init "${@}" < /dev/console > /dev/console 2>&1