% Extension de volumes LVM

Ajout de disque virtuel dans une machine

`/dev/sdb`


```
# pvcreate /dev/sdb
  Physical volume "/dev/sdb" successfully created.
  
# vgextend debian-template-vg /dev/sdb
  Volume group "debian-template-vg" successfully extended

# lvextend -L +10G /dev/debian-template-vg/root
  Size of logical volume debian-template-vg/root changed from <6.81 GiB (1743 extents) to <16.81 GiB (4303 extents).
  Logical volume debian-template-vg/root successfully resized.

# resize2fs /dev/debian-template-vg/root
resize2fs 1.47.0 (5-Feb-2023)
Filesystem at /dev/debian-template-vg/root is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 3
The filesystem on /dev/debian-template-vg/root is now 4406272 (4k) blocks long.
```

# Sur nu

## Augmentation de la taille de home

```bash
$ sudo pvdisplay
...
  --- Physical volume ---
  PV Name               /dev/sdb
  VG Name               debian-template-vg
  PV Size               2.00 TiB / not usable 4.00 MiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              524287
  Free PE               519167
  Allocated PE          5120
  PV UUID               tweAEt-2Bs5-s2aL-mhsI-b2Mc-aDBW-HdMkBf
   
ladmyn@nu:~$ sudo lvdisplay
...   
  --- Logical volume ---
  LV Path                /dev/debian-template-vg/home
  LV Name                home
  VG Name                debian-template-vg
  LV UUID                hsjGv1-aTf8-Fffq-x372-qXCu-m7yY-aiz8vz
  LV Write Access        read/write
  LV Creation host, time debian-template, 2025-01-29 12:49:26 +0100
  LV Status              available
  # open                 1
  LV Size                <11.76 GiB
  Current LE             3010
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:2
```

### Ajout d'espace à partir du VG dans le LV

À partir des informations ci-dessus, on ajoute 500Go d'espace issus du VG `debian-template-vg` vers le LV `home` dont le chemin est `/dev/debian-template-vg/home`

```
ladmyn@nu:~$ sudo lvextend -L +500G /dev/debian-template-vg/home
  Size of logical volume debian-template-vg/home changed from <11.76 GiB (3010 extents) to <511.76 GiB (131010 extents).
  Logical volume debian-template-vg/home successfully resized.
```

Mise à jour de la taille de la partition:

```bash
ladmyn@nu:~$ sudo resize2fs /dev/debian-template-vg/home
resize2fs 1.47.0 (5-Feb-2023)
Filesystem at /dev/debian-template-vg/home is mounted on /home; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 64
The filesystem on /dev/debian-template-vg/home is now 134154240 (4k) blocks long.
```
