Search blog

Friday, December 12, 2014

How To Create Swap Partition/Space Using Gparted Partition Editor in Ubuntu



 First make sure you have some unallocated space on the left or right of the main partition where your Ubuntu is installed as the figure above.

Now lets evaluate the formula for creating the appropriate swap file. Below is a good explanation:

"I would say a good rule of thumb is indeed just as was mentioned above. 2 times the physical memory. Something to consider here, while it is possible to use a smaller swap partition, and it will suffice under most normal circumstances, if you want this system to be rock solid stable, I would indeed follow the 8 GB recommendation. In fact I recommend 2 * RAM + 1 MB so that there is absolutely room to swap out 2 entire copies of memory. This avoids the "shell game" scenario which can have negative performance repercussions. What this will do for you is guarantee a level of resiliency should you encounter an extraordinary event with your system.

I've seen scenarios where applications behave badly in unattended environments and before you know it, your system starts slowing down to a crawl.

Depending on what you are doing, you might even be able to dispense with the swap file entirely. The extra space for the OS is handy when running many applications at once. However if you only intend to run a few processes, do not intend to interact with the GUI disabling the swap file might be appropriate.

But if you are going to have a swap file I always use the sizing formula below.

 [(2 x RAM) + 1 MB] = Swap File Size  

I also recommend putting your swap file on a seperate disk whenver possible as this will increase performance as the OS can swap in and out at the same time as read/writes from the data disk.

I hope this is helpful." - Source: http://superuser.com/questions/16280/swap-partition-size-for-4gb-ramhttp://superuser.com/questions/16280/swap-partition-size-for-4gb-ram

Once you have decided on the swap space it's time to create it.

Right click on the unallocated space on your hard drive and click on New. A dialog box as the image below will appear. Make selection as in the image.


Then click on the 'green check icon' - which says 'Apply all operations' and wait.

Once the linux-swap partition is created - once again - Right Click on the 'linux-swap' partition and select Swapon.

But the problem here is this 'swap' turns off after restarting.

So to permanently activate the 'swap partition' follow the steps below:

Activating the swap partition

(If your swap is on your primary hard drive, you don't need to do anything here.) Now you need to find what partition your swap is on and what its UUID is. UUID?! you say? Well that's the Universally Unique IDentifier for the partition so you can reference it even if it's on a different mount point from boot-to-boot due to adding disks, etc.

  1. Pull up a terminal and run
     gksu gparted  
    
    & and enter your root password. The & lets this process run while still giving you access to the command line.
  2. br />
  3. Right-click on your swap partition and choose *Information*. You should see the **Path** and **UUID** listed there. Keep this open for further reference.
  4. Run
     gksu gedit /etc/fstab  
    
    & and look for the line that has *swap* in it. It should be the third column, separated by spaces or tabs. You can either use the path or the UUID to tell Linux where to find your swap partition. I recommend UUID because it'll stay constant even if you move the partition around or the disk somehow becomes sdb instead of sda or something like that. Make the appropriate edits and save the file. Your line should look something like this if you used UUID (with your UUID instead, of course):
    1. UUID=41e86209-3802-424b-9a9d-d7683142dab7 none swap sw 0 0
    2. or this if you used path: /dev/sda2 none swap sw 0 0
  5. Save the file.
  6. Enable the new swap partition with this command.
     sudo swapon --all OR $ sudo swapon --all --verbose  
      swapon on /dev/sda2 
     swapon: /dev/sda2: found swap signature: version 1, page-size 4, same byte order  
      swapon: /dev/sda2: pagesize=4096, swapsize=2147483648, devsize=2147483648  
    
  7. Confirm that the swap partition exists.
     $ cat /proc/swaps   
     Filename                Type      Size  Used  Priority  
     /dev/sda2                partition    2097148 0    -1  
    
  8. Reboot to make sure the new swap gets activated properly at startup.

No comments:

Post a Comment

Thank you for your Feedback!
www.evagabond.me

Top 5 Posts (Weekly)