Ceci est une ancienne révision du document !


Version : 2022.01

Dernière mise-à-jour : 2022/10/04 15:19

Topic 5: Advanced Storage Device Administration

Contenu du Module

  • LCF504 - Gestion des Disques, des Systèmes de Fichiers et du Swap
    • Contenu du Module
    • Logical Volume Manager (LVM)
      • LAB #1 - Volumes Logiques Linéaires
        • Physical Volume (PV)
        • Volume Group (VG) et Physical Extent (PE)
        • Logical Volumes (LV)
      • LAB #2 - Étendre un Volume Logique à Chaud
      • LAB #3 - Snapshots
      • LAB #4 - Suppression des Volumes
      • LAB #5 - Volumes Logiques en Miroir
      • LAB #6 - Modifier les Attributs LVM
      • LAB #7 - Volumes Logiques en Bandes
      • LAB #8 - Gérer les Métadonnées
    • Raid Logiciel
      • LAB #9 - Mise en Place du RAID 5 Logiciel
        • Concepts RAID
        • Créer une Unité RAID
        • Remplacer une Unité Défaillante

Logical Volume Manager (LVM)

LAB #3 - Volumes Logiques Linéaires

Afin de mettre en place le LVM, vous avez besoin du paquet lvm2 et du paquet device-mapper.

Nous allons travailler sous RHEL/CentOS 8 avec les partitions suivantes :

/dev/sdb6       1644544 2054143  409600  200M 8e Linux LVM
/dev/sdb7       2056192 2670591  614400  300M 8e Linux LVM
/dev/sdb9       3698688 4517887  819200  400M 8e Linux LVM

Pour initialiser le LVM saississez la commande suivante :

[root@centos8 ~]# vgscan
  Found volume group "cl_centos8" using metadata type lvm2

Les options de la commande vgscan sont :

[root@centos8 ~]# vgscan --longhelp
  vgscan - Search for all volume groups

  vgscan
	[    --ignorelockingfailure ]
	[    --mknodes ]
	[    --notifydbus ]
	[    --reportformat basic|json ]
	[ COMMON_OPTIONS ]

  Common options for lvm:
	[ -d|--debug ]
	[ -h|--help ]
	[ -q|--quiet ]
	[ -v|--verbose ]
	[ -y|--yes ]
	[ -t|--test ]
	[    --commandprofile String ]
	[    --config String ]
	[    --driverloaded y|n ]
	[    --nolocking ]
	[    --lockopt String ]
	[    --longhelp ]
	[    --profile String ]
	[    --version ]

  Common variables for lvm:
        Variables in option or position args are capitalized,
        e.g. PV, VG, LV, Size, Number, String, Tag.

        PV
        Physical Volume name, a device path under /dev.
        For commands managing physical extents, a PV positional arg
        generally accepts a suffix indicating a range (or multiple ranges)
        of PEs. When the first PE is omitted, it defaults to the start of
        the device, and when the last PE is omitted it defaults to the end.
        PV[:PE-PE]... is start and end range (inclusive),
        PV[:PE+PE]... is start and length range (counting from 0).

        LV
        Logical Volume name. See lvm(8) for valid names. An LV positional
        arg generally includes the VG name and LV name, e.g. VG/LV.
        LV followed by _<type> indicates that an LV of the given type is
        required. (raid represents raid<N> type).
        The _new suffix indicates that the LV name is new.

        Tag
        Tag name. See lvm(8) for information about tag names and using
        tags in place of a VG, LV or PV.

        Select
        Select indicates that a required positional arg can be omitted
        if the --select option is used. No arg appears in this position.

        Size[UNIT]
        Size is an input number that accepts an optional unit.
        Input units are always treated as base two values, regardless of
        capitalization, e.g. 'k' and 'K' both refer to 1024.
        The default input unit is specified by letter, followed by |UNIT.
        UNIT represents other possible input units: BbBsSkKmMgGtTpPeE.
        (This should not be confused with the output control --units, where
        capital letters mean multiple of 1000.)

Physical Volume (PV)

Pour créer le PV il convient d'utiliser la commande pvcreate :

[root@centos8 ~]# pvcreate /dev/sdb6 /dev/sdb7 /dev/sdb9
  Physical volume "/dev/sdb6" successfully created.
  Physical volume "/dev/sdb7" successfully created.
  Physical volume "/dev/sdb9" successfully created.

Les options de la commande pvcreate sont :

[root@centos8 ~]# pvcreate --longhelp
  pvcreate - Initialize physical volume(s) for use by LVM

  pvcreate PV ...
	[ -f|--force ]
	[ -M|--metadatatype lvm2 ]
	[ -u|--uuid String ]
	[ -Z|--zero y|n ]
	[    --dataalignment Size[k|UNIT] ]
	[    --dataalignmentoffset Size[k|UNIT] ]
	[    --bootloaderareasize Size[m|UNIT] ]
	[    --labelsector Number ]
	[    --pvmetadatacopies 0|1|2 ]
	[    --metadatasize Size[m|UNIT] ]
	[    --metadataignore y|n ]
	[    --norestorefile ]
	[    --setphysicalvolumesize Size[m|UNIT] ]
	[    --reportformat basic|json ]
	[    --restorefile String ]
	[ COMMON_OPTIONS ]

  Common options for lvm:
	[ -d|--debug ]
	[ -h|--help ]
	[ -q|--quiet ]
	[ -v|--verbose ]
	[ -y|--yes ]
	[ -t|--test ]
	[    --commandprofile String ]
	[    --config String ]
	[    --driverloaded y|n ]
	[    --nolocking ]
	[    --lockopt String ]
	[    --longhelp ]
	[    --profile String ]
	[    --version ]

  Common variables for lvm:
        Variables in option or position args are capitalized,
        e.g. PV, VG, LV, Size, Number, String, Tag.

        PV
        Physical Volume name, a device path under /dev.
        For commands managing physical extents, a PV positional arg
        generally accepts a suffix indicating a range (or multiple ranges)
        of PEs. When the first PE is omitted, it defaults to the start of
        the device, and when the last PE is omitted it defaults to the end.
        PV[:PE-PE]... is start and end range (inclusive),
        PV[:PE+PE]... is start and length range (counting from 0).

        LV
        Logical Volume name. See lvm(8) for valid names. An LV positional
        arg generally includes the VG name and LV name, e.g. VG/LV.
        LV followed by _<type> indicates that an LV of the given type is
        required. (raid represents raid<N> type).
        The _new suffix indicates that the LV name is new.

        Tag
        Tag name. See lvm(8) for information about tag names and using
        tags in place of a VG, LV or PV.

        Select
        Select indicates that a required positional arg can be omitted
        if the --select option is used. No arg appears in this position.

        Size[UNIT]
        Size is an input number that accepts an optional unit.
        Input units are always treated as base two values, regardless of
        capitalization, e.g. 'k' and 'K' both refer to 1024.
        The default input unit is specified by letter, followed by |UNIT.
        UNIT represents other possible input units: BbBsSkKmMgGtTpPeE.
        (This should not be confused with the output control --units, where
        capital letters mean multiple of 1000.)

Pour visualiser le PV il convient d'utiliser la commande pvdisplay :

[root@centos8 ~]# pvdisplay /dev/sdb6 /dev/sdb7 /dev/sdb9
  "/dev/sdb6" is a new physical volume of "200.00 MiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb6
  VG Name               
  PV Size               200.00 MiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               xsAjLA-sUEU-dexm-H7G1-Dsi4-q6qW-8Tqkay
   
  "/dev/sdb7" is a new physical volume of "300.00 MiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb7
  VG Name               
  PV Size               300.00 MiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               WpssK3-sThn-3nS0-80O3-NcW3-23e0-gxejn4
   
  "/dev/sdb9" is a new physical volume of "400.00 MiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb9
  VG Name               
  PV Size               400.00 MiB
  Allocatable           NO
  PE Size               0   
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               rqaB99-3UdD-pJxE-Z1Eo-h9yv-tZ41-r4UJSY

Les options de la commande pvdisplay sont :

[root@centos8 ~]# pvdisplay --longhelp
  pvdisplay - Display various attributes of physical volume(s)

  pvdisplay
	[ -a|--all ]
	[ -c|--colon ]
	[ -C|--columns ]
	[ -m|--maps ]
	[ -o|--options String ]
	[ -S|--select String ]
	[ -s|--short ]
	[ -O|--sort String ]
	[    --aligned ]
	[    --binary ]
	[    --configreport log|vg|lv|pv|pvseg|seg ]
	[    --foreign ]
	[    --ignorelockingfailure ]
	[    --logonly ]
	[    --noheadings ]
	[    --nosuffix ]
	[    --readonly ]
	[    --reportformat basic|json ]
	[    --separator String ]
	[    --shared ]
	[    --unbuffered ]
	[    --units r|R|h|H|b|B|s|S|k|K|m|M|g|G|t|T|p|P|e|E ]
	[ COMMON_OPTIONS ]
	[ PV|Tag ... ]

  Common options for lvm:
	[ -d|--debug ]
	[ -h|--help ]
	[ -q|--quiet ]
	[ -v|--verbose ]
	[ -y|--yes ]
	[ -t|--test ]
	[    --commandprofile String ]
	[    --config String ]
	[    --driverloaded y|n ]
	[    --nolocking ]
	[    --lockopt String ]
	[    --longhelp ]
	[    --profile String ]
	[    --version ]

  Common variables for lvm:
        Variables in option or position args are capitalized,
        e.g. PV, VG, LV, Size, Number, String, Tag.

        PV
        Physical Volume name, a device path under /dev.
        For commands managing physical extents, a PV positional arg
        generally accepts a suffix indicating a range (or multiple ranges)
        of PEs. When the first PE is omitted, it defaults to the start of
        the device, and when the last PE is omitted it defaults to the end.
        PV[:PE-PE]... is start and end range (inclusive),
        PV[:PE+PE]... is start and length range (counting from 0).

        LV
        Logical Volume name. See lvm(8) for valid names. An LV positional
        arg generally includes the VG name and LV name, e.g. VG/LV.
        LV followed by _<type> indicates that an LV of the given type is
        required. (raid represents raid<N> type).
        The _new suffix indicates that the LV name is new.

        Tag
        Tag name. See lvm(8) for information about tag names and using
        tags in place of a VG, LV or PV.

        Select
        Select indicates that a required positional arg can be omitted
        if the --select option is used. No arg appears in this position.

        Size[UNIT]
        Size is an input number that accepts an optional unit.
        Input units are always treated as base two values, regardless of
        capitalization, e.g. 'k' and 'K' both refer to 1024.
        The default input unit is specified by letter, followed by |UNIT.
        UNIT represents other possible input units: BbBsSkKmMgGtTpPeE.
        (This should not be confused with the output control --units, where
        capital letters mean multiple of 1000.)

Volume Group (VG) et Physical Extent (PE)

Pour créer un Volume Group dénommé vg0, il convient d'utiliser la commande vgcreate :

[root@centos8 ~]# vgcreate -s 8M vg0 /dev/sdb6 /dev/sdb7 /dev/sdb9
  Volume group "vg0" successfully created

Les options de la commande vgcreate sont :

[root@centos8 ~]# vgcreate --help
  vgcreate - Create a volume group

  vgcreate VG_new PV ...
	[ -A|--autobackup y|n ]
	[ -c|--clustered y|n ]
	[ -l|--maxlogicalvolumes Number ]
	[ -p|--maxphysicalvolumes Number ]
	[ -M|--metadatatype lvm2 ]
	[ -s|--physicalextentsize Size[m|UNIT] ]
	[ -f|--force ]
	[ -Z|--zero y|n ]
	[    --addtag Tag ]
	[    --alloc contiguous|cling|cling_by_tags|normal|anywhere|inherit ]
	[    --metadataprofile String ]
	[    --labelsector Number ]
	[    --metadatasize Size[m|UNIT] ]
	[    --pvmetadatacopies 0|1|2 ]
	[    --vgmetadatacopies all|unmanaged|Number ]
	[    --reportformat basic|json ]
	[    --dataalignment Size[k|UNIT] ]
	[    --dataalignmentoffset Size[k|UNIT] ]
	[    --shared ]
	[    --systemid String ]
	[    --locktype sanlock|dlm|none ]
	[ COMMON_OPTIONS ]

  Common options for lvm:
	[ -d|--debug ]
	[ -h|--help ]
	[ -q|--quiet ]
	[ -v|--verbose ]
	[ -y|--yes ]
	[ -t|--test ]
	[    --commandprofile String ]
	[    --config String ]
	[    --driverloaded y|n ]
	[    --nolocking ]
	[    --lockopt String ]
	[    --longhelp ]
	[    --profile String ]
	[    --version ]

  Use --longhelp to show all options and advanced commands.

