Infrastruktur

Server Ancha

Netz
IPv4172.23.195.31, 212.114.51.124 (NAT)
IPv62a01:367:ff1f:100::31
Hostnameancha.lurk.space
Netbox

ancha ist ein Server, auf welchem neben öffentlichen Services primär Privates und Backups lagern. Als Betriebssystem wird NixOS eingesetzt, dessen Setup hier dokumentiert ist.

Services

NixOS Setup

Installationsziel: 2x 2TB in einem RAID1, dieses LUKS-verschlüsselt und darauf ein LVM

# Enable UEFI-Boot in the BIOS
# Prepare and mount a NixOS-Live-Stick

# /dev/sdb and /dev/sdc were mapped to my two disks (sda was the stick..)

# Create partitions on the two hard disks
parted /dev/sdb -- mklabel gpt
parted /dev/sdb -- mkpart ESP fat32 1MiB 512MiB
parted /dev/sdb -- mkpart primary 512MiB 100%
parted /dev/sdb -- set 1 boot on

parted /dev/sdc -- mklabel gpt
parted /dev/sdc -- mkpart primary 512MiB 100%

# Create a RAID1
mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb2 /dev/sdc2

# Create and open the LUKS on top of the RAID
cryptsetup luksFormat /dev/md0
cryptsetup luksOpen /dev/md0 pv

# Create volumes
pvcreate /dev/mapper/pv
vgcreate vg /dev/mapper/pv
lvcreate -n swag vg -L 8G
lvcreate -n root vg -l 100%FREE

# Create filesystems
mkfs.btrfs -L nixos /dev/vg/root
mkswap -L swag /dev/vg/swag
mkfs.fat -F 32 -n boot /dev/sdb1

# Mount new filesystems
mount /dev/disk/by-label/nixos /mnt/
mkdir -p /mnt/boot
mount /dev/disk/by-label/boot /mnt/boot

# Swag on
swapon /dev/disk/by-label/swag

# Generate and modify configuration
nixos-generate-config --root /mnt

vim /mnt/etc/nixos/configuration.nix
# Make sure your configuration contains:
#
#  boot.loader.systemd-boot.enable = true;
#  boot.loader.efi.canTouchEfiVariables = true;
#
#  boot.initrd.luks.devices = [
#    {
#      name = "root";
#      device = "/dev/disk/by-uuid/UID-OF-dev-md0";
#      preLVM = true;
#      allowDiscards = true;
#    }
#  ];
#
# Don't forget to modify the device's UUID.

# Install and reboot
nixos-install
reboot