LVM Backup · 3 min read · Nov 05, 2025
LVM-Partitionen mit LVM-Snapshots sichern (und wiederherstellen) - Seite 2
3 Erstellen Sie einen LVM-Snapshot von /
Jetzt ist es an der Zeit, den Snapshot des /dev/server1/root-Volumes zu erstellen. Wir nennen den Snapshot rootsnapshot:
lvcreate -L10G -s -n rootsnapshot /dev/server1/rootDie Ausgabe von
lvdisplaysollte so aussehen:
server1:~# lvdisplay
— Logisches Volume —
LV-Name /dev/server1/root
VG-Name server1
LV-UUID UK1rjH-LS3l-f7aO-240S-EwGw-0Uws-5ldhlW
LV-Schreibzugriff lesen/schreiben
LV-Snapshot-Status Quelle von
/dev/server1/rootsnapshot [aktiv]
LV-Status verfügbar
LV-Größe 9.30 GB
Aktuelle LE 2382
Segmente 1
Zuweisung erben
Vorlese-Sektoren 0
Blockgerät 254:0
— Logisches Volume —
LV-Name /dev/server1/swap_1
VG-Name server1
LV-UUID 2PASi6-fQV4-I8sJ-J0yq-Y9lH-SJ32-F9jHaj
LV-Schreibzugriff lesen/schreiben
LV-Status verfügbar
LV-Größe 464.00 MB
Aktuelle LE 116
Segmente 1
Zuweisung erben
Vorlese-Sektoren 0
Blockgerät 254:1
— Logisches Volume —
LV-Name /dev/server1/backups
VG-Name server1
LV-UUID sXq2Xe-y2CE-Ycko-rCoE-M5kl-E1vH-KQRoP6
LV-Schreibzugriff lesen/schreiben
LV-Status verfügbar
LV-Größe 30.00 GB
Aktuelle LE 7680
Segmente 1
Zuweisung erben
Vorlese-Sektoren 0
Blockgerät 254:2
— Logisches Volume —
LV-Name /dev/server1/rootsnapshot
VG-Name server1
LV-UUID 9zR5X5-OhM5-xUI0-OolP-vLjG-pexO-nk36oz
LV-Schreibzugriff lesen/schreiben
LV-Snapshot-Status aktives Ziel für /dev/server1/root
LV-Status verfügbar
LV-Größe 9.30 GB
Aktuelle LE 2382
COW-Tabellengröße 10.00 GB
COW-Tabellen-LE 2560
Zugewiesen an Snapshot 0.01%
Snapshot-Chunk-Größe 8.00 KB
Segmente 1
Zuweisung erben
Vorlese-Sektoren 0
Blockgerät 254:5
Wir möchten /dev/server1/rootsnapshot auf /mnt/server1/rootsnapshot einhängen, also müssen wir zuerst dieses Verzeichnis erstellen:
mkdir -p /mnt/server1/rootsnapshotDann hängen wir unseren Snapshot ein:
mount /dev/server1/rootsnapshot /mnt/server1/rootsnapshotDann führen wir aus
ls -l /mnt/server1/rootsnapshot/Dies sollte alle Verzeichnisse und Dateien anzeigen, die wir von unserer /-Partition kennen:
server1:~# ls -l /mnt/server1/rootsnapshot/
total 132
drwxr-xr-x 2 root root 4096 2007-04-10 21:02 backups
drwxr-xr-x 2 root root 4096 2007-04-10 20:35 bin
drwxr-xr-x 2 root root 4096 2007-04-10 20:25 boot
lrwxrwxrwx 1 root root 11 2007-04-10 20:25 cdrom -> media/cdrom
drwxr-xr-x 13 root root 40960 2007-04-10 20:36 dev
drwxr-xr-x 57 root root 4096 2007-04-10 21:09 etc
drwxr-xr-x 3 root root 4096 2007-04-10 20:36 home
drwxr-xr-x 2 root root 4096 2007-04-10 20:26 initrd
lrwxrwxrwx 1 root root 28 2007-04-10 20:29 initrd.img -> boot/initrd.img-2.6.18-4-486
drwxr-xr-x 13 root root 4096 2007-04-10 20:34 lib
drwx—— 2 root root 16384 2007-04-10 20:25 lost+found
drwxr-xr-x 4 root root 4096 2007-04-10 20:25 media
drwxr-xr-x 2 root root 4096 2006-10-28 16:06 mnt
drwxr-xr-x 2 root root 4096 2007-04-10 20:26 opt
drwxr-xr-x 2 root root 4096 2006-10-28 16:06 proc
drwxr-xr-x 3 root root 4096 2007-04-10 20:42 root
drwxr-xr-x 2 root root 4096 2007-04-10 20:36 sbin
drwxr-xr-x 2 root root 4096 2007-03-07 23:56 selinux
drwxr-xr-x 2 root root 4096 2007-04-10 20:26 srv
drwxr-xr-x 2 root root 4096 2007-01-30 23:27 sys
drwxrwxrwt 2 root root 4096 2007-04-10 21:09 tmp
drwxr-xr-x 10 root root 4096 2007-04-10 20:26 usr
drwxr-xr-x 13 root root 4096 2007-04-10 20:26 var
lrwxrwxrwx 1 root root 25 2007-04-10 20:29 vmlinuz -> boot/vmlinuz-2.6.18-4-486
Unser Snapshot wurde also erfolgreich erstellt!
Jetzt können wir ein Backup des Snapshots auf der /backups-Partition mit unserer bevorzugten Backup-Lösung erstellen. Zum Beispiel, wenn Sie ein dateibasiertes Backup machen möchten, können Sie es so machen:
tar -pczf /backups/root.tar.gz /mnt/server1/rootsnapshotUnd wenn Sie ein bitweises Backup (d.h. ein Image) machen möchten, können Sie es so machen:
dd if=/dev/server1/rootsnapshot of=/backups/root.ddserver1:~# dd if=/dev/server1/rootsnapshot of=/backups/root.dd
19513344+0 records in
19513344+0 records out
9990832128 bytes (10 GB) kopiert, 320.059 Sekunden, 31.2 MB/s
Sie könnten auch beide Methoden verwenden, um auf alles vorbereitet zu sein, was mit Ihrem /dev/server1/root-Volume passieren könnte. In diesem Fall sollten Sie danach zwei Backups haben:
ls -l /backups/server1:~# ls -l /backups/
total 9947076
drwx—— 2 root root 16384 2007-04-10 21:04 lost+found
-rw-r–r– 1 root root 9990832128 2007-04-10 21:28 root.dd
-rw-r–r– 1 root root 184994590 2007-04-10 21:18 root.tar.gz
Anschließend hängen wir den Snapshot aus und entfernen ihn, um zu verhindern, dass er Systemressourcen verbraucht:
umount /mnt/server1/rootsnapshot
lvremove /dev/server1/rootsnapshot
Das war’s, Sie haben gerade Ihr erstes Backup von einem LVM-Snapshot erstellt.
Erhalte neue Beiträge in deinem Posteingang.
Kein Spam. Jederzeit abmelden.