Différences
Ci-dessous, les différences entre deux révisions de la page.
systemes:linux:lvm [2017/10/13 11:31] william créée |
systemes:linux:lvm [2019/02/06 14:03] |
||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | ====== Gestion des disques et des partitions avec LVM ====== | ||
- | |||
- | * Prenons le cas d'un ajout de disque à une machine virtuelle | ||
- | |||
- | ===== Découverte des disques ===== | ||
- | |||
- | * Lorsque l'on ajoute un disque à une machine Linux, il n'est pas nécessaire de rebooter pour le voir <code bash> | ||
- | ll /dev/sdb | ||
- | </ | ||
- | |||
- | * S'il n'est pas apparu, il faut déclencher un scan< | ||
- | # ll / | ||
- | total 0 | ||
- | lrwxrwxrwx 1 root root 0 14 juin 16:20 host0 -> ../ | ||
- | lrwxrwxrwx 1 root root 0 14 juin 16:20 host1 -> ../ | ||
- | lrwxrwxrwx 1 root root 0 14 juin 16:20 host2 -> ../ | ||
- | |||
- | #Pour chaque répertoire " | ||
- | echo "- - -" >/ | ||
- | echo "- - -" >/ | ||
- | echo "- - -" >/ | ||
- | </ | ||
- | |||
- | * Vérification <code bash> | ||
- | fdisk -l | ||
- | </ | ||
- | |||
- | ===== Utilisation des volumes logiques ===== | ||
- | |||
- | ==== Mise en place ==== | ||
- | |||
- | === 1.Création du volume physique ==== | ||
- | * Il faut d' | ||
- | - Préparer la partition avec fdisk< | ||
- | fdisk /dev/sdb | ||
- | n --> creer nouvelle parition | ||
- | p --> partition primaire | ||
- | 1 | ||
- | t (type de partition --> 8e LVM) | ||
- | </ | ||
- | - Créer le volume physique <code bash> | ||
- | pvcreate /dev/sdb1 | ||
- | </ | ||
- | |||
- | |||
- | * Pour voir le résultat :<code bash> | ||
- | --- Physical volume --- | ||
- | "/ | ||
- | --- NEW Physical volume --- | ||
- | PV Name / | ||
- | VG Name | ||
- | PV Size 25.00 GiB | ||
- | Allocatable | ||
- | PE Size | ||
- | Total PE 0 | ||
- | Free PE 0 | ||
- | Allocated PE 0 | ||
- | PV UUID | ||
- | </ | ||
- | |||
- | === 2.Création d'un groupe ==== | ||
- | * Il faut ensuite créer un groupe et associer le volume physique précédemment créé. <code bash> | ||
- | </ | ||
- | * nomDeVolumeGroup --> est le nom du groupe | ||
- | |||
- | * Pour voir le résultat : <code bash> | ||
- | --- Volume group --- VG Name | ||
- | System ID | ||
- | Format | ||
- | Metadata Areas 1 | ||
- | Metadata Sequence No 1 | ||
- | VG Access | ||
- | VG Status | ||
- | MAX LV 0 | ||
- | Cur LV 0 | ||
- | Open LV 0 | ||
- | Max PV 0 | ||
- | Cur PV 1 | ||
- | Act PV 1 | ||
- | VG Size 24.97 GiB | ||
- | PE Size 32.00 MiB | ||
- | Total PE 799 | ||
- | Alloc PE / Size 0 / 0 | ||
- | Free PE / Size 799 / 24.97 GiB | ||
- | VG UUID | ||
- | </ | ||
- | |||
- | === 3.Création d'une partition logique === | ||
- | |||
- | * Il faut ensuite créer une partition et la formater :<code bash> | ||
- | lvcreate -L 10G -n nomDePartition nomDeVolumeGroup | ||
- | ou | ||
- | lvcreate -l 100%FREE -n nomDePartition nomDeVolumeGroup | ||
- | |||
- | mkfs.xfs | ||
- | </ | ||
- | |||
- | |||
- | * Pour voir le résultat : <code bash> | ||
- | --- Logical volume --- | ||
- | LV Path / | ||
- | LV Name nomDePartition | ||
- | VG Name nomDeVolumeGroup | ||
- | LV UUID 6AR39c-dDUK-EPpo-ifF0-cAnV-wWMQ-0QfWpQ | ||
- | LV Write Access | ||
- | LV Creation host, time xxx, 2016-04-07 17:43:59 +0200 | ||
- | LV Status | ||
- | # open 0 | ||
- | LV Size 10.00 GiB | ||
- | Current LE 320 | ||
- | Segments | ||
- | Allocation | ||
- | Read ahead sectors | ||
- | - currently set to 8192 | ||
- | Block device | ||
- | </ | ||
- | |||
- | === 4.Montage d'une partition === | ||
- | |||
- | * <code bash># | ||
- | / | ||
- | #Recharger la table de partition : | ||
- | mount -a | ||
- | </ | ||
- | |||
- | |||
- | ==== Accroitre la capacité ==== | ||
- | |||
- | === Augmenter la capacité du volume group === | ||
- | |||
- | * pvcreate <nouveau device> | ||
- | * vgextend <VG name> | ||
- | |||
- | |||
- | === Augmenter la taille de la partition === | ||
- | |||
- | * L' | ||
- | - **Augmentation de la taille du volume logique** | ||
- | * Vérification des valeurs (nomDeVolumeGroup - nomDePartition) avant l' | ||
- | lvs | ||
- | LV VG | ||
- | nomDePartition vg0 -wi-ao | ||
- | lvol1 vg0 -wi-ao 512.00M | ||
- | nomDePartition nomDeVolumeGroup | ||
- | </ | ||
- | * Augmentation de la taille | ||
- | * __cas 1__ : augmentation donnée (exemple : 30G)< | ||
- | lvextend -L30G / | ||
- | Extending logical volume nomDePartition to 30.00 GB | ||
- | Logical volume nomDePartition successfully resized | ||
- | </ | ||
- | * __cas 2__ : augmentation avec tout le disponible | ||
- | * Pour **xfs**< | ||
- | xfs_growfs / | ||
- | </ | ||
- | * Pour **ext4**< | ||
- | lvextend -l +100%FREE | ||
- | ... | ||
- | </ | ||
- | * Vérification du résultat< | ||
- | lvs | ||
- | LV VG | ||
- | nomDePartition vg0 -wi-ao | ||
- | lvol1 vg0 -wi-ao 512.00M | ||
- | nomDePartition nomDeVolumeGroup | ||
- | </ | ||