This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
deb12:migrate [2025/07/13 11:03] – created Bernard Condrau | deb12:migrate [2025/07/13 15:11] (current) – Bernard Condrau | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Migrate data drives ====== | ====== Migrate data drives ====== | ||
+ | This guide shows how to migrate data drives from an old server to a new machine. This works when the old server is still accessible. My setup is 2 HDD -> RAID 1 -> LVM2 -> LUKS -> ext4 so it is very important to do all the steps in the correct sequence as outlined below. In my setup all data is mounted as /home. | ||
+ | |||
+ | ===== Old Server ===== | ||
+ | ==== File System ==== | ||
+ | - Unmount / | ||
+ | - You might need to force unmount. Alternatively, | ||
+ | |||
+ | update-initramfs -u | ||
===== LUKS ===== | ===== LUKS ===== | ||
sudo cryptsetup luksHeaderBackup / | sudo cryptsetup luksHeaderBackup / | ||
Line 5: | Line 13: | ||
sudo cryptsetup luksHeaderRestore /dev/sdb1 --header-backup-file / | sudo cryptsetup luksHeaderRestore /dev/sdb1 --header-backup-file / | ||
+ | https:// | ||
===== LVM2 ===== | ===== LVM2 ===== | ||
- | | + | |
+ | - Use the -a n argument of the vgchange command to mark the volume group as inactive, which prevents any further activity on the volume group. | ||
+ | - Use the vgexport command to export the volume group. This prevents it from being accessed by the system from which you are removing it. | ||
+ | - pvscan | ||
+ | - When the system is next shut down, you can unplug the disks that constitute the volume group and connect them to the new system. | ||
+ | - When the disks are plugged into the new system, use the vgimport command to import the volume group, making it accessible to the new system. | ||
+ | - Activate the volume group with the -a y argument of the vgchange command. | ||
+ | - Mount the file system to make it available for use. | ||
+ | |||
+ | https:// | ||
+ | |||
+ | - Unmount filesystem(s): | ||
+ | - Deactivate logical volume(s): lvchange -an / | ||
+ | - Deactivate volume group: vgchange -an NASRaid1 | ||
+ | - Export the volume group: vgexport NASRaid1 | ||
+ | - Add RAID Array to new system and boot up. Running pvscan lists the exported volume group(s). | ||
+ | - Import the volume group: vgimport NASRaid1 | ||
+ | - Activate the volume group: vgchange -ay NASRaid1 | ||
+ | - Activate the volume(s): lvchange -ay / | ||
+ | - Mount the filesystem(s): | ||
+ | |||
+ | https:// | ||
+ | |||
+ | ===== RAID ===== |