Skip navigation

LVM : mise en place

Mise en place de LVM

Lister les disques dur présent sur la machine.

root@debian~#: lsblk

sortie

NAME                            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                               8:0    0    8G  0 disk
├─sda1                            8:1    0    1G  0 part /boot
└─sda2                            8:2    0    7G  0 part
  ├─centos-root                 253:0    0  6.2G  0 lvm  /
  └─centos-swap                 253:1    0  820M  0 lvm  [SWAP]
sdb                               8:16   0    8G  0 disk 

Dans le cas présent c’est le disque sdb qui sera manipulé.

Créer un “Volume Group” à partir d’un disque ou d’une partition formatée.

root@debian~#: vgcreate lvm-volume_vg /dev/sdb

sortie

  Physical volume "/dev/sdb" successfully created.
  Volume group "lvm-volume_vg" successfully created

Créer un “Logical Volume” de 100Mo à partir d’un “Volume Group”.

root@debian~#: lvcreate -L100M -n lvm-volume_lg lvm-volume_vg

Alternativement, allouer 100% de l’espace disponible au “Logical Volume”.

root@debian~#: lvcreate -l 100%FREE -n lvm-volume_lg lvm-volume_vg

sortie

  Logical volume "lvm-volume_lg" created.

Affiche le “Logical Volume” spécifié en option.

root@debian~#: lvdisplay -v /dev/lvm-volume_vg/lvm-volume_lg
  --- Logical volume ---
  LV Path                /dev/lvm-volume_vg/lvm-volume_lg
  LV Name                lvm-volume_lg
  VG Name                lvm-volume_vg
  LV UUID                vqTvWz-N4uj-2Lxq-oMoW-QLAg-2sla-uE2AQQ
  LV Write Access        read/write
  LV Creation host, time lvm, 2018-03-15 08:19:23 -0400
  LV Status              available
  # open                 0
  LV Size                100.00 MiB
  Current LE             25
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:2

Formater le “Logical Volume” en ext4

root@debian~#: mkfs.ext4 /dev/lvm-volume_vg/lvm-volume_lg

sortie

mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
25688 inodes, 102400 blocks
5120 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=33685504
13 block groups
8192 blocks per group, 8192 fragments per group
1976 inodes per group
Superblock backups stored on blocks:
	8193, 24577, 40961, 57345, 73729

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

Créer le point de montage.

root@debian~#: mkdir /mnt/lvm-data

Monter le “Logical Volume”.

root@debian~#: mount /dev/lvm-volume_vg/lvm-volume_lg/mnt/lvm-data/

Vérification de la présence de ce LVM

Afficher les “Volume Group”.

root@debian~#: vgdisplay

sortie

[…]
--- Volume group ---
VG Name               lvm-volume_vg
System ID
Format                lvm2
Metadata Areas        1
Metadata Sequence No  2
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                1
Open LV               0
Max PV                0
Cur PV                1
Act PV                1
VG Size               <8.00 GiB
PE Size               4.00 MiB
Total PE              2047
Alloc PE / Size       25 / 100.00 MiB
Free  PE / Size       2022 / <7.90 GiB
VG UUID               PTaL0D-LEyS-tfBA-aVhW-Aeef-RwH6-76U7yl

Enfin la commande lsblk indique également que le LVM est bien présent.

root@debian~#: lsblk
NAME                            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                               8:0    0    8G  0 disk
├─sda1                            8:1    0    1G  0 part /boot
└─sda2                            8:2    0    7G  0 part
  ├─centos-root                 253:0    0  6.2G  0 lvm  /
  └─centos-swap                 253:1    0  820M  0 lvm  [SWAP]
sdb                               8:16   0    8G  0 disk
└─lvm--volume_vg-lvm--volume_lg 253:2    0  100M  0 lvm
sr0                              11:0    1 1024M  0 rom

by | March 15, 2018 | No Comments | Système | Tags : disque dur