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 Virtual Box Ubuntu guest and i need to have more space on my disk (actually it's 8 gb). I have already increased the space allocated for the VDI to 16 gb.

Now with GParted Live i'm trying to expand my partition, but the swap blocks the expansion, as is in this image

the situation now

I'm going to do some move/resize to get the unallocated space near the /dev/sda1.

The operations are these:


Now, if i do this, surely i will have problems with the next boot. What i have to do to fix that?

share|improve this question
You may not even need a swap when running Ubuntu in virtual box. – Takkat Oct 23 '11 at 16:49
what are the disadvantages of having swap on a file like albercuba said? – apelliciari Oct 23 '11 at 17:29
None, swap on file is fine but you don't really need a swap that would enable you to suspend your RAM to disk - however you don't do that in virtual box. Try without (you can always assign a swap on file later if you feel like you need it). – Takkat Oct 23 '11 at 17:53
up vote 8 down vote accepted

The resizing operations won't cause any issues with the filesystem, but you may need to update your /etc/fstab to point at the new partition ID.

  1. use GParted as you've described.

  2. Find the updated UUID of the swap partition from the output of:

    sudo blkid

  3. edit /etc/fstab in the guest OS to have the new UUID in the line with a 'type' of 'swap'

That should do it.

share|improve this answer
this worked, even without the edit to /etc/fstab; there was no line of type 'swap' in there and system booted successfully after the gparted operations – apelliciari Oct 23 '11 at 19:00
Interestingly, using this strategy I forgot to edit fstab and when I checked it later, the swap mount's UUID was already the same as what blkid showed. So I guess it's good to have the UUID's match, but depending on which OS you use it might track itself or depending on which Gparted version you use it might be kept in line by Gparted ?rising-tone-like-a-question? – cardiff space man Aug 24 '15 at 3:36

Just delete the swap partition and use a swap file. To do this type: This example is for a 1GB swap file

dd if=/dev/zero of=/swapfile bs=1024 count=1048576
mkswap /swapfile
swapon /swapfile

Be sure to tell the OS to stop using the swap partition before you delete it, like this.

swapoff /dev/nameOfCurrentSwap

And remove or comment out the line in fstab that points to it.

Then you have to enable the swap space at boot time, add this line in fstab:

/swapfile none swap sw 0 0
share|improve this answer
How can I direct the swap file to be on a specific storage device? – Matt Jun 30 '15 at 10:56

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.