Debian: System reparieren nach Plattenausfall mit verschlüsselter Platte
Or how to recover from a disk failure with an encrypted disk - English version below.Nach einem Ausfall der Festplatte in meinem Laptop hatte ich zwar eine Ersatzplatte, aber die Herausforderung, dass die Platte mit Debian-Bordmitteln verschlüsselt war. Das stellte ein paar zusätzliche Hürden auf. Hier mein Vorgehen:
- Installation eines aktuellen Debian per CD - es empfiehlt sich, den möglichst identischen Stand zu installieren, den man nachher auch wiederherstellen/nutzen möchte.
- Einspielen des Backups des vorherigen Systems - das ist alles kein
Problem. Es hätte sich aber empfohlen, sowohl
/etc/crypttab
als auch/boot/grub/grub.cfg
nach der Neuinstallation zu sichern, das hätte einigen Ärger erspart. Auch/etc/fstab
zu sichern ist hilfreich. - Der nächste Reboot ging schief. Schade, das Einspielen des Backups hat
natürlich in der grub-Konfiguration die UUID der Platte überschrieben. Zum
Glück lässt sich die neue UUID per
ls -l
in der grub-Kommandozeile herausfinden. - Schade auch, dass das noch nicht gereicht hat. Die initrd landete jetzt
nach erfolglosem Versuch, etwas mit der Platte anzufangen, in einer Shell.
Es stellte sich heraus, dass die initrd aus dem Backup natürlich auch auf
die alten UUIDs der Partitionen eingestellt war. Aber hier konnte ein
Reboot mit der entsprechenden linux-Kommandozeile Abhilfe schaffen:
cryptopts=target=sda5_crypt,source=UUID=<neue_UUID_hierher>,rootdev,lvm=<hostname>--vg-root,key=none
Hier müssen natürlich gegebenenfalls auch das target und der lvm-Parameter noch etwas angepasst werden. - Der Rechner hat jetzt gebootet. Soweit, sogut. Also jetzt
/etc/crypttab
und/boot/grub/grub.cfg
mit den entsprechend neuen UUIDs angepasst, ebensp/etc/fstab
. Das ist doch schonmal der halbe Weg zum Erfolg. - Das reicht aber noch nicht. Es muss noch eine passende initrd gebaut
werden:
update-initramfs
- Und zur Sicherheit nochmal dem Grub auf die Sprünge helfen:
update-grub
- Achso, damit ping wieder als User funktioniert, müssen die Capabilities
passen. Hierzu war noch ein
dpkg-reconfigure iputils-ping
nötig. - Jetzt noch ein Reboot, und hoffentlich ist alles wieder, wie es mal vorher war...
English version:
After a failure of the harddisk in my laptop I had a replacement disk, but there still was the challenge that the harddisk was encrypted. That added some extra work. Here is what I did:
- Installation of a recent Debian via CD - you should install a version that is as close as possible to what you want to use again.
- Restoration of the backup of the previous system - not much of a problem.
It would have been a good idea however to save
/etc/crypttab
and/boot/grub/grub.cfg
after the reinstallation, same goes for/etc/fstab
. That would have spared some trouble. - The next reboot failed. Bad luck, the restoration of the backup overwrote
the UUID in grub's configuration with the one of the old disk. Grub's
commandline to the rescue:
ls -l
showed the new UUID. - Well, also bad luck that the initrd couldn't work with the new UUID
either. So another reboot, this time adding to the linux commandline
another parameter, helped to recover that as well:
cryptopts=target=sda5_crypt,source=UUID=<neue_UUID_hierher>,rootdev,lvm=<hostname>--vg-root,key=none
Of course you might have to change the target and lvm parameters accordingly. - Now the laptop booted again. Time to adjust
/etc/crypttab
and/boot/grub/grub.cfg
as well as/etc/fstab
using the new UUIDs. - That is still not enough. A new initrd needs to be built as well:
update-initramfs
- Just to be sure, let's also help grub:
update-grub
- OK, and as we also want to be able to ping again as normal user, let's
restore the capabilities for this as well:
dpkg-reconfigure iputils-ping
- Another reboot, and you're hopefully back to normal.