Jump to content

How can I reduce the swap partition of Ubuntu?

I have 2 HDDs one for windows 7 and the other one for Ubuntu. I have only allocated 80 GB from  500 GB HDD for ubuntu and the remaining 385 GB is in NTFS for windows usage. I wanted to resize the swap patition of ubuntu. I only have 2 partition one is swap and the other one is root I don't have home partition. I currently have a 6 GB of swap and I wanted to reduce it to 2 GB. And I want to merge the extra unallocated 4 GB to the root partition. How can I do that. 

 

I have ubuntu gnome. Below is the screenshot:- I am able to reduce the swap but how can I merge the unallocated 4 GB with the root partition ? Please help!

 

 

Screenshot from 2017-08-07 13-49-15.png

Link to comment
Share on other sites

Link to post
Share on other sites

First of all, you got to clarify what you want:

 

17 minutes ago, 4klips said:

6 GB of swap and I wanted to reduce it to 2 GB

means reducing the swap, and

18 minutes ago, 4klips said:

I am able to reduce the swap but how can I merge the 4 GB with the swap?

is confusing...

I guess the last one is a typo, and you mean merge with /dev/sda3

 

If you want to do that you will have to reduce /dev/sda2 to the same size as /dev/sda5, to make the unallocated space available outside of /dev/sda2 and then you can resize /dev/sda3.

You can't however do this from within your Ubuntu installation, so you'll have to do this using a liveCD. (because you can't resize a mounted partition (indicated by the key-icon))

Be safe, don't drink and sudo

 

Laptop: ASUS K541UA (i5-6198DU, 8GB RAM, 250GB 850 EVO) OS: Debian Buster (KDE)

Desktop: i7-7700, ASUS Strix H270F, 16GB RAM, 128GB SSD from laptop, some HDD's, iGPU, some NIC's, OS: Debian Buster (KDE)

 

Link to comment
Share on other sites

Link to post
Share on other sites

3 hours ago, 101dmrs said:

-snip-

Yes it was a typo my bad. Now I have corrected it. yes I want to merge the unallocated  4GB to  /dev/sda3.

And actually I am a linux noob. I installed Ubuntu to learn it. How can I reduce /dev/sda2 to 2 GB in live USB.

And can I use Lubuntu in live USB mode in 2 GB pendrive?

 

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, 4klips said:

Yes it was a typo my bad. Now I have corrected it. yes I want to merge the unallocated  4GB to  /dev/sda3.

And actually I am a linux noob. I installed Ubuntu to learn it. How can I reduce /dev/sda2 to 2 GB in live USB.

And can I use Lubuntu in live USB mode in 2 GB pendrive?

 

If Lubuntu has something like GParted installed, then yes. If it's not installed, put `sudo apt install gparted` into a terminal and open GParted once that's finished. You can install things when booted into a live image, but they won't stay after you shut down the live image.

Link to comment
Share on other sites

Link to post
Share on other sites

I found this video. It showed me how to do exactly the same thing.

 

https://www.youtube.com/watch?v=23GholsmQiU

 

and thank you for this:-

Just now, 101dmrs said:

 

If you want to do that you will have to reduce /dev/sda2 to the same size as /dev/sda5, to make the unallocated space available outside of /dev/sda2 and then you can resize /dev/sda3.

You can't however do this from within your Ubuntu installation, so you'll have to do this using a liveCD. (because you can't resize a mounted partition (indicated by the key-icon))

 

Now I have successfully reduced my swap partition to 2 GB.xD

Link to comment
Share on other sites

Link to post
Share on other sites

you can do this from a running system. Just type sudo swapoff into terminal and this will unmount the swap partition. If you are using ext4 for root partition you should be able to resize it without using a live cd.

I recommend using a swap file than a swap partition.

Turn off swap.

go to /etc/fstab and delete the line for the swap partition.

setup a swap file with instructions on the ubuntu wiki.

if you have 8gb+ of ram it is likely you dont even need swap. I have 8 GB on my laptop and i dont use swap.

             ☼

ψ ︿_____︿_ψ_   

Link to comment
Share on other sites

Link to post
Share on other sites

  • 2 weeks later...

Ubuuntu doesn't use a swap partition anymore. It uses a dynamic swap file. Delete it and let the system deal with swap as it was designed to do.

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, snkiz said:

Ubuuntu doesn't use a swap partition anymore. It uses a dynamic swap file. Delete it and let the system deal with swap as it was designed to do.

if that were true was does the installer default create a swap partition? I believe it's the next version of ubuntu that will default swap file

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, vorticalbox said:

if that were true was does the installer default create a swap partition? I believe it's the next version of ubuntu that will default swap file

I could've sworn they did it 16.04. but either way the solution is in place and can be back ported to older systems. This is not new, Ubuntu was actually late to the party.

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, snkiz said:

I could've sworn they did it 16.04. but either way the solution is in place and can be back ported to older systems. This is not new, Ubuntu was actually late to the party.

yeah it really is. 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×