Joining two halves together

No replies
nadebula.1984
Offline
Joined: 05/01/2018

Two of my workstations, named Foo and Bar, both have an SSD used for /boot and /, and an HDD used for /home and swap. Both computers used full disk encryption (FDE) and ran same GNU/Linux distribution, too.

Some time before, Foo's SSD and Bar's HDD failed, so I installed Foo's HDD and Bar's SSD (still working) on a third workstation, named Baz, and tried to figure out how to put the two disks together without re-installing the operating system. (If I managed to make the system bootable, I no longer needed to migrate the data.)

Naturally, I used a Live media and decrypted both LUKS. Then I used vgscan and lvscan as well as blkid (all with sudo) to look up the UUIDs and VG/LV names. I mounted the logical volume for / and edited crypttab and fstab under /etc directory.

However, this is insufficient to make the system usable, because cryptsetup still tried to find the LUKS on Bar's HDD. The next step was to update the initrd.img on the /boot partition. Therefore I have to decrypt both LUKS, mount / and /boot, and chroot to the (mounted) / directory.

Fortunately, the Rescue Mode for Debian Installer made all these easier. I Booted into Debian Installer and selected Rescue Mode. Then I followed the instructions to decrypt both LUKS, and chose the logical volume on Foo's SSD which was used as / and mounted it. The Installer asked me whether to mount the /boot partition. I accepted it and /boot was mounted automatically.

Then I could launch a terminal in the chroot'ed directory with root privilege. I simply run "update-initramfs -u" as root to rebuild the initrd.img file. When finished, I chose to reboot the system, and everything was fine. The personal data and configuration files in Bar's HDD were intact. So I managed to minimize the effort and saved several hours' work.

The tricks include modifying /etc/crypttab and /etc/fstab, and subsequently chroot'ing and rebuilding initramfs, with / and /boot mounted.