###Swap Partitions & Files###

Features:
 1. Extra, virtual RAM for the OS


Steps:
 1. Identify current swap space
  a. 'swapon -s' - enumerates partitions and/or files, which constitute swap storage
  b. 'free -m'

 2. Select target drive and provision swap partition
  a. 'fdisk /dev/sdb'
  b. 'n'
  c. '2'
  d. '500'
  e. '+512M' (cylinder 562) - 63 cylinders are required for 512MB
  f. 't' - Change Type
  g. '82' - Linux Swap/Solaris
  h. 'w' - committ changes to disk

 3. Create the swap file system on the raw partition: /dev/sdb2
  a. 'mkswap /dev/sdb2'

 4. Enable swapping - publish the swap space to the kernel
  a. 'swapon /dev/sdb2' - this enables swapping on /dev/sdb2

 5. update /etc/fstab
  a. '/dev/sdb2 swap swap defaults 0 0

swapoff /dev/sdb2 - disables swapping on /dev/sdb2

Task:
 1. Improve system performance by distributing swapping to /dev/sdb2
  a. swapon /dev/sdb2
  b. swapoff /dev/sda6
  c. disable /dev/sda6 via /etc/fstab


###Create Swap based on File###

Features:
 1. The ability to provision swap space based on a file, similar to pagefile.sys in Windows NT, etc. if you have no available disk space to partition
 2. Doesn't waste partitions


Task:
 1. Create 512MB swap file
  a. 'dd if=/dev/zero of=/home1/swapfile1 bs=1024 count=524288'
  b. 'mkswap /home1/swapfile1' - overlays swap file system
  c. 'swapon /home1/swapfile1' - makes swap space available to the kernel

 2. Ensure that when the system reboots, the swapfile is made available to the kernel
  a. 'nano /etc/fstab' - /home1/swapfile1 swap swap default 0 0

 3. Create 2GB swap file
  a. 'dd if=/dev/zero of=/home1/swapfile2 bs=1M count=2048'


###Encrypt a partition###

Features:
 1. Encrypt a Partition


Tasks:
 1. Create a partition
  a. 'fdisk -cu /dev/vda'

 2. Encrypt
  a. 'cryptsetup luksFormat /dev/vda5'

 3. Open
  a. 'cryptsetup luksOpen /dev/vda5 encdisk'

 4. Format
  a. 'mkfs.ext4 /dev/mapper/encdisk'

 5. Use
  a. 'mkdir /encdisk'
  b. 'mount /dev/mapper/encdisk /encdisk'

 6. Auto-mount

  a. Edit /etc/crypttab
encdisk        /dev/vda5    /root/encdisk

  b. 'echo westos > /root/encdisk'
  c. 'chown root /root/encdisk
  d. 'chmod 600 /root/encdisk
  e. 'cryptsetup luksAddKey /dev/vda5 /root/encdisk