Spis treści

LIN: Resize the LVM to Use the Whole Disk

1. Backup Important Data

Before proceeding, always back up your data. Resizing partitions can lead to data loss if something goes wrong.

Check Free Space

First, ensure there’s unallocated space on your disk. You already noted that /dev/sda is 136.13 GiB total. Check the layout to see if your /dev/sda3 (which currently holds the majority of the space) has free space:

sudo pvs
sudo vgs
sudo lvs

3. Resize the Physical Volume

Assuming /dev/sda3 is your physical volume, you will need to resize it. If it is currently at 134.1G, you’ll first need to resize the partition table using fdisk or parted to reclaim the unallocated space.

Open the partitioning tool:

   sudo fdisk /dev/sda

Delete the existing /dev/sda3 (don't worry, the data should be safe as it’s managed in LVM) and recreate it using the full disk size.

Recreate /dev/sda3:

Save changes and exit by typing w.

4. Resize the Physical Volume

After adjusting the partitions on the disk, you'll need to resize the physical volume to recognize the new space:

sudo pvresize /dev/sda3

5. Resize the Logical Volume

Now, you can resize the logical volume where the system is mounted. For example, if your logical volume is named ubuntu–lv:

sudo lvresize -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv

6. Resize the Filesystem

Finally, resize the filesystem to use the additional space. Assuming it's ext4, use:

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

7. Verify

Run `df -h` to verify that the filesystem has grown:

df -h

Summary

These steps will resize your partitions to use the entire disk efficiently. Be cautious, as improper use of partition tools can lead to data loss. If you have any doubts, consider consulting with a professional or accessing more detailed documentation.

Feel free to ask if you have any questions or need further clarification!