Fix swapfile
Snapshots won't work on swapfile containing subvolume, best to move it to it's own
This commit is contained in:
parent
afbacbe3c2
commit
01e03e865e
|
|
@ -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 "
|
||||
-------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Reference in New Issue