public inbox for dm-crypt@saout.de
 help / color / mirror / Atom feed
From: "Michael Kjörling" <michael@kjorling.se>
To: dm-crypt@saout.de
Subject: Re: [dm-crypt] Moving LUKS-LVM partition with KDE Partition Manager broke it
Date: Tue, 15 Oct 2019 08:01:20 +0000	[thread overview]
Message-ID: <3jtd39kfhz9vzkwvb3bnsbvc@localhost> (raw)
In-Reply-To: <CAAhQhiO0K-ueKOY0tH6UTcWoC_m-WhbUo8BfH_UX_GMhgE0qeg@mail.gmail.com>

On 15 Oct 2019 06:16 +0000, from hijackeel@gmail.com (Hijack Eel):
> However, things went wrong when I used KDE Partition Manager to move the
> shrunken LUKS partition to the right. After that, the partition's type
> showed up in partitionmanager and gparted as "unknown" instead of LUKS, and
> trying to run cryptsetup luksOpen returned that the partition "is not a
> valid LUKS device".
> 
> I did manage to recover the LUKS header from the freshly unallocated space
> between the Windows and LUKS partitions by using hexdump and dd. Decrypting
> the LUKS partition using the recovered header (i.e: sudo cryptsetup
> --readonly --header /path/to/recovered/header/file luksOpen /dev/partition
> <insert some name here>) seems to work in the sense that cryptsetup accepts
> my password, and the mapping shows up in /dev/mapper. However, lvdisplay
> and vgdisplay detect nothing, and mounting it fails.

So it sounds like the data, including LUKS metadata, is (at least
mostly) intact, and that you've now got a copy of the LUKS header and
know a corresponding passphrase. That's good; whatever you do, take
care to not do anything that would jeopordize that.

I would very strongly suggest making a full disk copy of what you
currently have, if at all possible, and then working with one of the
copies while strictly not touching the other; in case you make a
mistake at some point, that would allow for far easier recovery to at
least where you are now. (If you care about your data, a second
same-size HDD should be cheap insurance against mistakes, and you can
always use it for regular backups later.)

It's not entirely surprising if the partition offsets are wrong that
LVM would not recognize the contents of the LUKS container, since LVM
metadata would not be where it is expected to be relative to the
container start, even if the decryption itself yields useful
plaintext.

As for what to try to recover from this, I don't have a handy
step-by-step guide ready for you, but I would consider trying to
figure out the original partition offsets for the now-moved partition,
feeding those original offsets to losetup, and try to open the LUKS
container through that mapping. (This should be plenty doable without
touching the current, broken, partitioning.) If that works, then see
what lsblk as well as the LVM tools can tell you about the contents of
the container at that point.

It's certainly possible that all you'd need to do in the end is to
restore the original partition offsets and perform the resizing all
over again.

-- 
Michael Kjörling • https://michael.kjorling.se • michael@kjorling.se
  “The most dangerous thought that you can have as a creative person
              is to think you know what you’re doing.” (Bret Victor)

      reply	other threads:[~2019-10-15  8:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-15  6:16 [dm-crypt] Moving LUKS-LVM partition with KDE Partition Manager broke it Hijack Eel
2019-10-15  8:01 ` Michael Kjörling [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3jtd39kfhz9vzkwvb3bnsbvc@localhost \
    --to=michael@kjorling.se \
    --cc=dm-crypt@saout.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox