I'm trying to extend a LVM in a Vmware Workstation 12 Pro CentOS VM. Below are the steps I am following and where I stopped because don't know how to folow from there:
fdisk
commandGet partition table info using fdisk -l
:
# fdisk -l
Disk /dev/sda: 85.9 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0001d929
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 5222 41430016 8e Linux LVM
/dev/sda3 5222 10443 41940357+ 8e Linux LVM
Disk /dev/mapper/vg_webserver-lv_root: 38.3 GB, 38277218304 bytes
255 heads, 63 sectors/track, 4653 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vg_webserver-lv_swap: 4143 MB, 4143972352 bytes
255 heads, 63 sectors/track, 503 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Convert the partition to physical volume:
# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created
Get the name of the volume to extend:
# vgdisplay
--- Volume group ---
VG Name vg_webserver
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 39.51 GiB
PE Size 4.00 MiB
Total PE 10114
Alloc PE / Size 10114 / 39.51 GiB
Free PE / Size 0 / 0
VG UUID qo4qm0-yTZc-TVzt-Ys0t-Ap2j-sH4X-rtMqPS
Extend the physical volume:
# vgextend vg_webserver /dev/sda3
Volume group "vg_webserver" successfully extended
Get the "free" space available:
# vgextend vg_webserver /dev/sda3
Volume group "vg_webserver" successfully extended
Get the info for logical volume:
# lvdisplay
--- Logical volume ---
LV Path /dev/vg_webserver/lv_root
LV Name lv_root
VG Name vg_webserver
LV UUID ayl9Ae-Y7nk-CVXG-c0G1-P4vx-wdlD-hEmXSO
LV Write Access read/write
LV Creation host, time webserver.localhost, 2015-10-27 12:48:48 -0400
LV Status available
# open 1
LV Size 35.65 GiB
Current LE 9126
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/vg_webserver/lv_swap
LV Name lv_swap
VG Name vg_webserver
LV UUID vwXfta-tGr0-kQFI-B2vF-L4gT-skE5-yb5qXA
LV Write Access read/write
LV Creation host, time webserver.localhost, 2015-10-27 12:48:52 -0400
LV Status available
# open 1
LV Size 3.86 GiB
Current LE 988
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
Extend the logical volume:
# lvextend -L+40G /dev/vg_webserver/lv_root
Insufficient free space: 10240 extents needed, but only 10239 available
I got the error above and I don't know where to go from there and how to fix this, can any help me? What I am doing wrong and what is the logical explanation behind the issue I am running?
Note: I have read this but I am not sure how to undone every change I've already made and if this info is the path to follow
UPDATE
As requested here is the ouptut of the following commands:
# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name vg_webserver
PV Size 39.51 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 10114
Free PE 0
Allocated PE 10114
PV UUID mwFIHY-mwwJ-b3uk-PkbP-7JXp-Vp2t-foCZtt
--- Physical volume ---
PV Name /dev/sda3
VG Name vg_webserver
PV Size 40.00 GiB / not usable 1.38 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 10239
Free PE 0
Allocated PE 10239
PV UUID tWg4Oj-ZknB-mefb-Ggy9-V8Cu-C7S2-OvO5aU
# vgdisplay
--- Volume group ---
VG Name vg_webserver
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 79.50 GiB
PE Size 4.00 MiB
Total PE 20353
Alloc PE / Size 20353 / 79.50 GiB
Free PE / Size 0 / 0
VG UUID qo4qm0-yTZc-TVzt-Ys0t-Ap2j-sH4X-rtMqPS
# lvdisplay
--- Logical volume ---
LV Path /dev/vg_webserver/lv_root
LV Name lv_root
VG Name vg_webserver
LV UUID ayl9Ae-Y7nk-CVXG-c0G1-P4vx-wdlD-hEmXSO
LV Write Access read/write
LV Creation host, time webserver.localhost, 2015-10-27 12:48:48 -0400
LV Status available
# open 1
LV Size 75.64 GiB
Current LE 19365
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/vg_webserver/lv_swap
LV Name lv_swap
VG Name vg_webserver
LV UUID vwXfta-tGr0-kQFI-B2vF-L4gT-skE5-yb5qXA
LV Write Access read/write
LV Creation host, time webserver.localhost, 2015-10-27 12:48:52 -0400
LV Status available
# open 1
LV Size 3.86 GiB
Current LE 988
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
I think thare is some roundings at work that cause your lvextend
to fail.
Try this: lvextend /dev/vg_webserver/lv_root -l+100%FREE
The above command will ask the system to allocate all free space to the selected logical volume, without asking for a specific size.
You can run grab all free spaces: lvextend /dev/vg_webserver/lv_root -l+100%FREE
Following that you need to run:
In case of xfs: xfs_growfs <partition>
For ext4: resize2fs <partition>
You can use -l
option with number of available extents:
sudo lvextend -l+10239 /dev/vg_webserver/lv_root
citation from man lvextend
:
-l|--extents [+]Number[PERCENT]
Specifies the new size of the LV in logical extents.
The --size and --extents options are alternate methods of specifying size. The total number of physical extents used will be greater when redundant data is needed for RAID levels. An alternate syntax allows the size to be determined indirectly as a percentage of the size of a related VG, LV, or set of PVs. The suffix %VG denotes the total size of the VG, the suffix %FREE the remaining free space in the VG, and the suffix %PVS the free space in the specified PVs. For a snapshot, the size can be expressed as a percentage of the total size of the origin LV with the suffix %ORIGIN (100%ORIGIN provides space for the whole origin). When expressed as a percentage, the size defines an upper limit for the number of logical extents in the new LV. The precise number of logical extents in the new LV is not determined until the command has completed. When the plus + or minus - prefix is used, the value is not an absolute size, but is relative and added or subtracted from the current size.
User contributions licensed under CC BY-SA 3.0