Author Topic: Can i shrink the SWAP partition?  (Read 1347 times)

Offline Dreamofgilgamesh

  • Full Member
  • ***
  • Posts: 215
Can i shrink the SWAP partition?
« on: April 25, 2012, 07:01:58 AM »
Dear Group, I have installed PCLinux on a spare PC and being a bit of a newcomer I've made a mistake with the partitioning,  I have made the SWAP partition a whopping 19gb instead of the 3gb which i intended.  I dare say it's not a problem, but i like things to be right.

I had an idea to shrink the SWAP partition but the warning message about data loss scared me off.  Is it safe to carry out the action or am i risking breaking my new install?

Many thanks

Offline rubentje1991

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2110
  • Rubenus Parvus MCMXCI
Re: Can i shrink the SWAP partition?
« Reply #1 on: April 25, 2012, 07:10:40 AM »
No problem to shrink it in this case - when you do such operation, it should be unmounted I think, and it's also some "temporary" place - so after a reboot, really everything should be OK in my opinion
=> to be safe, you can execute the shrink from a live cd  ;)

Offline Dreamofgilgamesh

  • Full Member
  • ***
  • Posts: 215
Re: Can i shrink the SWAP partition?
« Reply #2 on: April 25, 2012, 07:35:14 AM »
Oh thank you!  So, presumably i can then enlarge my "HOME" partition to take of the saved space?

Offline rubentje1991

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2110
  • Rubenus Parvus MCMXCI
Re: Can i shrink the SWAP partition?
« Reply #3 on: April 25, 2012, 07:38:39 AM »
That's more difficult I think.... extending a drive is possible in one direction (as far as I know) - OK it may be possible in two directions with some dirty hacks but....  :)
=> I don't know where the the SWAP partition is located on your hard drive?

Offline 7272andy

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1628
  • UK MLU
Re: Can i shrink the SWAP partition?
« Reply #4 on: April 25, 2012, 08:22:36 AM »
Yes, it is possible to do these things; but you do need to do them with the partitions unmounted.

The simplest way is to use something like the gparted live CD to boot your PC and then make the modifications you need using gparted

Regards


Bare Metal 1         Bare Metal 2
Intel Celeron 420M   Intel i5 540M
2GB Ram              4GB Ram
Intel 943GM          Radeon HD 5650 PCI Express
RT2573               RT2790
32bit KDE            32&64bit KDE

Online Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10678
  • MLUs Forever!
Re: Can i shrink the SWAP partition?
« Reply #5 on: April 25, 2012, 08:36:12 AM »
If the Swap partition comes AFTER the /home partition then extending /home should be short and easy.

If it comes BEFORE the /home partition then it will take much longer to do, IIRC, as all the contents of /home are moved on the partition to the space previously occupied by Swap, in so far as is possible.

I would also recommend Gparted in this case .....  running from its own livecd or from a PCLOS liveCD.

MLUs rule the roost!

Linux XPS 3.4.38-pclos1.bfs  64 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline Dreamofgilgamesh

  • Full Member
  • ***
  • Posts: 215
Re: Can i shrink the SWAP partition?
« Reply #6 on: April 25, 2012, 10:42:56 AM »
Thank you, the order of my partitions is SWAP ROOT then HOME.  I booted with the live cd as suggested and i can indeed shrink the SWAP partition down to 3gb.  That then leaves a new block of about 16gb.  Naively i had hoped that i could merely enlarge the Home to contain this new block, not quite as easy as that.  The new block seems to have the same property as a bubble under the new wallpaper!  I can chase it but i can't get rid of it so to speak.

You couldn't be so kind could you as to point me in the right direction?

Online Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10678
  • MLUs Forever!
Re: Can i shrink the SWAP partition?
« Reply #7 on: April 25, 2012, 10:52:16 AM »
Thank you, the order of my partitions is SWAP ROOT then HOME.  I booted with the live cd as suggested and i can indeed shrink the SWAP partition down to 3gb.  That then leaves a new block of about 16gb.  Naively i had hoped that i could merely enlarge the Home to contain this new block, not quite as easy as that.  The new block seems to have the same property as a bubble under the new wallpaper!  I can chase it but i can't get rid of it so to speak.

