1
0
mirror of https://github.com/tommytran732/Arch-Setup-Script synced 2024-11-21 17:11:34 -05:00

Better control over the swapfile creation.

This commit is contained in:
Tommaso Chiti 2021-02-01 07:20:36 +01:00
parent 20f08bb9f6
commit e520f12d9b

View File

@ -113,22 +113,28 @@ sed -i -e 's,BINARIES=(),BINARIES=(/usr/bin/btrfs),g' /mnt/etc/mkinitcpio.conf
sed -i -e 's,#COMPRESSION="zstd",COMPRESSION="zstd",g' /mnt/etc/mkinitcpio.conf sed -i -e 's,#COMPRESSION="zstd",COMPRESSION="zstd",g' /mnt/etc/mkinitcpio.conf
sed -i -e 's,modconf block filesystems keyboard,keyboard keymap modconf block encrypt filesystems,g' /mnt/etc/mkinitcpio.conf sed -i -e 's,modconf block filesystems keyboard,keyboard keymap modconf block encrypt filesystems,g' /mnt/etc/mkinitcpio.conf
# Enabling LUKS in GRUB. # Enabling LUKS in GRUB and setting the UUID of the LUKS container.
UUID=$(blkid $Cryptroot | cut -f2 -d'"') UUID=$(blkid $Cryptroot | cut -f2 -d'"')
sed -i 's/#\(GRUB_ENABLE_CRYPTODISK=y\)/\1/' /mnt/etc/default/grub sed -i 's/#\(GRUB_ENABLE_CRYPTODISK=y\)/\1/' /mnt/etc/default/grub
sed -i -e "s,quiet,quiet cryptdevice=UUID=$UUID:cryptroot root=$BTRFS,g" /mnt/etc/default/grub sed -i -e "s,quiet,quiet cryptdevice=UUID=$UUID:cryptroot root=$BTRFS,g" /mnt/etc/default/grub
# Creating a swapfile. # Creating a swapfile.
echo "How much big should the swap file be? Type the size, just a number (eg: 1 = 1GB..) " read -r -p "Do you want a swapfile? [y/N]? " response
read swap response=${response,,}
truncate -s 0 /mnt/swap/swapfile if [[ "$response" =~ ^(yes|y)$ ]]
chattr +C /mnt/swap/swapfile then
btrfs property set /mnt/swap/swapfile compression none read -r -p "How much big should the swap file be? Type the size, just a number (eg: 1 = 1GB..): " swap
dd if=/dev/zero of=/mnt/swap/swapfile bs=1G count=$swap status=progress truncate -s 0 /mnt/swap/swapfile
chmod 600 /mnt/swap/swapfile chattr +C /mnt/swap/swapfile
mkswap /mnt/swap/swapfile btrfs property set /mnt/swap/swapfile compression none
swapon /mnt/swap/swapfile dd if=/dev/zero of=/mnt/swap/swapfile bs=1G count=$swap status=progress
echo "/swap/swapfile none swap defaults 0 0" >> /mnt/etc/fstab chmod 600 /mnt/swap/swapfile
mkswap /mnt/swap/swapfile
swapon /mnt/swap/swapfile
echo "/swap/swapfile none swap defaults 0 0" >> /mnt/etc/fstab
else
break
fi
# Configuring the system. # Configuring the system.
arch-chroot /mnt /bin/bash -xe <<"EOF" arch-chroot /mnt /bin/bash -xe <<"EOF"