Skip to contentSkip to conversation

Luks resizing error

dm-crypt Ditis Nietmijnnaam 2 participants 2 messages Sep 6, 2013

lore
Share & tools
lore
#0 lore raw

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.

in the answer on that page it gives the following commands:

# parted /dev/sda2
...
(parted) rm 2
(parted) mkpart Everything 250035s 124844158s

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?

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.

#1 lore raw

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 loss."

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

Quoted 6 lines · Ditis Nietmijnnaam

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.

Quoted 5 lines

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.

Quoted 29 lines

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

Quoted 2 lines

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.

Quoted 7 lines

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

Signature · 7 lines
Arno Wagner,     Dr. sc. techn., Dipl. Inform.,    Email: [email protected]
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