0

I am running an Ubuntu guest on a Mac host using Virtualbox. I ran out of space so I doubled the size of the disk from 8G to 16G using VBoxManage modifyhd /path/to/my.vdi --resize 16384 and extended the partition using a GParted live CD. As you can see, the partition is now 16GB.

$ sudo parted /dev/sda p
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 17.2GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type      File system  Flags
 1      1049kB  512MB   511MB   primary   ext2         boot
 2      513MB   17.2GB  16.7GB  extended
 5      513MB   17.2GB  16.7GB  logical

However, the extended space is not automatically being recognized by /dev/mapper/nanu64--vg-root:

$ df -h
Filesystem                   Size  Used Avail Use% Mounted on
udev                         477M     0  477M   0% /dev
tmpfs                        100M  3.2M   97M   4% /run
/dev/mapper/nanu64--vg-root  6.3G  3.9G  2.1G  66% /
tmpfs                        497M  4.0K  497M   1% /dev/shm
tmpfs                        5.0M     0  5.0M   0% /run/lock
tmpfs                        497M     0  497M   0% /sys/fs/cgroup
/dev/sda1                    472M  105M  343M  24% /boot
tmpfs                        100M     0  100M   0% /run/user/501
/home/stephen/.Private       6.3G  3.9G  2.1G  66% /home/stephen

I tried to extend the volume but it is unaware of this extra space:

$ sudo lvextend -L +8G /dev/mapper/nanu64--vg-root
  Insufficient free space: 2048 extents needed, but only 0 available

I also tried the lvresize command with similar results:

$ sudo lvresize -L +8G /dev/mapper/nanu64--vg-root 
  Insufficient free space: 2048 extents needed, but only 0 available
$ sudo lvresize -l +100%PVS /dev/mapper/nanu64--vg-root
  Insufficient free space: 1924 extents needed, but only 0 available

I need more room in my home directory. Is there a way to add extents to /dev/mapper/nanu64--vg-root? Is there another way to use the extended partition size to increase the free space in /home?

Running resize2fs seems unnecessary:

$ sudo resize2fs /dev/mapper/nanu64--vg-root 
resize2fs 1.42.13 (17-May-2015)
The filesystem is already 1708032 (4k) blocks long.  Nothing to do!

Running pvdisplay gives the following:

$ sudo pvdisplay
  --- Physical volume ---
  PV Name               /dev/mapper/sda5_crypt
  VG Name               nanu64-vg
  PV Size               7.52 GiB / not usable 4.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              1924
  Free PE               0
  Allocated PE          1924
  PV UUID               EiMXHd-Kwql-bpFF-Wafc-Beit-o72B-nU8M23

1 Answers1

1

After some findings I see that one should extend the .vdi disk using this line:

VBoxManage modifymedium <name_of_vm>.vdi --resize 8000

You can create a new virtual disk and associate it with the virtual machine to provide the extra space:

VBoxManage createmedium --filename <name_of_vm>.vdi --size 8000

Basically the above steps is what was left out, but in your case you did it a bit wrong. The steps aught to have been:

  1. Resize using VBoxManage

  2. Use gparted iso file in Virtualbox to boot and resize.

  3. Resize the physical volume: sudo pvresize /dev/location/of/device

  4. Make the assigned space available with lvresize command Now I have added link and hopefully you will need only the first two commands I gave.

Source:

https://oracle-base.com/articles/vm/virtualbox-extend-disk-and-file-system

https://technology.amis.nl/2017/01/30/ubuntu-vm-virtualbox-increase-size-disk-make-smaller-exports-distribution/

http://derekmolloy.ie/resize-a-virtualbox-disk/

George Udosen
  • 36,677