Setting up initramfs-tools preparing and creating the initrd image
Add the encryption information to crypttab
Code:
echo "btcrypt /dev/sda2 none luks,retry=1,lvm=btcrypt" >> /etc/crypttab
Make fstab and lilo.conf look like the following
Code:
/dev/mapper/btcrypt-root / auto defaults 0 0
/dev/mapper/btcrypt-swap none swap auto,defaults,pri=1 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
tmpfs /dev/shm tmpfs defaults 0 0
LABEL=boot /boot ext2 auto,noatime 0 0
Code:
nano /etc/lilo.conf
Code:
lba32
boot=/dev/sda
large-memory
prompt
timeout=50
vga=0x317
image=/boot/vmlinuz
label="BT4"
read-only
initrd=/boot/initrd.img-2.6.28.1
root= /dev/mapper/btcrypt-root
Add the encryption modules to the initramfs-tools config file
Code:
nano /etc/initramfs-tools/modules
Check the initramfs config file for MODULES=most
Code:
nano /etc/initramfs-tools/initramfs.conf
Create a blank modules.dep file, without which I have some errors on booting
Code:
mkdir -p /etc/initramfs-tools/lib/modules/2.6.28.1/
touch /etc/initramfs-tools/lib/modules/2.6.28.1/modules.dep
depmod -a
Fix the default resume partition, so suspend can work
Code:
blkid /dev/mapper/btcrypt-swap
add this to /etc/initramfs-tools/conf.d/resume
replace /dev/sd* with the UUID from the previous command
Code:
nano /etc/initramfs-tools/conf.d/resume
Code:
RESUME=UUID=e0eb116b-b425-4896-8faa-279f18ca0341
Ok let's make an initrd,
Code:
update-initramfs -k all -c
ls -l /boot/
You will see initrd.img-2.6.28.1 in your boot partition, this is our newly created initrd
Checking the initrd image
Code:
cd /root/
mkdir tmp
cd tmp
Decompress the initrd and pipe it through cpio
Code:
gzip -dc /boot/initrd.img-2.6.28.1 | cpio -id
You can see the the file system of the initrd image laid out
First check that the encrypted partitions were being picked up properly by the update-initramfs script (Line should read as below)
Code:
cat conf/conf.d/cryptroot
Code:
target=btcrypt,source=/dev/sda2,key=none,lvm=btcrypt-root,lvm=btcrypt
Then check the modules directory
Code:
ls -l lib/modules/2.6.28.1/
If there is no modules.dep file in lib/modules/2.6.28.1/ then create it
Code:
touch lib/modules/2.6.28.1/modules.dep
And repack the files
Code:
find ./ | cpio -H newc -o > /boot/initrd.img-2.6.28.1.new
gzip and renamed the initrd
Code:
cd /boot/
gzip initrd.img-2.6.28.1.new
mv initrd.img-2.6.28.1.new.gz initrd.img-2.6.28.1
Cleaning up
Ran lilo, exit chroot and rebooted
Sources and Further Reading
Code:
hxxp://forums.remote-exploit.org/showthread.php?t=19550
man cpio
man initramfs-tools
man initramfs.conf
man update-initramfs
man mkinitramfs
man crypttab
Thanks for the release guys.