I recently wanted to add a swap partition to my Fedora Core 19 system as apparently I was running all this time without one. This is the command that I used to find a partition to use.
root@neo homer# fdisk -l /dev/sdb Disk /dev/sdb: 500.1 GB, 500107862016 bytes, 976773168 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x03eec363 Device Boot Start End Blocks Id System /dev/sdb1 * 2048 882687 440320 83 Linux /dev/sdb2 882688 25458687 12288000 82 Linux swap / Solaris /dev/sdb3 25458688 971634687 473088000 7 HPFS/NTFS/exFAT /dev/sdb4 971638782 976758783 2560001 5 Extended /dev/sdb5 971638784 976758783 2560000 82 Linux swap / Solaris |
This the command that you use to switch on a swap partition.
root@neo homer# swapon /dev/sdb5 |
And again for /dev/sdb2.
root@neo homer# swapon /dev/sdb2 |
Now I can list the active swap partitions and get some results.
root@neo homer# cat /proc/swaps Filename Type Size Used Priority /dev/sdb5 partition 2559996 0 -1 /dev/sdb2 partition 12287996 0 -2 |
This command will also return the same information.
root@neo homer# swapon -s Filename Type Size Used Priority /dev/sdb5 partition 2559996 0 -1 /dev/sdb2 partition 12287996 0 -2 |
Using these commands the Linux user will easily be able to add more swap partitions to better manage memory on a Linux system.