Pour afficher les informations concernant vg0, il convient d'utiliser la commande vgdisplay :

[root@centos8 ~]# vgdisplay vg0
  --- Volume group ---
  VG Name               vg0
  System ID             
  Format                lvm2
  Metadata Areas        3
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                3
  Act PV                3
  VG Size               880.00 MiB
  PE Size               8.00 MiB
  Total PE              110
  Alloc PE / Size       0 / 0   
  Free  PE / Size       110 / 880.00 MiB
  VG UUID               6cO8IX-xhvn-5J4z-Em2t-7RAq-u3y8-1cVZln

Les options de la commande vgdisplay sont :

[root@centos8 ~]# vgdisplay --help
  vgdisplay - Display volume group information

  vgdisplay
	[ -A|--activevolumegroups ]
	[ -c|--colon ]
	[ -C|--columns ]
	[ -o|--options String ]
	[ -S|--select String ]
	[ -s|--short ]
	[ -O|--sort String ]
	[    --aligned ]
	[    --binary ]
	[    --configreport log|vg|lv|pv|pvseg|seg ]
	[    --foreign ]
	[    --ignorelockingfailure ]
	[    --logonly ]
	[    --noheadings ]
	[    --nosuffix ]
	[    --readonly ]
	[    --reportformat basic|json ]
	[    --shared ]
	[    --separator String ]
	[    --unbuffered ]
	[    --units r|R|h|H|b|B|s|S|k|K|m|M|g|G|t|T|p|P|e|E ]
	[ COMMON_OPTIONS ]
	[ VG|Tag ... ]

  Common options for lvm:
	[ -d|--debug ]
	[ -h|--help ]
	[ -q|--quiet ]
	[ -v|--verbose ]
	[ -y|--yes ]
	[ -t|--test ]
	[    --commandprofile String ]
	[    --config String ]
	[    --driverloaded y|n ]
	[    --nolocking ]
	[    --lockopt String ]
	[    --longhelp ]
	[    --profile String ]
	[    --version ]

  Use --longhelp to show all options and advanced commands.

Logical Volumes (LV)

Pour créer un Logical Volume dénommé lv0 dans le Volume Group vg0, il convient d'utiliser la commande lvcreate :

[root@centos8 ~]# lvcreate -L 350 -n lv0 vg0
  Rounding up size to full physical extent 352.00 MiB
  Logical volume "lv0" created.

Important -Notez que la taille du LV est un multiple du PE.

Les options de la commande lvcreate sont :

[root@centos8 ~]# lvcreate --help
  lvcreate - Create a logical volume

  Create a linear LV.
  lvcreate -L|--size Size[m|UNIT] VG
	[ -l|--extents Number[PERCENT] ]
	[    --type linear ]
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Create a striped LV (infers --type striped).
  lvcreate -i|--stripes Number -L|--size Size[m|UNIT] VG
	[ -l|--extents Number[PERCENT] ]
	[ -I|--stripesize Size[k|UNIT] ]
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Create a raid1 or mirror LV (infers --type raid1|mirror).
  lvcreate -m|--mirrors Number -L|--size Size[m|UNIT] VG
	[ -l|--extents Number[PERCENT] ]
	[ -R|--regionsize Size[m|UNIT] ]
	[    --mirrorlog core|disk ]
	[    --minrecoveryrate Size[k|UNIT] ]
	[    --maxrecoveryrate Size[k|UNIT] ]
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Create a raid LV (a specific raid level must be used, e.g. raid1).
  lvcreate --type raid -L|--size Size[m|UNIT] VG
	[ -l|--extents Number[PERCENT] ]
	[ -m|--mirrors Number ]
	[ -i|--stripes Number ]
	[ -I|--stripesize Size[k|UNIT] ]
	[ -R|--regionsize Size[m|UNIT] ]
	[    --minrecoveryrate Size[k|UNIT] ]
	[    --maxrecoveryrate Size[k|UNIT] ]
	[    --raidintegrity y|n ]
	[    --raidintegritymode String ]
	[    --raidintegrityblocksize Number ]
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Create a raid10 LV.
  lvcreate -m|--mirrors Number -i|--stripes Number -L|--size Size[m|UNIT] VG
	[ -l|--extents Number[PERCENT] ]
	[ -I|--stripesize Size[k|UNIT] ]
	[ -R|--regionsize Size[m|UNIT] ]
	[    --minrecoveryrate Size[k|UNIT] ]
	[    --maxrecoveryrate Size[k|UNIT] ]
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Create a COW snapshot LV of an origin LV.
  lvcreate -s|--snapshot -L|--size Size[m|UNIT] LV
	[ -l|--extents Number[PERCENT] ]
	[ -i|--stripes Number ]
	[ -I|--stripesize Size[k|UNIT] ]
	[ -c|--chunksize Size[k|UNIT] ]
	[    --type snapshot ]
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Create a thin pool.
  lvcreate --type thin-pool -L|--size Size[m|UNIT] VG
	[ -l|--extents Number[PERCENT] ]
	[ -c|--chunksize Size[k|UNIT] ]
	[ -i|--stripes Number ]
	[ -I|--stripesize Size[k|UNIT] ]
	[    --thinpool LV_new ]
	[    --poolmetadatasize Size[m|UNIT] ]
	[    --poolmetadataspare y|n ]
	[    --discards passdown|nopassdown|ignore ]
	[    --errorwhenfull y|n ]
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Create a cache pool.
  lvcreate --type cache-pool -L|--size Size[m|UNIT] VG
	[ -l|--extents Number[PERCENT] ]
	[ -H|--cache ]
	[ -c|--chunksize Size[k|UNIT] ]
	[    --poolmetadatasize Size[m|UNIT] ]
	[    --poolmetadataspare y|n ]
	[    --cachemode writethrough|writeback|passthrough ]
	[    --cachepolicy String ]
	[    --cachesettings String ]
	[    --cachemetadataformat auto|1|2 ]
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Create a thin LV in a thin pool (infers --type thin).
  lvcreate -V|--virtualsize Size[m|UNIT] --thinpool LV_thinpool VG
	[ -T|--thin ]
	[    --type thin ]
	[    --discards passdown|nopassdown|ignore ]
	[    --errorwhenfull y|n ]
	[ COMMON_OPTIONS ]

  Create a thin LV that is a snapshot of an existing thin LV 
  (infers --type thin).
  lvcreate -s|--snapshot LV_thin
	[    --type thin ]
	[    --discards passdown|nopassdown|ignore ]
	[    --errorwhenfull y|n ]
	[ COMMON_OPTIONS ]

  Create a thin LV that is a snapshot of an external origin LV.
  lvcreate --type thin --thinpool LV_thinpool LV
	[ -T|--thin ]
	[ -c|--chunksize Size[k|UNIT] ]
	[    --poolmetadatasize Size[m|UNIT] ]
	[    --poolmetadataspare y|n ]
	[    --discards passdown|nopassdown|ignore ]
	[    --errorwhenfull y|n ]
	[ COMMON_OPTIONS ]

  Create a LV that returns VDO when used.
  lvcreate --type vdo -L|--size Size[m|UNIT] VG
	[ -l|--extents Number[PERCENT] ]
	[ -V|--virtualsize Size[m|UNIT] ]
	[ -i|--stripes Number ]
	[ -I|--stripesize Size[k|UNIT] ]
	[    --vdo ]
	[    --vdopool LV_new ]
	[    --compression y|n ]
	[    --deduplication y|n ]
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Create a thin LV, first creating a thin pool for it, 
  where the new thin pool is named by the --thinpool arg.
  lvcreate --type thin -V|--virtualsize Size[m|UNIT] -L|--size Size[m|UNIT] --thinpool LV_new
	[ -l|--extents Number[PERCENT] ]
	[ -T|--thin ]
	[ -c|--chunksize Size[k|UNIT] ]
	[ -i|--stripes Number ]
	[ -I|--stripesize Size[k|UNIT] ]
	[    --poolmetadatasize Size[m|UNIT] ]
	[    --poolmetadataspare y|n ]
	[    --discards passdown|nopassdown|ignore ]
	[    --errorwhenfull y|n ]
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Create a new LV, then attach the specified cachepool 
  which converts the new LV to type cache.
  lvcreate --type cache -L|--size Size[m|UNIT] --cachepool LV_cachepool VG
	[ -l|--extents Number[PERCENT] ]
	[ -H|--cache ]
	[ -c|--chunksize Size[k|UNIT] ]
	[ -i|--stripes Number ]
	[ -I|--stripesize Size[k|UNIT] ]
	[    --poolmetadatasize Size[m|UNIT] ]
	[    --poolmetadataspare y|n ]
	[    --cachemode writethrough|writeback|passthrough ]
	[    --cachepolicy String ]
	[    --cachesettings String ]
	[    --cachemetadataformat auto|1|2 ]
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Create a new LV, then attach the specified cachevol 
  which converts the new LV to type cache.
  lvcreate --type cache -L|--size Size[m|UNIT] --cachevol LV VG
	[ -l|--extents Number[PERCENT] ]
	[ -c|--chunksize Size[k|UNIT] ]
	[ -i|--stripes Number ]
	[ -I|--stripesize Size[k|UNIT] ]
	[    --cachemode writethrough|writeback|passthrough ]
	[    --cachepolicy String ]
	[    --cachesettings String ]
	[    --cachemetadataformat auto|1|2 ]
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Create a new LV, then attach a cachevol created from 
  the specified cache device, which converts the 
  new LV to type cache.
  lvcreate --type cache -L|--size Size[m|UNIT] --cachedevice PV VG
	[ -l|--extents Number[PERCENT] ]
	[ -c|--chunksize Size[k|UNIT] ]
	[ -i|--stripes Number ]
	[ -I|--stripesize Size[k|UNIT] ]
	[    --cachemode writethrough|writeback|passthrough ]
	[    --cachepolicy String ]
	[    --cachesettings String ]
	[    --cachemetadataformat auto|1|2 ]
	[    --cachesize Size[m|UNIT] ]
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Create a new LV, then attach the specified cachevol 
  which converts the new LV to type writecache.
  lvcreate --type writecache -L|--size Size[m|UNIT] --cachevol LV VG
	[ -l|--extents Number[PERCENT] ]
	[ -i|--stripes Number ]
	[ -I|--stripesize Size[k|UNIT] ]
	[    --cachesettings String ]
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Create a new LV, then attach a cachevol created from 
  the specified cache device, which converts the 
  new LV to type writecache.
  lvcreate --type writecache -L|--size Size[m|UNIT] --cachedevice PV VG
	[ -l|--extents Number[PERCENT] ]
	[ -i|--stripes Number ]
	[ -I|--stripesize Size[k|UNIT] ]
	[    --cachesize Size[m|UNIT] ]
	[    --cachesettings String ]
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Common options for command:
	[ -a|--activate y|n|ay ]
	[ -A|--autobackup y|n ]
	[ -C|--contiguous y|n ]
	[ -M|--persistent y|n ]
	[ -j|--major Number ]
	[ -k|--setactivationskip y|n ]
	[ -K|--ignoreactivationskip ]
	[ -n|--name String ]
	[ -p|--permission rw|r ]
	[ -r|--readahead auto|none|Number ]
	[ -W|--wipesignatures y|n ]
	[ -Z|--zero y|n ]
	[    --addtag Tag ]
	[    --alloc contiguous|cling|cling_by_tags|normal|anywhere|inherit ]
	[    --ignoremonitoring ]
	[    --metadataprofile String ]
	[    --minor Number ]
	[    --monitor y|n ]
	[    --nosync ]
	[    --noudevsync ]
	[    --reportformat basic|json ]

  Common options for lvm:
	[ -d|--debug ]
	[ -h|--help ]
	[ -q|--quiet ]
	[ -v|--verbose ]
	[ -y|--yes ]
	[ -t|--test ]
	[    --commandprofile String ]
	[    --config String ]
	[    --driverloaded y|n ]
	[    --nolocking ]
	[    --lockopt String ]
	[    --longhelp ]
	[    --profile String ]
	[    --version ]

  Use --longhelp to show all options and advanced commands.

Créez maintenant un répertoire dans /mnt pour monter lv0 :

[root@centos8 ~]# mkdir /mnt/lvm

Créez un système de fichiers en ext3 sur /dev/vg0/lv0 :

[root@centos8 ~]# mke2fs -j /dev/vg0/lv0
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 360448 1k blocks and 90112 inodes
Filesystem UUID: 87b6d526-d379-4e0c-8984-94811f1cee33
Superblock backups stored on blocks: 
	8193, 24577, 40961, 57345, 73729, 204801, 221185

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

