LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   change disk partitions without reboot (https://www.linuxquestions.org/questions/linux-kernel-70/change-disk-partitions-without-reboot-4175640149/)

zio_mangrovia 10-11-2018 04:08 AM

change disk partitions without reboot
 
iN cENTOS 6 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 ?
i THINK kernel has the partition table in memory (2nd case) while if I'm using a partition-tables-less disk (1st case) It's necessary no boot.

rknichols 10-11-2018 09:40 AM

I don't know of any way to make the kernel accept new partitioning while the disk is in use, but consider just adding another disk with just the added space and adding that new disk to the volume group. If you want to clean things up at some later time when you are rebooting, enlarge that first disk, boot, and then pvmove the LVM extents on the second disk back to the first. Once you've done that, you can remove the second disk from the volume group and delete it. Yes, you can do pvmove while the system is running.

zio_mangrovia 10-11-2018 10:28 AM

Here is my method applied in 1st, whole disk is linux LVM

increase vmware disk size
echo 1 > /sys/class/scsi_device/x:y:z:k/device/rescan
pvresize /dev/sdx
lvextend -l +100%FREE /dev/...
xfs_growfs /dev/...

This procedure works only disk has no partitions, /dev/sdd:


Quote:

I don't know of any way to make the kernel accept new partitioning while the disk is in use
infact this method works only when disk has no partitions.

michaelk 10-11-2018 10:35 AM

Quote:

iN cENTOS 6 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".
As far as I know the behavior is the same regardless if using the whole disk or a partition.

Yes the partition table is in memory and may not be automatically reread after using a partitioning utility. There are other utilities to reread the MBR/partition table which might work i.e. partx or partprobe.

zio_mangrovia 10-11-2018 10:49 AM

Quote:

Originally Posted by michaelk (Post 5913640)
As far as I know the behavior is the same regardless if using the whole disk or a partition.

No, this one is not the same behaviour, you should try it with both methods

Quote:

Yes the partition table is in memory and may not be automatically reread after using a partitioning utility. There are other utilities to reread the MBR/partition table which might work i.e. partx or partprobe
In first case (the whole disk) I don't understand, because you says partition table if I don't use disk 'fdisk command' to change partition table but I change only VMware disk size. I have no partitions inside disk

rknichols 10-11-2018 01:36 PM

Quote:

Originally Posted by michaelk (Post 5913640)
Yes the partition table is in memory and may not be automatically reread after using a partitioning utility. There are other utilities to reread the MBR/partition table which might work i.e. partx or partprobe.

You will find that, for this situation, partprobe will be unable to load the new table. (I tried it.)

michaelk 10-11-2018 01:44 PM

Thanks for the info.

zio_mangrovia 10-12-2018 01:46 PM

Quote:

Originally Posted by rknichols (Post 5913620)
I don't know of any way to make the kernel accept new partitioning while the disk is in use, but consider just adding another disk with just the added space and adding that new disk to the volume group. If you want to clean things up at some later time when you are rebooting, enlarge that first disk, boot, and then pvmove the LVM extents on the second disk back to the first. Once you've done that, you can remove the second disk from the volume group and delete it. Yes, you can do pvmove while the system is running.

this way permits to increase disk numbers while I want to keep the same disk.
What reason for similar behaviour for 1st and 2nd according to your opinion?

rknichols 10-12-2018 04:16 PM

Quote:

Originally Posted by zio_mangrovia (Post 5914096)
What reason for similar behaviour for 1st and 2nd according to your opinion?

Please clarify your question. I'm not sure what you are asking. I don't know any way to expand that partition without either rebooting or at least temporarily adding a second disk.

zio_mangrovia 10-15-2018 08:26 AM

Quote:

Originally Posted by rknichols (Post 5914138)
Please clarify your question.

I'm searching 2 answers:
  1. 1st case (disk has no partitions): Why am I able to modify physical volume size and to detect immediately it without reboot? Because It doesn't exist partitions table loaded into kernel?
  2. 2nd case (disk has LVM partitions): If I don't want to add other disks and I want to resize my disk, I have to make reboot ? There are no solutions? Right?
now I hope my questions are more clear

rknichols 10-15-2018 08:45 AM

Actually, I find it a bit surprising that the kernel will recognize a changed size of an active disk. Any explanation of why those two cases differ would be pure speculation on my part. You will just have to accept that there is no way to get the kernel to recognize a changed partition size without rebooting.


All times are GMT -5. The time now is 11:00 PM.