diff --git a/README.md b/README.md index 4b7e356..2ebcc1b 100644 --- a/README.md +++ b/README.md @@ -66,8 +66,27 @@ use the `deploy #name` command, at least if it's executed from a NixOS desktop. ### Niflheim ```console -sudo loadkeys de -sudo nix-shell --packages nixUnstable +apt install -y sudo + +mkdir -p /etc/nix +echo "build-users-group =" > /etc/nix/nix.conf + +curl -L https://nixos.org/nix/install | sh +. $HOME/.nix-profile/etc/profile.d/nix.sh + +nix-env -f https://github.com/nix-community/nixos-generators/archive/master.tar.gz -i -v + +cat < /root/config.nix +{ + services.openssh.enable = true; + users.users.root.openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINaQYR0/Oj6k1H03kshz2J7rlGCaDSuaGPhhOs9FcZfn" + ]; +} +EOF + +nixos-generate -o /root/result -f kexec-bundle -c /root/config.nix +/root/result bash -c "$(curl -fsSL https://raw.githubusercontent.com/tboerger/nixos-config/master/scripts/niflheim-partitions)" diff --git a/scripts/asgard-partitions b/scripts/asgard-partitions index 948c058..b9e3dd2 100755 --- a/scripts/asgard-partitions +++ b/scripts/asgard-partitions @@ -23,6 +23,8 @@ while true; do done echo "----> Remove previous VGs" +vgchange -an + for VG in $(vgs --noheadings 2>/dev/null | sed -e 's/^[[:space:]]*//' | cut -d" " -f 1); do vgremove -y ${VG} 2>/dev/null done @@ -33,18 +35,10 @@ for PV in $(pvs --noheadings 2>/dev/null | sed -e 's/^[[:space:]]*//' | cut -d" done echo "----> Remove previous MDs" -if [[ -d /dev/md ]]; then - for MD in /dev/md/*; do - mdadm --stop $MD - done -fi +mdadm --stop --scan || true -echo "----> Remove previous MDs" -if [[ -d /dev/md ]]; then - for MD in /dev/md/*; do - mdadm --stop $MD - done -fi +echo 'AUTO -all +ARRAY UUID=00000000:00000000:00000000:00000000' > /etc/mdadm/mdadm.conf echo "----> Drop existing partitions" for DISK in pci-0000:00:14.1-ata-1 pci-0000:00:11.0-ata-1.0 pci-0000:00:11.0-ata-2.0 pci-0000:00:11.0-ata-3.0 pci-0000:00:11.0-ata-4.0; do @@ -98,7 +92,9 @@ echo "-----> Reload partition table" partprobe echo "-----> Create raid0 volume" -echo yes | mdadm --create /dev/md0 --level=10 --raid-devices=4 /dev/disk/by-partlabel/tank1 /dev/disk/by-partlabel/tank2 /dev/disk/by-partlabel/tank3 /dev/disk/by-partlabel/tank4 +echo yes | mdadm --create /dev/md0 --level=10 --raid-devices=4 --homehost=asgard --name=md0 /dev/disk/by-partlabel/tank1 /dev/disk/by-partlabel/tank2 /dev/disk/by-partlabel/tank3 /dev/disk/by-partlabel/tank4 +wipefs -a /dev/md0 +echo 0 > /proc/sys/dev/raid/speed_limit_max echo "-----> Wait for raids" sleep 3 diff --git a/scripts/chnum-partitions b/scripts/chnum-partitions index b924116..1f2fda6 100755 --- a/scripts/chnum-partitions +++ b/scripts/chnum-partitions @@ -23,6 +23,8 @@ while true; do done echo "----> Remove previous VGs" +vgchange -an + for VG in $(vgs --noheadings 2>/dev/null | sed -e 's/^[[:space:]]*//' | cut -d" " -f 1); do vgremove -y ${VG} 2>/dev/null done @@ -33,18 +35,10 @@ for PV in $(pvs --noheadings 2>/dev/null | sed -e 's/^[[:space:]]*//' | cut -d" done echo "----> Remove previous MDs" -if [[ -d /dev/md ]]; then - for MD in /dev/md/*; do - mdadm --stop $MD - done -fi +mdadm --stop --scan || true -echo "----> Remove previous MDs" -if [[ -d /dev/md ]]; then - for MD in /dev/md/*; do - mdadm --stop $MD - done -fi +echo 'AUTO -all +ARRAY UUID=00000000:00000000:00000000:00000000' > /etc/mdadm/mdadm.conf echo "----> Drop existing partitions" for DISK in pci-0000:00:1f.2-ata-1.0; do diff --git a/scripts/niflheim-partitions b/scripts/niflheim-partitions index 8cd2ea2..8e9884b 100755 --- a/scripts/niflheim-partitions +++ b/scripts/niflheim-partitions @@ -23,6 +23,8 @@ while true; do done echo "----> Remove previous VGs" +vgchange -an + for VG in $(vgs --noheadings 2>/dev/null | sed -e 's/^[[:space:]]*//' | cut -d" " -f 1); do vgremove -y ${VG} 2>/dev/null done @@ -33,11 +35,10 @@ for PV in $(pvs --noheadings 2>/dev/null | sed -e 's/^[[:space:]]*//' | cut -d" done echo "----> Remove previous MDs" -if [[ -d /dev/md ]]; then - for MD in /dev/md/*; do - mdadm --stop $MD - done -fi +mdadm --stop --scan || true + +echo 'AUTO -all +ARRAY UUID=00000000:00000000:00000000:00000000' > /etc/mdadm/mdadm.conf echo "----> Drop existing partitions" for DISK in pci-0000:00:1f.2-ata-3.0 pci-0000:00:1f.2-ata-4.0 pci-0000:00:1f.2-ata-5.0 pci-0000:00:1f.2-ata-6.0; do @@ -93,7 +94,9 @@ echo "-----> Reload partition table" partprobe echo "-----> Create raid0 volume" -echo yes | mdadm --create /dev/md0 --level=10 --raid-devices=4 /dev/disk/by-partlabel/tank1 /dev/disk/by-partlabel/tank2 /dev/disk/by-partlabel/tank3 /dev/disk/by-partlabel/tank4 +echo yes | mdadm --create /dev/md0 --level=10 --raid-devices=4 --homehost=niflheim --name=md0 /dev/disk/by-partlabel/tank1 /dev/disk/by-partlabel/tank2 /dev/disk/by-partlabel/tank3 /dev/disk/by-partlabel/tank4 +wipefs -a /dev/md0 +echo 0 > /proc/sys/dev/raid/speed_limit_max echo "-----> Wait for raids" sleep 3 diff --git a/scripts/utgard-partitions b/scripts/utgard-partitions index bfe423f..ff15a0e 100755 --- a/scripts/utgard-partitions +++ b/scripts/utgard-partitions @@ -23,6 +23,8 @@ while true; do done echo "----> Remove previous VGs" +vgchange -an + for VG in $(vgs --noheadings 2>/dev/null | sed -e 's/^[[:space:]]*//' | cut -d" " -f 1); do vgremove -y ${VG} 2>/dev/null done @@ -33,18 +35,10 @@ for PV in $(pvs --noheadings 2>/dev/null | sed -e 's/^[[:space:]]*//' | cut -d" done echo "----> Remove previous MDs" -if [[ -d /dev/md ]]; then - for MD in /dev/md/*; do - mdadm --stop $MD - done -fi +mdadm --stop --scan || true -echo "----> Remove previous MDs" -if [[ -d /dev/md ]]; then - for MD in /dev/md/*; do - mdadm --stop $MD - done -fi +echo 'AUTO -all +ARRAY UUID=00000000:00000000:00000000:00000000' > /etc/mdadm/mdadm.conf echo "----> Drop existing partitions" for DISK in pci-0000:00:1f.2-ata-1.0 pci-0000:00:1f.2-ata-2.0; do diff --git a/servers/asgard/filesystems.nix b/servers/asgard/filesystems.nix index 799b008..ee43929 100644 --- a/servers/asgard/filesystems.nix +++ b/servers/asgard/filesystems.nix @@ -30,7 +30,7 @@ }; fileSystems."/boot" = { - device = "/dev/disk/by-label/boot1"; + device = "/dev/disk/by-label/boot"; fsType = "ext4"; options = [ "noatime" diff --git a/servers/niflheim/filesystems.nix b/servers/niflheim/filesystems.nix index 823ff22..b78ca87 100644 --- a/servers/niflheim/filesystems.nix +++ b/servers/niflheim/filesystems.nix @@ -30,7 +30,7 @@ }; fileSystems."/boot" = { - device = "/dev/disk/by-label/boot1"; + device = "/dev/disk/by-label/boot"; fsType = "ext4"; options = [ "noatime"