Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a laptop with 2GB RAM and not the funds to buy more RAM. Ever since I installed 64-BIT Mint (MATE desktop), I am using more than 1GB RAM compared to between 170 - 500MB when I was in 32-BIT Cinnamon.

I have created a swap partition and now I want to set it permanently so that it is activated upon startup/reboot. Can someone please help me with the commands to use in ROOT terminal for this?

PS: Below is a list of fdisk -l, showing drive partitions

255 heads, 63 sectors/track, 60801 cylinders, total 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 identifier: 0x000814ae

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      718847      358400    7  HPFS/NTFS/exFAT
/dev/sda2          718848   571549695   285415424    7  HPFS/NTFS/exFAT
/dev/sda3       571549696   781264895   104857600    7  HPFS/NTFS/exFAT
/dev/sda4       781264896   976771071    97753088    f  W95 Ext'd (LBA)
/dev/sda5       781266944   966531071    92632064    7  HPFS/NTFS/exFAT
/dev/sda6       966533120   976771071     5118976   82  Linux swap / Solaris

Disk /dev/sdb: 8100 MB, 8100249600 bytes
204 heads, 51 sectors/track, 1520 cylinders, total 15820800 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 identifier: 0x000d308d

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    15820799     7909376   83  Linux

Here is my fstab file contents:

# /etc/fstab: static file system information.
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to
# name devices that works even if disks are added and removed. 
# See fstab(5).
# <file system>          unt point>   <type> <options>    <dump>  <pass>
/host/linuxmint/disks/root.disk /     ext4   loop,errors=remount-ro 0 1
/host/linuxmint/disks/swap.disk none  swap   loop,sw                0 0

# a swapfile is not a swap partition, so no using swapon|off from here on
#use  dphys-swapfile swap[on|off]  for that
share|improve this question
Could you post the content of your etc/fstab file? If your swap partition is listed there, you have nothing else to do. – Spack Oct 9 '13 at 9:19
Add it to /etc/fstab. See man 5 fstab for format details. – Dan D. Oct 9 '13 at 9:20

Start your favourite editor and open /etc/fstab. Since this is a system wide configuration file you will either need to do this as root (or any other account with uid 0) or you need to start the editor with extra rights (sudo).
Find an empty line and add /dev/sda6 swap swap defaults 0 0.

Save, then test with 'swapon -a`.


/etc/fstab contains information about which partitions to mounts and which filesystems those partitions are formatted with. Most of these will get automatically added when you boot. (Exception: noauto option).

The swap partition is treated as any other partition, except that is has no mount point.

This is how a typical fstab file might look:

# file system  mount-point  type     options    dump     fsck_order
/dev/sda1      /            ext2      defaults            0   0
/dev/sda2      /usr         ext2      defaults            0   1
/dev/sda3      /usr/local   ext2      defaults            0   1
/dev/sda4      /home        ext2      defaults, noatime   0   1

# Disk 2
/dev/sdb1      /tmp         ext2      defaults, noatime   0   0
/dev/sdb2      swap         swap      defaults            0   0

After you made en entry in fstab you can test this by turning on all standard swap locations with the command swapon -a.

share|improve this answer
This is a good answer; however, if the partitions are changed, or if /dev/sda ever becomes /dev/sdb or something else (because disks are added, for instance), the new entry will fail. Most distributions now use UUIDs to avoid such problems. To do this, instead of /dev/sda6 in the first column, you'd enter UUID=########-####-####-####-############, where ########-####-####-####-############ is the UUID for the swap space. You can learn the UUID by using blkid, as in sudo blkid /dev/sda6. Making this change just makes the entry a little more robust against possible future problems. – Rod Smith Oct 9 '13 at 15:31
I know. However this would make the answer more complex so I went for the simple solution. If I would write a canonical answer then I would include things like device ID, swap priorities, why it is a good idea to put swap on a separate disk, why rotating disk are faster on some tracks (outer tracks). Why swap on multiple devices is a good idea etc. However the OP seemed after a simple solution, so I wrote one. – Hennes Oct 9 '13 at 16:10
I wasn't trying to be critical; I just thought it was worth mentioning because device filenames aren't very stable these days. – Rod Smith Oct 9 '13 at 17:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .