- Resize the partition using
fdisk. - Extend the physical volume with
pvresize. - Expand the logical volume with
lvextend. - Resize the filesystem with
resize2fs.
Asume we have added HW or virtual disk in Hypervisor. Make snapshot if possible before any action just to sleep well π΄.
OS: Ubuntu \ Debian
Ensure that you have added additional disk space via your hardware or hypervisor settings.
df -h
sudo fdisk -l
sudo fdisk /dev/sdXa) Type p to view the partition table and note down the partition number (e.g., /dev/sda3).
b) Type d to delete the existing partition (donβt worry, this doesnβt delete data).
c) Type n to create a new partition. Choose Primary (usually option p) and specify the same starting sector as before. This ensures no data is lost. Press Enter for the default (which will use the full available size).
π’ If we get the message:
Created a new partition 3 of type 'Linux filesystem' and of size 46.9 GiB.
Partition #3 contains a LVM2_member signature.
Do you want to remove the signature? [Y]es/[N]o:
Select n !!! Do not remove signature β οΈ !!!
d) Type w to write changes and exit.
You may need to inform the kernel of the partition changes:
sudo partprobe /dev/sdXIf you are using ext4:
sudo resize2fs /dev/sdX1df -h
lsblkEnsure that you have added additional disk space via your hardware or hypervisor settings.
df -h
sudo fdisk -l
sudo fdisk /dev/sdXa) Type p to view the partition table and note down the partition number (e.g., /dev/sda3).
b) Type d to delete the existing partition (donβt worry, this doesnβt delete data).
c) Type n to create a new partition. Choose Primary (usually option p) and specify the same starting sector as before. This ensures no data is lost. Press Enter for the default (which will use the full available size).
π’ If we get the message:
Created a new partition 3 of type 'Linux filesystem' and of size 46.9 GiB.
Partition #3 contains a LVM2_member signature.
Do you want to remove the signature? [Y]es/[N]o:
Select n !!! Do not remove signature β οΈ!!!
d) Type w to write changes and exit.
You may need to inform the kernel of the partition changes:
sudo partprobe /dev/sdXsudo pvresize /dev/sda3vgdisplayLook for the "Free PE / Size" field, which indicates the amount of space you can allocate.
Then extend the logical volume using all or part of the available free space (replace ubuntu-vg and ubuntu-lv with your volume group and logical volume names, if different):
sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lvFinally, resize the filesystem on the logical volume to make use of the new space:
sudo resize2fs /dev/ubuntu-vg/ubuntu-lvdf -h
lsblk