1

I went through this forum post, and found out that it is possible to install a swap partition after installation of the OS. I just wanted a guide as to how I should do it so as to have it done safely and neatly. Do I first free up space equal to 4000MB (my RAM size) from my Windows 8 installation drive and simply format the new free space to a linux-swap? How exactly do I then bind it to /etc/fstab? Do I use the terminal and run: sudo update-initramfs -u first, and then update the UUID using the commands shown in that thread? Also, can I include the previously "unallocated" and "unknown" partitions on my disk in the swap partition? Please help.

enter image description here

UserName
  • 209
  • 2
  • 5
  • 19

2 Answers2

1

You probably want to look at this question: Creating a Dedicated swap hard drive

You won't have to use a partition for swap, a swap file is totally fine, no performance penalty at all. See the abovementioned question, use fallocate or dd to create a swap file and swapon to use it. To make it survive reboots, add it to /etc/fstab.

Terry Wang
  • 9,775
  • I did all the stuff you recommended and I rebooted my computer. This is what I got:-

    http://i39.tinypic.com/2iudohw.png

    http://i40.tinypic.com/epg38p.png

    The system seems to not be able to detect a swap.

    I figured I should have used the instructions suggested on the thread whose link I posted, especially identifying the UUID part, but now I am unsure as to how to redo it, because I didn't save the UUID which was shown on the terminal at the time of creation of swap.img. Do I just use swapoff and simply delete the file and start over? Please help.

    – UserName Aug 31 '13 at 15:07
  • Also, it seems as if my system has become a tad slower, perhaps it is not a good idea to have a 4GB swap file leaving only 11 GB free on a 20 GB partition? Just wondering. – UserName Aug 31 '13 at 15:20
  • You can swapoff the swap file and delete it, recreate it an use UUID, no problem. For swap file /path/to/file is OK, for swap partition UUID is recommended but /dev/xxx does the same job technically. – Terry Wang Sep 01 '13 at 01:00
  • The screen shots showed you have no swap. Have you done mkswap /mnt/swap.img and then swapon /mnt/swap.img? Disk space is NOT the problem, slowness is mostly caused by swap in/out (check using vmstat), also adjust the /proc/sys/vm/swappiness value, set to 1 (don't set to 0 unless you know what you are doing). – Terry Wang Sep 01 '13 at 01:02
  • Yes I followed the steps as you mentioned in the same exact order. I will retry it to check if I did anything wrong. Also /proc/sys/vm/swappiness reads 60. Is it a garbage value? Is it because there is no active swap present? – UserName Sep 01 '13 at 04:10
  • I realized I had made a horrible mistake. I used a # before adding the line in the fstab file which effectively made it a comment instead of a line with information. I have added the UUID in the file now and the swap is showing.

    i44.tinypic.com/f26dcl.png

    However, after I restart the system, it doesn't show again and I have to use swapon to reactivate it. Is there something left to be done?

    – UserName Sep 01 '13 at 05:03
  • Cool, good to see it works;-) – Terry Wang Sep 01 '13 at 10:03
0

I found this thread helpful, especially the last suggestion. http://ubuntuforums.org/showthread.php?t=1796024 . I ran a boot repair which made the GRUB my default boot manager. That has made things a lot easier now. My swap gets turned automatically on, unlike previously when I had to use swapon to turn it on.

UserName
  • 209
  • 2
  • 5
  • 19