0

This is the status of my system:

$ grep 'Swap' /proc/meminfo
SwapCached: 0 kB
SwapTotal: 0 kB
SwapFree: 0 kB

Please let me know how can I increase the swap area without re-installing.

Eric Carvalho
  • 54,385

2 Answers2

0

To add 1GB of swap to your computer follow these steps:

Open a terminal,

Press Ctrl+Alt+T

And run:

To create the file myfile.swap in /mnt, to be used for swap:

sudo dd if=/dev/zero of=/mnt/myfile.swap bs=1024 count=1048576

To format the file for swap:

sudo mkswap /mnt/myfile.swap

To add the file to the system as a swap file:

sudo swapon /mnt/myfile.swap

You must edit file /etc/fstab to make the change permanent:

sudo nano /etc/fstab

Add this line to the end of file:

/mnt/myfile.swap  none  swap  sw 0  0

Ctrl + O, save file. Ctrl + X, close nano.

Reboot your computer to ensure that the changes go into effect.

kyodake
  • 15,401
0

First off:

    sudo apt-get install gparted && sudo gparted

Then make yourself your swap partition (using these steps), save, exit, and be relieved that you have easy access to as partition editor.

  1. Go to the choice tab in the top right, and choose the drive you want the swap on.

  2. If the device isn't already partitioned, go to Device -> Create Partition table -> Make FileSystem Type "EXT4" and make the memory Close to all of it (I'd say 93%.) Now save this and proceed.

  3. Now create another partition from that, make the FileSystem type "Swap" Make it use the rest of the memory, and save. DO NOT DO THIS IF THIS IS THE BOOT DRIVE. IF THIS IS THE BOOT DRIVE, TELL ME.

  4. If the device is already partitioned and you need to re partition it, just remove all partitions, and start from scratch. (Follow step 3)

  5. Now do

    sudo apt-get install gedit && sudo gedit /etc/fstab

You will see a line all the way at the bottom that looks like this:

    /dev/sda1 /home                                   ext4    defaults        0       0

Now make new lines copying this format for the partitions you just made. The only thing you will have to change is the FileSystem, the mount point, and the options. For example my swap line looks like this:

    /dev/mapper/ubuntu--vg-swap_1 none                swap    sw              0       0

After that, save and exit.

  1. The next step is crucially important to use root.

    sudo -i

  2. Now

    whoami

If whoami doesn't return root you've done something wrong, and you need to do

  sudo -i
  1. Now type

    mount -a

Into the terminal. THIS SHOULD NOT RETURN ANYTHING, IF IT DOES, STOP, AND LEAVE A COMMENT

  1. If it didn't return any lines, do

    reboot now

  2. When your computer boots back on, do free -m.

  3. You should see something like

    Swap: 8043 0 8043

  4. If you see that, you're done! If not, go back and do everything again.

David
  • 3,367