-
-
Save RichieB2B/bf57c77cfff4c0805eeefa08ef11fbfb to your computer and use it in GitHub Desktop.
Mount zfs from luks-encrypted drive when booting from Ubuntu Live CD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo "Select disk:" | |
select CHOICE_DISK in $(ls /dev/disk/by-id/ | grep -v "\-part"); | |
do | |
echo "Selected ${CHOICE_DISK}" | |
break | |
done | |
echo "Select root partition:" | |
select CHOICE_PART in $(ls /dev/disk/by-id/ | grep ${CHOICE_DISK}- | sed "s/$CHOICE_DISK//"); | |
do | |
echo "Selected ${CHOICE_PART}" | |
break | |
done | |
# Install zfs-support | |
sudo apt-get update | |
sudo apt install --yes zfsutils-linux | |
# open encrypted disk | |
sudo cryptsetup luksOpen /dev/disk/by-id/${CHOICE_DISK}${CHOICE_PART} luks1 | |
sudo zpool import -N -R /mnt rpool | |
sudo zfs mount rpool/ROOT/ubuntu | |
sudo zfs mount rpool/home | |
# TODO: Let user select partitions for boot and efi, perhaps using `blkid` to identify partitions | |
sudo mount /dev/disk/by-id/${CHOICE_DISK}-part4 /mnt/boot/ | |
sudo mount /dev/disk/by-id/${CHOICE_DISK}-part3 /mnt/boot/efi/ | |
sudo mount --rbind /dev /mnt/dev/ | |
sudo mount --rbind /proc /mnt/proc | |
sudo mount --rbind /sys /mnt/sys | |
sudo mount --rbind /run /mnt/run | |
sudo chroot /mnt /bin/bash --login | |
# ln -s /dev/mapper/luks1 /dev/luks1 | |
# update-grub | |
# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ubuntu --recheck --no-floppy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Added /run because of udev