Expanding a LUN on RedHat Linux

Assuming you have a LUN that has been provisioned to your server, containing a physical volume, volume group and one or more logical volumes that is currently mounted and in use on your server. You can follow these steps to increase the size of that resource.

First of of course you will have to go onto your storage device and increase the size of the LUN to your new desired amount. This process varies by vendor so I will not cover it here, but it should be simple enough.

After you have increased the LUN size at the storage side if you look at the running RHEL server and run df, multipath -l, or fdisk -l you will see that the size of the disk has not changed. Similarly if you run pvdisplay, vgdisplay, and lvdisplay you will see that the server is unaware of any changes. In order to rescan your disks you will have to do the following.

First determine the device you are trying to resize by running:

# multipath -l
mpath7 (360050768028180a83400000000000021) dm-0 IBM,2145
[size=1000G][features=1 queue_if_no_path][hwhandler=0][rw]
\_ round-robin 0 [prio=0][active]
\_ 5:0:2:0 sde 8:64 [active][undef]
\_ 5:0:3:0 sdf 8:80 [active][undef]
\_ 6:0:2:0 sdi 8:128 [active][undef]
\_ 6:0:3:0 sdj 8:144 [active][undef]
\_ round-robin 0 [prio=0][enabled]
\_ 5:0:0:0 sdc 8:32 [active][undef]
\_ 5:0:1:0 sdd 8:48 [active][undef]
\_ 6:0:0:0 sdg 8:96 [active][undef]
\_ 6:0:1:0 sdh 8:112 [active][undef]

In my case, I only have one LUN associated with this server identified as mpath7.

Now run the following, which is an interesting piece of script I found over on the RedHat Archive here. This script will instruct each device associated with your LUN to rescan for changes. In my case this will echo “1” to devices sdc through sdj.

# for varTmp in `multipath -ll mpath7 | grep sd | awk '{print $2}'`; do
echo 1 > /sys/class/scsi_device/$varTmp/device/rescan ;done ; unset varTmp

]# multipathd -k"resize multipath mpath7"

Now when we run multipath -l you should see that the device has been updated to reflect the changes on the storage side.

Now we can resize the device using the following.

# pvresize /dev/mapper/mpath7
  Physical volume "/dev/dm-0" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized

# lvresize /dev/vg_grp_name/my_lv_name -l +100%FREE
  Extending logical volume my_lv_name to XXXXXX
  Logical volume my_lv_name successfully resized

# resize2fs /dev/vg_grp_name/my_lv_name
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/vg_grp_name/my_lv_name is mounted on /my_mount_point; on-line
resizing required
Performing an on-line resize of /dev/vg_grp_name/my_lv_name to XXXXXX
(4k) blocks.
The filesystem on /dev/vg_grp_name/my_lv_name is now XXXXXXX blocks

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>