Montez votre lv0 :

[root@centos8 ~]# mount -t ext3 /dev/vg0/lv0 /mnt/lvm

Vous allez maintenant copier le contenu de votre répertoire /home vers /mnt/lvm.

Saisissez donc la commande pour copier le contenu de /home :

[root@centos8 ~]# cp -a /home /mnt/lvm

Constatez ensuite le contenu de /mnt/lvm :

[root@centos8 ~]# ls -l /mnt/lvm
total 14
drwxr-xr-x. 5 root root  1024 Apr 20 14:35 home
drwx------. 2 root root 12288 May 26 17:00 lost+found

Une particularité du volume logique est la capacité de d'être aggrandi ou réduit sans pertes de données. Commencez par constater la taille totale du volume :

[root@centos8 ~]# df -h /mnt/lvm
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/vg0-lv0  333M  17M  314M   1% /mnt/lvm

Dans la cas de notre exemple, la taille est de 333 Mo avec 17 Mo occupé.

LAB #4 - Etendre un Volume Logique à Chaud

Pour agrandir un volume logique, le paquet lvm2 contient les commandes lvextend et resize2fs :

[root@centos8 ~]# lvextend -L +100M /dev/vg0/lv0
  Rounding size to boundary between physical extents: 104.00 MiB.
  Size of logical volume vg0/lv0 changed from 352.00 MiB (44 extents) to 456.00 MiB (57 extents).
  Logical volume vg0/lv0 successfully resized.

Important - Notez que l'agrandissement du volume est un multiple du PE.

Les options de la commande lvextend sont :

[root@centos8 ~]# lvextend --help
  lvextend - Add space to a logical volume

  Extend an LV by a specified size.
  lvextend -L|--size [+]Size[m|UNIT] LV
	[ -l|--extents [+]Number[PERCENT] ]
	[ -r|--resizefs ]
	[ -i|--stripes Number ]
	[ -I|--stripesize Size[k|UNIT] ]
	[    --poolmetadatasize [+]Size[m|UNIT] ]
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Extend an LV by specified PV extents.
  lvextend LV PV ...
	[ -r|--resizefs ]
	[ -i|--stripes Number ]
	[ -I|--stripesize Size[k|UNIT] ]
	[ COMMON_OPTIONS ]

  Extend a pool metadata SubLV by a specified size.
  lvextend --poolmetadatasize [+]Size[m|UNIT] LV_thinpool
	[ -i|--stripes Number ]
	[ -I|--stripesize Size[k|UNIT] ]
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Extend an LV according to a predefined policy.
  lvextend --usepolicies LV_snapshot_thinpool
	[ -r|--resizefs ]
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Common options for command:
	[ -A|--autobackup y|n ]
	[ -f|--force ]
	[ -m|--mirrors Number ]
	[ -n|--nofsck ]
	[    --alloc contiguous|cling|cling_by_tags|normal|anywhere|inherit ]
	[    --nosync ]
	[    --noudevsync ]
	[    --reportformat basic|json ]
	[    --type linear|striped|snapshot|mirror|raid|thin|cache|vdo|thin-pool|cache-pool|vdo-pool ]

  Common options for lvm:
	[ -d|--debug ]
	[ -h|--help ]
	[ -q|--quiet ]
	[ -v|--verbose ]
	[ -y|--yes ]
	[ -t|--test ]
	[    --commandprofile String ]
	[    --config String ]
	[    --driverloaded y|n ]
	[    --nolocking ]
	[    --lockopt String ]
	[    --longhelp ]
	[    --profile String ]
	[    --version ]

  Use --longhelp to show all options and advanced commands.

Le volume ayant été agrandi, il est necessaire maintenant d'agrandir le filesystem qui s'y trouve :

[root@centos8 ~]# resize2fs /dev/vg0/lv0
resize2fs 1.45.6 (20-Mar-2020)
Filesystem at /dev/vg0/lv0 is mounted on /mnt/lvm; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 2
The filesystem on /dev/vg0/lv0 is now 466944 (1k) blocks long.

Constatez maintenant la modification de la taille du volume :

[root@centos8 ~]# df -h /mnt/lvm
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/vg0-lv0  434M   17M  395M   5% /mnt/lvm

Vous noterez que la taille a augmentée mais que les données sont toujours présentes.

LAB #5 - Snapshots

Un snapshot est un instantané d'un système de fichiers. Dans cet exemple, vous allez créer un snapshot de votre lv0 :

Avant de commencer, créez un fichier de 10Mo dans le volume :

[root@centos8 ~]# dd if=/dev/zero of=/mnt/lvm/10M bs=1048576 count=10
10+0 records in
10+0 records out
10485760 bytes (10 MB, 10 MiB) copied, 0.0281282 s, 373 MB/s

Créez maintenant un snapshot :

[root@centos8 ~]# lvcreate -s -L 18M -n testsnap /dev/vg0/lv0
  Rounding up size to full physical extent 24.00 MiB
  Logical volume "testsnap" created.

Pour avoir une confirmation de la création du snapshot, utilisez la commande lvs :

[root@centos8 ~]# lvs
  LV       VG         Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root     cl_centos8 -wi-ao----  27.79g                                                    
  swap     cl_centos8 -wi-ao----   3.20g                                                    
  lv0      vg0        owi-aos--- 456.00m                                                    
  testsnap vg0        swi-a-s---  24.00m      lv0    0.05  

Important - Notez que le snapshot est créé dans le même VG que le LV d'origine.

Les options de la commande lvs sont :

[root@centos8 ~]# lvs --help
  lvs - Display information about logical volumes

  lvs
	[ -H|--history ]
	[ -a|--all ]
	[ -o|--options String ]
	[ -S|--select String ]
	[ -O|--sort String ]
	[    --segments ]
	[    --aligned ]
	[    --binary ]
	[    --configreport log|vg|lv|pv|pvseg|seg ]
	[    --foreign ]
	[    --ignorelockingfailure ]
	[    --logonly ]
	[    --nameprefixes ]
	[    --noheadings ]
	[    --nosuffix ]
	[    --readonly ]
	[    --reportformat basic|json ]
	[    --rows ]
	[    --separator String ]
	[    --shared ]
	[    --unbuffered ]
	[    --units r|R|h|H|b|B|s|S|k|K|m|M|g|G|t|T|p|P|e|E ]
	[    --unquoted ]
	[ COMMON_OPTIONS ]
	[ VG|LV|Tag ... ]

  Common options for lvm:
	[ -d|--debug ]
	[ -h|--help ]
	[ -q|--quiet ]
	[ -v|--verbose ]
	[ -y|--yes ]
	[ -t|--test ]
	[    --commandprofile String ]
	[    --config String ]
	[    --driverloaded y|n ]
	[    --nolocking ]
	[    --lockopt String ]
	[    --longhelp ]
	[    --profile String ]
	[    --version ]

  Use --longhelp to show all options and advanced commands.

Créez maintenant un répertoire pour monter le snapshot :

[root@centos8 ~]# mkdir /mnt/testsnap

Montez le snapshot :

[root@centos8 ~]# mount /dev/vg0/testsnap /mnt/testsnap

Comparez le volume d'origine et le snapshot :

[root@centos8 ~]# ls -l /mnt/lvm
total 10296
-rw-r--r--. 1 root root 10485760 Jun 24 04:41 10M
drwxr-xr-x. 3 root root     1024 Jun 16 06:39 home
drwx------. 2 root root    12288 Jun 24 04:20 lost+found
[root@centos8 ~]# ls -l /mnt/testsnap/
total 10296
-rw-r--r--. 1 root root 10485760 Jun 24 04:41 10M
drwxr-xr-x. 3 root root     1024 Jun 16 06:39 home
drwx------. 2 root root    12288 Jun 24 04:20 lost+found

Supprimez maintenant le fichier 10M de votre volume d'origine :

[root@centos8 ~]# rm /mnt/lvm/10M
rm: remove regular file '/mnt/lvm/10M'? y

Constatez le résultat de cette suppression :

[root@centos8 ~]# df -Ph /mnt/lvm
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/vg0-lv0  434M   17M  395M   5% /mnt/lvm

[root@centos8 ~]# df -Ph /mnt/testsnap/
Filesystem                Size  Used Avail Use% Mounted on
/dev/mapper/vg0-testsnap  434M   27M  385M   7% /mnt/testsnap

[root@centos8 ~]# lvs
  LV       VG         Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root     cl_centos8 -wi-ao----  27.79g                                                    
  swap     cl_centos8 -wi-ao----   3.20g                                                    
  lv0      vg0        owi-aos--- 456.00m                                                    
  testsnap vg0        swi-aos---  24.00m      lv0    0.24     

A Faire - Restaurez le fichier 10M à partir du snapshot.

LAB #6 - Suppression des Volumes

La suppression d'un volume logique se fait grace à la commande lvremove :

[root@centos8 ~]# umount /mnt/testsnap/
[root@centos8 ~]# lvremove /dev/vg0/testsnap
Do you really want to remove active logical volume vg0/testsnap? [y/n]: y
  Logical volume "testsnap" successfully removed
[root@centos8 ~]# umount /mnt/lvm 
[root@centos8 ~]# lvremove /dev/vg0/lv0
Do you really want to remove active logical volume vg0/lv0? [y/n]: y
  Logical volume "lv0" successfully removed

Important - Notez que cette opération necéssite à ce que le volume logique soit démonté.

Les options de la commande lvremove sont :

[root@centos8 ~]# lvremove --help
  lvremove - Remove logical volume(s) from the system

  lvremove VG|LV|Tag|Select ...
	[ -A|--autobackup y|n ]
	[ -f|--force ]
	[ -S|--select String ]
	[    --nohistory ]
	[    --noudevsync ]
	[    --reportformat basic|json ]
	[ COMMON_OPTIONS ]

  Common options for lvm:
	[ -d|--debug ]
	[ -h|--help ]
	[ -q|--quiet ]
	[ -v|--verbose ]
	[ -y|--yes ]
	[ -t|--test ]
	[    --commandprofile String ]
	[    --config String ]
	[    --driverloaded y|n ]
	[    --nolocking ]
	[    --lockopt String ]
	[    --longhelp ]
	[    --profile String ]
	[    --version ]

  Use --longhelp to show all options and advanced commands

Le Volume Group peut aussi être supprimé :

[root@centos8 ~]# vgremove vg0
  Volume group "vg0" successfully removed

Les options de la commande vgremove sont :

[root@centos8 ~]# vgremove --help
  vgremove - Remove volume group(s)

  vgremove VG|Tag|Select ...
	[ -f|--force ]
	[ -S|--select String ]
	[    --noudevsync ]
	[    --reportformat basic|json ]
	[ COMMON_OPTIONS ]

  Common options for lvm:
	[ -d|--debug ]
	[ -h|--help ]
	[ -q|--quiet ]
	[ -v|--verbose ]
	[ -y|--yes ]
	[ -t|--test ]
	[    --commandprofile String ]
	[    --config String ]
	[    --driverloaded y|n ]
	[    --nolocking ]
	[    --lockopt String ]
	[    --longhelp ]
	[    --profile String ]
	[    --version ]

  Use --longhelp to show all options and advanced commands.

Ainsi que le volume physique :

[root@centos8 ~]# pvremove /dev/sdb6 /dev/sdb7 /dev/sdb9
  Labels on physical volume "/dev/sdb6" successfully wiped.
  Labels on physical volume "/dev/sdb7" successfully wiped.
  Labels on physical volume "/dev/sdb9" successfully wiped.

Les options de la commande pvremove sont :

[root@centos8 ~]# pvremove --help
  pvremove - Remove LVM label(s) from physical volume(s)

  pvremove PV ...
	[ -f|--force ]
	[    --reportformat basic|json ]
	[ COMMON_OPTIONS ]

  Common options for lvm:
	[ -d|--debug ]
	[ -h|--help ]
	[ -q|--quiet ]
	[ -v|--verbose ]
	[ -y|--yes ]
	[ -t|--test ]
	[    --commandprofile String ]
	[    --config String ]
	[    --driverloaded y|n ]
	[    --nolocking ]
	[    --lockopt String ]
	[    --longhelp ]
	[    --profile String ]
	[    --version ]

  Use --longhelp to show all options and advanced commands.

LAB #7 - Volumes Logiques en Miroir

Re-créez maintenant votre Volume Group :

[root@centos8 ~]# pvcreate /dev/sdb6 /dev/sdb7 /dev/sdb9
  Physical volume "/dev/sdb6" successfully created.
  Physical volume "/dev/sdb7" successfully created.
  Physical volume "/dev/sdb9" successfully created.

