3

I have two external hard discs on an OpenSUSE 13.1 system.

On one I have created a partition structure:

  1. An encrypted LVM partition (LUKS)
  2. Several volumes (10) on this LVM partition, some formatted with xfs, some with ext4.
sdf                              8:80   0   5,5T  0 disk  
└─sdf1                           8:81   0   5,5T  0 part  
  └─extern-2-crypt             253:5    0   5,5T  0 crypt 
    ├─extern--2-nelson--home   253:10   0     8G  0 lvm   /extern/nelson/home
    ├─extern--2-lucien--boot   253:11   0   300M  0 lvm   /extern/lucien/boot
    ├─extern--2-nelson--root   253:12   0  11,5G  0 lvm   /extern/nelson/root
    ├─extern--2-nelson--space  253:13   0  90,1G  0 lvm   /extern/nelson/space
    ├─extern--2-lucien--backup 253:14   0   400G  0 lvm   /extern/lucien/backup
    ├─extern--2-lucien--home   253:15   0    20G  0 lvm   /extern/lucien/home
    ├─extern--2-lucien--raid   253:16   0   3,5T  0 lvm   /extern/lucien/raid
    ├─extern--2-lucien--root   253:17   0   8,5G  0 lvm   /extern/lucien/root
    └─extern--2-lucien--space  253:18   0    30G  0 lvm   /extern/lucien/space

How can I replicate this structure easily including the LVM config from one disc to the other (with only one disc running at the same time)?

I know of sgdisk (8) and parted (mentioned in How to copy the partition layout of a whole disk using standard tools), but that covers only the partition, not the LUKS information and certainly not the LVM config.

  • Wait, what? "with only one disk running at the same time"? You want to copy all partitions, lvm config, and the data on each volume, from one disk to another, with only one disk present at any given time? – phemmer Oct 16 '14 at 01:43
  • @Patrick: "How can I replicate this structure easily" - I want to replicate the structure, not the data in the volumes. At the end of this step I want to have empty volumes/partitions. – Martin Schröder Oct 16 '14 at 11:20

1 Answers1

1

ReaR (Relax-and-Recover) is a collection of shell scripts that can recreate the lvm structures. It does using either vgcfgbackup/vgcfgrestore backup restore native tools or lvm create.

It does not yet support recreating lvm configurations on thin pools.

For luks, it prompts for the passphrase and recreates the container.

It proclaims itself as "the leading Open Source disaster recovery and system migration solution" and appears to be backed by RedHat

  • That's nice, but seems to be centered solely on bare metal recovery (which is o.k., but not what I need). – Martin Schröder May 27 '21 at 17:57
  • 1
    ReaR saves the layout and creates a script based on the saved file. I think the script/the saved layout could be easily adapted to target the desired new disk. To run the resulting script you wouldn't need to boot into the ReaR recovery environment. – Costin Gușă May 27 '21 at 18:51
  • ultimately if running the script on host is not possible, you could get around by running the recovery environment inside a small kvm guest with the target disk attached to the guest virtual machine and run the disk layout recreation phase from there – Costin Gușă May 27 '21 at 18:54
  • 1
    see also http://www.it3.be/2016/06/08/rear-diskrestore/ – Costin Gușă May 27 '21 at 19:10