Debian und die Probleme damit...

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:
  1. Installation eines aktuellen Debian per CD - es empfiehlt sich, den möglichst identischen Stand zu installieren, den man nachher auch wiederherstellen/nutzen möchte.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. Das reicht aber noch nicht. Es muss noch eine passende initrd gebaut werden:
    update-initramfs
  7. Und zur Sicherheit nochmal dem Grub auf die Sprünge helfen:
    update-grub
  8. Achso, damit ping wieder als User funktioniert, müssen die Capabilities passen. Hierzu war noch ein
    dpkg-reconfigure iputils-ping
    nötig.
  9. 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:
  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. Now the laptop booted again. Time to adjust
    /etc/crypttab
    and
    /boot/grub/grub.cfg
    as well as
    /etc/fstab
    using the new UUIDs.
  6. That is still not enough. A new initrd needs to be built as well:
    update-initramfs
  7. Just to be sure, let's also help grub:
    update-grub
  8. 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
  9. Another reboot, and you're hopefully back to normal.