[root@centos8 ~]# vgcreate -s 8M vg0 /dev/sdb6 /dev/sdb7 /dev/sdb9
  Volume group "vg0" successfully created

Créez maintenant un Logical Volume en miroir grâce à l'option -m de la commande lvcreate, suivi du nombre de miroirs :

[root@centos8 ~]# lvcreate -m 1 -L 100M -n lv1 vg0
  Rounding up size to full physical extent 104.00 MiB
  Logical volume "lv1" created.

Constatez maintenant la présence du miroir :

[root@centos8 ~]# lvdisplay -m /dev/vg0/lv1
  --- Logical volume ---
  LV Path                /dev/vg0/lv1
  LV Name                lv1
  VG Name                vg0
  LV UUID                lJQQWs-n05T-pxzi-Zq2R-UzRI-kYZf-hsNPYQ
  LV Write Access        read/write
  LV Creation host, time centos8.ittraining.loc, 2021-06-02 07:37:28 -0400
  LV Status              available
  # open                 0
  LV Size                104.00 MiB
  Current LE             13
  Mirrored volumes       2
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:4
   
  --- Segments ---
  Logical extents 0 to 12:
    Type		raid1
    Monitoring		monitored
    Raid Data LV 0
      Logical volume	lv1_rimage_0
      Logical extents	0 to 12
    Raid Data LV 1
      Logical volume	lv1_rimage_1
      Logical extents	0 to 12
    Raid Metadata LV 0	lv1_rmeta_0
    Raid Metadata LV 1	lv1_rmeta_1

Le miroir s'étend sur plusieurs volumes physiques :

[root@centos8 ~]# pvdisplay -m /dev/sdb6 /dev/sdb7 /dev/sdb9
  --- Physical volume ---
  PV Name               /dev/sdb6
  VG Name               vg0
  PV Size               200.00 MiB / not usable 8.00 MiB
  Allocatable           yes 
  PE Size               8.00 MiB
  Total PE              24
  Free PE               10
  Allocated PE          14
  PV UUID               lxuKRI-l3Dd-jhsv-OWtw-au2c-0ti0-XGnt1E
   
  --- Physical Segments ---
  Physical extent 0 to 0:
    Logical volume	/dev/vg0/lv1_rmeta_0
    Logical extents	0 to 0
  Physical extent 1 to 13:
    Logical volume	/dev/vg0/lv1_rimage_0
    Logical extents	0 to 12
  Physical extent 14 to 23:
    FREE
   
  --- Physical volume ---
  PV Name               /dev/sdb7
  VG Name               vg0
  PV Size               300.00 MiB / not usable 4.00 MiB
  Allocatable           yes 
  PE Size               8.00 MiB
  Total PE              37
  Free PE               23
  Allocated PE          14
  PV UUID               QDmfcX-Pv8o-hapq-TJOI-RaPH-qecT-VUMY4v
   
  --- Physical Segments ---
  Physical extent 0 to 0:
    Logical volume	/dev/vg0/lv1_rmeta_1
    Logical extents	0 to 0
  Physical extent 1 to 13:
    Logical volume	/dev/vg0/lv1_rimage_1
    Logical extents	0 to 12
  Physical extent 14 to 36:
    FREE
   
  --- Physical volume ---
  PV Name               /dev/sdb9
  VG Name               vg0
  PV Size               400.00 MiB / not usable 8.00 MiB
  Allocatable           yes 
  PE Size               8.00 MiB
  Total PE              49
  Free PE               49
  Allocated PE          0
  PV UUID               ZTQV1b-Ha76-BQtB-zJEU-kfyK-ausJ-CxnRwg
   
  --- Physical Segments ---
  Physical extent 0 to 48:
    FREE

La suppression du miroir se fait en utilisant la commande lvconvert en indiquant quel volume physique doit être vidé de son contenu :

[root@centos8 ~]# lvconvert -m 0 /dev/vg0/lv1 /dev/sdb7
Are you sure you want to convert raid1 LV vg0/lv1 to type linear losing all resilience? [y/n]: y
  Logical volume vg0/lv1 successfully converted.

De même, il est possible de créer un miroir pour un volume logique existant :

[root@centos8 ~]# lvconvert -m 1 /dev/vg0/lv1
Are you sure you want to convert linear LV vg0/lv1 to raid1 with 2 images enhancing resilience? [y/n]: y
  Logical volume vg0/lv1 successfully converted.

Supprimez de nouveau votre miroir :

[root@centos8 ~]# lvconvert -m 0 /dev/vg0/lv1 /dev/sdb7
Are you sure you want to convert raid1 LV vg0/lv1 to type linear losing all resilience? [y/n]: y
  Logical volume vg0/lv1 successfully converted.

Les options de la commande lvconvert sont :

[root@centos8 ~]# lvconvert --help
  lvconvert - Change logical volume layout

  Convert LV to linear.
  lvconvert --type linear LV
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Convert LV to striped.
  lvconvert --type striped LV
	[ -I|--stripesize Size[k|UNIT] ]
	[ -R|--regionsize Size[m|UNIT] ]
	[ -i|--interval Number ]
	[    --stripes Number ]
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Convert LV to type mirror (also see type raid1),
  lvconvert --type mirror LV
	[ -m|--mirrors [+|-]Number ]
	[ -I|--stripesize Size[k|UNIT] ]
	[ -R|--regionsize Size[m|UNIT] ]
	[ -i|--interval Number ]
	[    --stripes Number ]
	[    --mirrorlog core|disk ]
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Convert LV to raid or change raid layout 
  (a specific raid level must be used, e.g. raid1).
  lvconvert --type raid LV
	[ -m|--mirrors [+|-]Number ]
	[ -I|--stripesize Size[k|UNIT] ]
	[ -R|--regionsize Size[m|UNIT] ]
	[ -i|--interval Number ]
	[    --stripes Number ]
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Convert LV to raid1 or mirror, or change number of mirror images.
  lvconvert -m|--mirrors [+|-]Number LV
	[ -R|--regionsize Size[m|UNIT] ]
	[ -i|--interval Number ]
	[    --mirrorlog core|disk ]
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Convert raid LV to change number of stripe images.
  lvconvert --stripes Number LV_raid
	[ -i|--interval Number ]
	[ -R|--regionsize Size[m|UNIT] ]
	[ -I|--stripesize Size[k|UNIT] ]
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Convert raid LV to change the stripe size.
  lvconvert -I|--stripesize Size[k|UNIT] LV_raid
	[ -i|--interval Number ]
	[ -R|--regionsize Size[m|UNIT] ]
	[ COMMON_OPTIONS ]

  Split images from a raid1 or mirror LV and use them to create a new LV.
  lvconvert --splitmirrors Number -n|--name LV_new LV_cache_mirror_raid1
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Split images from a raid1 LV and track changes to origin for later merge.
  lvconvert --splitmirrors Number --trackchanges LV_cache_raid1
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Merge LV images that were split from a raid1 LV.
  lvconvert --mergemirrors VG|LV_linear_raid|Tag ...
	[ COMMON_OPTIONS ]

  Convert LV to a thin LV, using the original LV as an external origin.
  lvconvert --type thin --thinpool LV LV_linear_striped_thin_cache_raid
	[ -T|--thin ]
	[ -r|--readahead auto|none|Number ]
	[ -c|--chunksize Size[k|UNIT] ]
	[ -Z|--zero y|n ]
	[    --originname LV_new ]
	[    --poolmetadata LV ]
	[    --poolmetadatasize Size[m|UNIT] ]
	[    --poolmetadataspare y|n ]
	[    --metadataprofile String ]
	[ COMMON_OPTIONS ]

  Attach a cache pool to an LV, converts the LV to type cache.
  lvconvert --type cache --cachepool LV LV_linear_striped_thinpool_vdo_vdopool_vdopooldata_raid
	[ -H|--cache ]
	[ -Z|--zero y|n ]
	[ -r|--readahead auto|none|Number ]
	[ -c|--chunksize Size[k|UNIT] ]
	[    --cachemetadataformat auto|1|2 ]
	[    --cachemode writethrough|writeback|passthrough ]
	[    --cachepolicy String ]
	[    --cachesettings String ]
	[    --poolmetadata LV ]
	[    --poolmetadatasize Size[m|UNIT] ]
	[    --poolmetadataspare y|n ]
	[    --metadataprofile String ]
	[ COMMON_OPTIONS ]

  Attach a writecache to an LV, converts the LV to type writecache.
  lvconvert --type writecache --cachevol LV LV_linear_striped_raid
	[    --cachesettings String ]
	[ COMMON_OPTIONS ]

  Attach a cache to an LV, converts the LV to type cache.
  lvconvert --type cache --cachevol LV LV_linear_striped_thinpool_raid
	[ -H|--cache ]
	[ -Z|--zero y|n ]
	[ -c|--chunksize Size[k|UNIT] ]
	[    --cachemetadataformat auto|1|2 ]
	[    --cachemode writethrough|writeback|passthrough ]
	[    --cachepolicy String ]
	[    --cachesettings String ]
	[    --poolmetadatasize Size[m|UNIT] ]
	[ COMMON_OPTIONS ]

  Add a writecache to an LV, using a specified cache device.
  lvconvert --type writecache --cachedevice PV LV_linear_striped_raid
	[    --cachesize Size[m|UNIT] ]
	[    --cachesettings String ]
	[ COMMON_OPTIONS ]

  Add a cache to an LV, using a specified cache device.
  lvconvert --type cache --cachedevice PV LV_linear_striped_thinpool_raid
	[    --cachesize Size[m|UNIT] ]
	[    --cachesettings String ]
	[ COMMON_OPTIONS ]

  Convert LV to type thin-pool.
  lvconvert --type thin-pool LV_linear_striped_cache_raid
	[ -I|--stripesize Size[k|UNIT] ]
	[ -r|--readahead auto|none|Number ]
	[ -c|--chunksize Size[k|UNIT] ]
	[ -Z|--zero y|n ]
	[    --stripes Number ]
	[    --discards passdown|nopassdown|ignore ]
	[    --poolmetadata LV ]
	[    --poolmetadatasize Size[m|UNIT] ]
	[    --poolmetadataspare y|n ]
	[    --metadataprofile String ]
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Convert LV to type cache-pool.
  lvconvert --type cache-pool LV_linear_striped_raid
	[ -Z|--zero y|n ]
	[ -r|--readahead auto|none|Number ]
	[ -c|--chunksize Size[k|UNIT] ]
	[    --cachemetadataformat auto|1|2 ]
	[    --cachemode writethrough|writeback|passthrough ]
	[    --cachepolicy String ]
	[    --cachesettings String ]
	[    --poolmetadata LV ]
	[    --poolmetadatasize Size[m|UNIT] ]
	[    --poolmetadataspare y|n ]
	[    --metadataprofile String ]
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Convert LV to type vdopool.
  lvconvert --type vdo-pool LV_linear_striped_cache_raid
	[ -n|--name LV_new ]
	[ -V|--virtualsize Size[m|UNIT] ]
	[    --compression y|n ]
	[    --deduplication y|n ]
	[ COMMON_OPTIONS ]

  Detach a cache from an LV.
  lvconvert --splitcache LV_thinpool_cache_cachepool_vdopool_writecache
	[ COMMON_OPTIONS ]

  Merge thin LV into its origin LV.
  lvconvert --mergethin LV_thin ...
	[ COMMON_OPTIONS ]

  Merge COW snapshot LV into its origin.
  lvconvert --mergesnapshot LV_snapshot ...
	[ -i|--interval Number ]
	[ COMMON_OPTIONS ]

  Combine a former COW snapshot (second arg) with a former 
  origin LV (first arg) to reverse a splitsnapshot command.
  lvconvert --type snapshot LV LV_linear_striped
	[ -s|--snapshot ]
	[ -c|--chunksize Size[k|UNIT] ]
	[ -Z|--zero y|n ]
	[ COMMON_OPTIONS ]

  Replace failed PVs in a raid or mirror LV. 
  Repair a thin pool. 
  Repair a cache pool.
  lvconvert --repair LV_thinpool_cache_cachepool_mirror_raid
	[ -i|--interval Number ]
	[    --usepolicies ]
	[    --poolmetadataspare y|n ]
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Replace specific PV(s) in a raid LV with another PV.
  lvconvert --replace PV LV_raid
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Poll LV to continue conversion.
  lvconvert --startpoll LV_mirror_raid
	[ COMMON_OPTIONS ]

  Add or remove data integrity checksums to raid images.
  lvconvert --raidintegrity y|n LV_raid
	[    --raidintegritymode String ]
	[    --raidintegrityblocksize Number ]
	[ COMMON_OPTIONS ]
	[ PV ... ]

  Common options for command:
	[ -b|--background ]
	[ -f|--force ]
	[    --alloc contiguous|cling|cling_by_tags|normal|anywhere|inherit ]
	[    --noudevsync ]

  Common options for lvm:
	[ -d|--debug ]
	[ -h|--help ]
	[ -q|--quiet ]
	[ -v|--verbose ]
	[ -y|--yes ]
	[ -t|--test ]
	[    --commandprofile String ]
	[    --config String ]
	[    --driverloaded y|n ]
	[    --nolocking ]
	[    --lockopt String ]
	[    --longhelp ]
	[    --profile String ]
	[    --version ]

  Use --longhelp to show all options and advanced commands.

