diff --git a/0-preinstall.sh b/0-preinstall.sh index ddc03c9..7e9f162 100755 --- a/0-preinstall.sh +++ b/0-preinstall.sh @@ -177,16 +177,18 @@ echo -ne " " TOTALMEM=$(cat /proc/meminfo | grep -i 'memtotal' | grep -o '[[:digit:]]*') if [[ $TOTALMEM -lt 8000000 ]]; then - #Put swap into the actual system, not into RAM disk, otherwise there is no point in it, it'll cache RAM into RAM. So, /mnt/ everything. - mkdir /mnt/opt/swap #make a dir that we can apply NOCOW to to make it btrfs-friendly. - chattr +C /mnt/opt/swap #apply NOCOW, btrfs needs that. - dd if=/dev/zero of=/mnt/opt/swap/swapfile bs=1M count=2048 status=progress - chmod 600 /mnt/opt/swap/swapfile #set permissions. - chown root /mnt/opt/swap/swapfile - mkswap /mnt/opt/swap/swapfile - swapon /mnt/opt/swap/swapfile - #The line below is written to /mnt/ but doesn't contain /mnt/, since it's just / for the sysytem itself. - echo "/opt/swap/swapfile none swap sw 0 0" >> /mnt/etc/fstab #Add swap to fstab, so it KEEPS working after installation. + # Put swapfile into separate subvolume or else you wouldn't be able to make snapshots of root + btrfs subvolume create /mnt/swap + truncate -s 0 /mnt/swap/swapfile + chattr +C /mnt/swap/swapfile #apply NOCOW, btrfs needs that. + btrfs property set /mnt/swap/swapfile compression none + dd if=/dev/zero of=/mnt/swap/swapfile bs=1M count=4096 status=progress + chmod 600 /mnt/swap/swapfile #set permissions. + chown root /mnt/swap/swapfile + mkswap /mnt/swap/swapfile + swapon /mnt/swap/swapfile + echo "/swap/swapfile none swap sw 0 0" >> /mnt/etc/fstab #Add swap to fstab, so it KEEPS working after installation. + echo "vm.swappiness=10" >> /mnt/etc/sysctl.conf # Lower swappiness fi echo -ne " -------------------------------------------------------------------------