Ubuntu – How to recover data from an encrypted hard drive on a dead laptop

16.04data-recoveryencryptionhardware

My current laptop won't power on at all. It's not just the battery, pretty sure the motherboard is fried. (Assume it's irreparable.)

The hard drive on the laptop (SSD, in case that matters) was encrypted when I installed Ubuntu 16.04. Unfortunately for me, my external hard drive died about a month ago and I had yet to set up a new backup external when this laptop bit the dust. So at present I'm missing about a month of work.

How can I retrieve the data off of the dead laptop's encrypted hard drive and transfer it to a new laptop? (Assume the hard drive is intact and there are no problems there.)

Best Answer

I am assuming that you used the "Encrypt the new Ubuntu installation" or its manual equivalent; that is, your hard disk is encrypted by LUKS and in the encrypted container you have an LVM volume group.

Before starting, make sure that you have cryptsetup and lvm2 installed; if not, install them:

sudo apt-get install cryptsetup-bin lvm2
  1. Take the drive out and put it into a USB enclosure.

  2. Connect it to a working computer running Ubuntu or any other Debian derivative; you can even use a live DVD or USB flash drive for this. Say that the disk is seen by the system as /dev/sdb.

  3. Find out which partition on the disk is the LUKS container:

    for p in /dev/sdb*; do
      sudo cryptsetup isLuks $p && echo $p is a LUKS container
    done
    
  4. For example, suppose that you found out that /dev/sdb2 is a LUKS container. Open it:

    sudo crypsetup luksOpen /dev/sdb2 old-hard-disk
    
  5. LVM should automatically detect the logical volumes; see if it did so with

    sudo lvs -o full_name,size,seg_pe_ranges
    

    If not, you may have to trigger LVM recognition with sudo vgchange -aay.

  6. Now you have the logical volumes in /dev/mapper. Mount them onto some directories.