LAB #8 - Modifier les Attributs LVM

En cas de présence d'un miroir, la commande lvs indique la présence du miroir dans la colonne Attr avec la lettre m :

[root@centos8 ~]# lvs
  LV   VG         Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root cl_centos8 -wi-ao----  27.79g                                                    
  swap cl_centos8 -wi-ao----   3.20g                                                    
  lv1  vg0        -wi-a----- 104.00m                                                                                                 

Consultez cette page pour comprendre les attributs.

La commande equivalente pour les Volume Groups est vgs :

[root@centos8 ~]# vgs
  VG         #PV #LV #SN Attr   VSize   VFree  
  cl_centos8   1   2   0 wz--n- <31.00g      0 
  vg0          3   1   0 wz--n- 880.00m 776.00m

Consultez cette page pour comprendre les attributs.

La commande equivalente pour les Physical Volumes est pvs :

[root@centos8 ~]# pvs
  PV         VG         Fmt  Attr PSize   PFree  
  /dev/sda2  cl_centos8 lvm2 a--  <31.00g      0 
  /dev/sdb6  vg0        lvm2 a--  192.00m  88.00m
  /dev/sdb7  vg0        lvm2 a--  296.00m 296.00m
  /dev/sdb9  vg0        lvm2 a--  392.00m 392.00m    

Consultez cette page pour comprendre les attributs.

Les commandes lvchange, vgchange et pvchange permettent de modifier les attributs des Logical Volumes, Volume Groups et Physical Volumes respectivement.

Par exemple, pour rendre inutilisable un Logical Volume, il convient d'enlever l'attribut a :

[root@centos8 ~]# lvchange -a n /dev/vg0/lv1

Pour faire l'inverse il convient de saisir la commande suivante :

[root@centos8 ~]# lvchange -a y /dev/vg0/lv1

Les options de la commande lvchange sont :

[root@centos8 ~]# lvchange --help
  lvchange - Change the attributes of logical volume(s)

  Change a general LV attribute. 
  For options listed in parentheses, any one is 
  required, after which the others are optional.
  lvchange
	( -C|--contiguous y|n,
	  -p|--permission rw|r,
	  -r|--readahead auto|none|Number,
	  -k|--setactivationskip y|n,
	  -Z|--zero y|n,
	  -M|--persistent n,
	     --addtag Tag,
	     --deltag Tag,
	     --alloc contiguous|cling|cling_by_tags|normal|anywhere|inherit,
	     --compression y|n,
	     --deduplication y|n,
	     --detachprofile,
	     --metadataprofile String,
	     --profile String,
	     --errorwhenfull y|n,
	     --discards passdown|nopassdown|ignore,
	     --cachemode writethrough|writeback|passthrough,
	     --cachepolicy String,
	     --cachesettings String,
	     --minrecoveryrate Size[k|UNIT],
	     --maxrecoveryrate Size[k|UNIT],
	     --writebehind Number,
	     --writemostly PV[:t|n|y] )
	 VG|LV|Tag|Select ...
	[ -a|--activate y|n|ay ]
	[    --poll y|n ]
	[    --monitor y|n ]
	[ COMMON_OPTIONS ]

  Resyncronize a mirror or raid LV. 
  Use to reset 'R' attribute on a not initially synchronized LV.
  lvchange --resync VG|LV_mirror_raid|Tag|Select ...
	[ -a|--activate y|n|ay ]
	[ COMMON_OPTIONS ]

  Resynchronize or check a raid LV.
  lvchange --syncaction check|repair VG|LV_raid|Tag|Select ...
	[ COMMON_OPTIONS ]

  Reconstruct data on specific PVs of a raid LV.
  lvchange --rebuild PV VG|LV_raid|Tag|Select ...
	[ COMMON_OPTIONS ]

  Activate or deactivate an LV.
  lvchange -a|--activate y|n|ay VG|LV|Tag|Select ...
	[ -P|--partial ]
	[ -K|--ignoreactivationskip ]
	[    --activationmode partial|degraded|complete ]
	[    --poll y|n ]
	[    --monitor y|n ]
	[    --ignorelockingfailure ]
	[    --sysinit ]
	[    --readonly ]
	[ COMMON_OPTIONS ]

  Reactivate an LV using the latest metadata.
  lvchange --refresh VG|LV|Tag|Select ...
	[ -P|--partial ]
	[    --activationmode partial|degraded|complete ]
	[    --poll y|n ]
	[    --monitor y|n ]
	[ COMMON_OPTIONS ]

  Start or stop monitoring an LV from dmeventd.
  lvchange --monitor y|n VG|LV|Tag|Select ...
	[ COMMON_OPTIONS ]

  Start or stop processing an LV conversion.
  lvchange --poll y|n VG|LV|Tag|Select ...
	[    --monitor y|n ]
	[ COMMON_OPTIONS ]

  Make the minor device number persistent for an LV.
  lvchange -M|--persistent y --minor Number LV
	[ -j|--major Number ]
	[ -a|--activate y|n|ay ]
	[    --poll y|n ]
	[    --monitor y|n ]
	[ COMMON_OPTIONS ]

  Common options for command:
	[ -A|--autobackup y|n ]
	[ -f|--force ]
	[ -S|--select String ]
	[    --ignoremonitoring ]
	[    --noudevsync ]
	[    --reportformat basic|json ]

  Common options for lvm:
	[ -d|--debug ]
	[ -h|--help ]
	[ -q|--quiet ]
	[ -v|--verbose ]
	[ -y|--yes ]
	[ -t|--test ]
	[    --commandprofile String ]
	[    --config String ]
	[    --driverloaded y|n ]
	[    --nolocking ]
	[    --lockopt String ]
	[    --longhelp ]
	[    --profile String ]
	[    --version ]

  Use --longhelp to show all options and advanced commands.

LAB #9 - Volumes Logiques en Bandes

Un volume logique en bandes est créé pour augmenter, comme dans le cas du RAID, les performances des entrées et sorties. Pour créer ce volume, la commande lvcreate prend deux option supplémentaires :

  • -i - indique le nombre de volumes de bandes,
  • -I - indique la taille en Ko de chaque bande.

Saisissez donc la commande suivante :

[root@centos8 ~]# lvcreate -i2 -I64 -n lv2 -L 100M vg0 /dev/sdb7 /dev/sdb9
  Rounding up size to full physical extent 104.00 MiB
  Rounding size 104.00 MiB (13 extents) up to stripe boundary size 112.00 MiB(14 extents).
  Logical volume "lv2" created.

Constatez la présence de vos bandes sur /dev/sda7 et sur /dev/sda9 :

[root@centos8 ~]# lvdisplay -m /dev/vg0/lv2
  --- Logical volume ---
  LV Path                /dev/vg0/lv2
  LV Name                lv2
  VG Name                vg0
  LV UUID                MmXbPt-ZF8u-rnIv-3YU9-m64J-RCz2-6NzAuG
  LV Write Access        read/write
  LV Creation host, time centos8.ittraining.loc, 2021-06-02 07:47:38 -0400
  LV Status              available
  # open                 0
  LV Size                112.00 MiB
  Current LE             14
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:1
   
  --- Segments ---
  Logical extents 0 to 13:
    Type		striped
    Stripes		2
    Stripe size		64.00 KiB
    Stripe 0:
      Physical volume	/dev/sdb7
      Physical extents	0 to 6
    Stripe 1:
      Physical volume	/dev/sdb9
      Physical extents	0 to 6

Utilisez maintenant la commande lvs pour visualiser les volumes physiques utilisés par le volume logique :

[root@centos8 ~]# lvs -o +devices
  LV   VG         Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices                  
  root cl_centos8 -wi-ao----  27.79g                                                     /dev/sda2(820)           
  swap cl_centos8 -wi-ao----   3.20g                                                     /dev/sda2(0)             
  lv1  vg0        -wi-a----- 104.00m                                                     /dev/sdb6(1)             
  lv2  vg0        -wi-a----- 112.00m                                                     /dev/sdb7(0),/dev/sdb9(0)

LAB #10 - Gérer les Métadonnées

Les métadonnées pour chaque Volume Group sont stockés dans un fichier texte au nom du Volume Group dans le répertoire /etc/lvm/backup :

[root@centos8 ~]# cat /etc/lvm/backup/vg0
# Generated by LVM2 version 2.03.09(2)-RHEL8 (2020-05-28): Wed Jun  2 07:47:38 2021

contents = "Text Format Volume Group"
version = 1

description = "Created *after* executing 'lvcreate -i2 -I64 -n lv2 -L 100M vg0 /dev/sdb7 /dev/sdb9'"

creation_host = "centos8.ittraining.loc"	# Linux centos8.ittraining.loc 4.18.0-240.22.1.el8_3.x86_64 #1 SMP Thu Apr 8 19:01:30 UTC 2021 x86_64
creation_time = 1622634458	# Wed Jun  2 07:47:38 2021

vg0 {
	id = "TDXUip-c3yg-J83l-Z30x-zcsJ-Rbvl-gjFvfd"
	seqno = 11
	format = "lvm2"			# informational
	status = ["RESIZEABLE", "READ", "WRITE"]
	flags = []
	extent_size = 16384		# 8 Megabytes
	max_lv = 0
	max_pv = 0
	metadata_copies = 0

	physical_volumes {

		pv0 {
			id = "lxuKRI-l3Dd-jhsv-OWtw-au2c-0ti0-XGnt1E"
			device = "/dev/sdb6"	# Hint only

			status = ["ALLOCATABLE"]
			flags = []
			dev_size = 409600	# 200 Megabytes
			pe_start = 2048
			pe_count = 24	# 192 Megabytes
		}

		pv1 {
			id = "QDmfcX-Pv8o-hapq-TJOI-RaPH-qecT-VUMY4v"
			device = "/dev/sdb7"	# Hint only

			status = ["ALLOCATABLE"]
			flags = []
			dev_size = 614400	# 300 Megabytes
			pe_start = 2048
			pe_count = 37	# 296 Megabytes
		}

		pv2 {
			id = "ZTQV1b-Ha76-BQtB-zJEU-kfyK-ausJ-CxnRwg"
			device = "/dev/sdb9"	# Hint only

			status = ["ALLOCATABLE"]
			flags = []
			dev_size = 819200	# 400 Megabytes
			pe_start = 2048
			pe_count = 49	# 392 Megabytes
		}
	}

	logical_volumes {

		lv1 {
			id = "lJQQWs-n05T-pxzi-Zq2R-UzRI-kYZf-hsNPYQ"
			status = ["READ", "WRITE", "VISIBLE"]
			flags = []
			creation_time = 1622633848	# 2021-06-02 07:37:28 -0400
			creation_host = "centos8.ittraining.loc"
			segment_count = 1

			segment1 {
				start_extent = 0
				extent_count = 13	# 104 Megabytes

				type = "striped"
				stripe_count = 1	# linear

				stripes = [
					"pv0", 1
				]
			}
		}

		lv2 {
			id = "MmXbPt-ZF8u-rnIv-3YU9-m64J-RCz2-6NzAuG"
			status = ["READ", "WRITE", "VISIBLE"]
			flags = []
			creation_time = 1622634458	# 2021-06-02 07:47:38 -0400
			creation_host = "centos8.ittraining.loc"
			segment_count = 1

			segment1 {
				start_extent = 0
				extent_count = 14	# 112 Megabytes

				type = "striped"
				stripe_count = 2
				stripe_size = 128	# 64 Kilobytes

				stripes = [
					"pv1", 0,
					"pv2", 0
				]
			}
		}
	}

}

Des archives sont créées lors de chaque modification d'un groupe de volumes et elles sont placés dans le répertoire /etc/lvm/archives :

