make fstab more flexible

master
lub 5 years ago
parent d9e0b99e1c
commit a81a3b18a9

@ -3,6 +3,6 @@
# #
# <file system> <dir> <type> <options> <dump> <pass> # <file system> <dir> <type> <options> <dump> <pass>
/dev/mapper/md0-unlocked / btrfs relatime 0 0 UUID=%root_uuid% / btrfs relatime 0 0
/dev/md1 /boot btrfs relatime 0 0 UUID=%boot_uuid% /boot btrfs relatime 0 0
UUID=%esp_uuid% /boot/efi vfat relatime 0 0 UUID=%esp_uuid% /boot/efi vfat relatime 0 0

@ -42,8 +42,12 @@ apt-get -y install grub-efi-amd64
update-grub update-grub
grub-install grub-install
# edit esp_uuid in fstab # edit uuids in fstab
root_uuid=$(blkid --output value "/dev/mapper/root-unlocked" | head -n1)
boot_uuid=$(blkid --output value "/hardware-setup/hardware/${1}/boot" | head -n1)
esp_uuid=$(blkid --output value "/hardware-setup/hardware/${1}/esp" | head -n1) esp_uuid=$(blkid --output value "/hardware-setup/hardware/${1}/esp" | head -n1)
sed -i "s/%root_uuid%/${root_uuid}/" /etc/fstab
sed -i "s/%boot_uuid%/${boot_uuid}/" /etc/fstab
sed -i "s/%esp_uuid%/${esp_uuid}/" /etc/fstab sed -i "s/%esp_uuid%/${esp_uuid}/" /etc/fstab

@ -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

Loading…
Cancel
Save