Find the LVM details of the volume group that you want to add a disk to:
sudo lvdisplay
Example output, The two with bold are the needed information in this example
root@packetfence02:~# sudo lvdisplay
--- Logical volume ---
LV Path /dev/packetfence02-vg/root
LV Name root
VG Name packetfence02-vg
LV UUID g5B36c-Yb10-sfmL-IjcI-0Z3E-iHup-EkS0oU
LV Write Access read/write
LV Creation host, time packetfence02, 2024-06-07 22:38:36 +0200
LV Status available
# open 1
LV Size <248.55 GiB
Current LE 63628
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:0
--- Logical volume ---
LV Path /dev/packetfence02-vg/swap_1
LV Name swap_1
VG Name packetfence02-vg
LV UUID X2A1xo-bWvK-0eei-322I-6QAU-KdhL-NVRjuz
LV Write Access read/write
LV Creation host, time packetfence02, 2024-06-07 22:38:36 +0200
LV Status available
# open 2
LV Size 976.00 MiB
Current LE 244
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:1
Find more info about the new disk
sudo fdisk -l
Example output, the text with bold are the new disk path:
root@packetfence02:~# sudo fdisk -l
Disk /dev/sda: 250 GiB, 268435456000 bytes, 524288000 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x878d4176
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 999423 997376 487M 83 Linux
/dev/sda2 1001470 524285951 523284482 249.5G 5 Extended
/dev/sda5 1001472 524285951 523284480 249.5G 8e Linux LVM
Disk /dev/mapper/packetfence02--vg-root: 248.55 GiB, 266875174912 bytes, 521240576 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/packetfence02--vg-swap_1: 976 MiB, 1023410176 bytes, 1998848 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sdb: 250 GiB, 268435456000 bytes, 524288000 sectors
Disk model: QEMU HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Create the new disk
sudo pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created.
Add newly created pv named /dev/sdb to an existing lv packetfence02-vg
sudo vgextend packetfence02-vg /dev/sdb
Volume group "packetfence02-vg" successfully extended
Extend the volume group with all available disk space
sudo lvm lvextend -l +100%FREE /dev/packetfence02-vg/root
Size of logical volume packetfence02-vg/root changed from <248.55 GiB (63628 extents) to 498.56 GiB (127632 extents).
Logical volume packetfence02-vg/root successfully resized.
Resize volume
sudo resize2fs -p /dev/packetfence02-vg/root
resize2fs 1.46.2 (28-Feb-2021)
Filesystem at /dev/packetfence02-vg/root is mounted on /; on-line resizing required
old_desc_blocks = 32, new_desc_blocks = 63
The filesystem on /dev/packetfence02-vg/root is now 130695168 (4k) blocks long.
Validate result with df
sudo df -H
root@packetfence02:~# df -H
Filesystem Size Used Avail Use% Mounted on
udev 8.4G 0 8.4G 0% /dev
tmpfs 1.7G 2.2M 1.7G 1% /run
/dev/mapper/packetfence02--vg-root 526G 23G 480G 5% /
.....
For other filesystems
The resize2fs command is the standard and most reliable tool for resizing ext{2,3,4} filesystems. Are you using different filesystem? Try the following tools:
- btrfs filesystem resize Use this command to grow or shrink Btrfs filesystems online.
- xfs_growfs : Use for resizing XFS filesystems. It can only grow filesystems and works online.