In most cases, fully resizing an online LUN/DISK involves two things: resizing the LUN/DISK itself and reflecting the size change in the corresponding multipath device (if multipathing is enabled on the system).
Different scenarios of LUN/DISK extension has been explained with examples.
Extending space on Existing LUN/DISK will fall under either of the below listed scenarios. The below scenarios assume that the LUN/DISK has been already extended on storage.
- Extending space on Non-Multipath, Unpartitioned LUNS/DISKS
- Extending space on Multipath, Unpartitioned LUNS/DISKS
- Extending space on Non-Multipath, Partitioned LUNS/DISKS
- Extending space on Multipath, partitioned LUNS/DISKS
The LUNS/DISKS should be extended first on storage, and extending existing LUNS might or might not be possible on some occasions, depending on type of storage being used. It is recommended to check with Storage Administrator for possible options. Also, It is highly recommended that you read through each of these scenarios carefully before proceeding to run the commands in your environment.
#scan the block device for changes echo 1 > /sys/class/block/sdc/device/rescan #Verify additional space fdisk -l | grep -i "sdc" #resize PVs pvresize /dev/sdc
Now the VGs that contain the PV (sdc) should reflect the additional space that was added. If this is a NON LVM disk, you can directly resize the File system with the below command.
resize2fs /dev/sdc
In case this is an LVM, you can extend the LVs from the additional space. (See LVM Cheat Sheet for reference).
Scan all paths to disk. (Example, if /dev/sdc and /dev/sdd are two different paths to same DISK/LUN)
#scan all paths to block device for changes echo 1 > /sys/block/sdc/device/rescan echo 1 > /sys/block/sdd/device/rescan #Issue the multipath resize map command command. #Note that there is no space betweek '-k' and the begin quote, this is not a typo. multipathd -k"resize map mpath" The below scenarios assume that the LUN/DISK has been already extended on storage. #verify the new size in multipath -ll output for the disk multipath -ll #resize PVs pvresize /dev/mapper/mpath1 #Verify if the PVs are reflecting the new size with below commands. pvs
Now the VGs that contains the extended PV (mpath1) should reflect the additional space that was added.
If this is a NON LVM disk, you can directly resize the File system with the below command
resize2fs /dev/mpath1
In case this is an LVM, you can extend the LVs from the additional space. (See LVM Cheat Sheet for reference).
#scan the block device for changes echo 1> /sys/class/block/sdc/device/rescan #Verify additional space fdisk -l | grep -i "sdc"
Assuming that your disks were partitioned with fdisk with an MBR partition table, If you have less than 4 Primary partitions on the Disk (/dev/sdc), you can to create a new primary partion with additional space from disk. This partion can be used to create PVs, which in turn can be used to extend VGs and LVs.
If you’ve consumed all the primary partitions, It is possible to extend only the last primary partiton (4th partition), since the extended space (cylinders) cannot be added to the middle of the disk. Therefore in this case, if you’re trying to extend space on a filesystem that is consuming anything but the last partition, it is not possible.
Suppose if /dev/sdc has been extended with additional space from Storage and suppose /dev/sdc has 4 partitions already,
/dev/sdc1
/dev/sdc2
/dev/sdc3
/dev/sdc4
It is possible to extend only /dev/sdc4 and not others, as you have run out of primary partitions (4 is the limit for primary partition in MBR). Whereas, if your Disks were already partitioned with GPT, You can have upto 128 partitions, in which case you’d be using parted or gdisk instead of fdisk.
fdisk /dev/sdc
The number of cylinders for this disk is set to 11096. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): p Disk /dev/sdc: 91.2 GB, 91268055040 bytes 255 heads, 63 sectors/track, 11096 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdc1 * 1 14 104391 83 Linux Partition 1 does not end on cylinder boundary. /dev/sdc2 14 4178 33450007+ 8e Linux LVM /dev/sdc3 4178 8354 33549073+ 8e Linux LVM /dev/sdc4 8355 9137 6289447+ 8e Linux LVM Command (m for help): d Partition number (1-4): 4 Command (m for help): n Command action e extended p primary partition (1-4) p Selected partition 4 First cylinder (8355-11096, default 8355): Using default value 8355 Last cylinder or +size or +sizeM or +sizeK (8355-11096, default 11096): Using default value 11096 Command (m for help): t Partition number (1-4): 4 Hex code (type L to list codes): 8e Changed system type of partition 4 to 8e (Linux LVM) Command (m for help): p Disk /dev/sdc: 91.2 GB, 91268055040 bytes 255 heads, 63 sectors/track, 11096 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdc1 * 1 14 104391 83 Linux Partition 1 does not end on cylinder boundary. /dev/sdc2 14 4178 33450007+ 8e Linux LVM /dev/sdc3 4178 8354 33549073+ 8e Linux LVM /dev/sdc4 8355 11096 22025115 8e Linux LVM 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 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot. Syncing disks.
partprobe -s pvresize /dev/sdc4
Physical volume "/dev/sdc4" changed 1 physical volume(s) resized / 0 physical volume(s) not resized
If this is a NON LVM disk, you can directly resize the File system with the below command
resize2fs /dev/sdc4
In case this is an LVM, you can extend the LVs from the additional space. (See LVM Cheat Sheet for reference).
Assuming that your disks were partitioned with fdisk with an MBR partition table, If you have less than 4 Primary partitions on the Disk, you can to create a new primary partion with additional space from disk. This partion can be used to create PVs, which in turn can be used to extend VGs and LVs.
If you’ve consumed all the primary partitions, It is possible to extend only the last primary partiton (4th partition), since the extended space (cylinders) cannot be added to the middle of the disk. Therefore in this case, if you’re trying to extend space on a filesystem that is consuming anything but the last partition, it is not possible.
Suppose if /dev/mapper/mpatha has been extended with additional space from Storage and suppose /dev/mapper/mpatha has 4 partitions,
/dev/mapper/mpathap1
/dev/mapper/mpathap2
/dev/mapper/mpathap3
/dev/mapper/mpathap4
It is possible to extend only /dev/mapper/mpathap4 and not others, as you have run out of primary partitions (4 is the limit for primary partition in MBR). Whereas, if your Disks were already partitioned with GPT, You can have upto 128 partitions, in which case you’d be using parted or gdisk instead of fdisk.
Scan all paths to disk. (Example, if /dev/sdc and /dev/sdd are two different paths to same DISK/LUN)
#scan the all paths to block device for changes echo 1 > /sys/block/sdc/device/rescan echo 1 > /sys/block/sdd/device/rescan #Issue the multipath resize map command command. #Note that there is no space betweek '-k' and the begin quote, this is not a typo. multipathd -k"resize map mpath" #verify the new size in multipath -ll output for the disk multipath -ll
fdisk /dev/mapper/mpatha
The number of cylinders for this disk is set to 11096. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): p Disk /dev/mapper/mpatha: 91.2 GB, 91268055040 bytes 255 heads, 63 sectors/track, 11096 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/mapper/mpatha1 * 1 14 104391 83 Linux Partition 1 does not end on cylinder boundary. /dev/mapper/mpathap2 14 4178 33450007+ 8e Linux LVM /dev/mapper/mpathap3 4178 8354 33549073+ 8e Linux LVM /dev/mapper/mpathap4 8355 9137 6289447+ 8e Linux LVM Command (m for help): d Partition number (1-4): 4 Command (m for help): n Command action e extended p primary partition (1-4) p Selected partition 4 First cylinder (8355-11096, default 8355): Using default value 8355 Last cylinder or +size or +sizeM or +sizeK (8355-11096, default 11096): Using default value 11096 Command (m for help): t Partition number (1-4): 4 Hex code (type L to list codes): 8e Changed system type of partition 4 to 8e (Linux LVM) Command (m for help): p Disk /dev/mapper/mpatha: 91.2 GB, 91268055040 bytes 255 heads, 63 sectors/track, 11096 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/mapper/mpatha1 * 1 14 104391 83 Linux Partition 1 does not end on cylinder boundary. /dev/mapper/mpathap2 14 4178 33450007+ 8e Linux LVM /dev/mapper/mpathap3 4178 8354 33549073+ 8e Linux LVM /dev/mapper/mpathap4 8355 11096 22025115 8e Linux LVM 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 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot. Syncing disks.
partprobe -s pvresize /dev/mapper/mpathap4
Physical volume "/dev/mapper/mpathap4" changed 1 physical volume(s) resized / 0 physical volume(s) not resized
If this is a NON LVM disk, you can directly resize the File system with the below command
resize2fs /dev/mapper/mpathap4
In case this is an LVM, you can extend the LVs from the additional space. (See LVM Cheat Sheet for reference).