From 63ee47c89a4f974555ee2a73790806540459365e Mon Sep 17 00:00:00 2001 From: Infinidoge Date: Thu, 9 Dec 2021 13:00:25 -0500 Subject: [PATCH] hosts/Infini-STICK: improve setup script --- hosts/Infini-STICK/readme.org | 77 +++++++++++++++++++++++++++++++---- hosts/Infini-STICK/setup.bash | 29 ++++++++++--- 2 files changed, 94 insertions(+), 12 deletions(-) mode change 100644 => 100755 hosts/Infini-STICK/setup.bash diff --git a/hosts/Infini-STICK/readme.org b/hosts/Infini-STICK/readme.org index 89121a4..b3f7d4f 100644 --- a/hosts/Infini-STICK/readme.org +++ b/hosts/Infini-STICK/readme.org @@ -1,5 +1,8 @@ #+TITLE: Infini-STICK Specification #+AUTHOR: Infinidoge +#+OPTIONS: toc:nil +#+LaTeX_CLASS_OPTIONS: [12pt] +#+LATEX_HEADER: \usepackage[margin=1in]{geometry} * Partition Scheme @@ -12,20 +15,53 @@ Setup with a wide array of hardware compatibility, specifically using the =portable= form defined in the =hardware/form= module. -* Setup Script +* Setup Scripts -#+BEGIN_SRC bash :tangle setup.bash -#!/usr/bin/env bash +#+BEGIN_SRC bash :tangle setup.bash :tangle-mode :shebang "#!/usr/bin/env bash" :noweb yes DISK=$1 +<> + +<> + +<> + +<> + +<> + +<> +#+END_SRC + +** Partitioning + +#+NAME: partitioning +#+BEGIN_SRC bash +echo "LOG: Partitioning $DISK" sudo parted $DISK -- mktable gpt -sudo parted $DISK -- mkpart primary btrfs 512MiB 100% -sudo parted $DISK -- mkpart ESP fat32 1MiB 512MiB -sudo parted $DISK -- set 2 esp on +sudo parted $DISK -s -- mkpart primary btrfs 512MiB 100% +sudo parted $DISK -s -- mkpart ESP fat32 1MiB 512MiB +sudo parted $DISK -s -- set 2 esp on +#+END_SRC -sudo mkfs.btrfs "${DISK}1" -L "Infini-STICK" +** Making Filesystems + +#+NAME: filesystems +#+BEGIN_SRC bash +echo "LOG: Making filesystems" +echo "- Making btrfs filesystem on ${DISK}1" +sudo mkfs.btrfs "${DISK}1" -L "Infini-STICK" -f +echo "- Making fat32 filesystem on ${DISK}2" sudo mkfs.fat -F 32 -n boot "${DISK}2" +#+END_SRC +** Making Subvolumes + +#+NAME: subvolumes +#+BEGIN_SRC bash +sudo mkdir -p /mnt + +echo "LOG: Making subvolumes on ${DISK}1" sudo mount "${DISK}1" /mnt sudo btrfs subvolume create /mnt/root sudo btrfs subvolume create /mnt/root/home @@ -34,15 +70,42 @@ sudo btrfs subvolume create /mnt/root/etc/nixos sudo btrfs subvolume create /mnt/boot sudo btrfs subvolume create /mnt/nix sudo btrfs subvolume create /mnt/nix/store +sudo umount /mnt +#+END_SRC +** Mounting Volumes +#+NAME: mounting +#+BEGIN_SRC bash +echo "LOG: Mounting tmpfs" sudo mount -t tmpfs root /mnt +echo "LOG: - Mounting persistent directories" sudo mkdir -p /mnt/persist /mnt/nix /mnt/boot sudo mount -o subvol=root,autodefrag,noatime "${DISK}1" /mnt/persist sudo mount -o subvol=nix,autodefrag,noatime "${DISK}1" /mnt/nix sudo mount -o subvol=boot,autodefrag,noatime "${DISK}1" /mnt/boot +echo "LOG: - Mounting EFI System Partition" sudo mkdir -p /mnt/boot/efi sudo mount "${DISK}2" /mnt/boot/efi #+END_SRC + +** Installing + +#+NAME: installing +#+BEGIN_SRC bash +echo "LOG: Cloning configuration" +sudo git clone --no-hardlinks --progress /etc/nixos /mnt/persist/etc/nixos + +echo "LOG: Installing NixOS" +sudo nixos-install --flake /mnt/persist/etc/nixos#Infini-STICK --no-root-password +#+END_SRC + +** Finishing Setup + +#+NAME: finishing_setup +#+BEGIN_SRC bash +echo "LOG: Unmounting all" +sudo umount -R /mnt +#+END_SRC diff --git a/hosts/Infini-STICK/setup.bash b/hosts/Infini-STICK/setup.bash old mode 100644 new mode 100755 index f2f5ff6..172ca46 --- a/hosts/Infini-STICK/setup.bash +++ b/hosts/Infini-STICK/setup.bash @@ -1,14 +1,21 @@ #!/usr/bin/env bash DISK=$1 +echo "LOG: Partitioning $DISK" sudo parted $DISK -- mktable gpt -sudo parted $DISK -- mkpart primary btrfs 512MiB 100% -sudo parted $DISK -- mkpart ESP fat32 1MiB 512MiB -sudo parted $DISK -- set 2 esp on +sudo parted $DISK -s -- mkpart primary btrfs 512MiB 100% +sudo parted $DISK -s -- mkpart ESP fat32 1MiB 512MiB +sudo parted $DISK -s -- set 2 esp on -sudo mkfs.btrfs "${DISK}1" -L "Infini-STICK" +echo "LOG: Making filesystems" +echo "- Making btrfs filesystem on ${DISK}1" +sudo mkfs.btrfs "${DISK}1" -L "Infini-STICK" -f +echo "- Making fat32 filesystem on ${DISK}2" sudo mkfs.fat -F 32 -n boot "${DISK}2" +sudo mkdir -p /mnt + +echo "LOG: Making subvolumes on ${DISK}1" sudo mount "${DISK}1" /mnt sudo btrfs subvolume create /mnt/root sudo btrfs subvolume create /mnt/root/home @@ -17,14 +24,26 @@ sudo btrfs subvolume create /mnt/root/etc/nixos sudo btrfs subvolume create /mnt/boot sudo btrfs subvolume create /mnt/nix sudo btrfs subvolume create /mnt/nix/store +sudo umount /mnt - +echo "LOG: Mounting tmpfs" sudo mount -t tmpfs root /mnt +echo "LOG: - Mounting persistent directories" sudo mkdir -p /mnt/persist /mnt/nix /mnt/boot sudo mount -o subvol=root,autodefrag,noatime "${DISK}1" /mnt/persist sudo mount -o subvol=nix,autodefrag,noatime "${DISK}1" /mnt/nix sudo mount -o subvol=boot,autodefrag,noatime "${DISK}1" /mnt/boot +echo "LOG: - Mounting EFI System Partition" sudo mkdir -p /mnt/boot/efi sudo mount "${DISK}2" /mnt/boot/efi + +echo "LOG: Cloning configuration" +sudo git clone --no-hardlinks --progress /etc/nixos /mnt/persist/etc/nixos + +echo "LOG: Installing NixOS" +sudo nixos-install --flake /mnt/persist/etc/nixos#Infini-STICK --no-root-password + +echo "LOG: Unmounting all" +sudo umount -R /mnt