You couldn't be so kind could you as to point me in the right direction?

I think your best bet at present is to enlarge the swap again to fill the space.

To add that space to your /home would require you to move the / partition into the space, then expand /home to include the space vacated by root.

Unless you have a dire need to do this then I suggest don't bother.

The alternative would be to create a remaster of your present install, check it for functionality, repartition the drive as you now wish, and reinstall from the remaster.

Personally I would not bother unless I was badly short of a few GBs of HDD space.

regards.
MLUs rule the roost!

Linux XPS 3.4.38-pclos1.bfs  64 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline Dreamofgilgamesh

  • Full Member
  • ***
  • Posts: 215
Re: Can i shrink the SWAP partition?
« Reply #8 on: April 25, 2012, 11:58:51 AM »
You mean if it ain't broke don't fix it!  Sage advice, and advice i intend to take. 

Thanks again


Online Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10678
  • MLUs Forever!
Re: Can i shrink the SWAP partition?
« Reply #9 on: April 25, 2012, 12:01:19 PM »
YW  ;)
MLUs rule the roost!

Linux XPS 3.4.38-pclos1.bfs  64 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline rubentje1991

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2110
  • Rubenus Parvus MCMXCI
Re: Can i shrink the SWAP partition?
« Reply #10 on: April 25, 2012, 02:56:34 PM »
You mean if it ain't broke don't fix it!  Sage advice, and advice i intend to take. 

Thanks again



Or you can add a little data partition for some purpose.... however, I can't think of one at the moment  :)
[however..... maybe installing a test/packagers install for PCLinuxOS, that would be my choice - but don't risk anything if you don't want to  ;)]

Online Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10678
  • MLUs Forever!
Re: Can i shrink the SWAP partition?
« Reply #11 on: April 25, 2012, 04:05:52 PM »
You mean if it ain't broke don't fix it!  Sage advice, and advice i intend to take. 

Thanks again



Or you can add a little data partition for some purpose.... however, I can't think of one at the moment  :)
[however..... maybe installing a test/packagers install for PCLinuxOS, that would be my choice - but don't risk anything if you don't want to  ;)]

If you do go down that route, be aware that you will need to edit the boot stanzas, as introducing another partition before the  / & /home would have an affect on numbering.

MLUs rule the roost!

Linux XPS 3.4.38-pclos1.bfs  64 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline dvhenry

  • Full Member
  • ***
  • Posts: 106
Re: Can i shrink the SWAP partition?
« Reply #12 on: April 27, 2012, 04:12:12 AM »
Quote
I think your best bet at present is to enlarge the swap again to fill the space.
I recall reading that the Linux kernel has issues with excessively large swap partitions (out of proportion with RAM).
But I also recall there was a 'recent' re-write of the code that handles RAM and swap, so, perhaps that is fixed.



 
« Last Edit: April 27, 2012, 04:14:36 AM by dvhenry »

Offline dvhenry

  • Full Member
  • ***
  • Posts: 106
Re: Can i shrink the SWAP partition?
« Reply #13 on: April 27, 2012, 04:29:04 AM »
One more point,
Without seeing the output of fdisk -l or an image from gparted, is it even posible to give reliable advice?
Do we realy know what the poster has as far as a partition table is concerned?

Offline rubentje1991

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 2110
  • Rubenus Parvus MCMXCI
Re: Can i shrink the SWAP partition?
« Reply #14 on: April 27, 2012, 04:50:17 AM »
One more point,
Without seeing the output of fdisk -l or an image from gparted, is it even posible to give reliable advice?
Do we realy know what the poster has as far as a partition table is concerned?

This can really help with more advanced questions....
But we know now that there exists a 19GB SWAP before the ROOT and HOME partitions - I think that's really enough to give advice to the op's question  ;)