it-wiki:linux:lvm_index:lvm-grundkonfiguration
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
it-wiki:linux:lvm_index:lvm-grundkonfiguration [2023/02/10 08:18] – [Erstellung von PVs] marko | it-wiki:linux:lvm_index:lvm-grundkonfiguration [2023/02/11 07:24] (aktuell) – [Entfernen eines LVs] marko | ||
---|---|---|---|
Zeile 2: | Zeile 2: | ||
Im folgenden Artikel wird die grundlegende Konfiguration von LVs erläutert. Das verwendete System ist ein Ubuntu Server 10.4 mit dem Kernel 2.6.32-24 und der LVM-Version 2.02.54(1) (2009-10-26). Es wird das Anlegen der Partitionen, | Im folgenden Artikel wird die grundlegende Konfiguration von LVs erläutert. Das verwendete System ist ein Ubuntu Server 10.4 mit dem Kernel 2.6.32-24 und der LVM-Version 2.02.54(1) (2009-10-26). Es wird das Anlegen der Partitionen, | ||
- | ===== Anlegen der Partitionen ===== | ||
---- | ---- | ||
+ | ===== Anlegen der Partitionen ===== | ||
Zu Beginn werden die Partitionen für die PVs angelegt. Folgende Dinge müssen dabei beachtet werden: | Zu Beginn werden die Partitionen für die PVs angelegt. Folgende Dinge müssen dabei beachtet werden: | ||
* Partition Alignment | * Partition Alignment | ||
Zeile 50: | Zeile 50: | ||
</ | </ | ||
- | ===== Erstellung von PVs ===== | ||
---- | ---- | ||
+ | ===== Erstellung von PVs ===== | ||
PVs beinhalten auch immer Metadaten für die Verwaltung der Volumes (s.a. Artikel zu [[it-wiki: | PVs beinhalten auch immer Metadaten für die Verwaltung der Volumes (s.a. Artikel zu [[it-wiki: | ||
''< | ''< | ||
Zeile 71: | Zeile 71: | ||
</ | </ | ||
- | ===== Anlegen einer VG ===== | ||
---- | ---- | ||
+ | ===== Anlegen einer VG ===== | ||
Die zuvor angelegten PVs werden nun zu einer VG zusammengefasst. | Die zuvor angelegten PVs werden nun zu einer VG zusammengefasst. | ||
+ | <code bash> | ||
+ | root@ubuntu: | ||
+ | Volume group " | ||
+ | </ | ||
+ | |||
+ | Der Befehl " | ||
+ | <code bash> | ||
+ | root@ubuntu: | ||
+ | --- Physical volume --- | ||
+ | PV Name / | ||
+ | VG Name vg00 | ||
+ | PV Size 2.00 GiB / not usable 3.00 MiB | ||
+ | Allocatable | ||
+ | PE Size 4.00 MiB | ||
+ | Total PE 511 | ||
+ | Free PE 511 | ||
+ | Allocated PE 0 | ||
+ | PV UUID | ||
+ | |||
+ | --- Physical volume --- | ||
+ | PV Name / | ||
+ | VG Name vg00 | ||
+ | PV Size 2.00 GiB / not usable 3.00 MiB | ||
+ | Allocatable | ||
+ | PE Size 4.00 MiB | ||
+ | Total PE 511 | ||
+ | Free PE 511 | ||
+ | Allocated PE 0 | ||
+ | PV UUID | ||
+ | </ | ||
+ | |||
+ | vgdisplay zeigt außerdem die Informationen zur VG an: | ||
+ | <code bash> | ||
+ | root@ubuntu: | ||
+ | --- Volume group --- | ||
+ | VG Name vg00 | ||
+ | System ID | ||
+ | Format | ||
+ | Metadata Areas 2 | ||
+ | Metadata Sequence No 1 | ||
+ | VG Access | ||
+ | VG Status | ||
+ | MAX LV 0 | ||
+ | Cur LV 0 | ||
+ | Open LV 0 | ||
+ | Max PV 0 | ||
+ | Cur PV 2 | ||
+ | Act PV 2 | ||
+ | VG Size 3.99 GiB | ||
+ | PE Size 4.00 MiB | ||
+ | Total PE 1022 | ||
+ | Alloc PE / Size 0 / 0 | ||
+ | Free PE / Size 1022 / 3.99 GiB | ||
+ | VG UUID | ||
+ | </ | ||
+ | |||
+ | Hier fällt auf, dass die PE Größe 4.00 MiB beträgt. Seit dem lvm2-Format ist die Anzahl der PEs nicht mehr beschränkt, | ||
+ | |||
+ | '' | ||
+ | |||
+ | hinzu. | ||
+ | |||
+ | ---- | ||
+ | ===== Anlegen von LVs ===== | ||
+ | Um die Größe des anzulegenden LVs zu spezifizieren gibt es verschiedene Möglichkeiten, | ||
+ | |||
+ | * Größenangabe in z.B. Gigabyte: | ||
+ | |||
+ | '' | ||
+ | |||
+ | * Angabe in Prozent des verfügbaren Speichers in der VG: | ||
+ | |||
+ | '' | ||
+ | |||
+ | * Angabe in Prozent des freien Speichers in der VG: | ||
+ | |||
+ | '' | ||
+ | |||
+ | Wir führen das begonnene Beispiel so weiter, dass wir die VG in zwei gleich große LV unterteilen: | ||
+ | <code bash> | ||
+ | root@ubuntu: | ||
+ | Logical volume " | ||
+ | root@ubuntu: | ||
+ | Logical volume " | ||
+ | </ | ||
+ | |||
+ | Nun kann der Status der Logical Volumes begutachtet werden: | ||
+ | <code bash> | ||
+ | root@ubuntu: | ||
+ | --- Logical volume --- | ||
+ | LV Name / | ||
+ | VG Name vg00 | ||
+ | LV UUID S1btrq-zQZQ-h9oU-2VE6-UNoT-hkqB-Fpv7pG | ||
+ | LV Write Access | ||
+ | LV Status | ||
+ | # open 0 | ||
+ | LV Size 2.00 GiB | ||
+ | Current LE 511 | ||
+ | Segments | ||
+ | Allocation | ||
+ | Read ahead sectors | ||
+ | - currently set to 256 | ||
+ | Block device | ||
+ | |||
+ | --- Logical volume --- | ||
+ | LV Name / | ||
+ | VG Name vg00 | ||
+ | LV UUID Syaml9-d1Ax-RYTs-tSZy-vEyq-yzqW-VoOddZ | ||
+ | LV Write Access | ||
+ | LV Status | ||
+ | # open 0 | ||
+ | LV Size 2.00 GiB | ||
+ | Current LE 511 | ||
+ | Segments | ||
+ | Allocation | ||
+ | Read ahead sectors | ||
+ | - currently set to 256 | ||
+ | Block device | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | ===== Anlegen eines Dateisystems | ||
+ | Nun können die LVs mit einem Dateisystem formatiert und anschließend gemountet werden: | ||
+ | <code bash> | ||
+ | mkfs.ext4 / | ||
+ | mkdir data | ||
+ | mount / | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | ===== Entfernen eines LVs ===== | ||
+ | Soll ein LV wieder entfernt werden, so wird dies über das lvremove Kommando durchgeführt: | ||
+ | <code bash> | ||
+ | root@ubuntu: | ||
+ | Do you really want to remove active logical volume data_snap? [y/n]: y | ||
+ | Logical volume " | ||
+ | </ | ||
+ | |||
+ | Das LV data_snap scheint nun nicht mehr als LV auf. Als PV befindet es sich die darunterliegende Partition aber immer noch: | ||
+ | <code bash> | ||
+ | --- Physical volume --- | ||
+ | PV Name / | ||
+ | VG Name | ||
+ | PV Size 2.00 GiB / not usable 3.00 MiB | ||
+ | Allocatable | ||
+ | PE Size 4.00 MiB | ||
+ | Total PE 511 | ||
+ | Free PE | ||
+ | Allocated PE 0 | ||
+ | PV UUID | ||
+ | </ | ||
+ | |||
+ | Soll die Partition komplett freigegeben werden, so muss das PV zuerst aus der VG genommen werden: | ||
+ | <code bash> | ||
+ | root@ubuntu: | ||
+ | Removed "/ | ||
+ | root@ubuntu: | ||
+ | "/ | ||
+ | --- NEW Physical volume --- | ||
+ | PV Name / | ||
+ | VG Name | ||
+ | PV Size 2.00 GiB | ||
+ | | ||
+ | PE Size 0 | ||
+ | Total PE 0 | ||
+ | Free PE 0 | ||
+ | | ||
+ | PV UUID | ||
+ | </ | ||
+ | |||
+ | Nun kann auch das PV komplett gelöscht werden, um z.B. die Festplatte neu zu formatieren: | ||
+ | <code bash> | ||
+ | root@ubuntu: | ||
+ | Labels on physical volume "/ | ||
+ | </ | ||
+ | |||
+ | \\ | ||
+ | \\ | ||
+ | \\ | ||
+ | --- // |
it-wiki/linux/lvm_index/lvm-grundkonfiguration.1676017114.txt.gz · Zuletzt geändert: von marko