Naposledy aktivní 2 days ago

Revize ee834bac52988a38691609b712adc7eec1b9566b

encrypted.sh Raw
1#! /usr/bin/env bash
2# adapted from https://docs.zfsbootmenu.org/en/v2.3.x/guides/ubuntu/uefi.html
3# script is not meant to be run non-interactively. read and understand before executing
4
5sudo -i
6
7source /etc/os-release
8export ID
9
10export POOL_DISK="/dev/sdg"
11export POOL_PART="3"
12export POOL_DEVICE="${POOL_DISK}${POOL_PART}"
13
14echo 'passphrase' > /etc/zfs/zroot.key
15chmod 000 /etc/zfs/zroot.key
16
17zpool create -f -o ashift=12 \
18 -O compression=zstd \
19 -O acltype=posixacl \
20 -O xattr=sa \
21 -O relatime=on \
22 -O encryption=aes-256-gcm \
23 -O keylocation=file:///etc/zfs/zroot.key \
24 -O keyformat=passphrase \
25 -o autotrim=on \
26 -o compatibility=openzfs-2.1-linux \
27 -m none zroot "$POOL_DEVICE"
28
29zfs create -o mountpoint=none zroot/ROOT
30zfs create -o mountpoint=/ -o canmount=noauto zroot/ROOT/${ID}
31zfs create -o mountpoint=/home zroot/home
32
33zpool set bootfs=zroot/ROOT/${ID} zroot
34
35zpool export zroot
36zpool import -N -R /mnt zroot
37zfs load-key -L prompt zroot
38
39zfs mount zroot/ROOT/${ID}
40zfs mount zroot/home
41
42udevadm trigger
43
44rsync -avAHXx --numeric-ids --exclude='/home' --exclude='/timeshift' /media/curiouser/5b30118c-3837-4895-9c60-70ea27dd36d9/ mnt/
45rsync -av --numeric-ids /media/curiouser/5b30118c-3837-4895-9c60-70ea27dd36d9/home/ mnt/home/
46
47mount -t proc proc mnt/proc
48mount -t sysfs sys mnt/sys
49mount -B /dev mnt/dev
50mount -t devpts pts mnt/dev/pts
51chroot mnt /bin/bash
52
53source /etc/os-release
54export ID
55
56apt update
57apt install zfs-initramfs zfsutils-linux
58
59systemctl enable zfs.target
60systemctl enable zfs-import-cache
61systemctl enable zfs-mount
62systemctl enable zfs-import.target
63
64echo "UMASK=0077" > /etc/initramfs-tools/conf.d/umask.conf
65
66update-initramfs -c -k all
67
68zfs set org.zfsbootmenu:commandline="systemd.show_status=false splash loglevel=0 quiet resume=UUID=9a4e4168-0964-4895-8d40-0e1ee0bf5d9a" zroot/ROOT
69zfs set org.zfsbootmenu:keysource="zroot/ROOT/${ID}" zroot
70
71exit
72
73umount -n -R /mnt
74zpool export zroot
75
76sudo -i
77apt remove kernelstub
78apt-mark hold kernelstub grub-pc grub-efi-amd64 grub-efi-amd64:i386 grub-efi-ia32 lilo
79# next time you have a kernel update, you'll likely have to upgrade with flags since we've held back dependencies
80sudo apt upgrade --with-new-pkgs linux-generic
81
82# assumes your ESP is mounted at /boot/efi
83
84# copy zbm boot files
85wget -qO- https://get.zfsboot.menu/components/release | tar xvz -C /boot/efi/EFI
86# ignore ownership errors
87mv /boot/efi/EFI/zfsbootmenu-release-x86_64-v* /boot/efi/EFI/zbm
88
89# add entries
90cat << EOF > /boot/efi/loader/entries/pop.conf
91title Pop!_OS
92linux /EFI/zbm/vmlinuz-bootmenu
93initrd /EFI/zbm/initramfs-bootmenu.img
94options zbm.skip systemd.show_status=false splash loglevel=0 quiet
95EOF
96
97cat << EOF > /boot/efi/loader/entries/zbm.conf
98title ZFSBootMenu
99linux /EFI/zbm/vmlinuz-bootmenu
100initrd /EFI/zbm/initramfs-bootmenu.img
101options zbm.show
102EOF
103
104echo 'default pop' > /boot/efi/loader/loader.conf
105
106# removing kernelstub entries and boot files
107rm /boot/efi/loader/entries/Pop-*
108rm -r /boot/efi/EFI/Pop*
109
110# reboot into system
111systemctl reboot
unencrypted.sh Raw
1#! /usr/bin/env bash
2# adapted from https://docs.zfsbootmenu.org/en/v2.3.x/guides/ubuntu/uefi.html
3# script is not meant to be run non-interactively. read and understand before executing
4
5sudo -i
6
7source /etc/os-release
8export ID
9
10export POOL_DEVICE="/dev/nvme1n1p3"
11
12zpool create -f -o ashift=12 \
13 -O compression=zstd \
14 -O acltype=posixacl \
15 -O xattr=sa \
16 -O relatime=on \
17 -o autotrim=on \
18 -o compatibility=openzfs-2.1-linux \
19 -m none zroot "$POOL_DEVICE"
20
21zfs create -o mountpoint=none zroot/ROOT
22zfs create -o mountpoint=/ -o canmount=noauto zroot/ROOT/${ID}
23zfs create -o mountpoint=/home zroot/home
24
25zpool set bootfs=zroot/ROOT/${ID} zroot
26
27zpool export zroot
28zpool import -N -R /mnt/shredder-zfs zroot
29
30zfs mount zroot/ROOT/${ID}
31zfs mount zroot/home
32
33udevadm trigger
34
35rsync -avAHXx --numeric-ids --exclude='/home' --exclude='/timeshift' /mnt/shredder/ /mnt/shredder-zfs/
36rsync -av --numeric-ids /mnt/shredder/home/ /mnt/shredder-zfs/home/
37umount /mnt/shredder
38
39mount -t proc /proc /mnt/shredder-zfs/proc
40mount -t sysfs /sys /mnt/shredder-zfs/sys
41mount -B /dev /mnt/shredder-zfs/dev
42mount -t devpts pts /mnt/shredder-zfs/dev/pts
43mount /dev/nvme1n1p1 /mnt/shredder-zfs/boot/efi
44chroot /mnt/shredder-zfs /bin/bash
45
46
47
48### now in zroot
49
50
51
52source /etc/os-release
53export ID
54
55apt update
56apt remove kernelstub
57apt-mark hold kernelstub grub-common grub-pc grub-efi-amd64-signed grub-efi-amd64:i386 grub-efi-amd64-bin grub-efi-ia32 lilo
58apt install zfs-initramfs zfsutils-linux zfs-dkms
59# next time you have a kernel update, you'll likely have to upgrade with flags since we've held back dependencies
60sudo apt upgrade --with-new-pkgs linux-generic
61
62systemctl enable zfs.target
63systemctl enable zfs-import-cache
64systemctl enable zfs-mount
65systemctl enable zfs-import.target
66
67echo "UMASK=0077" > /etc/initramfs-tools/conf.d/umask.conf
68
69update-initramfs -c -k all
70
71zfs set org.zfsbootmenu:commandline="systemd.show_status=false splash loglevel=0 quiet" zroot/ROOT
72
73# assumes your ESP is mounted at /boot/efi
74
75# removing kernelstub entries and boot files
76rm /boot/efi/loader/entries/Pop*
77rm -r /boot/efi/EFI/Pop*
78
79# copy zbm boot files
80wget -qO- https://get.zfsboot.menu/components/release | tar xvz -C /boot/efi/EFI
81# ignore ownership errors
82mv /boot/efi/EFI/zfsbootmenu-release-x86_64-v* /boot/efi/EFI/zbm
83
84# add entries
85cat << EOF > /boot/efi/loader/entries/pop.conf
86title Pop!_OS
87linux /EFI/zbm/vmlinuz-bootmenu
88initrd /EFI/zbm/initramfs-bootmenu.img
89options zbm.skip systemd.show_status=false splash loglevel=0 quiet
90EOF
91
92cat << EOF > /boot/efi/loader/entries/zbm.conf
93title ZFSBootMenu
94linux /EFI/zbm/vmlinuz-bootmenu
95initrd /EFI/zbm/initramfs-bootmenu.img
96options zbm.show
97EOF
98
99echo 'default pop' > /boot/efi/loader/loader.conf
100
101exit
102
103
104
105### out of zroot
106
107
108
109umount -n -R /mnt/shredder-zfs
110zpool export zroot
111
112# reboot into system
113systemctl reboot