Friday, October 7, 2016

partitioning - Resize VirtualBox Ubuntu



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




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








  • 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







  • 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







  • 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


No comments:

Post a Comment

11.10 - Can't boot from USB after installing Ubuntu

I bought a Samsung series 5 notebook and a very strange thing happened: I installed Ubuntu 11.10 from a usb pen drive but when I restarted (...