| 1 | # to do, add instructions for revising EFI |
root.sh
· 2.0 KiB · Bash
Eredeti
#! /usr/bin/env bash
# adapted from https://docs.zfsbootmenu.org/en/v2.3.x/guides/ubuntu/uefi.html
source /etc/os-release
export ID
export POOL_DISK="/dev/sdg"
export POOL_PART="3"
export POOL_DEVICE="${POOL_DISK}${POOL_PART}"
echo 'passphrase' > /etc/zfs/zroot.key
chmod 000 /etc/zfs/zroot.key
zpool create -f -o ashift=12 \
-O compression=zstd \
-O acltype=posixacl \
-O xattr=sa \
-O relatime=on \
-O encryption=aes-256-gcm \
-O keylocation=file:///etc/zfs/zroot.key \
-O keyformat=passphrase \
-o autotrim=on \
-o compatibility=openzfs-2.1-linux \
-m none zroot "$POOL_DEVICE"
zfs create -o mountpoint=none zroot/ROOT
zfs create -o mountpoint=/ -o canmount=noauto zroot/ROOT/${ID}
zfs create -o mountpoint=/home zroot/home
zpool set bootfs=zroot/ROOT/${ID} zroot
zpool export zroot
zpool import -N -R /mnt zroot
zfs load-key -L prompt zroot
zfs mount zroot/ROOT/${ID}
zfs mount zroot/home
udevadm trigger
rsync -avAHXx --numeric-ids --exclude='/home' --exclude='/timeshift' /media/curiouser/5b30118c-3837-4895-9c60-70ea27dd36d9/ mnt/
rsync -av --numeric-ids /media/curiouser/5b30118c-3837-4895-9c60-70ea27dd36d9/home/ mnt/home/
mount -t proc proc mnt/proc
mount -t sysfs sys mnt/sys
mount -B /dev mnt/dev
mount -t devpts pts mnt/dev/pts
chroot mnt /bin/bash
source /etc/os-release
export ID
apt update
apt install zfs-initramfs zfsutils-linux
systemctl enable zfs.target
systemctl enable zfs-import-cache
systemctl enable zfs-mount
systemctl enable zfs-import.target
echo "UMASK=0077" > /etc/initramfs-tools/conf.d/umask.conf
update-initramfs -c -k all
zfs set org.zfsbootmenu:commandline="systemd.show_status=false splash loglevel=0 quiet resume=UUID=9a4e4168-0964-4895-8d40-0e1ee0bf5d9a" zroot/ROOT
zfs set org.zfsbootmenu:keysource="zroot/ROOT/${ID}" zroot
exit
umount -n -R /mnt
zpool export zroot
# reboot into system
sudo -i
apt remove kernelstub
cat <<EOF > /etc/apt/preferences.d/blacklist-kernelstub
Package: kernelstub
Pin: release *
Pin-Priority: -1
EOF
| 1 | #! /usr/bin/env bash |
| 2 | # adapted from https://docs.zfsbootmenu.org/en/v2.3.x/guides/ubuntu/uefi.html |
| 3 | |
| 4 | source /etc/os-release |
| 5 | export ID |
| 6 | |
| 7 | export POOL_DISK="/dev/sdg" |
| 8 | export POOL_PART="3" |
| 9 | export POOL_DEVICE="${POOL_DISK}${POOL_PART}" |
| 10 | |
| 11 | echo 'passphrase' > /etc/zfs/zroot.key |
| 12 | chmod 000 /etc/zfs/zroot.key |
| 13 | |
| 14 | zpool create -f -o ashift=12 \ |
| 15 | -O compression=zstd \ |
| 16 | -O acltype=posixacl \ |
| 17 | -O xattr=sa \ |
| 18 | -O relatime=on \ |
| 19 | -O encryption=aes-256-gcm \ |
| 20 | -O keylocation=file:///etc/zfs/zroot.key \ |
| 21 | -O keyformat=passphrase \ |
| 22 | -o autotrim=on \ |
| 23 | -o compatibility=openzfs-2.1-linux \ |
| 24 | -m none zroot "$POOL_DEVICE" |
| 25 | |
| 26 | zfs create -o mountpoint=none zroot/ROOT |
| 27 | zfs create -o mountpoint=/ -o canmount=noauto zroot/ROOT/${ID} |
| 28 | zfs create -o mountpoint=/home zroot/home |
| 29 | |
| 30 | zpool set bootfs=zroot/ROOT/${ID} zroot |
| 31 | |
| 32 | zpool export zroot |
| 33 | zpool import -N -R /mnt zroot |
| 34 | zfs load-key -L prompt zroot |
| 35 | |
| 36 | zfs mount zroot/ROOT/${ID} |
| 37 | zfs mount zroot/home |
| 38 | |
| 39 | udevadm trigger |
| 40 | |
| 41 | rsync -avAHXx --numeric-ids --exclude='/home' --exclude='/timeshift' /media/curiouser/5b30118c-3837-4895-9c60-70ea27dd36d9/ mnt/ |
| 42 | rsync -av --numeric-ids /media/curiouser/5b30118c-3837-4895-9c60-70ea27dd36d9/home/ mnt/home/ |
| 43 | |
| 44 | mount -t proc proc mnt/proc |
| 45 | mount -t sysfs sys mnt/sys |
| 46 | mount -B /dev mnt/dev |
| 47 | mount -t devpts pts mnt/dev/pts |
| 48 | chroot mnt /bin/bash |
| 49 | |
| 50 | source /etc/os-release |
| 51 | export ID |
| 52 | |
| 53 | apt update |
| 54 | apt install zfs-initramfs zfsutils-linux |
| 55 | |
| 56 | systemctl enable zfs.target |
| 57 | systemctl enable zfs-import-cache |
| 58 | systemctl enable zfs-mount |
| 59 | systemctl enable zfs-import.target |
| 60 | |
| 61 | echo "UMASK=0077" > /etc/initramfs-tools/conf.d/umask.conf |
| 62 | |
| 63 | update-initramfs -c -k all |
| 64 | |
| 65 | zfs set org.zfsbootmenu:commandline="systemd.show_status=false splash loglevel=0 quiet resume=UUID=9a4e4168-0964-4895-8d40-0e1ee0bf5d9a" zroot/ROOT |
| 66 | zfs set org.zfsbootmenu:keysource="zroot/ROOT/${ID}" zroot |
| 67 | |
| 68 | exit |
| 69 | |
| 70 | umount -n -R /mnt |
| 71 | zpool export zroot |
| 72 | # reboot into system |
| 73 | |
| 74 | sudo -i |
| 75 | apt remove kernelstub |
| 76 | cat <<EOF > /etc/apt/preferences.d/blacklist-kernelstub |
| 77 | Package: kernelstub |
| 78 | Pin: release * |
| 79 | Pin-Priority: -1 |
| 80 | EOF |
| 81 |