diff options
author | ene <ene@sils.li> | 2023-03-20 18:42:26 +0100 |
---|---|---|
committer | ene <ene@sils.li> | 2023-03-20 18:44:26 +0100 |
commit | 1b5eb56269683dc1eb033e3acae616a013aaca9b (patch) | |
tree | 115a25ad69cd361cb7593889cdaf5cff6a21cccb /bootstrap | |
parent | Docs(todo): Update (diff) | |
download | nixos-config-1b5eb56269683dc1eb033e3acae616a013aaca9b.tar.gz nixos-config-1b5eb56269683dc1eb033e3acae616a013aaca9b.zip |
Feat(system): Enable swap & zram swap & hibernate
Diffstat (limited to 'bootstrap')
-rwxr-xr-x | bootstrap/install/install.sh | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/bootstrap/install/install.sh b/bootstrap/install/install.sh index c4e8eefe..91caa186 100755 --- a/bootstrap/install/install.sh +++ b/bootstrap/install/install.sh @@ -83,6 +83,7 @@ bsc nix-store bsc persistent-storage bsc persistent-storage/nixos-config bsc persistent-storage/.snapshots +bsc swap cd / umount -R /mnt mount -t tmpfs none /mnt @@ -90,11 +91,47 @@ mount --mkdir "$DISK_EFI" /mnt/boot mne nix-store /mnt/nix mne persistent-storage /mnt/srv +mne swap /mnt/swap mount --mkdir --options bind /mnt/srv/nixos-config /mnt/etc/nixos msg "Finished mounting and generating btrfs subvolumes" +msg "Creating swapfile..." +btrfs filesystem mkswapfile --size "$(free -m | awk '{if (NR==2) {printf "%sm\n", $2 + 500}}')" /mnt/swap/swapfile +resume_offset=$(btrfs inspect-internal map-swapfile -r /mnt/swap/swapfile); +swap_uuid=$(findmnt -no UUID -T /mnt/swap/swapfile); +msg "Finished creating the swapfile"; +msg2 "UUID is: " "$swap_uuid"; +msg2 "Resume offset is: " "$resume_offset"; + +msg "Checking for incompatibilities..." +ssd_or_hdd=$(cat /sys/block/$disk/queue/rotational); +case "$ssd_or_hdd" in + 0) + msg "You seem to use a ssd." + trim_support=$(lsblk --bytes --json --discard | jq --arg name "$disk" '.blockdevices | .[] | select(.name == $name) | (.["disc-gran"] + .["disc-max"]) != 0'); + case $trim_support in + "true") + msg2 "Yay, your ssd supports trim, go on and activate it"; + ;; + "false") + msg2 "Nay, your ssd doesn't support trim, go on"; + ;; + *) + warning "Your ssd doesn't seem to exists, if this bothers you please open an issue.'"; + ;; + esac + ;; + 1) + msg "You seem to use a hdd there is nothing you have to do"; + ;; + *) + warning "There is no indicator, which shows, which drive your are using.\n This means, that you have to check yourself, which optimizations you should activate." + ;; +esac + + readp "Do you want to continue with nixos-install? [N/y]: " result case $result in [Yy]) |