Add Linux Swap Partition


Please use fdisk -l to get the target drive you want to use as the Swap space. Note: format the disk will lose all your data, Please back up before proceeding.

1. Format Disk into Linux swap / Solaris

$ fdisk /dev/sdb

Command (m for help): n
Command action: p
Partition number: 1
First cylinder: 
Last cylinder:

Note: Empty means use default value

command (m for help): t
Hex code: 82

command (m for help): w

2. Enable swap

$ mkswap -L swap1 /dev/sdb1

Modify /etc/fstab to add the line below

/dev/sdb1  swap  swap  defaults  0  0

3. Check Swap Space

$ swapon -a
$ swapon -s

Leave a Reply

Your email address will not be published. Required fields are marked *