Skip to content

Instantly share code, notes, and snippets.

@tuoxie007
Last active January 10, 2016 12:38
Show Gist options
  • Save tuoxie007/8ff3c4d58a78ca7d8bfe to your computer and use it in GitHub Desktop.
Save tuoxie007/8ff3c4d58a78ca7d8bfe to your computer and use it in GitHub Desktop.
linux use swap manual

Use swap partition

  1. add a new device
  2. partition with fdisk $ sudo fdisk /dev/sdb $ n # create a new partition $ p # primary partition $ # use default startor selector $ # use default end selector $ w # write to disk $ ls /dev/sdb* # show the new partition file
  3. format as swap $ sudo mkswap /dev/sdb1 $ sudo swapon /dev/sdb1
  4. edit the fstab config file I. copy the UUID from mkswap command output II. add a new line in /etc/fstab for the new swap mount point. III. reboot.

Use swap file on your disk

$ dd if=/dev/zero of=/swapfile bs=1024 count=65536 $ mkswap /swapfile $ swapon /swapfile $ add new mount point to your fstab like '/swapfile swap swap defaults 0 0'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment