Howto::Resize LVM: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 4: | Line 4: | ||
== Resize the LVM partition == | == Resize the LVM partition == | ||
First you must resize the partition that LVM is using. Make sure that you use your correct VM disk device and partition! Run these as root: | First you must resize the partition that LVM is using. Make sure that you use your correct VM disk device and partition! Run these as root: | ||
Determine your LVM partition: | |||
* <code>pvs</code> | |||
<pre> | |||
PV VG Fmt Attr PSize PFree | |||
/dev/sda5 vgubuntu lvm2 a-- <49.50g 48.00m | |||
</pre> | |||
* <code>parted /dev/sda</code> - In this case the VM disk is ''/dev/sda'' | * <code>parted /dev/sda</code> - In this case the VM disk is ''/dev/sda'' | ||
* <code>resizepart 2 100%</code> - In this case the LVM partition is extended partition ''2 | * <code>(parted) p</code> | ||
* <code>resizepart 5 100%</code> | <pre> | ||
* <code>quit</code> | Model: QEMU QEMU HARDDISK (scsi) | ||
Disk /dev/sda: 161GB | |||
Sector size (logical/physical): 512B/512B | |||
Partition Table: msdos | |||
Disk Flags: | |||
Number Start End Size Type File system Flags | |||
1 1049kB 538MB 537MB primary fat32 boot | |||
2 539MB 161GB 161GB extended | |||
5 539MB 161GB 161GB logical lvm | |||
</pre> | |||
* <code>(parted) resizepart 2 100%</code> - In this case the LVM partition is logical partition ''5'' which means you have to resize the extended partition ''2'' as well | |||
* <code>(parted) resizepart 5 100%</code> | |||
* <code>(parted) quit</code> | |||
== Resize the LVM physical volume == | == Resize the LVM physical volume == |
Revision as of 10:20, 19 August 2021
Introduction
This how to will explain how to resize your LVM volume to use to full size available on your Virtual Machine.
Resize the LVM partition
First you must resize the partition that LVM is using. Make sure that you use your correct VM disk device and partition! Run these as root:
Determine your LVM partition:
pvs
PV VG Fmt Attr PSize PFree /dev/sda5 vgubuntu lvm2 a-- <49.50g 48.00m
parted /dev/sda
- In this case the VM disk is /dev/sda(parted) p
Model: QEMU QEMU HARDDISK (scsi) Disk /dev/sda: 161GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1049kB 538MB 537MB primary fat32 boot 2 539MB 161GB 161GB extended 5 539MB 161GB 161GB logical lvm
(parted) resizepart 2 100%
- In this case the LVM partition is logical partition 5 which means you have to resize the extended partition 2 as well(parted) resizepart 5 100%
(parted) quit
Resize the LVM physical volume
Determine your LVM physical volume:
pvs
PV VG Fmt Attr PSize PFree /dev/sda5 vgubuntu lvm2 a-- <49.50g 48.00m
Resize the PV:
pvresize /dev/sda5
- In this case the LVM PV is /dev/sda5
Your LVM group should now have the full amount available. You can create a new logical volume or resize an existing volume.
Resize an existing LVM logical volume
Determine the LVM LV that you want to resize
lvdisplay
--- Logical volume --- LV Path /dev/vgubuntu/root LV Name root VG Name vgubuntu LV UUID cgSheV-OV17-d5Zy-oeJ2-evqi-O1Pz-qmLTaR LV Write Access read/write LV Creation host, time ubuntu, 2021-08-18 13:47:23 -0400 LV Status available # open 1 LV Size <48.50 GiB Current LE 12415 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 --- Logical volume --- LV Path /dev/vgubuntu/swap_1 LV Name swap_1 VG Name vgubuntu LV UUID i9VuXs-U6v9-UTvP-dL1P-ItpK-WRed-wc5Axq LV Write Access read/write LV Creation host, time ubuntu, 2021-08-18 13:47:23 -0400 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 253:1
Resize the LV:
lvresize --extents +100%FREE --resizefs /dev/vgubuntu/root
- In this case the LV path is /dev/vgubuntu/root
Note: This command also automatically resizes your filesystem for you