Introduction
If your Ubuntu system is not using all available disk space, you can expand the root partition using LVM (Logical Volume Manager). This guide will walk you through extending the root volume (/
) to utilize the full disk space.
Steps
1. Check Current Disk Usage
Run the following command to see the current disk layout:
lsblk
Example output:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sr0 11:0 1 2K 0 rom
vda 253:0 0 75G 0 disk
├─vda1 253:1 0 1G 0 part /boot/efi
├─vda2 253:2 0 2G 0 part /boot
└─vda3 253:3 0 71.9G 0 part
└─ubuntu--vg-ubuntu--lv 252:0 0 36G 0 lvm /
This shows that the logical volume is only using 36GB, while vda3
has 71.9GB available.
2. Extend the Logical Volume
First, check free space available in the volume group:
sudo vgdisplay
If there is free space, extend the logical volume:
sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
3. Resize the Filesystem
Once the volume is extended, resize the filesystem based on its type:
If using ext4
sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
If using XFS
sudo xfs_growfs /
4. Verify Changes
Check the updated disk usage:
df -h
You should now see the root partition (/
) using all available space.
Conclusion
You have successfully extended the root partition to utilize all available disk space. This ensures your system has enough storage for applications and data. 🚀
Have questions? Drop a comment below!
Top comments (0)