Q:

How to use gparted to allocate unallocated space from VBox dynamic drive

I'm using VirtualBox with a Ubuntu 16.04 VM on OS X High Sierra. I increased the size of my dynamic storage and rebooted the VM using a live ISO and ran gparted.
gparted output

The two partitions that offer resizing when right-clicked are /dev/sda1 and /dev/sda5, but with neither is the space available equal to the unallocated space... they are as follows:

How do I make use of the 40G unallocated space? One answer (1054352) says to first increase the size of the extended partition first, but mine (sda2) doesn't have that option.
When I follow Curtis's answer, doing the gparted and then a mount:
# df -h
Filesystem                   Size  Used Avail Use% Mounted on
udev                         3.0G     0  3.0G   0% /dev
tmpfs                        601M  8.6M  592M   2% /run
/dev/mapper/ubuntu--vg-root   18G   12G  4.9G  71% /
tmpfs                        3.0G  6.7M  3.0G   1% /dev/shm
tmpfs                        5.0M     0  5.0M   0% /run/lock
tmpfs                        3.0G     0  3.0G   0% /sys/fs/cgroup
/dev/loop2                    90M   90M     0 100% /snap/core/6673
/dev/loop3                    92M   92M     0 100% /snap/core/6531
/dev/loop1                   264M  264M     0 100% /snap/phpstorm/90
/dev/loop0                    91M   91M     0 100% /snap/core/6405
/dev/sda1                    472M  463M     0 100% /boot
tmpfs                        601M   44K  601M   1% /run/user/1000

which looks like the 20G partition is mounted, but when I try:
apt-get install byobu 

gzip: stdout: No space left on device. update-initramfs: failed for /boot/initrd.img-4.13.0-43-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1

A:

One reason the partition cannot be resized is because it is active.
To increase the size of the /dev/sda5 LVM2 PV logical partition:

Select the /dev/sda5 LMV2 PV logical partition and Deactivate it with the menu option Partition > Deactivate.
Select the /dev/sda2 extended partition and use Partition > Resize/Move to grow the partition to use the unallocated space.
Edit > Apply all operations.
Select the /dev/sda5 LVM2 PV logical partitition and use Partition > Resize/Move to grow the partition to use the unallocated space within the extended partition.
Edit > Apply all operations.
Open an terminal prompt and use commands such as lvresize to grow the LVM Logical Volume which you would like to be larger, such as the one containing the Root Volume Group.

I recommend learning more about Logical Volume Management by reading a tutorial or two from the Internet.
'Hope that helps.

