Create SWAP file

mikussikus

Verified User
Joined
Dec 21, 2022
Messages
21
I have vps with below configuration.
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 500G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 200M 0 part /boot/efi
├─sda3 8:3 0 1G 0 part /boot
└─sda4 8:4 0 498.8G 0 part /
sr0 11:0 1 4M 0 rom

I found information how to create a swap file in directadmin docs.
dd if=/dev/zero of=/swapfile count=4096 bs=1MiB
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile

If I want to create swap file, need I use above scripts or have I do anything else? Use this code is safety?
 
need I use above scripts or have I do anything else?
That code is safe, but don't forget to do the last part in the docs. Test if it's working and if it's working, then add the appropriate line to the /etc/fstab file as mentioned.
 
Back
Top