This guide is a continuation of the previous guides which add free space to your volume group. If you do not have any Free PE / Size available when running vgdisplay
, you will need to follow one of the previous guides to expand your volume group first.
Now we have free space in the Volume Group, we can assign that to the Logical Volume mounted on /. You can check the size of the logical volume with the command lvdisplay
root@deskpro:~# lvdisplay
--- Logical volume ---
LV Path /dev/ubuntu-vg/ubuntu-lv
LV Name ubuntu-lv
VG Name ubuntu-vg
LV UUID t2f071-1PHF-fYIb-mgId-5g8G-fF7V-ZPxTGp
LV Write Access read/write
LV Creation host, time ubuntu-server, 2023-11-28 12:12:11 +0000
LV Status available
# open 1
LV Size <28.00 GiB
Current LE 7167
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0 copy
To grow the size of the logical volume, you need to use the command lvresize
, specifying the amount you want to resize and the LV path. You can specify a specific size with the -L
flag (i.e. -L +500M
), or an extent with the -l
flag (i.e. -l +100%FREE
). In thie example, we will allocate all the space available to the logical volume:
root@deskpro:~# lvresize -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from <28.00 GiB (7167 extents) to <48.00 GiB (12287 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized. copy
We can confirm that the logical volume has grown by checking lvdisplay
again:
root@deskpro:~# lvdisplay
--- Logical volume ---
LV Path /dev/ubuntu-vg/ubuntu-lv
LV Name ubuntu-lv
VG Name ubuntu-vg
LV UUID t2f071-1PHF-fYIb-mgId-5g8G-fF7V-ZPxTGp
LV Write Access read/write
LV Creation host, time ubuntu-server, 2023-11-28 12:12:11 +0000
LV Status available
# open 1
LV Size <48.00 GiB
Current LE 12287
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0 copy
Growing the filesystem
So far, we have increased the size of the disk, grown the partition, grown the physical volume and grown the logical volume. The final step is to grow the filesystem.
The method to grow the filesystem depends on the type of filesystem used. You can find your filesystem by running the command df -Th
to get the type.
root@deskpro:~# df -Th
Filesystem Type Size Used Avail Use% Mounted on
tmpfs tmpfs 392M 1.2M 391M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv ext4 28G 6.7G 20G 26% /
tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda2 ext4 2.0G 129M 1.7G 8% /boot
tmpfs tmpfs 392M 4.0K 392M 1% /run/user/1000 copy
The default filesystem that Ubuntu uses is ext4
, which uses the command resize2fs
. If you use another filesystem (such as xfs
, btrfs
etc), you will need to use the tool specifically for that filesystem.
If you are using ext4, run the command resize2fs
with the LV path:
root@deskpro:~# resize2fs /dev/ubuntu-vg/ubuntu-lv
resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /; on-line resizing required
old_desc_blocks = 4, new_desc_blocks = 6
The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 12581888 (4k) blocks long. copy
We can confirm that has applied by re-running df -h
to confirm the filesystem has grown to the new disk size:
root@deskpro:~# df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 392M 1.2M 391M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 48G 6.7G 39G 15% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/sda2 2.0G 129M 1.7G 8% /boot
tmpfs 392M 4.0K 392M 1% /run/user/1000 copy
You have now successfully grown your filesystem.
Please log in or register to submit a comment.