[root@centos8 ~]# ls /etc/lvm/archive/
vg0_00000-427117660.vg   vg0_00002-2064899457.vg  vg0_00004-5061041.vg    vg0_00006-1956284179.vg  vg0_00008-708301076.vg   vg0_00010-1200598227.vg  vg0_00012-854342401.vg
vg0_00001-1993147316.vg  vg0_00003-1757437978.vg  vg0_00005-116946854.vg  vg0_00007-1006758937.vg  vg0_00009-1054420117.vg  vg0_00011-973084311.vg

La commande vgcfgbackup est utilisée pour sauvegarder les métadonnées manuellement dans le fichier /etc/lvm/backup/nom_du_volume_group :

La commande vgcfgrestore permet de restaurer une sauvegarde. Sans l'option -f pour spécifier la sauvegarde à restaurer, cette commande renvoie la liste des sauvegardes disponibles :

[root@centos8 ~]# vgcfgbackup vg0
  Volume group "vg0" successfully backed up.

Il est aussi possible de modifier l'emplacement de la sauvegarde avec l'option -f de la commande :

[root@centos8 ~]# vgcfgbackup -f /tmp/vg0_backup vg0
  Volume group "vg0" successfully backed up.

Par contre, toute sauvegarde en dehors des répertoires par défaut n'est pas visible dans la sortie de la commande vgcfgrestore –list :

[root@centos8 ~]# vgcfgrestore --list vg0
   
  File:		/etc/lvm/archive/vg0_00000-427117660.vg
  VG name:    	vg0
  Description:	Created *before* executing 'vgcreate -s 8M vg0 /dev/sdb6 /dev/sdb7 /dev/sdb9'
  Backup Time:	Wed May 26 10:43:14 2021

   
  File:		/etc/lvm/archive/vg0_00001-1993147316.vg
  VG name:    	vg0
  Description:	Created *before* executing 'lvcreate -L 350 -n lv0 vg0'
  Backup Time:	Wed May 26 16:56:31 2021

   
  File:		/etc/lvm/archive/vg0_00002-2064899457.vg
  VG name:    	vg0
  Description:	Created *before* executing 'lvextend -L +100M /dev/vg0/lv0'
  Backup Time:	Wed May 26 22:12:15 2021

   
  File:		/etc/lvm/archive/vg0_00003-1757437978.vg
  VG name:    	vg0
  Description:	Created *before* executing 'lvcreate -s -L 13M -n testsnap /dev/vg0/lv0'
  Backup Time:	Wed May 26 22:19:25 2021

   
  File:		/etc/lvm/archive/vg0_00004-5061041.vg
  VG name:    	vg0
  Description:	Created *before* executing 'lvremove /dev/vg0/testsnap'
  Backup Time:	Wed May 26 22:38:37 2021

   
  File:		/etc/lvm/archive/vg0_00005-116946854.vg
  VG name:    	vg0
  Description:	Created *before* executing 'lvremove /dev/vg0/lv0'
  Backup Time:	Wed May 26 22:42:18 2021

   
  File:		/etc/lvm/archive/vg0_00006-1956284179.vg
  VG name:    	vg0
  Description:	Created *before* executing 'vgremove vg0'
  Backup Time:	Wed May 26 22:43:49 2021

   
  File:		/etc/lvm/archive/vg0_00007-1006758937.vg
  VG name:    	vg0
  Description:	Created *before* executing 'vgcreate -s 8M vg0 /dev/sdb6 /dev/sdb7 /dev/sdb9'
  Backup Time:	Wed Jun  2 07:37:07 2021

   
  File:		/etc/lvm/archive/vg0_00008-708301076.vg
  VG name:    	vg0
  Description:	Created *before* executing 'lvcreate -m 1 -L 100M -n lv1 vg0'
  Backup Time:	Wed Jun  2 07:37:28 2021

   
  File:		/etc/lvm/archive/vg0_00009-1054420117.vg
  VG name:    	vg0
  Description:	Created *before* executing 'lvconvert -m 0 /dev/vg0/lv1 /dev/sdb7'
  Backup Time:	Wed Jun  2 07:41:04 2021

   
  File:		/etc/lvm/archive/vg0_00010-1200598227.vg
  VG name:    	vg0
  Description:	Created *before* executing 'lvconvert -m 1 /dev/vg0/lv1'
  Backup Time:	Wed Jun  2 07:41:53 2021

   
  File:		/etc/lvm/archive/vg0_00011-973084311.vg
  VG name:    	vg0
  Description:	Created *before* executing 'lvconvert -m 0 /dev/vg0/lv1 /dev/sdb7'
  Backup Time:	Wed Jun  2 07:42:23 2021

   
  File:		/etc/lvm/archive/vg0_00012-854342401.vg
  VG name:    	vg0
  Description:	Created *before* executing 'lvcreate -i2 -I64 -n lv2 -L 100M vg0 /dev/sdb7 /dev/sdb9'
  Backup Time:	Wed Jun  2 07:47:38 2021

   
  File:		/etc/lvm/backup/vg0
  VG name:    	vg0
  Description:	Created *after* executing 'vgcfgbackup vg0'
  Backup Time:	Wed Jun  2 07:50:57 2021

LAB #20 - Créer un Système de Fichiers ISO

La Commande mkisofs

Pour créer un fichier ISO à partir d'une arborescence de fichiers, il convient d'utiliser la commande mkisofs :

[root@centos8 ~]# cd /tmp
[root@centos8 tmp]# mkisofs -r -T -o tmp.iso .
I: -input-charset not specified, using utf-8 (detected in locale settings)
Total translation table size: 1827
Total rockridge attributes bytes: 1976
Total directory bytes: 14336
Path table size(bytes): 122
Max brk space used 1c000
186 extents written (0 MB)

Le fichier ISO peut être monter en utilisant un périphérique de type loop :

[root@centos8 tmp]# mount tmp.iso /mnt -o loop
mount: /mnt: WARNING: device write-protected, mounted read-only.
[root@centos8 tmp]# ls /mnt
systemd-private-192104a9224f499286f5adb5754e9e04-chronyd.service-FI2YXs  TRANS.TBL  vg0_backup
[root@centos8 tmp]# ls 
systemd-private-192104a9224f499286f5adb5754e9e04-chronyd.service-FI2YXs  tmp.iso  vg0_backup

Démontez maintenant le fichier ISO :

[root@centos8 tmp]# cd ~
[root@centos8 ~]# umount /tmp/tmp.iso

Options de la Commande mkisofs

Les options de cette commande sont :

[root@centos8 ~]# mkisofs --help
Usage: genisoimage [options] file...
Options:
  -nobak                      Do not include backup files
  -no-bak                     Do not include backup files
  -abstract FILE              Set Abstract filename
  -A ID, -appid ID            Set Application ID
  -biblio FILE                Set Bibliographic filename
  -cache-inodes               Cache inodes (needed to detect hard links)
  -no-cache-inodes            Do not cache inodes (if filesystem has no unique unides)
  -check-oldnames             Check all imported ISO9660 names from old session
  -check-session FILE         Check all ISO9660 names from previous session
  -copyright FILE             Set Copyright filename
  -debug                      Set debug flag
  -b FILE, -eltorito-boot FILE
                              Set El Torito boot image name
  -e FILE, -efi-boot FILE     Set EFI boot image name
  -eltorito-alt-boot          Start specifying alternative El Torito boot parameters
  -B FILES, -sparc-boot FILES Set sparc boot image names
  -sunx86-boot FILES          Set sunx86 boot image names
  -G FILE, -generic-boot FILE Set generic boot image name
  -sparc-label label text     Set sparc boot disk label
  -sunx86-label label text    Set sunx86 boot disk label
  -c FILE, -eltorito-catalog FILE
                              Set El Torito boot catalog name
  -C PARAMS, -cdrecord-params PARAMS
                              Magic paramters from cdrecord
  -d, -omit-period            Omit trailing periods from filenames (violates ISO9660)
  -dir-mode mode              Make the mode of all directories this mode.
  -D, -disable-deep-relocation
                              Disable deep directory relocation (violates ISO9660)
  -file-mode mode             Make the mode of all plain files this mode.
  -f, -follow-links           Follow symbolic links
  -gid gid                    Make the group owner of all files this gid.
  -graft-points               Allow to use graft points for filenames
  -root DIR                   Set root directory for all new files and directories
  -old-root DIR               Set root directory in previous session that is searched for files
  -help                       Print option help
  -hide GLOBFILE              Hide ISO9660/RR file
  -hide-list FILE             File with list of ISO9660/RR files to hide
  -hidden GLOBFILE            Set hidden attribute on ISO9660 file
  -hidden-list FILE           File with list of ISO9660 files with hidden attribute
  -hide-joliet GLOBFILE       Hide Joliet file
  -hide-joliet-list FILE      File with list of Joliet files to hide
  -hide-joliet-trans-tbl      Hide TRANS.TBL from Joliet tree
  -hide-rr-moved              Rename RR_MOVED to .rr_moved in Rock Ridge tree
  -gui                        Switch behaviour for GUI
  -i ADD_FILES                No longer supported
  -input-charset CHARSET      Local input charset for file name conversion
  -output-charset CHARSET     Output charset for file name conversion
  -iso-level LEVEL            Set ISO9660 conformance level (1..3) or 4 for ISO9660 version 2
  -J, -joliet                 Generate Joliet directory information
  -joliet-long                Allow Joliet file names to be 103 Unicode characters
  -jcharset CHARSET           Local charset for Joliet directory information
  -l, -full-iso9660-filenames Allow full 31 character filenames for ISO9660 names
  -max-iso9660-filenames      Allow 37 character filenames for ISO9660 names (violates ISO9660)
  -allow-limited-size         Allow different file sizes in ISO9660/UDF on large files
  -allow-leading-dots         Allow ISO9660 filenames to start with '.' (violates ISO9660)
  -ldots                      Allow ISO9660 filenames to start with '.' (violates ISO9660)
  -L, -allow-leading-dots     Allow ISO9660 filenames to start with '.' (violates ISO9660)
  -log-file LOG_FILE          Re-direct messages to LOG_FILE
  -m GLOBFILE, -exclude GLOBFILE
                              Exclude file name
  -exclude-list FILE          File with list of file names to exclude
  -pad                        Pad output to a multiple of 32k (default)
  -no-pad                     Do not pad output to a multiple of 32k
  -M FILE, -prev-session FILE Set path to previous session to merge
  -dev SCSIdev                Set path to previous session to merge
  -N, -omit-version-number    Omit version number from ISO9660 filename (violates ISO9660)
  -new-dir-mode mode          Mode used when creating new directories.
  -force-rr                   Inhibit automatic Rock Ridge detection for previous session
  -no-rr                      Inhibit reading of Rock Ridge attributes from previous session
  -no-split-symlink-components
                              Inhibit splitting symlink components
  -no-split-symlink-fields    Inhibit splitting symlink fields
  -o FILE, -output FILE       Set output file name
  -path-list FILE             File with list of pathnames to process
  -p PREP, -preparer PREP     Set Volume preparer
  -print-size                 Print estimated filesystem size and exit
  -publisher PUB              Set Volume publisher
  -P PUB, -publisher PUB      Set Volume publisher
  -quiet                      Run quietly
  -r, -rational-rock          Generate rationalized Rock Ridge directory information
  -R, -rock                   Generate Rock Ridge directory information
  -s TYPE, -sectype TYPE      Set output sector type to e.g. data/xa1/raw
  -alpha-boot FILE            Set alpha boot image name (relative to image root)
  -hppa-cmdline CMDLINE       Set hppa boot command line (relative to image root)
  -hppa-kernel-32 FILE        Set hppa 32-bit image name (relative to image root)
  -hppa-kernel-64 FILE        Set hppa 64-bit image name (relative to image root)
  -hppa-bootloader FILE       Set hppa boot loader file name (relative to image root)
  -hppa-ramdisk FILE          Set hppa ramdisk file name (relative to image root)
  -mips-boot FILE             Set mips boot image name (relative to image root)
  -mipsel-boot FILE           Set mipsel boot image name (relative to image root)
  -jigdo-jigdo FILE           Produce a jigdo .jigdo file as well as the .iso
  -jigdo-template FILE        Produce a jigdo .template file as well as the .iso
  -jigdo-min-file-size SIZE   Minimum size for a file to be listed in the jigdo file
  -jigdo-force-md5 PATTERN    Pattern(s) where files MUST match an externally-supplied MD5sum
  -jigdo-exclude PATTERN      Pattern(s) to exclude from the jigdo file
  -jigdo-map PATTERN1=PATTERN2
                              Pattern(s) to map paths (e.g. Debian=/mirror/debian)
  -md5-list FILE              File containing MD5 sums of the files that should be checked
  -jigdo-template-compress ALGORITHM
                              Choose to use gzip or bzip2 compression for template data; default is gzip
  -checksum_algorithm_iso alg1,alg2,...
                              Specify the checksum types desired for the output image
  -checksum_algorithm_template alg1,alg2,...
                              Specify the checksum types desired for the output jigdo template
  -sort FILE                  Sort file content locations according to rules in FILE
  -split-output               Split output into files of approx. 1GB size
  -stream-file-name FILE_NAME Set the stream file ISO9660 name (incl. version)
  -stream-media-size #        Set the size of your CD media in sectors
  -sysid ID                   Set System ID
  -T, -translation-table      Generate translation tables for systems that don't understand long filenames
  -table-name TABLE_NAME      Translation table file name
  -ucs-level LEVEL            Set Joliet UCS level (1..3)
  -udf                        Generate UDF file system
  -dvd-video                  Generate DVD-Video compliant UDF file system
  -uid uid                    Make the owner of all files this uid.
  -U, -untranslated-filenames Allow Untranslated filenames (for HPUX & AIX - violates ISO9660). Forces -l, -d, -N, -allow-leading-dots, -relaxed-filenames, -allow-lowercase, -allow-multidot
  -relaxed-filenames          Allow 7 bit ASCII except lower case characters (violates ISO9660)
  -no-iso-translate           Do not translate illegal ISO characters '~', '-' and '#' (violates ISO9660)
  -allow-lowercase            Allow lower case characters in addition to the current character set (violates ISO9660)
  -allow-multidot             Allow more than one dot in filenames (e.g. .tar.gz) (violates ISO9660)
  -use-fileversion LEVEL      Use file version # from filesystem
  -v, -verbose                Verbose
  -version                    Print the current version
  -V ID, -volid ID            Set Volume ID
  -volset ID                  Set Volume set ID
  -volset-size #              Set Volume set size
  -volset-seqno #             Set Volume set sequence number
  -x FILE, -old-exclude FILE  Exclude file name(depreciated)
  -hard-disk-boot             Boot image is a hard disk image
  -no-emul-boot               Boot image is 'no emulation' image
  -no-boot                    Boot image is not bootable
  -boot-load-seg #            Set load segment for boot image
  -boot-load-size #           Set numbers of load sectors
  -boot-info-table            Patch boot image with info table
  -XA                         Generate XA directory attruibutes
  -xa                         Generate rationalized XA directory attruibutes
  -z, -transparent-compression
                              Enable transparent compression of files
  -hfs-type TYPE              Set HFS default TYPE
  -hfs-creator CREATOR        Set HFS default CREATOR
  -g, -apple                  Add Apple ISO9660 extensions
  -h, -hfs                    Create ISO9660/HFS hybrid
  -map MAPPING_FILE           Map file extensions to HFS TYPE/CREATOR
  -H MAPPING_FILE, -map MAPPING_FILE
                              Map file extensions to HFS TYPE/CREATOR
  -magic FILE                 Magic file for HFS TYPE/CREATOR
  -probe                      Probe all files for Apple/Unix file types
  -mac-name                   Use Macintosh name for ISO9660/Joliet/RockRidge file name
  -no-mac-files               Do not look for Unix/Mac files (depreciated)
  -boot-hfs-file FILE         Set HFS boot image name
  -part                       Generate HFS partition table
  -cluster-size SIZE          Cluster size for PC Exchange Macintosh files
  -auto FILE                  Set HFS AutoStart file name
  -no-desktop                 Do not create the HFS (empty) Desktop files
  -hide-hfs GLOBFILE          Hide HFS file
  -hide-hfs-list FILE         List of HFS files to hide
  -hfs-volid HFS_VOLID        Volume name for the HFS partition
  -icon-position              Keep HFS icon position
  -root-info FILE             finderinfo for root folder
  -input-hfs-charset CHARSET  Local input charset for HFS file name conversion
  -output-hfs-charset CHARSET Output charset for HFS file name conversion
  -hfs-unlock                 Leave HFS Volume unlocked
  -hfs-bless FOLDER_NAME      Name of Folder to be blessed
  -hfs-parms PARAMETERS       Comma separated list of HFS parameters
  -prep-boot FILE             PReP boot image file -- up to 4 are allowed
  -chrp-boot                  Add CHRP boot header
  --cap                       Look for AUFS CAP Macintosh files
  --netatalk                  Look for NETATALK Macintosh files
  --double                    Look for AppleDouble Macintosh files
  --ethershare                Look for Helios EtherShare Macintosh files
  --exchange                  Look for PC Exchange Macintosh files
  --sgi                       Look for SGI Macintosh files
  --macbin                    Look for MacBinary Macintosh files
  --single                    Look for AppleSingle Macintosh files
  --ushare                    Look for IPT UShare Macintosh files
  --xinet                     Look for XINET Macintosh files
  --dave                      Look for DAVE Macintosh files
  --sfm                       Look for SFM Macintosh files
  --osx-double                Look for MacOS X AppleDouble Macintosh files
  --osx-hfs                   Look for MacOS X HFS Macintosh files

