[dm-crypt] Luks resizing error

Arno Wagner arno at wagner.name
Fri Sep 6 05:07:59 CEST 2013

On the risk of repeating myself: "The backup is really non-optional 
here, as a lot can go wrong, resulting in partial or complete data 

So, lets see whether we can figire out what you did...

On Fri, Sep 06, 2013 at 03:10:27AM +0100, Ditis Nietmijnnaam wrote:
> Hello,
> I tried to shrink a luks partition using these instructions: http://unix.stackexchange.com/questions/41091/how-can-i-shrink-a-luks-partition-what-does-cryptsetup-resize-do
> but it failed.

I have left an agnry comment there. Giving these instructions
without clear warnings is downright malicious. 
> in the answer on that page it gives the following commands:
> # parted /dev/sda2
> ...
> (parted) rm 2
> (parted) mkpart Everything 250035s 124844158s

That is about the most risky thing you can do.
> this last command failed with me:
> Instead of a name (Everything) the mkpart command wanted (extended/primary).
> So I made the partition the way I remembered them to be.
> gparted now shows :  http://i998.photobucket.com/albums/af104/ditisnietmijnnaam/gparted_zps85ed6ad9.png
> when I rebooted, I got this error: alert /dev/mapper/vg-mint-root does not exist dropping to shell
> (I cant the remember the exact message and names, so it might be off a little)
> Using an ubuntu live usb I could get some following information.
> The luks authentication seems to be working:
> ~$ sudo cryptsetup luksOpen /dev/sda5 partName
> Enter passphrase for /dev/sda5: 
> ~$ sudo cryptsetup status partName
> /dev/mapper/partName is active.
>   type:    LUKS1
>   cipher:  aes-xts-plain64
>   keysize: 512 bits
>   device:  /dev/sda5
>   offset:  4096 sectors
>   size:    1743302656 sectors
>   mode:    read/write
> There was a (fully updated) linux mint 15 installation on that partition.
> Can any of it be recovered?

Well, at least you did not damage the LUKS header and key-slots.
You can now do an ordinary data-recovery job for a botched partition
resize on /dev/mapper/partName. Or rather never, ever, ever work on
your only copy. Make a binary copy of /dev/mapper/partName (better:
the whole disk) and work on that. You have ignored the advice to never 
do this without backup once already, if you really want to lose 
everything, just ignore it again.
The revoery job on /dev/mapper/partName has nothing to do with
cryptsetup though, try web-resource for recovering things from
a damaged Linux filesystem.

> Thanks in advance and best regards,
> dinmn
> P.S. some extra info:
> sda3 in the picture did not exist; the mint partition covered the entire hard drive.
> I wanted to shrink it to install windows beside my main OS.
> sda3 now temporarily has ubunt 13.04 installed on it.

And stop writing things to this disk NOW. If you messed up 
the filesystem resize, that Ubuntu 13.04 is now where
your data used to be.

Arno Wagner,     Dr. sc. techn., Dipl. Inform.,    Email: arno at wagner.name
GnuPG: ID: CB5D9718  FP: 12D6 C03B 1B30 33BB 13CF  B774 E35C 5FA1 CB5D 9718
There are two ways of constructing a software design: One way is to make it
so simple that there are obviously no deficiencies, and the other way is to
make it so complicated that there are no obvious deficiencies. The first
method is far more difficult.  --Tony Hoare

More information about the dm-crypt mailing list