Linux/Ubuntu/HardyRAID5EncryptedLVM: update-liveCD-RAIDencryptedLVM.sh

File update-liveCD-RAIDencryptedLVM.sh, 1.1 KB (added by tj, 9 years ago)

Recreates the installation chroot environment when using the LiveCD

Line 
1#!/bin/bash
2if [ -z "$KEYFILE" ]; then
3        echo "Please assign the name of the LUKS key-file to KEYFILE (KEYFILE=\"/path/file.ext\")"
4else
5        swapoff -a
6        cat /proc/swaps
7        apt-get install mdadm cryptsetup lvm2
8        modprobe dm-crypt
9        mdadm -A /dev/md0
10        mdadm -A /dev/md1 /dev/sdb1 /dev/sdd1
11        mdadm -A /dev/md2
12        cat /proc/mdstat
13        cryptsetup luksOpen /dev/md2 md2encrypted --key-file /media/casper-rw/$KEYFILE
14        if [ $? -eq 0 ]; then
15                lvdisplay
16                MNT="/mnt/target"
17                mkdir ${MNT}
18                mount /dev/mapper/VGraid5-root ${MNT}
19                mount /dev/mapper/VGraid5-var ${MNT}/var
20                mount /dev/mapper/VGraid5-home ${MNT}/home
21                mount /dev/md0 ${MNT}/boot
22                mount -o bind /proc ${MNT}/proc
23                mount -o bind /dev ${MNT}/dev
24                KEYSCRIPT="/usr/local/sbin/crypto-usb-key.sh"
25                wget http://tjworld.net/raw-attachment/wiki/Linux/Ubuntu/HardyRAID5EncryptedLVM/crypto-usb-key.sh -O ${MNT}${KEYSCRIPT}
26                # cp Desktop/crypto-usb-key.sh ${MNT}${KEYSCRIPT}
27                chroot ${MNT} /bin/bash -c "chown root:root ${KEYSCRIPT}; chmod a+x ${KEYSCRIPT}"
28                ls -l ${MNT}/usr/local/sbin/
29                chroot ${MNT} /bin/bash -c "update-initramfs -u all"
30        fi
31fi
32