Add disk space to lvgroup

General support questions
Post Reply
garyw
Posts: 17
Joined: 2012/05/22 22:20:30
Contact:

Add disk space to lvgroup

Post by garyw » 2020/07/24 12:57:35

Hi all,

I'm probably missing something silly here but I'm stuck. I've got a linux CentOs 6.10 box (yes I know, I don't own it, I'm helping out a customer, I have told them to upgrade) that is in VMware. I've grown the disk form 35GB to 43GB and now need to add that disk space.
Normally I'd create a partition and use pvcreate to kick off the process of growing the LVM but the partition is only giving me 1MB of space:

[root@serverone ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
sda 8:0 0 43G 0 disk
├─sda1 8:1 0 500M 0 part /boot
├─sda2 8:2 0 34.5G 0 part
│ ├─VolGroup-lv_swap (dm-0) 253:0 0 7.8G 0 lvm [SWAP]
│ └─VolGroup-lv_root (dm-1) 253:1 0 26.7G 0 lvm /
└─sda3 8:3 0 1008K 0 part
[root@serverone ~]#

I can see the disk space as part of sda2? I haven't grown it so I'm confused as to why sda2 is 34.5G?

df -h shows:
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
27G 4.2G 21G 17% /

Clearly I've missed something somewhere!

help! :-)

Thanks.

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Add disk space to lvgroup

Post by TrevorH » 2020/07/24 13:45:25

If you didn't reboot after expanding the "disk" then you need to or it will only show you the space that was there before. On KVM (vs vmware) you can do a virsh blockresize to tell the guest that the disk has changed size but I don't think a vmware equivalent to that exists. I suspect you just happened to have 1MB left on the existing disk size which is why it will only make the new partition that size. So, reboot to get the disk recognised at its new size, then use fdisk or whatever to add a new partition then reboot again since the partition table will be in use and the change won't be seen, then you can pvcreate the new partition and add it to the VG...
I'm confused as to why sda2 is 34.5G?
Because that's how big it was before. 34.5GB + the 0.5GB given to /boot = 35GB, the original disk size.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

garyw
Posts: 17
Joined: 2012/05/22 22:20:30
Contact:

Re: Add disk space to lvgroup

Post by garyw » 2020/07/24 13:56:00

I have rebooted and I still get the same issue.

garyw
Posts: 17
Joined: 2012/05/22 22:20:30
Contact:

Re: Add disk space to lvgroup

Post by garyw » 2020/07/24 14:04:02

I've deleted the partition and rebooted again but I'm still not able to add the disk space to the new parition:

Disk /dev/sda: 46.2 GB, 46170898432 bytes
64 heads, 32 sectors/track, 44032 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0007b94a

Device Boot Start End Blocks Id System
/dev/sda1 * 2 501 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 502 35840 36187136 8e Linux LVM
Partition 2 does not end on cylinder boundary.
/dev/sda3 1 1 1008 83 Linux

Partition table entries are not in disk order

/dev/sda is 46.2 GB but /dev/sda3 still goes to 1Mbit.

lsblk gives me this:

AME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
sda 8:0 0 43G 0 disk
├─sda1 8:1 0 500M 0 part /boot
├─sda2 8:2 0 34.5G 0 part
│ ├─VolGroup-lv_swap (dm-0) 253:0 0 7.8G 0 lvm [SWAP]
│ └─VolGroup-lv_root (dm-1) 253:1 0 26.7G 0 lvm /
└─sda3 8:3 0 1008K 0 part

garyw
Posts: 17
Joined: 2012/05/22 22:20:30
Contact:

Re: Add disk space to lvgroup

Post by garyw » 2020/07/24 14:19:50

Weird. This process worked like a charm on another server. It just appears that one of the machines is not happy.

I'm going to break out a partition editor to see if I can see what's going on.

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Add disk space to lvgroup

Post by TrevorH » 2020/07/24 18:49:30

/dev/sda3 1 1 1008 83 Linux
This partition is being allocated in freespace right at the start of your disk not in the new gigabytes of it that you just added.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

garyw
Posts: 17
Joined: 2012/05/22 22:20:30
Contact:

Re: Add disk space to lvgroup

Post by garyw » 2020/07/30 15:43:38

So it is! That answers that, thank you. That was driving me mad.

Is there a way to tell fdisk to use the freespace that is at the end of the disk?

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Add disk space to lvgroup

Post by TrevorH » 2020/07/30 16:01:54

Yes, it should ask you when you tell it to create a new partition. It should ask for a starting sector number and it defaults to the first bit of freespace it can find. Even if it's minute. :-( Print out the existing partition table entries, make a note of the ending sector of the last partition and add at least 1 to it (making sure that it's aligned to a 1MB boundary on the disk to avoid problems with 4KB sectors). It should then pick the end address of the freespace starting there as the default ending sector when it asks about that too.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

garyw
Posts: 17
Joined: 2012/05/22 22:20:30
Contact:

Re: Add disk space to lvgroup

Post by garyw » 2020/07/30 19:13:29

Thanks for the help TrevorH - Much appreciated.

I've a few more servers to add space to so I'll try it again :-)

Post Reply