|
|
@ -5,36 +5,39 @@ set -e
|
|
|
|
apt-get -y install mdadm cryptsetup debootstrap
|
|
|
|
apt-get -y install mdadm cryptsetup debootstrap
|
|
|
|
|
|
|
|
|
|
|
|
# returns /dev/md0 as root device
|
|
|
|
# returns /dev/md0 as root device
|
|
|
|
# returns /dev/md1 as boot device
|
|
|
|
# returns "$boot" as boot device
|
|
|
|
"./hardware/${1}/parted.sh" "$2"
|
|
|
|
"./hardware/${1}/parted.sh" "$2"
|
|
|
|
|
|
|
|
root="hardware/${1}/root"
|
|
|
|
|
|
|
|
boot="hardware/${1}/boot"
|
|
|
|
|
|
|
|
esp="hardware/${1}/esp"
|
|
|
|
|
|
|
|
|
|
|
|
# encrypt and unlock root device
|
|
|
|
# encrypt and unlock root device
|
|
|
|
echo -n 'Enter luks password: '
|
|
|
|
echo -n 'Enter luks password: '
|
|
|
|
read -s md0pwd
|
|
|
|
read -s root_pwd
|
|
|
|
echo #to indicate progress after password prompt
|
|
|
|
echo #to indicate progress after password prompt
|
|
|
|
echo -n $md0pwd | cryptsetup -q luksFormat /dev/md0
|
|
|
|
echo -n $root_pwd | cryptsetup -q luksFormat "$root"
|
|
|
|
echo -n $md0pwd | cryptsetup open --type luks /dev/md0 md0-unlocked
|
|
|
|
echo -n $root_pwd | cryptsetup open --type luks "$root" root-unlocked
|
|
|
|
unset md0pwd
|
|
|
|
unset root_pwd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# format
|
|
|
|
# format
|
|
|
|
|
|
|
|
|
|
|
|
chroot=/mnt/md0-unlocked
|
|
|
|
chroot=/mnt/root-unlocked
|
|
|
|
|
|
|
|
|
|
|
|
# root device
|
|
|
|
# root device
|
|
|
|
mkfs.btrfs /dev/mapper/md0-unlocked
|
|
|
|
mkfs.btrfs /dev/mapper/root-unlocked
|
|
|
|
mkdir /mnt/md0-unlocked
|
|
|
|
mkdir /mnt/root-unlocked
|
|
|
|
mount /dev/mapper/md0-unlocked /mnt/md0-unlocked
|
|
|
|
mount /dev/mapper/root-unlocked /mnt/root-unlocked
|
|
|
|
|
|
|
|
|
|
|
|
# boot device
|
|
|
|
# boot device
|
|
|
|
mkfs.btrfs /dev/md1
|
|
|
|
mkfs.btrfs "$boot"
|
|
|
|
mkdir "$chroot/boot"
|
|
|
|
mkdir "$chroot/boot"
|
|
|
|
mount /dev/md1 "$chroot/boot"
|
|
|
|
mount "$boot" "$chroot/boot"
|
|
|
|
|
|
|
|
|
|
|
|
# esp device
|
|
|
|
# esp device
|
|
|
|
mkfs.fat "hardware/${1}/esp"
|
|
|
|
mkfs.fat "$esp"
|
|
|
|
mkdir "$chroot/boot/efi"
|
|
|
|
mkdir "$chroot/boot/efi"
|
|
|
|
mount "hardware/${1}/esp" "$chroot/boot/efi"
|
|
|
|
mount "$esp" "$chroot/boot/efi"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# debootstrap
|
|
|
|
# debootstrap
|
|
|
|