Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a laptop with 4GB RAM, but when I first set it up, I had no plans to hibernate so I gave it 2GB swap. I don't want to use a swap file, so is it safe to resize the swap partition (and of course the main ext4 partition)?

share|improve this question
up vote 3 down vote accepted

Yeah, that should be just fine. Swap space is used when the system has too many applications running to hold all of their data in memory; it's a feature of the paging/virtual memory system. If you shut down the machine properly before repartitioning, there shouldn't be any data in the swap space and you should be able to expand it safely.

share|improve this answer
I'm well informed on what it does, just wanted to be sure it wouldn't cause any issues :D. Thanks – RolandiXor Nov 14 '10 at 19:58

The problem you will encounter is that if you try to resize a partition it probably won't work as you are currently using it. In the computer system jargon we says the partition is "mounted", reflecting the fact that you can browse it and access its data.

So what you want to do is boot from a Live CD or USB and use the disk partition manager to resize your "home" partition for instance. As you would have started the computer from the Live device, your real home partition would not be "mounted", and as such you can edit it.

Though, in most cases you won't have problems resizing a partition you should always perform a complete backup of your data on your computer. And in addition, you should check the following, it will help avoiding problem:

  • as you have a laptop, check that your battery is fully charged and that the power cable is plugged in. So you're reducing the risk of power failure during the resizing process
  • you should check the partition for errors and correct them before resizing. You could check the Ubuntu wiki for fsck, or you can use the command sudo fsck -y /dev/sda<n> replacing by the proper partition number. I advise you to do that from the Live CD/USB too.
  • as you want to reduce a partition of 2GB, you should verify first that you have more than 2GB free on this partition.
  • finally it's good practice to avoid having a file system too full (more than 80 or 90 %) as this helps keeping file fragmentation low. You should be aware that file fragmentation could raise the time and complexity necessary to resize a partition.

But don't be afraid, it's doable. I've done on a production development server at work. And everything worked fine.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.