If you expand a block storage volume that is attached to a virtual machine by using the
Default attach block disk add-on that is greater than or equal to 2 TB that
was previously formatted to Logical Volume Manager (LVM), you must complete additional
steps.
About this task
If you are using Red Hat Enterprise Linux® 6.x and if
you expand a block storage volume to greater than or equal to 2 TB, you must resize the logical
volume that is mounted on the virtual machines manually. During this manual expansion, you must
detach the volume or restart the virtual instance. Therefore, you might want to complete this task
during a maintenance window. If you expand the logical volume to 2 TB or more on Red Hat
Enterprise Linux 6.x, during a Refresh
action or during a new deployment that uses an add-on, the following error message is produced:
The block storage device size expansion is not reflected in the mounted logical volume.
Automatic logical volume size refresh is not supported on RHEL 6.x if the size is expanded to 2 TB
or more. To refresh the logical volume size, manually rescan the device, create a new partition,
restart or the detach volume, and then add the partition to a physical volume, volume group, logical
volume and refresh the mount.
After you expand the size of the external volume and
then rediscover the size change from the page in the
Cloud Pak System Software
console, log in to the virtual machine by
using SSH and complete the following steps.
Note: You might have to also change the
size in PowerVC.
-
Identify the mount point that is associated with the block storage from the pattern instance
block storage table.
-
Run
df -Ph
to get the logical volume file system name that corresponds to the
mount point. The file system name is in the following format:
/dev/mapper/<volume_group_name>-<logical_volume_name>.
For example, if your mount point is
/mount1, when you run
df
-Ph
you must see something similar to the following output:
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/datavg0-LV21328 3.0G 1.6M 2.8G 1% /mount1
-
Get the volume group name and logical volume name from the output of the command that you ran
in the previous step.
In the example in the previous step, the volume group name is datavg0
and
logical volume name is LV21328
.
-
Run the
pvs
command to get the physical device that is associated with the
volume group. The pvs
command returns the physical device with the partition
number.
When you run the
pvs
command, you see output similar to the following
example:
PV VG Fmt Attr PSize PFree
/dev/sda2 rhel lvm2 a-- 11.75g 0
/dev/sdb1 datavg0 lvm2 a-- 1020.00m 0
/dev/sdb2 datavg0 lvm2 a-- 1020.00m 0
If
your volume group is datavg0
then your physical device is
/dev/sdb
-
Rescan the device to get the new size:
echo 1 >
/sys/block/<PHYSICAL_DEVICE>/device/rescan
.
For example, echo 1 > /sys/block/sdb/device/rescan
.
-
Run the following command to fix any alignment errors:
parted /dev/sdb print
.
When you are prompted to fix or ignore errors, type Fix.
-
Run the following command to get the start and end values for expanded disk segment:
parted -s /dev/<PHYSICAL_DEVICE> u MB p free
. The expanded
disk segment is the last entry in the output.
The preceding command returns output similar to the following
example:
parted -s /dev/sdb u MB p free
Model: IBM 2145 (scsi)
Disk /dev/sdb: 3221MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
0.02MB 1.05MB 1.03MB Free Space
1 1.05MB 1073MB 1072MB P1 lvm
2 1073MB 2147MB 1075MB P2 lvm
2147MB 3221MB 1074MB Free Space
The
start value is 2147 MB and the end value is 3221 MB.
-
Run the following command to partition:
parted -s -a optimal
/dev/<PHYSICAL_DEVICE> mkpart <Partition_Name>
<start> <end>
. The start and end value must be the same as the values that you
retrieved in the previous step (including the trailing MB string).
The following example creates a new partition with the start and end value that was
obtained from previous step:parted -s -a optimal /dev/sdb mkpart P3 2147MB
3221MB
-
Run the following command to set the
lvm
flags on the new partition:
parted /dev/<PHYSICAL_DEVICE> set <partition_number> lvm on
.
For example, to get the new partition number run
parted /dev/sdb print
.
The output
is:
Number Start End Size File system Name Flags
0.02MB 1.05MB 1.03MB Free Space
1 1.05MB 1073MB 1072MB P1 lvm
2 1073MB 2147MB 1075MB P2 lvm
3 2147MB 3221MB 1074MB P3
To
set partition 3 to lvm
, run: parted /dev/sdb set 3 lvm
on
.
-
Detach and reattach the volume from pattern instance page or restart the virtual machine so
that the kernel can identify the new partition.
-
After the volume is reattached or restarted, run
ls /dev/sd*
. You should see
the new partition in the command output.
For example, the following command displays the new partition:
/dev/sdb3 ls /dev/sdb*
/dev/sdb /dev/sdb1 /dev/sdb2 /dev/sdb3
-
Run the following command to create a new physical volume from the new partition:
pvcreate /dev/<PHYSICAL_DEVICE><PARTITION_NUMBER>
For example, to add /dev/sdb3 run: pvcreate
/dev/sdb3
.
-
Run the following command to add the new physical volume to the volume group that is associated
with the block storage:
vgextend <volume_group_name>
/dev/<PHYSICAL_DEVICE><PARTITION_NUMBER>
. To get the volume group
that is associated with the block storage, see step 2 and 3.
For example, if the block storage is associated with volume group datavg0
,
to extend volume group datavg0
with /dev/sdb3 run:
vgextend datavg0 /dev/sdb3
.
-
Run the following command to extend the logical volume that is associated with the block
storage:
lvextend -l +100%FREE
/dev/<volume_group_name>/<logical_volume_name>
.
To get the logical volume that is associated with the block storage, see step 2 and 3.
For example, if the block storage is associated with volume group datavg0
and logical volume LV21328
, to extend the logical volume run lvextend -l
+100%FREE /dev/datavg0/LV21328
.
-
Run the following command to refresh the size of the file system:
resize2fs
/dev/<volume_group_name>/<logical_volume_name>
.
For example, if the block storage is associated with volume group datavg0
and logical volume LV21328
, to refresh the file system run: resize2fs
/dev/datavg0/LV21328
.
-
To confirm that the file system is resized, run
df -Ph
and you should see the
new size.