You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.1 KiB
Bash

#!/bin/bash
set -e
# / 1990GB /dev/sda1 & /dev/sdb1 btrfs raid1
# /boot 2GB /dev/md0
# /boot/efi 1GB /dev/sda3 || /dev/sdb3
# free 7GB
chroot="$1"
boot="hardware/${2}/boot"
esp="hardware/${2}/esp"
root="hardware/${2}/root"
# encrypt and unlock the root partitions
echo -n 'Enter LUKS password: '
read -s root_pwd
echo #to indicate progress after password prompt
for root in "sda1" "sdb1"; do
echo -n $root_pwd | cryptsetup -q luksFormat "/dev/$root"
echo -n $root_pwd | cryptsetup open --type luks "/dev/$root" "root-unlocked-$root"
done
unset root_pwd
# root device btrfs raid1
mkfs.btrfs /dev/mapper/root-unlocked-sda1
mount /dev/mapper/root-unlocked-sda1 "$chroot"
btrfs device add /dev/mapper/root-unlocked-sdb1 "$chroot" -f
btrfs balance start -dconvert=raid1 -mconvert=raid1 "$chroot"
# boot device ext4
echo mkfs.ext4 "$boot"
mkfs.ext4 "$boot"
echo mkdir "$chroot/boot"
mkdir "$chroot/boot"
echo mount "$boot" "$chroot/boot"
mount "$boot" "$chroot/boot"
# esp device FAT
mkfs.fat "$esp"
mkdir "$chroot/boot/efi"
mount "$esp" "$chroot/boot/efi"