úterý 10. října 2023

LVM - replace 2-disk LV by a large single drive

The original LV named data/bigdata consists of two separate drives: /dev/sdc1 (6T) and /dev/sdd1 (5T) .

I would like to replace these two disks by the 12T single drive (/dev/sde).

The standard way is using the pvmove commnad. However, I opted to use mirroring approach.

  •  Create mirror:

    pvcreate /dev/sde1
    vgextend data /dev/sde1
    lvconvert --type mirror  -m 1 /dev/data/bigdata 

    lvs -a -o name,copy_percent,devices data

    lvs --all --segments -o +devices

  • remove old disks from the mirror
    lvconvert -m0 data/bigdata /dev/sdc1 /dev/sdd1

Now there is 1PE free space between two segments on /dev/sde1

[root@server ~]# pvs --segments -v
  PV         VG     Fmt  Attr PSize    PFree   Start   SSize   LV      Start   Type   PE Ranges
/dev/sdc1  data   lvm2 a--    <5.46t   <5.46t       0 1430791             0 free
/dev/sdd1  data   lvm2 a--    <4.55t   <4.55t       0 1192326             0 free
/dev/sde1  data   lvm2 a--    10.91t  <5.46t       0 1430791 bigdata      0 linear /dev/sde1:0-1430790
/dev/sde1  data   lvm2 a--    10.91t  <5.46t 1430791 1                    0 free
/dev/sde1  data   lvm2 a--    10.91t  <5.46t 1430792 1192326 bigdata      0 linear /dev/sde1:1430792-2623117


to remove the free space, move  the second segment from /dev/sde1 to the old drive, and than back to /dev/sde1

pvmove /dev/sde1:1430792-2623117 /dev/sdc1
pvmove /dev/sdc1 /dev/sde1

[root@server ~]# pvs --segments -v
  PV         VG     Fmt  Attr PSize    PFree    Start   SSize   LV      Start Type   PE Ranges
/dev/sdc1  data   lvm2 a--    <5.46t   <5.46t       0 1430791             0 free
/dev/sdd1  data   lvm2 a--    <4.55t   <4.55t       0 1192326             0 free
/dev/sde1  data   lvm2 a--    10.91t <929.45g       0 2623117 bigdata     0 linear /dev/sde1:0-2623116
/dev/sde1  data   lvm2 a--    10.91t <929.45g 2623117  237938             0 free

This way the two segments join without further conditions.

pvdisplay -m /dev/sde1
lvs --all --segments -o +devices data
lvs -a -o name,copy_percent,devices datapvs --segments -v

Žádné komentáře:

Okomentovat