Report problems to debburn-devel@lists.alioth.debian.org.

Concepts RAID

Les solutions RAID ou Redundant Array of Independent Disks ou encore Redundant Array of Inexpensive Disks permettent la combinaison de plusieurs disques de façon à ce que ceux-ci soient vu comme un seul disque logique.

Les solutions RAID sont issues du travail fourni par l'université de Berkeley en Californie sur un projet de tolérances de pannes. Les systèmes RAID offre maintenant plusieurs avantages :

  • Addition des capacités,
  • Amélioration des performances,
  • Apporter la tolérance de panne.

Deux concepts sont fondamentaux à la compréhension des solutions RAID.

Disques en miroir

La technique des disques en miroir consiste à dupliquer l'écriture des données sur plusieurs disques. Le miroir peut être géré par un logiciel ou par du matériel.

Bandes de données

La technique des bandes de données, autrement appelée data striping consiste à couper les données à enregistrer en segments séquentiels et contigus pour les enregistrer sur plusieurs disques physiques. L'ensemble des segments constitue alors un disque logique ou striped disk. Cette technique peut être améliorée en déposant une bande de parité, calculée à partir des données des autres bandes, afin de pouvoir reconstituer une bande de données défaillante.

Types de RAID

RAID 0 - Concaténation

Création de volume par récupération de l'espace libre sur un ou plusieurs disques. Le principe de la concaténation est la création d'un volume à bandes où chaque bande est une tranche.

Avantages

  • Récupération de l'espace disque.

Inconvénients

  • Pas de protection des données,
  • Pas d'augmentation des performances d'E/S.

RAID 0 - Striping

Création de volume sur plusieurs disques afin d'augmenter les performances d'E/S. Le principe du striping est la création d'un volume à bandes réparties sur plusieurs tranches. La taille de la bande doit être fonction des données à écrire sur le volume (16k, 32k, 64k, etc.) Cette taille est choisie à la création du volume.

Avantages

  • Augmentation des performances d'E/S par écriture en parallèle sur les disques.

Inconvénients

  • Pas de protection des données.

RAID 1 - Miroir

Création d'un volume où les disques sont en miroir. Quand les deux disques sont connectés à des contrôleurs de disques différents, on parle de duplexing :

Avantages

  • Protection des données contre une défaillance d'un disque.

Inconvénients

  • Coûteux à cause de l'augmentation du nombre de disques.

RAID 1+0 - Striping en Miroir

Le RAID 1+0 ou encore 0+1 est une technique qui réunit le RAID 0 et le RAID 1. On l'appelle aussi un RAID exotique:

Avantages

  • Protection des données contre une défaillance d'un disque.
  • Augmentation des performances d'E/S par écriture en parallèle sur les disques.

Inconvénients

  • Coûteux à cause de l'augmentation du nombre de disques.

RAID 2 - Miroir avec Contrôle d'Erreurs

Le RAID 2 est une technique de miroir avec contrôle de correction d'erreurs (EEC). De nos jours cette technique est peu utilisée, ayant été remplacée par les RAID 3, 4 et 5.

RAID 3 et 4 - Striping avec Parité

Les RAID 3 et 4 sont des technologies avec bandes de parité distribuées sur un seul disque :

En RAID 3, la taille des segments n’est pas modifiable et est fixée à 512 octets (en RAID 3 : un segment = un secteur de disque dur = 512 octets).

En RAID 4, la taille des segments est variable et se modifie en temps réel. Cela implique que les informations de parité doivent être mise à jour à chaque écriture afin de vérifier si la taille des segments a été modifiée.

Avantages

  • Protection des données contre une défaillance d'un disque.

Inconvénients

  • Création d'un goulot d'étranglement des données à cause de l'écriture des données de parité sur un seul disque.

RAID 5 - Striping avec Parité Distribuée

Le RAID 5 est une technologie avec bandes de parité distribuées sur plusieurs disques :

Avantages

  • Protection des données contre une défaillance d'un disque,
  • Evite le goulot d'étranglement d'un seul disque de parité.

Inconvénients

  • Lecture moins performante qu'avec RAID 3 et 4.

Au délà de RAID 5

Il existe aussi deux autres technologies RAID, toute deux issues de la technologie RAID 5 :

  • RAID 6
    • Disk Striping with Double Distributed Parity
  • RAID TP
    • Disk Striping with Triple Distributed Parity

RAID Logiciel sous RHEL/CentOS

Préparation du disque

Partitionnement

Suite à votre LAB de la leçon Gestion des Disques et le Swap, votre disque comporte 12 partitions :

[root@centos7 ~]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000c5a90

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      411647      204800   83  Linux
/dev/sda2          411648    20891647    10240000   83  Linux
/dev/sda3        20891648    25083903     2096128   82  Linux swap / Solaris
/dev/sda4        25083904    41943039     8429568    5  Extended
/dev/sda5        25085952    26109951      512000   fd  Linux raid autodetect
/dev/sda6        26112000    26521599      204800   8e  Linux LVM
/dev/sda7        26523648    27138047      307200   8e  Linux LVM
/dev/sda8        27140096    28164095      512000   fd  Linux raid autodetect
/dev/sda9        28166144    28985343      409600   8e  Linux LVM
/dev/sda10       28987392    30011391      512000   fd  Linux raid autodetect
/dev/sda11       30013440    31037439      512000   fd  Linux raid autodetect
/dev/sda12       31039488    31449087      204800   83  Linux

Mise en Place du RAID 5 Logiciel

Dans le cas de cet exemple les quatre partitions concernées par la mise en place d'un RAID 5 sont :

/dev/sda5        25085952    26109951      512000   fd  Linux raid autodetect
/dev/sda8        27140096    28164095      512000   fd  Linux raid autodetect
/dev/sda10       28987392    30011391      512000   fd  Linux raid autodetect
/dev/sda11       30013440    31037439      512000   fd  Linux raid autodetect

La création d'une unité RAID avec la commande mdadm se fait grâce aux options passées en arguments à la commande :

mdadm --create <unité RAID> [options] <unités physiques>

Par exemple, saisissez la commande suivante :

[root@centos7 ~]# mdadm --create /dev/md1 --level=5 --raid-devices=3 /dev/sda5 /dev/sda8 /dev/sda11
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md1 started.

Les options dans la ligne de commande sont :

Option Courte Option Longue Description
-l - -level Le niveau RAID - linear, 0,1,2,4 ou 5
-n - -raid-devices=<nombre> Le nombre de périphériques actifs dans le RAID

Les autres options de la commande mdadm peuvent être visualisées grâce à la commande suivante :

[root@centos7 ~]# mdadm --help-options
Any parameter that does not start with '-' is treated as a device name
or, for --examine-bitmap, a file name.
The first such name is often the name of an md device.  Subsequent
names are often names of component devices.

Some common options are:
  --help        -h   : General help message or, after above option,
                       mode specific help message
  --help-options     : This help message
  --version     -V   : Print version information for mdadm
  --verbose     -v   : Be more verbose about what is happening
  --quiet       -q   : Don't print un-necessary messages
  --brief       -b   : Be less verbose, more brief
  --export      -Y   : With --detail, --detail-platform or --examine use
                       key=value format for easy import into environment
  --force       -f   : Override normal checks and be more forceful

  --assemble    -A   : Assemble an array
  --build       -B   : Build an array without metadata
  --create      -C   : Create a new array
  --detail      -D   : Display details of an array
  --examine     -E   : Examine superblock on an array component
  --examine-bitmap -X: Display the detail of a bitmap file
  --examine-badblocks: Display list of known bad blocks on device
  --monitor     -F   : monitor (follow) some arrays
  --grow        -G   : resize/ reshape and array
  --incremental -I   : add/remove a single device to/from an array as appropriate
  --query       -Q   : Display general information about how a
                       device relates to the md driver
  --auto-detect      : Start arrays auto-detected by the kernel

