Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Situation: We have a server that has a 40GB SAN (Fiber Channel) mounted as /opt/application.

If the LUN is expanded to 60GB, what needs to be done to expand /opt/application on the RHEL-server to 60GB having only 1 LVM partition?

One option is adding a second LVM partition with fdisk and using lvextend to add this partition, but what if we want to stick to having 1 LVM partition on the disk?

What is the best way to expand the LUN from 40GB to 60GB? An unmount is possible if necessary, it's better than adding a second LVM partition and using lvextend.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

I'll assume your underlying PV is multipathed.

  • View the partition table of the LUN in exact sectors
    fdisk -ul /dev/mpathX

  • Re-scan the LUN
    echo into rescan or issue_lip, or run rescan-scsi-bus.sh, or however you do it

  • Confirm the block device now has the larger size
    fdisk -ul /dev/mpathX

  • Edit the partition table
    fdisk -u /dev/mpathX

  • Delete the partition, re-create the partition with the same starting sector but a new end sector which reaches to the new end of the larger block device.

    If your partition starts at an early sector like 63 but fdisk will only let you start a partition at 2048 or later, then create the partition starting at 2048, then go into "expert mode" and "move beginning of data" back to 63.

  • Unmount your filesystem
    umount /opt/application

  • Set the VG inactive
    vgchange -an /dev/mapper/vg-lv

  • Have the system recognise the new partition table
    partprobe /dev/mpathX

  • Grow the PV to the new size of the partition
    pvresize /dev/mpathX

  • Set the VG active
    vgchange -ay /dev/mapper/vg-lv

  • Resize the LV and its underlying filesystem
    lvresize -r -l+100%FREE /dev/mapper/vg-lv

  • Mount the filesystem and confirm its new size
    df -h /opt/application

Disclaimer: These are the right steps to the best of my knowledge. Make a backup. Do a test run in your development environment before trusting your production data to some random internet commenter on Serverfault.

share|improve this answer
2  
Alternate choice, create a new 60GB LUN. Allow the server to see it. Do a pvcreate and then vgextend the existing LVM to it. Then do a pvmove to migrate all extents from the old 40GB LUN device to the new 60GB LUN device. Then you can remove the old LUN and do the lvresize (you'll also need to run your file system resize command). –  tgharold Jun 9 '13 at 6:45
1  
And if you go with the new-LUN route, note that the PV doesn't need to be a partition - it can span the raw LUN (no need for fdisk/partition table). If your current PV was on the raw LUN, you'd be able to expand the PV online (scsi rescan then pvresize). –  skarap Jun 9 '13 at 6:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.