Problem
I have a LUN of 2GB which is exported to one of my Red Hat Enterprise Linux (RHEL) servers. This volume is being used on the server and mounted on /rcptest. I need to increase this virtual volume from 2GB to 10GB on the storage side and then I need to increase the same on the RHEL server. I have to do all these activities online i.e. without rebooting the server or without removing the mounting.
[root@dbappweb.com ~]# multipath -ll mpathh mpathh (360002ac000000000000065c000010b4b) dm-4 3PARdata,VV size=2G features='0' hwhandler='0' wp=rw `-+- policy='round-robin 0' prio=1 status=active |- 1:0:0:5 sde 8:64 active ready running |- 2:0:0:5 sdaa 65:160 active ready running |- 1:0:2:5 sdo 8:224 active ready running `- 2:0:2:5 sdak 66:64 active ready running
This volume is in LVM and mounted on /rcptest
[root@dbappweb.com ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/rcptest-lvrcptest 2.0G 1.3G 576M 69% /rcptest
Solution
To increase the size of the volume first we have to increase the size of the virtual volume on the storage side. Once it will be increased from 2GB to 10GB on the storage side then we can increase the same on the RHEL server. Follow the steps given below to increase the size on volume online:
- Increase the size of virtual volume from 2GB to 10GB on storage.
- Resize the multipath device by executing the multipath resize command. Here multipath device name is mpathh which is already shown in multipath -ll.
[root@dbappweb.com ~]# multipathd resize map /dev/mapper/mpathh ok
- Now the size of the multipath device has been increased from 2GB to 10GB as shown below.
[root@dbappweb.com ~]# multipath -ll mpathh mpathh (360002ac000000000000065c000010b4b) dm-4 3PARdata,VV size=10G features='0' hwhandler='0' wp=rw `-+- policy='round-robin 0' prio=1 status=active |- 1:0:0:5 sde 8:64 active ready running |- 2:0:0:5 sdaa 65:160 active ready running |- 1:0:2:5 sdo 8:224 active ready running `- 2:0:2:5 sdak 66:64 active ready running
- Create a new primary partition using the fdisk command and give the partition number 2 to it as portion number 1 was already created.
[root@dbappweb.com ~]# fdisk /dev/mapper/mpathh WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (1-1305, default 262): Using default value 262 Last cylinder, +cylinders or +size{K,M,G} (262-1305, default 1305): Using default value 1305 Command (m for help): p Disk /dev/mapper/mpathh: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 16384 bytes / 16777216 bytes Disk identifier: 0xf3ced09e Device Boot Start End Blocks Id System /dev/mapper/mpathhp1 3 261 2080417+ 83 Linux Partition 1 does not start on physical sector boundary. /dev/mapper/mpathhp2 262 1305 8385930 83 Linux Partition 2 does not start on physical sector boundary. Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 22: Invalid argument. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks.
- In the above step, a warning is shown that “Re-reading the partition table failed with error 22: Invalid argument.”. To resolve this run the kpartx command.
[root@dbappweb.com ~]# kpartx -av -p p /dev/mapper/mpathh add map mpathhp1 (253:14): 0 4160835 linear /dev/mapper/mpathh 32130 add map mpathhp2 (253:30): 0 16771860 linear /dev/mapper/mpathh 4192965
- Run the fdisk -l command to verify the created partitions.
[root@dbappweb.com ~]# fdisk -l /dev/mapper/mpathh Disk /dev/mapper/mpathh: 10.7 GB, 10737418240 bytes 255 heads, 63 sectors/track, 1305 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 16384 bytes / 16777216 bytes Disk identifier: 0xf3ced09e Device Boot Start End Blocks Id System /dev/mapper/mpathhp1 3 261 2080417+ 83 Linux Partition 1 does not start on physical sector boundary. /dev/mapper/mpathhp2 262 1305 8385930 83 Linux Partition 2 does not start on physical sector boundary.
- Create the physical volume for /dev/mapper/mpathhp2 using pvcreate command
[root@dbappweb.com ~]# pvcreate /dev/mapper/mpathhp2 Physical volume "/dev/mapper/mpathhp2" successfully created
- Extend the volume group vgrcptest, using vgextend command.
[root@dbappweb.com ~]# vgextend rcptest /dev/mapper/mpathhp2 Volume group "rcptest" successfully extended
- Verify the VG size, which has been increased to 9.95GB but the LV size is still 1.96GB.
[root@dbappweb.com ~]# vgdisplay -v rcptest Using volume group(s) on command line. --- Volume group --- VG Name rcptest System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 2 Act PV 2 VG Size 9.95 GiB PE Size 4.00 MiB Total PE 2546 Alloc PE / Size 503 / 1.96 GiB Free PE / Size 2043 / 7.98 GiB VG UUID LLiW6z-9rhi-1cPj-LA0v-eW9C-HTMA-7TDdYS --- Logical volume --- LV Path /dev/rcptest/lvrcptest LV Name lvrcptest VG Name rcptest LV UUID VcJcMw-akzU-PZEI-v8bn-TU63-BjOV-Cdn9Wc LV Write Access read/write LV Creation host, time dbappweb.com, 2017-05-11 17:03:04 +0530 LV Status available # open 1 LV Size 1.96 GiB Current LE 503 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:27 --- Physical volumes --- PV Name /dev/mapper/mpathhp1 PV UUID AXBOp6-nhRs-cijS-oA3g-n3fV-5c1K-rH8V0h PV Status allocatable Total PE / Free PE 503 / 0 PV Name /dev/mapper/mpathhp2 PV UUID CbSixg-zJGD-ziR0-D0eF-qryR-JoWR-1NXfT4 PV Status allocatable Total PE / Free PE 2043 / 2043
- Extend the logical volume using the command lvextend, you may verify it by using the command lvdisplay
[root@dbappweb.com ~]# lvextend -l +100%FREE /dev/rcptest/lvrcptest Size of logical volume rcptest/lvrcptest changed from 1.96 GiB (503 extents) to 9.95 GiB (2546 extents). Logical volume lvrcptest successfully resized.
- Resize the filesystem by using the resize2fs command.
[root@dbappweb.com ~]# resize2fs /dev/rcptest/lvrcptest resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/rcptest/lvrcptest is mounted on /rcptest; on-line resizing required old desc_blocks = 1, new_desc_blocks = 1 Performing an on-line resize of /dev/rcptest/lvrcptest to 2607104 (4k) blocks. The filesystem on /dev/rcptest/lvrcptest is now 2607104 blocks long.
- Verify the filesystem, it has been increased to 10 GB.
[root@dbappweb.com ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/rcptest-lvrcptest 9.8G 1.3G 8.1G 14% /rcptest
Last Updated: August 29, 2020