more ZFS preparations
This commit is contained in:
parent
898cc97a9c
commit
6344eedd28
16
common.nix
16
common.nix
|
@ -56,23 +56,21 @@ in
|
||||||
options = [ "defaults" "size=8G" "mode=755" ];
|
options = [ "defaults" "size=8G" "mode=755" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
# nix store file system from encrypted disk
|
# nix store file system from encrypted ZFS
|
||||||
fileSystems."/nix" =
|
fileSystems."/nix" =
|
||||||
{ device = "/dev/mapper/crypt-system";
|
{ device = "zpool/nix";
|
||||||
fsType = "btrfs";
|
fsType = "zfs";
|
||||||
neededForBoot = true;
|
neededForBoot = true;
|
||||||
options = [ "subvol=nix" "noatime" "nodiratime" ];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# data store file system from encrypted disk
|
# data store file system from encrypted ZFS
|
||||||
fileSystems."/data" =
|
fileSystems."/data" =
|
||||||
{ device = "/dev/mapper/crypt-system";
|
{ device = "zpool/data";
|
||||||
fsType = "btrfs";
|
fsType = "zfs";
|
||||||
neededForBoot = true;
|
neededForBoot = true;
|
||||||
options = [ "subvol=data" "noatime" "nodiratime" ];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# bind mount to have homes
|
# bind mount to have user homes
|
||||||
fileSystems."/home" =
|
fileSystems."/home" =
|
||||||
{ device = "/data/home";
|
{ device = "/data/home";
|
||||||
fsType = "none";
|
fsType = "none";
|
||||||
|
|
|
@ -13,16 +13,13 @@
|
||||||
# don't check for split locks, for KVM and Co.
|
# don't check for split locks, for KVM and Co.
|
||||||
boot.kernelParams = [ "split_lock_detect=off" ];
|
boot.kernelParams = [ "split_lock_detect=off" ];
|
||||||
|
|
||||||
# system
|
|
||||||
boot.initrd.luks.devices."crypt-system".device = "/dev/disk/by-id/nvme-Seagate_FireCuda_530_ZP4000GM30013_7VS01VBM-part2";
|
|
||||||
|
|
||||||
# efi partition
|
# efi partition
|
||||||
fileSystems."/boot" =
|
fileSystems."/boot" =
|
||||||
{ device = "/dev/disk/by-id/nvme-Seagate_FireCuda_530_ZP4000GM30013_7VS01VBM-part1";
|
{ device = "/dev/disk/by-id/nvme-Seagate_FireCuda_530_ZP4000GM30013_7VS01VBM-part1";
|
||||||
fsType = "vfat";
|
fsType = "vfat";
|
||||||
neededForBoot = true;
|
neededForBoot = true;
|
||||||
};
|
};
|
||||||
|
/*
|
||||||
# vms
|
# vms
|
||||||
boot.initrd.luks.devices."crypt-vms".device = "/dev/disk/by-id/nvme-CT2000P5PSSD8_213330E4ED05";
|
boot.initrd.luks.devices."crypt-vms".device = "/dev/disk/by-id/nvme-CT2000P5PSSD8_213330E4ED05";
|
||||||
fileSystems."/home/cullmann/vms" =
|
fileSystems."/home/cullmann/vms" =
|
||||||
|
@ -41,7 +38,7 @@
|
||||||
neededForBoot = true;
|
neededForBoot = true;
|
||||||
options = [ "noatime" "nodiratime" ];
|
options = [ "noatime" "nodiratime" ];
|
||||||
depends = [ "/home" ];
|
depends = [ "/home" ];
|
||||||
};
|
};*/
|
||||||
|
|
||||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||||
|
|
|
@ -53,37 +53,35 @@ cat /proc/partitions
|
||||||
# boot partition
|
# boot partition
|
||||||
mkfs.fat -F 32 -n EFIBOOT $DISK-part1
|
mkfs.fat -F 32 -n EFIBOOT $DISK-part1
|
||||||
|
|
||||||
# create the crypto containers
|
|
||||||
cryptsetup luksFormat --sector-size 4096 --batch-mode --verify-passphrase $DISK-part2
|
|
||||||
|
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
# open them, set right options persistently
|
# ZFS zpool creation with encryption
|
||||||
cryptsetup luksOpen --allow-discards --perf-no_read_workqueue --perf-no_write_workqueue --persistent $DISK-part2 crypt-system
|
zpool create \
|
||||||
|
-o ashift=12 \
|
||||||
|
-o autotrim=on \
|
||||||
|
-O acltype=posixacl \
|
||||||
|
-O atime=off \
|
||||||
|
-O canmount=off \
|
||||||
|
-O compression=on \
|
||||||
|
-O dnodesize=auto \
|
||||||
|
-O normalization=formD \
|
||||||
|
-O xattr=sa \
|
||||||
|
-O mountpoint=none \
|
||||||
|
-O encryption=on \
|
||||||
|
-O keylocation=prompt \
|
||||||
|
-O keyformat=passphrase \
|
||||||
|
zpool $DISK-part2
|
||||||
|
|
||||||
sleep 5
|
sleep 5
|
||||||
lsblk --fs
|
|
||||||
|
|
||||||
# create btrfs with fast & strong checksumming and fast mounting
|
|
||||||
mkfs.btrfs -f --csum xxhash --features block-group-tree /dev/mapper/crypt-system
|
|
||||||
|
|
||||||
sleep 5
|
|
||||||
btrfs filesystem show
|
|
||||||
|
|
||||||
# create all the volumes
|
# create all the volumes
|
||||||
mount /dev/mapper/crypt-system /mnt
|
zfs create -o mountpoint=legacy zpool/data
|
||||||
btrfs subvolume create /mnt/data
|
zfs create -o mountpoint=legacy zpool/nix
|
||||||
btrfs subvolume create /mnt/nix
|
|
||||||
btrfs subvolume create /mnt/root
|
|
||||||
|
|
||||||
sleep 5
|
sleep 5
|
||||||
btrfs subvolume list /mnt
|
|
||||||
|
|
||||||
# umount again, we will only use explicit subvolumes
|
# prepare install, tmpfs root
|
||||||
umount /mnt
|
mount -t tmpfs none /mnt
|
||||||
|
|
||||||
# prepare install
|
|
||||||
mount -o subvol=root,noatime,nodiratime /dev/mapper/crypt-system /mnt
|
|
||||||
|
|
||||||
# Create directories to mount file systems on
|
# Create directories to mount file systems on
|
||||||
mkdir -p /mnt/{data,nix,home,boot,root,etc/nixos}
|
mkdir -p /mnt/{data,nix,home,boot,root,etc/nixos}
|
||||||
|
@ -92,8 +90,8 @@ mkdir -p /mnt/{data,nix,home,boot,root,etc/nixos}
|
||||||
mount $DISK-part1 /mnt/boot
|
mount $DISK-part1 /mnt/boot
|
||||||
|
|
||||||
# mount volumes
|
# mount volumes
|
||||||
mount -o subvol=data,noatime,nodiratime /dev/mapper/crypt-system /mnt/data
|
mount -t zfs zpool/data /mnt/data
|
||||||
mount -o subvol=nix,noatime,nodiratime /dev/mapper/crypt-system /mnt/nix
|
mount -t zfs zpool/nix /mnt/nix
|
||||||
|
|
||||||
# bind mount persistent stuff to data
|
# bind mount persistent stuff to data
|
||||||
mkdir -p /mnt/{data/home,data/root,data/nixos/$HOST}
|
mkdir -p /mnt/{data/home,data/root,data/nixos/$HOST}
|
||||||
|
|
Loading…
Reference in a new issue