LVM Volumen auf den maximalen Speicherplatz vergrößern

Unter dem Logical Volume Manager, kurz LVM, erstellte dynamisch veränderbare Partitionen können sich über mehrere physikalische Laufwerke (PVs) erstrecken.Das Erweitern eines logischen Laufwerks (LV) auf den maximal zur Verfügung stehenden Speicherplatz kann online und damit ohne jegliche Unterbrechung des laufenden Betriebes erfolgen. Das zu vergrößernde Volume hat derzeit eine Kapazität von 1,73 TB wie in der folgenden Ausgabe zu sehen ist:
root@server:~# lvdisplay
--- Logical volume ---  LV Name /dev/tank0/lvol0
 VG Name tank0
 LV UUID NmxWAS-s18B-CbpD-1Pmv-kkOt-idfQ-mbf5QD
 LV Write Access read/write
 LV Status available
 # open 1
 LV Size 1.73 TB
 Current LE 454144
 Segments 1
 Allocation inherit
 Read ahead sectors auto - currently set to 256
 Block device 252:0  

Das dahinterliegende physikalische Volume hat eine Kapazität von nutzbaren 1,82 TB:
root@server:~# pvdisplay
 --- Physical volume ---
 PV Name /dev/sde
 VG Name tank0
 PV Size 1.82 TB / not usable 1.09 MB
 Allocatable yes
 PE Size (KByte) 4096
 Total PE 476932
 Free PE 22788
 Allocated PE 454144
 PV UUID 2gS24Z-kT2s-Cgv4-0XvE-PISG-dFP0-nLfSTV

Wichtig an dieser Ausgabe ist die Zeile "Free PE", die die Anzahl der noch verfügbaren physical extents abbildet. Den angegebenen Wert benötigt man für den Befehl, der die eigentliche Erweiterung des logical volumes startet: 
root@server:~# lvextend -l +22788 -A y /dev/tank0/lvol0
Nachdem dieses Kommando erfolgreiche durchgelaufen ist, ist die "Partitionsgröße" nun bereits 1,82 TB- allerdings sind nach wie vor lediglich 1,73 TB nutzbar. 

root@server:~# lvdisplay
 --- Logical volume ---
 LV Name /dev/tank0/lvol0
 VG Name tank0
 LV UUID NmxWAS-s18B-CbpD-1Pmv-kkOt-idfQ-mbf5QD
 LV Write Access read/write
 LV Status available
 # open 1
 LV Size 1.82 TB
 Current LE 476932
 Segments 1
 Allocation inherit
 Read ahead sectors auto - currently set to 256
 Block device 252:0 

Das physikalische Volumen ist nun zur Gänze gefüllt, d.h. es ist kein weiterer Speicherplatz verfügbar: 
root@server:~# pvdisplay
 --- Physical volume ---
 PV Name /dev/sde
 VG Name tank0
 PV Size 1.82 TB / not usable 1.09 MB
 Allocatable yes (but full)
 PE Size (KByte) 4096
 Total PE 476932
 Free PE 0
 Allocated PE 476932 PV UUID 2gS24Z-kT2s-Cgv4-0XvE-PISG-dFP0-nLfSTV 

Nun muss noch das Filesystem auf diesem Volume vergrößert werden. Im Falle eines ext2/3/4 Dateisystems kommt der Befehl resize2fs zum Einsatz:
root@server:~# resize2fs /dev/mapper/tank0-lvol0
 resize2fs 1.41.9 (22-Aug-2009)
 Filesystem at /dev/mapper/tank0-lvol0 is mounted on /mnt/tank0; on-line resizing required
 old desc_blocks = 111, new_desc_blocks = 117
 Performing an on-line resize of /dev/mapper/tank0-lvol0 to 488378368 (4k) blocks.
The filesystem on /dev/mapper/tank0-lvol0 is now 488378368 blocks long.

Und das war es dann auch. Nun sind 1,83 TB verfügbar und auch ohne jegliche Unterbrechung sofort nutzbar.