51
edits
(Use dd instead of fallocate: https://man.archlinux.org/man/swapon.8#Files_with_holes) |
(Fixes, formatting) |
||
Line 131: | Line 131: | ||
==Creating and Enabling a Static Swapfile== <!--T:41--> | ==Creating and Enabling a Static Swapfile== <!--T:41--> | ||
</translate> | </translate> | ||
{{tip|<translate><!--T:42--> There is no reason you can't have both a swap partition and a swapfile. This is an easy way to add more swap without repartitioning.</translate>}} | {{tip|<translate><!--T:42--> | ||
There is no reason you can't have both a swap partition and a swapfile. This is an easy way to add more swap without repartitioning. | |||
</translate>}} | |||
<translate><!--T:43--> First create and intialize the file to hold the swap. For example, to create a 4GB swapfile, you could use the command:</translate> | <translate><!--T:43--> | ||
First create and intialize the file to hold the swap. For example, to create a 4GB swapfile, you could use the command: | |||
</translate> | |||
sudo dd if=/dev/zero of=/swapfile bs=1M count=4096 status=progress | sudo dd if=/dev/zero of=/swapfile bs=1M count=4096 status=progress | ||
<translate><!--T:44--> Set the appropriate permissions on the file. It should be readable and writable only by {{ic|root}}. This can be done with the command:</translate> | <translate><!--T:44--> | ||
sudo chmod | Set the appropriate permissions on the file. It should be readable and writable only by {{ic|root}}. This can be done with the command: | ||
</translate> | |||
sudo chmod 600 /swapfile | |||
<translate><!--T:45--> | |||
Next we need to format and enable the swapfile: | |||
</translate> | |||
sudo mkswap /swapfile | |||
sudo swapon /swapfile | sudo swapon /swapfile | ||
<translate><!--T:46--> In order to ensure that the swap is enabled at boot we can add an entry to {{ic|/etc/fstab}}. You can add the line to fstab manually or using the command:</translate> | <translate><!--T:46--> | ||
In order to ensure that the swap is enabled at boot we can add an entry to {{ic|/etc/fstab}}. You can add the line to fstab manually or using the command: | |||
</translate> | |||
sudo bash -c "echo /swapfile none swap defaults 0 0 >> /etc/fstab" | sudo bash -c "echo /swapfile none swap defaults 0 0 >> /etc/fstab" | ||