Posts Linux mount swap partition to a file
Post
Cancel

Linux mount swap partition to a file

Watch Explanation on YouTube

How to create Swap File on Linux

Link URL : https://youtu.be/43Inh_045_8

  • Create a file and give it same space as you would to a swap partition
1
2
3
4
$ sudo dd if=/dev/zero of=/swapPartitionAsFile bs=1M count=2048

$ # reduce file permissions
$ sudo chmod 0600 /swapPartitionAsFile
  • Use make swap to set file as swap
1
$ sudo mkswap /swapPartitionAsFile
  • Enable the file as swap using swapon
1
$ sudo swapon /swapPartitionAsFile
  • Add the file to be auto-mounted
1
2
3
$ sudo vi /etc/fstab

/swapPartitionAsFile swap swap defaults 0 0
This post is licensed under CC BY 4.0 by the author.