Les modes majeurs de la commande mdadm peuvent être visualisés grâce à la commande suivante :

[root@centos7 ~]# mdadm --help
mdadm is used for building, managing, and monitoring
Linux md devices (aka RAID arrays)
Usage: mdadm --create device options...
            Create a new array from unused devices.
       mdadm --assemble device options...
            Assemble a previously created array.
       mdadm --build device options...
            Create or assemble an array without metadata.
       mdadm --manage device options...
            make changes to an existing array.
       mdadm --misc options... devices
            report on or modify various md related devices.
       mdadm --grow options device
            resize/reshape an active array
       mdadm --incremental device
            add/remove a device to/from an array as appropriate
       mdadm --monitor options...
            Monitor one or more array for significant changes.
       mdadm device options...
            Shorthand for --manage.
Any parameter that does not start with '-' is treated as a device name
or, for --examine-bitmap, a file name.
The first such name is often the name of an md device.  Subsequent
names are often names of component devices.

 For detailed help on the above major modes use --help after the mode
 e.g.
         mdadm --assemble --help
 For general help on options use
         mdadm --help-options

Dernièrement, chaque mode majeur dispose de son propre aide :

[root@centos7 ~]# mdadm --assemble --help
Usage: mdadm --assemble device options...
       mdadm --assemble --scan options...

This usage assembles one or more raid arrays from pre-existing
components.
For each array, mdadm needs to know the md device, the identity of
the array, and a number of sub devices. These can be found in a number
of ways.

The md device is given on the command line, is found listed in the
config file, or can be deduced from the array identity.
The array identity is determined either from the --uuid, --name, or
--super-minor commandline arguments, from the config file,
or from the first component device on the command line.

The different combinations of these are as follows:
 If the --scan option is not given, then only devices and identities
 listed on the command line are considered.
 The first device will be the array device, and the remainder will be
 examined when looking for components.
 If an explicit identity is given with --uuid or --super-minor, then
 only devices with a superblock which matches that identity is considered,
 otherwise every device listed is considered.

 If the --scan option is given, and no devices are listed, then
 every array listed in the config file is considered for assembly.
 The identity of candidate devices are determined from the config file.
 After these arrays are assembled, mdadm will look for other devices
 that could form further arrays and tries to assemble them.  This can
 be disabled using the 'AUTO' option in the config file.

 If the --scan option is given as well as one or more devices, then
 Those devices are md devices that are to be assembled.  Their identity
 and components are determined from the config file.

 If mdadm can not find all of the components for an array, it will assemble
 it but not activate it unless --run or --scan is given.  To preserve this
 behaviour even with --scan, add --no-degraded.  Note that "all of the
 components" means as many as were present the last time the array was running
 as recorded in the superblock.  If the array was already degraded, and
 the missing device is not a new problem, it will still be assembled.  It
 is only newly missing devices that cause the array not to be started.

Options that are valid with --assemble (-A) are:
  --bitmap=          : bitmap file to use with the array
  --uuid=       -u   : uuid of array to assemble. Devices which don't
                       have this uuid are excluded
  --super-minor= -m  : minor number to look for in super-block when
                       choosing devices to use.
  --name=       -N   : Array name to look for in super-block.
  --config=     -c   : config file
  --scan        -s   : scan config file for missing information
  --run         -R   : Try to start the array even if not enough devices
                       for a full array are present
  --force       -f   : Assemble the array even if some superblocks appear
                     : out-of-date.  This involves modifying the superblocks.
  --update=     -U   : Update superblock: try '-A --update=?' for option list.
  --no-degraded      : Assemble but do not start degraded arrays.
  --readonly    -o   : Mark the array as read-only. No resync will start.

Constatez maintenant les informations concernant le RAID 5 créé :

[root@centos7 ~]# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4] 
md1 : active raid5 sda11[3] sda8[1] sda5[0]
      1021952 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]
      
unused devices: <none>

Grâce à la commande mdadm, il est possible d'obtenir d'avantage d'informations :

[root@centos7 ~]# mdadm --query /dev/md1
/dev/md1: 998.17MiB raid5 3 devices, 0 spares. Use mdadm --detail for more detail.

L'option - -detail produit le résultat suivant :

[root@centos7 ~]# mdadm --detail /dev/md1
/dev/md1:
        Version : 1.2
  Creation Time : Tue Aug  2 15:10:12 2016
     Raid Level : raid5
     Array Size : 1021952 (998.17 MiB 1046.48 MB)
  Used Dev Size : 510976 (499.08 MiB 523.24 MB)
   Raid Devices : 3
  Total Devices : 3
    Persistence : Superblock is persistent

    Update Time : Tue Aug  2 15:10:17 2016
          State : clean 
 Active Devices : 3
Working Devices : 3
 Failed Devices : 0
  Spare Devices : 0

         Layout : left-symmetric
     Chunk Size : 512K

           Name : centos7.fenestros.loc:1  (local to host centos7.fenestros.loc)
           UUID : fd8bac53:1457a4f4:30feab84:e0f9d8e0
         Events : 18

    Number   Major   Minor   RaidDevice State
       0       8        5        0      active sync   /dev/sda5
       1       8        8        1      active sync   /dev/sda8
       3       8       11        2      active sync   /dev/sda11

Notez la ligne Persistence : Superblock is persistent. En effet, cette implémentation de RAID inscrit les caractéristiques du volume dans un super bloc persistant en début de chaque unité de type bloc dans le volume.

Recherchez la signification des termes Layout, Chunk size, Major et Minor.

Cependant, il necéssaire de renseigner le fichier /etc/mdadm.conf afin que le RAID soit contruit à chaque démarrage :

[root@centos7 ~]# echo 'DEVICES /dev/sda5 /dev/sda8 /dev/sda11' > /etc/mdadm.conf
[root@centos7 ~]# mdadm --detail --scan >> /etc/mdadm.conf 
[root@centos7 ~]# cat /etc/mdadm.conf
DEVICES /dev/sda5 /dev/sda8 /dev/sda11
ARRAY /dev/md1 metadata=1.2 name=centos7.fenestros.loc:1 UUID=fd8bac53:1457a4f4:30feab84:e0f9d8e0

Chaque unité peut être examinée individuellement :

[root@centos7 ~]# mdadm --examine /dev/sda5
/dev/sda5:
          Magic : a92b4efc
        Version : 1.2
    Feature Map : 0x0
     Array UUID : fd8bac53:1457a4f4:30feab84:e0f9d8e0
           Name : centos7.fenestros.loc:1  (local to host centos7.fenestros.loc)
  Creation Time : Tue Aug  2 15:10:12 2016
     Raid Level : raid5
   Raid Devices : 3

 Avail Dev Size : 1021952 (499.08 MiB 523.24 MB)
     Array Size : 1021952 (998.17 MiB 1046.48 MB)
    Data Offset : 2048 sectors
   Super Offset : 8 sectors
   Unused Space : before=1960 sectors, after=0 sectors
          State : clean
    Device UUID : 4569e15e:20201bce:365776f2:75aed23f

    Update Time : Tue Aug  2 15:10:17 2016
  Bad Block Log : 512 entries available at offset 72 sectors
       Checksum : 4c9948d0 - correct
         Events : 18

         Layout : left-symmetric
     Chunk Size : 512K

   Device Role : Active device 0
   Array State : AAA ('A' == active, '.' == missing, 'R' == replacing)

A ce stade il est intéressant de noter comment réagir lors d'une défaillance d'un disque. Dans notre cas nous allons indiquer au système que la partition /dev/sda5 est devenue défaillante :

[root@centos7 ~]# mdadm --manage --set-faulty /dev/md1 /dev/sda5
mdadm: set /dev/sda5 faulty in /dev/md1

L'utilisation de la ligne de commande suivante nous confirme le statut de /dev/sda5 :

[root@centos7 ~]# mdadm --detail /dev/md1
/dev/md1:
        Version : 1.2
  Creation Time : Tue Aug  2 15:10:12 2016
     Raid Level : raid5
     Array Size : 1021952 (998.17 MiB 1046.48 MB)
  Used Dev Size : 510976 (499.08 MiB 523.24 MB)
   Raid Devices : 3
  Total Devices : 3
    Persistence : Superblock is persistent

    Update Time : Tue Aug  2 15:14:59 2016
          State : clean, degraded 
 Active Devices : 2
Working Devices : 2
 Failed Devices : 1
  Spare Devices : 0

         Layout : left-symmetric
     Chunk Size : 512K

           Name : centos7.fenestros.loc:1  (local to host centos7.fenestros.loc)
           UUID : fd8bac53:1457a4f4:30feab84:e0f9d8e0
         Events : 20

    Number   Major   Minor   RaidDevice State
       0       0        0        0      removed
       1       8        8        1      active sync   /dev/sda8
       3       8       11        2      active sync   /dev/sda11

       0       8        5        -      faulty   /dev/sda5

Il est maintenant nécessaire de supprimer /dev/sda5 de notre RAID 5 :

[root@centos7 ~]# mdadm --manage --remove /dev/md1 /dev/sda5
mdadm: hot removed /dev/sda5 from /dev/md1

A l'examen de notre RAID, on constate que /dev/sda5 a été supprimé :

[root@centos7 ~]# mdadm --detail /dev/md1
/dev/md1:
        Version : 1.2
  Creation Time : Tue Aug  2 15:10:12 2016
     Raid Level : raid5
     Array Size : 1021952 (998.17 MiB 1046.48 MB)
  Used Dev Size : 510976 (499.08 MiB 523.24 MB)
   Raid Devices : 3
  Total Devices : 2
    Persistence : Superblock is persistent

    Update Time : Tue Aug  2 15:16:41 2016
          State : clean, degraded 
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

         Layout : left-symmetric
     Chunk Size : 512K

           Name : centos7.fenestros.loc:1  (local to host centos7.fenestros.loc)
           UUID : fd8bac53:1457a4f4:30feab84:e0f9d8e0
         Events : 21

    Number   Major   Minor   RaidDevice State
       0       0        0        0      removed
       1       8        8        1      active sync   /dev/sda8
       3       8       11        2      active sync   /dev/sda11

Constatez maintenant l'existance de votre RAID :

[root@centos7 ~]# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4] 
md1 : active raid5 sda11[3] sda8[1]
      1021952 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/2] [_UU]
      
unused devices: <none>

Notez que le RAID a été démarré avec 2 unités au lieu de trois.

Pour ajouter un autre disque à notre RAID afin de remplacer /dev/sda5 il convient d'utiliser l'option –add :

[root@centos7 ~]# mdadm --manage --add /dev/md1 /dev/sda10
mdadm: added /dev/sda10

L'exemen du RAID indique que /dev/sda10 a été ajouté en tant que spare et à l'issu de quelques minutes le RAID 5 a été reconstruite :

[root@centos7 ~]# mdadm --detail /dev/md1
/dev/md1:
        Version : 1.2
  Creation Time : Tue Aug  2 15:10:12 2016
     Raid Level : raid5
     Array Size : 1021952 (998.17 MiB 1046.48 MB)
  Used Dev Size : 510976 (499.08 MiB 523.24 MB)
   Raid Devices : 3
  Total Devices : 3
    Persistence : Superblock is persistent

    Update Time : Tue Aug  2 15:19:06 2016
          State : clean 
 Active Devices : 3
Working Devices : 3
 Failed Devices : 0
  Spare Devices : 0

         Layout : left-symmetric
     Chunk Size : 512K

           Name : centos7.fenestros.loc:1  (local to host centos7.fenestros.loc)
           UUID : fd8bac53:1457a4f4:30feab84:e0f9d8e0
         Events : 40

    Number   Major   Minor   RaidDevice State
       4       8       10        0      active sync   /dev/sda10
       1       8        8        1      active sync   /dev/sda8
       3       8       11        2      active sync   /dev/sda11

Naturellement, il necéssaire de renseigner le fichier /etc/mdadm.conf du changement afin que le RAID soit contruit à chaque démarrage :

[root@centos7 ~]# echo 'DEVICES /dev/sda10 /dev/sda8 /dev/sda11' > /etc/mdadm.conf
[root@centos7 ~]# mdadm --detail --scan >> /etc/mdadm.conf 
[root@centos7 ~]# cat /etc/mdadm.conf
DEVICES /dev/sda10 /dev/sda8 /dev/sda11
ARRAY /dev/md1 metadata=1.2 name=centos7.fenestros.loc:1 UUID=fd8bac53:1457a4f4:30feab84:e0f9d8e0

Copyright © 2022 Hugh Norris.

Menu