Need to resize Ubuntu partition under VirtualBox. As per other posts, have resized VirtualBox from 8GB to 16GB. Have booted Ubuntu 16.04.1 from DVD.

I started gparted and see four partitions:

/dev/sda1 [ext4] which is 7.5GB [this is the partition I want to enlarge],

/dev/sda2 [extended] which is 510MB,

/dev/sda5 [linux-swap] which is 510MB,

followed by unallocated 8GB.

Unfortunately, selecting the sda1 partition and attempting Resize/Move shows no chance to enlarge. Selecting the sda2 partition and attempting Resize/Move does show the ability to consume the unallocated space, but this is not the partition I want to enlarge. Ditto swap.

How to get gparted to enlarge the sda1 partition? Thanks. GParted screenshot

  • It sounds like you will have to move the other partition(s) to free up the space. Be sure to back up completely before performing any partition operations. Feb 3, 2017 at 2:29
  • Yes, moving sda2 and sda5 then enlarging sda1 seemed the right thing to do. sda2 shows zero free space before and 8GB after. I tried setting 8GB free before and zero free space after, but gparted then increased the sda2 partition size from 510MB to 8GB, which is not what I want. Feb 3, 2017 at 2:34
  • Looking at another post, I perform a "sudo fdisk -l" and found that sda2 [ext4] and sda5 [linux-swap] occupy the same space on the hard drive, i.e., sda2 is a container for sda5. It appears sda2 and sda5 have to be resized and/or moved together. Can anyone detail the gparted sequence to do that, ultimately resulting in sda1 become the sole enlarged partition? Feb 3, 2017 at 3:20
  • If you edit your question to include a current-window-only screenshot of gparted, I can make better recommendations. Please start new comments directed at me with @heynnema or I may miss them.
    – heynnema
    Feb 3, 2017 at 16:43
  • @heynnema Uploaded screenshot of gparted, taken from Ubuntu 16.04.1 booted from DVD. Note that, according to fdisk, sda2 and sda5 appear to occupy the same space on the hard drive. Thanks for your time. Feb 3, 2017 at 16:59

1 Answer 1


We'll be deleting sda2/sda5, recreating a new sda2 swap partition and moving it to the right. Then we'll resize sda1.

Backup any important data on sda1 (standard disclaimer)

Step #1

  • boot your Ubuntu VM
  • first we'll disable the current swap...
  • open a terminal and type:
    • sudo swapoff -a
    • gksudo gedit /etc/fstab
    • find the line with swap that looks similar to UUID=071f8b0e-8e16-4f4d-90ff-a4ae9cc56e2b none swap sw 0 0, and place a # at the beginning of the line to disable it
    • save and quit gedit
  • we'll come back later and re-edit /etc/fstab

Step #2

  • boot to the Ubuntu Live DVD in your VM
  • start gparted
  • in the lower pane, right-click on sda5 and issue a swapoff command
  • in the lower pane, right-click on sda5 and issue a delete command
  • in the lower pane, right-click on sda2 and issue a delete command
  • in the lower pane, right-click on the unallocated space and create a new swap partition, file system type = linux-swap, size approximately = 512-1024MB. Note what partition number gets created... probably sda2
  • in the lower pane, right-click on sda2 and issue a move/resize command
  • in the upper pane, hover the mouse pointer over the new swap partition, it'll change to a hand cursor, click/hold and move it all the way to the right
  • in the lower pane, right-click on sda1 and issue at move/resize command
  • in the graphic portion of the move/resize window, hover the mouse pointer over the right side of sda1 and note the arrow. Resize sda1 by dragging the right side all the way to the right. Click OK.
  • observe the graphic and confirm that it's right... two partitions... sda1 and sda2 swap... if not... then STOP HERE!
  • Click the Apply icon

Step #3

  • boot back into Ubuntu VM
  • open a terminal and type:
    • sudo mkswap /dev/sda2 # changing sda2 to the value noted above, if need be
    • copy the new UUID that is displayed to the clipboard
    • if no new UUID is displayed, type sudo blkid and note the new UUID there
    • gksudo gedit /etc/fstab
    • remove the # from the beginning of the swap line
    • replace the UUID value with a paste of the new UUID from the clipboard
    • save and quit gedit
    • type sudo swapon -a
  • you're done
  • reboot your VM
  • It worked. You did it. Is there any way I can substantively express my gratitude for your time? Feb 3, 2017 at 22:04
  • @FrankNatoli Great! Did the swap finally show up as sda2 after you hit apply? In terminal, type swapon and free -h and confirm that swap is fully working. If you can vote, can you click the up arrow that's over the 0, just to the left of my answer?
    – heynnema
    Feb 3, 2017 at 22:12
  • Yes, swap became /dev/sda2. No, I am a peasant who cannot vote! I clicked the check, that's the best I can do. Feb 3, 2017 at 22:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .