Thursday 21 April 2016

Fixing 'segmentation fault' error while extending a striped logical volume


The purpose of this post is twofold.

First to fix 'segmentation fault' error.
Second to partially convert a striped logical volume to a linear logical volume online.

To partially convert a striped logical volume to a linear logical volume is fairly simple.
While running lvextend command specify num_stripes (i) value equal to 1.
This makes the extended size of the LV span in a linear fashion.

Yesterday I came across an issue while extending a striped logical volume strLV1.

[root@linuxserver ~]# lvs --segment vg
  LV      VG       Attr   #Str Type    SSize
  strLV0 vg -wi-ao    4 striped 205.00G
  strLV1 vg -wi-ao    4 striped 172.00G

The LV was striped across four disks. I had to extend this volume but did not have another four disks to span it on.
So I decided to do away with the stripe & span the additional space linearly.

[root@linuxserver ~]# lvextend -i1 -L +99G /dev/mapper/vg-strLV1
  Extending logical volume strLV1 to 271.00 GB
Segmentation fault

So, I got a segmentation fault error wich was a first time.

If I tried to extend the volume keeping the stiped layout in space I would've gotten the following error:

[root@linuxserver ~]# lvextend  -L +99G /dev/mapper/vg-strLV1
  Using stripesize of last segment 1.00 MB
  Extending logical volume strLV1 to 271.00 GB
  Insufficient suitable allocatable extents for logical volume strLV1: 19420 more required

After a lot of thinking I tried to apply the fundamental meaning of 'segmentation fault' to my scenario.
The system was trying to access a location that did not exist.

I then then ran lvextend command again & this time gave the disk name after the volume name to direct the expansion on the particular disk & this fixed the issue:

'df -h' before expansion:

[root@linuxserver ~]# df -h /FS
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg-strLV1
                      170G   57G  105G  35% /FS

  Logical volume strLV1 successfully resized
[root@linuxserver ~]# lvextend -i1 -L +94G /dev/mapper/vg-strLV1 /dev/mapper/mpath106
  Extending logical volume strLV1 to 272.00 GB
  Logical volume strLV1 successfully resized

[root@linuxserver ~]# resize2fs /dev/mapper/vg-strLV1
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/mapper/vg-strLV1 is mounted on /FS; on-line resizing required
Performing an on-line resize of /dev/mapper/vg-strLV1 to 71303168 (4k) blocks.
The filesystem on /dev/mapper/vg-strLV1 is now 71303168 blocks long.

[root@linuxserver ~]# df -h /FS
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg-strLV1
                      268G   57G  198G  23% /FS

The LV will look something like this after the expansion:

[root@linuxserver ~]# lvs --segments vg
  LV      VG       Attr   #Str Type    SSize
  strLV0 vg -wi-ao    4 striped 205.00G
  strLV1 vg -wi-ao    4 striped 172.00G
  strLV1 vg -wi-ao    1 linear   99.00G


Note: This procedure is a fix for a bad situation. You will lose performance once the stripe goes linear. Under normal circumstances you should always try to keep the striped layout intact.


1 comment:

Using capture groups in grep in Linux

Introduction Let me start by saying that this article isn't about capture groups in grep per se. What we are going to do here with gr...