resize PV and LV without reboot

Issues related to applications and software problems
Post Reply
zio_mangrovia
Posts: 34
Joined: 2015/06/11 08:34:13

resize PV and LV without reboot

Post by zio_mangrovia » 2018/10/09 04:09:55

I noted 2 different behaviour in LVM if I create Physical Volume to whole disk e.g. /dev/sda or if I create a PV to /dev/sda1, in both cases /dev/sda or /dev/sda1 are "Linux LVM - 8e".

If I need to increase size fo /dev/sda PV, I increase my physical disk (e.g. in VMware environment), I assure myself new disk size is detected by kernel (no reboot is necessary), I resize PV, LV and File System and I reach my target with no reboot server.
In second case that is /dev/sda1 (when I have LVM partition and not whole disk) I need to reboot server otherwise kernel is not able to detect new Physical volume size. There is way to make it with no reboot ? Why this case is different from first case?

User avatar
TrevorH
Forum Moderator
Posts: 23876
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: resize PV and LV without reboot

Post by TrevorH » 2018/10/09 07:56:33

The kernel has the partition table in use and it will not reread it without a reboot.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

hunter86_bg
Posts: 1422
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: resize PV and LV without reboot

Post by hunter86_bg » 2018/10/09 17:50:04

You can always try to run

Code: Select all

partprobe /dev/sda
2-3 times. Sometimes the kernel detects the changes, sometimes not.
My recommendation is to first add new disk (VmWare 5.5 limit is 60 disks - which is OK), then add it as a new PV and the rest is easy.
Extending a disk could cause the behaviour you have observed.
So in general you need to:

Code: Select all

  echo 1 > /sys/block/sda/device/rescan
Verify thew new size via:

Code: Select all

fdisk -l /dev/sda
Next, create a new partition (and mark as LVM) , as extending the current is quite risky - requires recreation of the partition but starting from the same sector.

Code: Select all

fdisk /dev/sda
Now comes the hard part -> re-detect the partition table:

Code: Select all

partprobe /dev/sda ; partprobe /dev/sda
If you see the new partition -> good to go.
Last , is to resize the PV and so on...

zio_mangrovia
Posts: 34
Joined: 2015/06/11 08:34:13

Re: resize PV and LV without reboot

Post by zio_mangrovia » 2018/10/10 05:58:20

hunter86_bg wrote:
2018/10/09 17:50:04

My recommendation is to first add new disk (VmWare 5.5 limit is 60 disks - which is OK), then add it as a new PV and the rest is easy.
I'm referencing to increase physical disk size, I'm not adding new disk to VMware virtual machine but change its size to larger one.

zio_mangrovia
Posts: 34
Joined: 2015/06/11 08:34:13

Re: resize PV and LV without reboot

Post by zio_mangrovia » 2018/10/10 06:13:19

TrevorH wrote:
2018/10/09 07:56:33
The kernel has the partition table in use and it will not reread it without a reboot.
As I said (and I repeat this job every month) in first case there is no need to reboot machine and LV is changed immediately.
Here is procedure:
  1. increase vmware disk size
  2. echo 1 > /sys/class/scsi_device/x:y:z:k/device/rescan
  3. pvresize /dev/sdx
  4. lvextend -l +100%FREE /dev/...
  5. xfs_growfs /dev/...
This procedure works only disk has no partitions, e.g. fdisk -l /dev/sdd:

Disk /dev/sdd: 107.3 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdd doesn't contain a valid partition table


If I have e.g. /dev/sda2 because it's a partition and not the whole disk , this task doesn't wotk and nobody can tell me why!

Disk /dev/sda: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 10443 83778975 8e Linux LVM

User avatar
TrevorH
Forum Moderator
Posts: 23876
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: resize PV and LV without reboot

Post by TrevorH » 2018/10/10 14:26:10

The kernel has the partition table in memory. Obviously it won't do that if you are using a partition-tables-less disk.

RH disabled the ability for partprobe to do anything useful due to data loss problems somewhere between CentOS 5 and 6. It's still disabled and there are still data loss issues with it.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

hunter86_bg
Posts: 1422
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: resize PV and LV without reboot

Post by hunter86_bg » 2018/10/10 17:30:52

And still ,
I have managed several times to redetect the partition table of the primary disk via 'partprobe' without dataloss , but this behaviour is not 100% reproducible.

zio_mangrovia
Posts: 34
Joined: 2015/06/11 08:34:13

Re: resize PV and LV without reboot

Post by zio_mangrovia » 2018/10/11 08:15:15

hunter86_bg wrote:
2018/10/10 17:30:52
but this behaviour is not 100% reproducible.
What mean s It's not reproducible?

zio_mangrovia
Posts: 34
Joined: 2015/06/11 08:34:13

Re: resize PV and LV without reboot

Post by zio_mangrovia » 2018/10/11 08:17:40

TrevorH wrote:
2018/10/10 14:26:10
RH disabled the ability for partprobe to do anything useful due to data loss problems somewhere between CentOS 5 and 6. It's still disabled and there are still data loss issues with it.
I don't understand it, because you are referencing to 'partprobe' command?
I can solve my problem with disk partitions without reboot?

User avatar
TrevorH
Forum Moderator
Posts: 23876
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: resize PV and LV without reboot

Post by TrevorH » 2018/10/11 08:43:56

No.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

Post Reply