Way back in January 2009, I wrote:
> Let's say I've got a PERC with some disks in a single RAID volume.
> That single volume is an LVM physical volume (no partition
> table - just a bare /dev/sdX). I create an LVM volume group over
> that PV and create one logical volume in that fills that volgroup.
>> Later I'm running out of disk space, so I buy another disk
> and do the MegaCli magic that expands the RAID volume onto the
> new disk.
>> How do I get LVM to see the larger space without downtime?
>> Last time I did this (CentOS 5.2 fully patched), I had to
> unmount the logical volume and deactivate the volume group.
>> Doing blockdev --rereadpt got the kernel to see the larger
> size of the /dev/sdX disk, but pvresize wouldn't extend the
> PV until the volgroup was deactivated.
>> So, instead of this expected sequence:
>> MegaCli ... # re-construct RAID volume
> blockdev --rereadpt /dev/sdX
> pvresize /dev/sdX
> lvresize ...
> resize2fs ...
>> I had to do this:
>> MegaCli ... # re-construct RAID volume
> blockdev --rereadpt /dev/sdX
> # stop all processes using /mnt/whatever
> # remove /etc/exports entry
> exportfs -r
> umount /mnt/whatever
> vgchange -a n volgroup # deactivate volgroup
> pvresize /dev/sdX
> vgchange -a y volgroup
> mount /mnt/whatever
> # restore /etc/exports entry
> exportfs -r
> # start processes using /mnt/whatever
> lvresize ...
> resize2fs ...
>> I was well irritated, let me tell you...
>> Is there any way around this?
Yes there is. What we need is to get the kernel to see that
the SCSI LUN has changed size:
echo 1 > /sys/block/sdX/device/rescan
While I've known for ages that you can re-scan SCSI buses with
something like
echo - - - > /sys/class/scsi_host/hostX/scan
I didn't realise you could trigger a rescan on a device too.
Once you've done the echo 1 > .../rescan, you can run pvresize
live. So the process looks like:
MegaCli ... # re-construct RAID volume
echo 1 > /sys/block/sdX/device/rescan
pvresize /dev/sdX
lvresize ...
resize2fs ...
Later,
Kenn
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!