Ubuntu 14.04 Encrypted Swapfile Setup: Difference between revisions

From myWiki
Created page with "In the installed system, first make a swap container. N is the size you want in gigabytes and if you've got 4GB or more of memory and you're not working on a server, then a mi..."
 
No edit summary
 
Line 1: Line 1:
In the installed system, first make a swap container. N is the size you want in gigabytes and if you've got 4GB or more of memory and you're not working on a server, then a minimum swap size of half your system's RAM is realistically sufficient. Below 4GB, a swap size of 75 to 100 percent of the RAM available is good.
In the installed system, first make a swap container. N is the size you want in megabytes and if you've got 4GB or more of memory and you're not working on a server, then a minimum swap size of half your system's RAM is realistically sufficient. Below 4GB, a swap size of 75 to 100 percent of the RAM available is good.


  sudo dd if=/dev/urandom of=/swapfile bs=1G count=N
  sudo dd if=/dev/urandom of=/swapfile bs=1M count=N
Then make the actual swap filesystem and restrict its permissions so that only the root user can read and write to it.
Then make the actual swap filesystem and restrict its permissions so that only the root user can read and write to it.

Latest revision as of 15:35, 21 August 2015

In the installed system, first make a swap container. N is the size you want in megabytes and if you've got 4GB or more of memory and you're not working on a server, then a minimum swap size of half your system's RAM is realistically sufficient. Below 4GB, a swap size of 75 to 100 percent of the RAM available is good.

sudo dd if=/dev/urandom of=/swapfile bs=1M count=N

Then make the actual swap filesystem and restrict its permissions so that only the root user can read and write to it.

sudo mkswap /swapfile
sudo chmod 0600 /swapfile

Add it to fstab.

/swapfile  none  swap  sw  0 0

And last, switch it on. No reboot necessary.

sudo swapon /swapfile