Ubuntu 14.04 Encrypted Swapfile Setup

From myWiki
Revision as of 15:35, 21 August 2015 by Stevet (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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.

sudo dd if=/dev/urandom of=/swapfile bs=1G 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