User Tools

Site Tools


m78:extend-your-lvm

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
m78:extend-your-lvm [2026/01/06 20:04] – created media78admm78:extend-your-lvm [2026/01/06 20:27] (current) media78adm
Line 5: Line 5:
 Once that is done, you may need to get Linux to rescan the disk for the new free space. Check for free space by running cfdisk and see if there is free space listed, use “q” to exit once you’re done.\\ Once that is done, you may need to get Linux to rescan the disk for the new free space. Check for free space by running cfdisk and see if there is free space listed, use “q” to exit once you’re done.\\
  
-Linux increase disk size space cfdisk+{{ :m78:9-linux-increase-disk-size-space-cfdisk.jpg?nolink&600 |Linux increase disk size space cfdisk}}
  
 If you don’t see free space listed, then initiate a rescan of /dev/sda  with echo 1>/sys/class/block/sda/device/rescan. Once done, rerun cfdisk and you should see the free space listed.\\ If you don’t see free space listed, then initiate a rescan of /dev/sda  with echo 1>/sys/class/block/sda/device/rescan. Once done, rerun cfdisk and you should see the free space listed.\\
  
-Linux free partition space scan+{{ :m78:10-linux-free-partition-space-scan.jpg?nolink&600 |Linux free partition space scan}}
  
 Select your /dev/sda3 partition from the list and then select “Resize” from the bottom menu. Hit ENTER and it will prompt you to confirm the new size. Hit ENTER again and you will now see the /dev/sda3 partition with a new larger size.\\ Select your /dev/sda3 partition from the list and then select “Resize” from the bottom menu. Hit ENTER and it will prompt you to confirm the new size. Hit ENTER again and you will now see the /dev/sda3 partition with a new larger size.\\
Line 17: Line 17:
 Now that the LVM partition backing the /dev/sda3 Physical Volume (PV) has been extended, we need to extend the PV itself. Run pvresize /dev/sda3 to do this and then use pvdisplay to check the new size.\\ Now that the LVM partition backing the /dev/sda3 Physical Volume (PV) has been extended, we need to extend the PV itself. Run pvresize /dev/sda3 to do this and then use pvdisplay to check the new size.\\
  
-Ubuntu extend physical volume pvresize+{{ :m78:11-ubuntu-extend-physical-volume-pvresize.jpg?nolink&600 |Ubuntu extend physical volume pvresize }}
  
 As you can see above, my PV has been increased from 98.5GB to 198.5GB. Now let’s check the Volume Group (VG) free space with vgdisplay.\\ As you can see above, my PV has been increased from 98.5GB to 198.5GB. Now let’s check the Volume Group (VG) free space with vgdisplay.\\
  
-Ubuntu LVM: check vg space vgdisplay+{{ :m78:12-ubuntu-lvm-check-vg-space-vgdisplay.jpg?nolink&600 |Ubuntu LVM: check vg space vgdisplay}}
  
 We can see above that the VG has 100GB of free space. Now let’s check the size of our upstream Logical Volume (LV) using lvdisplay, extend the LV to use up all the VG’s free space with lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv, and then check the LV one more time with lvdisplay to make sure it has been extended.\\ We can see above that the VG has 100GB of free space. Now let’s check the size of our upstream Logical Volume (LV) using lvdisplay, extend the LV to use up all the VG’s free space with lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv, and then check the LV one more time with lvdisplay to make sure it has been extended.\\
  
-Ubuntu LVM: check LV size lvdisplay+{{ :m78:13-ubuntu-lvm-check-lv-size-lvdisplay.jpg?nolink&600 |Ubuntu LVM: check LV size lvdisplay}}
  
 At this point, the block volume underpinning our root filesystem has been extended, but the filesystem itself has not been resized to fit that new volume. To do this, run df -h to check the current size of the file system, then run resize2fs /dev/mapper/ubuntu–vg-ubuntu–lv to resize it, and df -h one more time to check the new file system available space.\\ At this point, the block volume underpinning our root filesystem has been extended, but the filesystem itself has not been resized to fit that new volume. To do this, run df -h to check the current size of the file system, then run resize2fs /dev/mapper/ubuntu–vg-ubuntu–lv to resize it, and df -h one more time to check the new file system available space.\\
  
-Ubuntu LVM: extend filesystem resize2fs+{{ :m78:14-ubuntu-lvm-extend-filesystem-resize2fs.jpg?nolink&600 |Ubuntu LVM: extend filesystem resize2fs}}
  
 And there you go. You’ve now taken an expanded physical (or virtual) disk and moved that free space all the way up through the LVM abstraction layers to be used by your (critically full) root file system. Time to check it off the to-do list and move on to the next IT emergency.\\ And there you go. You’ve now taken an expanded physical (or virtual) disk and moved that free space all the way up through the LVM abstraction layers to be used by your (critically full) root file system. Time to check it off the to-do list and move on to the next IT emergency.\\
m78/extend-your-lvm.1767729875.txt.gz · Last modified: by media78adm