Mirror de un lvol en LVM de Linux

Para quien venga de HP-UX, resulta facil mirrorear un lvol bajo LVM: con un lvextend -m. En Linux, el lvextend -m simplemente no funciona…

De hecho el comando lvcreate si tiene una opcion -m, y esa si que funciona (lo he probado)! Pero con el lvextend no la coje.

Me he bajado las fuentes de lvm2. En commands.h he descubierto el comando lvconvert que no conocia:

alegrome# lvconvert
  Exactly one of --mirrors or --snapshot arguments required.
  lvconvert: Change logical volume layout

lvconvert [-m|--mirrors Mirrors [--corelog]]
        [--alloc AllocationPolicy]
        [-d|--debug]
        [-h|-?|--help]
        [-v|--verbose]
        [--version]
        LogicalVolume[Path] [PhysicalVolume[Path]...]

lvconvert [-s|--snapshot]
        [-c|--chunksize]
        [-d|--debug]
        [-h|-?|--help]
        [-v|--verbose]
        [-Z|--zero {y|n}]
        [--version]
        OriginalLogicalVolume[Path] SnapshotLogicalVolume[Path]

Este comando si que parece funcionar. Probemos a mirrorear un lvol:

# lvconvert -m 1 /dev/vg02/lvweb
  Logical volume lvweb converted.

Miremos con un lvdisplay lo que nos ha hecho el comando:

alegrome# lvdisplay -m lvweb
  --- Logical volume ---
  LV Name                /dev/vg02/lvweb
  VG Name                vg02
  LV UUID                9I4wK7-2hn7-j4dI-o5yT-ngYx-8Wtd-m3no6q
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                200.00 MB
  Current LE             50
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:6

  --- Segments ---
  Logical extent 0 to 49:
    Type                mirror
    Mirrors             2
    Mirror size         50
    Mirror log volume   lvweb_mlog
    Mirror region size  512.00 KB
    Mirror original:
      Logical volume    lvweb_mimage_0
      Logical extents   0 to 49
    Mirror destinations:
      Logical volume    lvweb_mimage_1
      Logical extents   0 to 49

A notar ahi: Type = mirror.

Como se puede ver, el lvweb ahora si esta en mirror. La verdad es que no he visto esto documentado en ningun sitio (¿alguien ha visto mas sobre esto?).

Para quitar el mirror (reducir), se haria asi:

# lvconvert -m 0 /dev/vg02/lvweb
  Logical volume lvweb converted.

# lvdisplay -m lvweb
  --- Logical volume ---
  LV Name                /dev/vg02/lvweb
  VG Name                vg02
  LV UUID                9I4wK7-2hn7-j4dI-o5yT-ngYx-8Wtd-m3no6q
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                200.00 MB
  Current LE             50
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:6

  --- Segments ---
  Logical extent 0 to 49:
    Type                linear
    Physical volume     /dev/hdh4
    Physical extents    18370 to 18419

Con lvs vemos el estado del mirrorring

alegrome# lvs lvweb
  LV     VG   Attr   LSize Origin Snap%  Move Log         Copy%
  lvweb  vg02 mwi-ao 200M                    lvweb_mlog   12.22

En Attr, la “m” es de mirror.

Este post viene originado por un comentario de Rubik a un post de Ivan sobre “Crear un raid 1 a partir de un disco con datos sin formatear“.. Gracias a ambos.

5 Responses to “Mirror de un lvol en LVM de Linux”


Leave a Reply




Close
Powered by ShareThis