Copia de Seguridad · 3 min read · Nov 05, 2025

Hacer Copia de Seguridad (Y Restaurar) Particiones LVM Con Instantáneas LVM - Página 2

3 Crear Una Instantánea LVM De /

Ahora es el momento de crear la instantánea del volumen /dev/server1/root. Llamaremos a la instantánea rootsnapshot:

lvcreate -L10G -s -n rootsnapshot /dev/server1/root

La salida de

lvdisplay

debe verse así:

server1:~# lvdisplay
— Logical volume —
LV Name /dev/server1/root
VG Name server1
LV UUID UK1rjH-LS3l-f7aO-240S-EwGw-0Uws-5ldhlW
LV Write Access read/write
LV snapshot status source of
/dev/server1/rootsnapshot [active]
LV Status available

LV Size 9.30 GB
Current LE 2382
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 254:0

— Logical volume —
LV Name /dev/server1/swap_1
VG Name server1
LV UUID 2PASi6-fQV4-I8sJ-J0yq-Y9lH-SJ32-F9jHaj
LV Write Access read/write
LV Status available

LV Size 464.00 MB
Current LE 116
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 254:1

— Logical volume —
LV Name /dev/server1/backups
VG Name server1
LV UUID sXq2Xe-y2CE-Ycko-rCoE-M5kl-E1vH-KQRoP6
LV Write Access read/write
LV Status available

LV Size 30.00 GB
Current LE 7680
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 254:2

— Logical volume —
LV Name /dev/server1/rootsnapshot
VG Name server1
LV UUID 9zR5X5-OhM5-xUI0-OolP-vLjG-pexO-nk36oz
LV Write Access read/write
LV snapshot status active destination for /dev/server1/root
LV Status available

LV Size 9.30 GB
Current LE 2382
COW-table size 10.00 GB
COW-table LE 2560
Allocated to snapshot 0.01%
Snapshot chunk size 8.00 KB
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 254:5

Queremos montar /dev/server1/rootsnapshot en /mnt/server1/rootsnapshot, así que primero tenemos que crear ese directorio:

mkdir -p /mnt/server1/rootsnapshot

Luego montamos nuestra instantánea:

mount /dev/server1/rootsnapshot /mnt/server1/rootsnapshot

Luego ejecutamos

ls -l /mnt/server1/rootsnapshot/

Esto debería mostrar todos los directorios y archivos que conocemos de nuestra partición /:

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

¡Así que nuestra instantánea ha sido creada con éxito!

Ahora podemos crear una copia de seguridad de la instantánea en la partición /backups usando nuestra solución de copia de seguridad preferida. Por ejemplo, si te gusta hacer una copia de seguridad basada en archivos, puedes hacerlo así:

tar -pczf /backups/root.tar.gz /mnt/server1/rootsnapshot

Y si prefieres hacer una copia de seguridad a nivel de bits (es decir, una imagen), puedes hacerlo así:

dd if=/dev/server1/rootsnapshot of=/backups/root.dd

server1:~# dd if=/dev/server1/rootsnapshot of=/backups/root.dd
19513344+0 records in
19513344+0 records out
9990832128 bytes (10 GB) copied, 320.059 seconds, 31.2 MB/s

También podrías usar ambos métodos para estar preparado para lo que pueda suceder con tu volumen /dev/server1/root. En este caso, deberías tener dos copias de seguridad después:

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

Después, desmontamos y eliminamos la instantánea para evitar que consuma recursos del sistema:

umount /mnt/server1/rootsnapshot
lvremove /dev/server1/rootsnapshot

Eso es todo, ¡acabas de hacer tu primera copia de seguridad desde una instantánea LVM!

Share: X/Twitter LinkedIn

Recibe nuevas publicaciones en tu bandeja de entrada.

No spam. Cancela la suscripción en cualquier momento.