Search This Blog

Friday, January 02, 2015

Resize an LVM partition on a HP Proliant server

1. Install HP Proliant support pack 

2. If you've installed the PSP before and it is already running on your server, you can skip this step, otherwise start HP Array Configuration Utility Online for Linux. 
cd /opt/compaq/cpqacuxe/bld
./cpqacuxe -R
note: after finishing online configuration utility, you might want to stop it by running
./cpqacuxe -stop

3. Expand array and logical drive
Go to https://localhost:2381 and click on array configuration utility link.
Click on expand array - it will take some time to finish (like 8hrs). After the expansion is finished, a new button called 'expand logical drive' will appear, clicking on it will finish expanding the array.

4. Make Linux kernel recognize the new size of your hardware raid5
Reboot Linux server, run  'partprobe' or 'sfdisk -R /dev/cciss/c0d0' followed by  'fdisk -l /dev/cciss/c0d0' multiple times, 'till it shows the new size.
You might have to reboot multiple times if the new size does not appear at fdisk -l.

5. Enlarge partition with fdisk - DANGEROUS, please have a full backup first!
fdisk /dev/cciss/c0d0  (you might consider using fdisk -u /dev/cciss/c0d0 - it will display the size in sectors instead of cyclinders)
"p" - take note where the /dev/cciss/c0d0p2 (your extended partition) starts!
press "d" then "2" to remove the c0d0p2 partition - yes you wil DELETE the partition, don't reboot, don't move, dont even breathe on top of that server!!!
press "n" for new, then "p" primary partition to use the full space
Make sure the old and new partition starts at the same cylinder or sector position, otherwise, all your data will be destroyed!!!
press "t" to change partition type to LVM
"w" to write
"q" to quit
now you will need to reboot again!

6. Resize physical volume size, logical volume size and perform file system online increase:

After reboot, check again the new size:
[root@log ~]# fdisk -l /dev/cciss/c0d0
Disk /dev/cciss/c0d0: 1799.7 GB, 1799797127168 bytes
255 heads, 63 sectors/track, 218812 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

           Device Boot      Start         End      Blocks   Id  System
/dev/cciss/c0d0p1   *           1          13      104391   83  Linux
/dev/cciss/c0d0p2              14      218813  1757509959+  8e  Linux LVM

Let's see ho many free phisical blocks we have:
[root@log ~]#vgdisplay -v | grep "Free PE"
    Finding all volume groups
    Finding volume group "VolGroup00"
  Total PE / Free PE    54337 / 17879

Now let's resize the phisical volume:
[root@log ~]# pvresize /dev/cciss/c0d0p2
  Physical volume "/dev/cciss/c0d0p2" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized
  note: we used vgdisplay -v to check the number of free PE, let's say it's 17879.

Now let's extend the lvm: 
[root@log ~]# lvextend -l +17879 /dev/VolGroup00/LogVol02
  Extending logical volume LogVol02 to 1.60 TB
  Logical volume LogVol02 successfully resized

And finally we will resize the filesystem:
[root@log ~]# resize2fs /dev/VolGroup00/LogVol02
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol02 is mounted on /data; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol02 to 430276608 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol02 is now 430276608 blocks long.

Ofc, steps 4 to 6 can be replaced with running offline gparted from a CD...

No comments:

Post a Comment

Blog Archive