create swapfile ubuntu 1

create swapfile ubuntu

sudo swapon --show

Here is what the above code is Doing:
1. Create a file named swapfile in the root directory.
2. Set the file permissions so that only the root user can read and write to the file.
3. Use the fallocate command to preallocate the file to the size of 4GB.
4. Use the mkswap command to set up a Linux swap area on the file.
5. Use the swapon command to turn on the swap file and make it available to the system.
6. Use the swapon command with the –show option to verify that the swap file is available and being used.

Similar Posts