Is it safe to resize my swap partition on a production system?

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.


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.