Increase the size of an Ubuntu VM's volume.

Glengineer

Dabbler
Joined
Dec 20, 2020
Messages
15
I want to increase the space available to a Linux ubuntu server VM.

It was initially set to 8GB.

I changed the Zvol from 8GB to 500GB:

kira-gxrngk VOLUME553.28 GiB9.91 TiBlz41.65falseOFF

This is what cfdisk looks like

Code:
                                                     Disk: /dev/vda
                                 Size: 500 GiB, 536870912000 bytes, 1048576000 sectors
                              Label: gpt, identifier: CCEBF416-6CF8-44EB-9356-5EA921A7A8C3

    Device                          Start                 End             Sectors          Size Type
>>  /dev/vda1                        2048             1050623             1048576          512M EFI System                  /dev/vda2                     1050624             3147775             2097152            1G Linux filesystem
    /dev/vda3                     3147776            20973567            17825792          8.5G Linux filesystem
    Free space                   20973568          1048575966          1027602399          490G


lvdisplay returns:
Code:
glen@kira:~$ sudo lvdisplay
  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/ubuntu-lv
  LV Name                ubuntu-lv
  VG Name                ubuntu-vg
  LV UUID                AfPl3K-h68d-KdwF-kZoB-QwR5-FKsQ-UMGjEW
  LV Write Access        read/write
  LV Creation host, time ubuntu-server, 2021-01-17 12:36:16 +0000
  LV Status              available
  # open                 1
  LV Size                <8.50 GiB
  Current LE             2175
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0


vgdisplayreturns
Code:
glen@kira:~$ sudo vgdisplay
  --- Volume group ---
  VG Name               ubuntu-vg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <8.50 GiB
  PE Size               4.00 MiB
  Total PE              2175
  Alloc PE / Size       2175 / <8.50 GiB
  Free  PE / Size       0 / 0
  VG UUID               FHMg3Q-cJS9-TB5N-ReEw-hOF8-hs1a-vzmTUD


I am unsure how to increase the volume to take up more space.

I tried sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv but that said there was nothing to do.

Can anyone help me increase the volume to take up all 500GB of space.?
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
Try shutting down and then restarting the VM. Bhyve only passes this info to the VM when the VM starts. You should be able to resize the partition via gparted afterwards.
 

Glengineer

Dabbler
Joined
Dec 20, 2020
Messages
15
Thanks,

Unfortunately, I cannot resize it using parted

Code:
Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 9123MB
Sector size (logical/physical): 512B/16384B
Partition Table: loop
Disk Flags:

Number  Start  End     Size    File system  Flags
 1      0.00B  9123MB  9123MB  ext4

(parted) resize
Error: The resize command has been removed in parted 3.0
(parted) resizepart
Partition number? 1
Warning: Partition /dev/mapper/ubuntu--vg-ubuntu--lv is being used. Are you sure you want to continue?
Yes/No? yes
End?  [9123MB]? 20000
Error: The location 20000 is outside of the device /dev/mapper/ubuntu--vg-ubuntu--lv.
(parted)
 

Heracles

Wizard
Joined
Feb 2, 2018
Messages
1,401
Looks like you are using LVM.

Have a look at this about how to increase the size of an LVM...
 

KrisBee

Wizard
Joined
Mar 20, 2017
Messages
1,288
Easier? You could have used cfdisk to resize /dev/vda3. Write the changes and reboot. Then use the appropriate LVM commands, eg.

pvresize /dev/vda3
lvextend -l +100%FREE ubuntu-vg/ubuntu-lv -r

Job done.
 
Top