use zfs
This commit is contained in:
parent
df2c614845
commit
b33c9a7c2a
|
@ -54,14 +54,45 @@ mkfs.fat -F 32 -n EFIBOOT $DISK-part1
|
||||||
|
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
# create the crypto container
|
# ZFS zpool creation with encryption
|
||||||
cryptsetup luksFormat --batch-mode --verify-passphrase $DISK-part2
|
zpool create \
|
||||||
|
-o ashift=13 \
|
||||||
|
-o autotrim=off \
|
||||||
|
-O acltype=posixacl \
|
||||||
|
-O atime=off \
|
||||||
|
-O canmount=off \
|
||||||
|
-O compression=on \
|
||||||
|
-O dnodesize=auto \
|
||||||
|
-O utf8only=on \
|
||||||
|
-O normalization=formD \
|
||||||
|
-O xattr=sa \
|
||||||
|
-O mountpoint=none \
|
||||||
|
-O encryption=on \
|
||||||
|
-O keylocation=prompt \
|
||||||
|
-O keyformat=passphrase \
|
||||||
|
zpool $DISK-part2
|
||||||
|
|
||||||
# open the container
|
sleep 5
|
||||||
cryptsetup luksOpen $DISK-part2 crypt0
|
|
||||||
|
|
||||||
# create one large btrfs on them with strong checksum
|
# show the pool
|
||||||
mkfs.btrfs -f --checksum blake2 --features block-group-tree --label nix /dev/mapper/crypt0
|
zpool status
|
||||||
|
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
# create all the volumes
|
||||||
|
zfs create -o mountpoint=legacy zpool/data
|
||||||
|
zfs create -o mountpoint=legacy zpool/nix
|
||||||
|
zfs create -o mountpoint=legacy zpool/tmp
|
||||||
|
|
||||||
|
# we want 64 KB recordsize
|
||||||
|
zfs set recordsize=64K zpool/data
|
||||||
|
zfs set recordsize=64K zpool/nix
|
||||||
|
zfs set recordsize=64K zpool/tmp
|
||||||
|
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
# show the pool
|
||||||
|
zpool status
|
||||||
|
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
|
@ -69,27 +100,25 @@ sleep 5
|
||||||
mount -t tmpfs none /mnt
|
mount -t tmpfs none /mnt
|
||||||
|
|
||||||
# Create directories to mount file systems on
|
# Create directories to mount file systems on
|
||||||
mkdir -p /mnt/{nix,home,boot,root,etc/nixos}
|
mkdir -p /mnt/{data,nix,home,boot,root,etc/nixos,tmp}
|
||||||
|
|
||||||
# mount the ESP
|
# mount the ESP
|
||||||
mount $DISK-part1 /mnt/boot
|
mount $DISK-part1 /mnt/boot
|
||||||
|
|
||||||
# mount large btrfs
|
# mount volumes
|
||||||
mount -t btrfs /dev/mapper/crypt0 /mnt/nix
|
mount -t zfs zpool/data /mnt/data
|
||||||
|
mount -t zfs zpool/nix /mnt/nix
|
||||||
# ensure tmp fills not the RAM
|
mount -t zfs zpool/tmp /mnt/tmp
|
||||||
mkdir -p /mnt/tmp /mnt/nix/tmp
|
|
||||||
mount --bind /mnt/nix/tmp /mnt/tmp
|
|
||||||
|
|
||||||
# bind mount persistent stuff to data
|
# bind mount persistent stuff to data
|
||||||
mkdir -p /mnt/nix/data/{home,root,nixos/$HOST}
|
mkdir -p /mnt/data/{home,root,nixos/$HOST}
|
||||||
mount --bind /mnt/nix/data/home /mnt/home
|
mount --bind /mnt/data/home /mnt/home
|
||||||
mount --bind /mnt/nix/data/root /mnt/root
|
mount --bind /mnt/data/root /mnt/root
|
||||||
mount --bind /mnt/nix/data/nixos/$HOST /mnt/etc/nixos
|
mount --bind /mnt/data/nixos/$HOST /mnt/etc/nixos
|
||||||
|
|
||||||
# create fake /nix/data to have the right paths
|
# create fake /data to have the right paths
|
||||||
mkdir -p /nix/data
|
mkdir -p /data
|
||||||
mount --bind /mnt/nix/data /nix/data
|
mount --bind /mnt/data /data
|
||||||
|
|
||||||
# take a look
|
# take a look
|
||||||
mount
|
mount
|
||||||
|
@ -101,7 +130,7 @@ nixos-generate-config --root /mnt
|
||||||
|
|
||||||
# copy config data from another machine including secrets
|
# copy config data from another machine including secrets
|
||||||
|
|
||||||
sudo scp -r /nix/data/nixos root@192.168.13.xxx:/mnt/nix/data
|
sudo scp -r /data/nixos root@192.168.13.102:/mnt/data
|
||||||
|
|
||||||
# install
|
# install
|
||||||
|
|
||||||
|
@ -109,9 +138,8 @@ nixos-install --option experimental-features 'nix-command flakes' --no-root-pass
|
||||||
|
|
||||||
# unmount all stuff and sync
|
# unmount all stuff and sync
|
||||||
|
|
||||||
umount -Rl /nix/data /mnt
|
umount -Rl /data /mnt
|
||||||
cryptsetup luksClose crypt0
|
zpool export -a
|
||||||
sync
|
|
||||||
|
|
||||||
# shutdown once
|
# shutdown once
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue