Ubuntu

Increase LVM

Here we will add two new hard drives to increase the LVM volume. This will be done on Ubuntu Linux current version is 22.04.02. The latest version can be downloaded from their website https://ubuntu.com/download/server. I have added two 450G hard drives to the system. Now I will show you how to add them to the system volume, the LVM. This volume is your main root volume where all the system files are and the /home directory is. The LMV is at peace as it will treat all the hard drives as one. I have SSH’d into the server so I need to open the SSH port before enabling the universal fire wall from fresh install.

# sudo ufw allow 22/tcp
# sudo ufw enable

Update server.

# sudo apt update && apt upgrade

Find the new drive names and the volume group name and the logic volume name.

# sudo lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 1.8G 0 part /boot
└─sda3 8:3 0 18.2G 0 part
└─ubuntu–vg-ubuntu–lv 253:0 0 10G 0 lvm / <—– we will be making this partition bigger sda3.
sdb 8:16 0 450G 0 disk <—– this is the drive name we are adding sdb
sdc 8:32 0 450G 0 disk <—– this is the drive name we are adding sdbc
sr0 11:0 1 1024M 0 rom

# 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 18.22 GiB <—– note for later to see change
PE Size 4.00 MiB <—– note for later to see change
Total PE 4665
Alloc PE / Size 2560 / 10.00 GiB
Free PE / Size 2105 / 8.22 GiB
VG UUID q0gibL-enf0-PJ9E-Sefu-zeFw-8YjZ-64xLM8

# sudo lvdisplay

— Logical volume —
LV Path /dev/ubuntu-vg/ubuntu-lv <—– needed for later when we lvextend and resize2fs
LV Name ubuntu-lv
VG Name ubuntu-vg <—– needed for later when we vgextend
LV UUID z2QI9z-ZbTo-vEY3-Fh6H-oEmy-d1ru-Yk95iI
LV Write Access read/write
LV Creation host, time ubuntu-server, 2023-06-15 22:50:26 +0000
LV Status available
# open 1
LV Size 10.00 GiB
Current LE 2560
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:0

Convert your new disk to a physical volume (in this case, the new disk is ‘sdb‘ and ‘sdc‘).

# sudo pvcreate /dev/sdb
# sudo pvcreate /dev/sdc

Add the physical volume to the volume group via ‘vgextend’.

# sudo vgextend ubuntu-vg /dev/sdb
# sudo vgextend ubuntu-vg /dev/sdc

Allocate the physical volume to a logical volume (extend the volume size by your new disk size).

# sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv

Resize the file system on the logical volume so it uses the additional space.

# sudo resize2fs /dev/ubuntu-vg/ubuntu-lv

Check all space was allocated and new configuration.

# sudo df -h
# sudo vgdisplay
# sudo lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1M 0 part
├─sda2 8:2 0 1.8G 0 part /boot
└─sda3 8:3 0 18.2G 0 part
└─ubuntu–vg-ubuntu–lv 253:0 0 918.2G 0 lvm / <—– you can see the increase in storage space to sda3
sdb 8:16 0 450G 0 disk
└─ubuntu–vg-ubuntu–lv 253:0 0 918.2G 0 lvm / <—– now part of the LVM
sdc 8:32 0 450G 0 disk
└─ubuntu–vg-ubuntu–lv 253:0 0 918.2G 0 lvm / <—– now part of the LVM
sr0 11:0 1 1024M 0 rom

# sudo lsblk output.
Scroll to Top