LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-11-2010, 09:28 AM   #1
kaulalla
LQ Newbie
 
Registered: Jan 2010
Posts: 3

Rep: Reputation: 0
Mounting LUKS with the help of a cloned drive?


I have cloned my LUKS-encrypted system drive to a bigger one, using dd. The big drive was working fine, until a possible power-failure caused it not to be mountable anymore:

Code:
root@xxx:/home/xxx# cryptsetup luksOpen /dev/sdc1 cheer
Enter LUKS passphrase:
Enter LUKS passphrase:
Enter LUKS passphrase:
Command failed: No key available with this passphrase.
No matter what i do, always results in the same "No key..." output. (Followed a few tutorials already, loaded modules, etc etc).

The original disk (which I'm still using, and this was the source of cloning):

Code:
Disk /dev/sda: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0001b495

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1       38882   312319633+  83  Linux
/dev/sda2           38883       38913      249007+   5  Extended
/dev/sda5           38883       38913      248976   83  Linux
The new (bigger drive):

Code:
Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0001b495

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *           1       38882   312319633+  83  Linux
/dev/sdc2           38883       38913      249007+   5  Extended
/dev/sdc3           38914      121601   664191360   83  Linux
/dev/sdc5           38883       38913      248976   83  Linux
Now here is what luksdump says about them:

Code:
LUKS header information for /dev/sda1

Version:        1
Cipher name:    aes
Cipher mode:    cbc-essiv:sha256
Hash spec:      sha1
Payload offset: 2056
MK bits:        256
MK digest:      21 a1 d6 b1 71 a1 99 90 1e 01 74 cd 25 84 16 c6 72 88 bb a7
MK salt:        ed f5 a0 8a 94 33 8d 77 65 28 14 5b da 21 4d 00
                f5 53 4c bf 19 5d 1a d5 21 6e b6 06 48 a6 e1 16
MK iterations:  10
UUID:           1b8386bd-a97e-45a3-9a68-d97969adc6c2

Key Slot 0: ENABLED
        Iterations:             252023
        Salt:                   e6 ab 6a f1 d2 6f 70 b5 96 5b 7d 71 3c 01 d4 de
                                cf 90 af ff 6b d7 4c 1d fa 34 7b 1e 7a 77 e3 42
        Key material offset:    8
        AF stripes:             4000
Key Slot 1: DISABLED
Key Slot 2: DISABLED
Key Slot 3: DISABLED
Key Slot 4: DISABLED
Key Slot 5: DISABLED
Key Slot 6: DISABLED
Key Slot 7: DISABLED
The other drive:
Code:
LUKS header information for /dev/sdc1

Version:        1
Cipher name:    aes
Cipher mode:    cbc-essiv:sha256
Hash spec:      sha1
Payload offset: 2056
MK bits:        256
MK digest:      21 a1 d6 b1 71 a1 99 90 1e 01 74 cd 25 84 16 c6 72 88 bb a7
MK salt:        ed f5 a0 8a 94 33 8d 77 65 28 14 5b da 21 4d 00
                f5 53 4c bf 19 5d 1a d5 21 6e b6 06 48 a6 e1 16
MK iterations:  10
UUID:           1b8386bd-a97e-45a3-9a68-d97969adc6c2

Key Slot 0: ENABLED
        Iterations:             252023
        Salt:                   e6 ab 6a f1 d2 6f 70 b5 96 5b 7d 71 3c 01 d4 de
                                cf 90 af ff 6b d7 4c 1d fa 34 7b 1e 7a 77 e3 42
        Key material offset:    8
        AF stripes:             4000
Key Slot 1: DISABLED
Key Slot 2: DISABLED
Key Slot 3: DISABLED
Key Slot 4: DISABLED
Key Slot 5: DISABLED
Key Slot 6: DISABLED
Key Slot 7: DISABLED
Question: Is there any possible way of mounting sdc1 with the help of sda1? At the moment sdc1 is sitting in an external case and the rest of the disk (truecrypt volume) working just fine. I just need the bugger be mounted for half an hour to backup my stuff from it.
 
Old 01-11-2010, 11:30 PM   #2
Elemecca
Member
 
Registered: Nov 2008
Location: San Francisco, CA
Distribution: Gentoo, CentOS
Posts: 71

Rep: Reputation: 22
As far as I can tell the LUKS tools don't directly support it. However, it is possible to manually clone the header from the old volume to the new one. Assuming the problem is header corruption (that's what it sounds like), that should fix it.

A LUKS volume starts with a 592-byte volume header, then an arbitrary-sized key material section, then the bulk data section (payload volume). The payload offset field of the volume header tells us what sector the bulk data section starts at. According to the luksDump output in your post, the payload offset is 2056 sectors. Thus, we need to clone the first 2056 sectors (the offset is zero-based so sector 2056 is the 2057th sector).

The first dd command below will back up the new volume's header to '/root/luks-backup.bin', just in case. The second will clone the header from the old volume to the new. These need to be run as root, of course.
Code:
dd if=/dev/sdc1 of=/root/luks-backup.bin bs=512 count=2056
dd if=/dev/sda1 of=/dev/sdc1 bs=512 count=2056
Once you've cloned the header you should be able to mount the new volume as normal.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't boot cloned drive richabblett Linux - Laptop and Netbook 1 06-28-2009 02:43 PM
Mounting LUKS encrypted drive from a failed pc: LVM2 error klearview Linux - Software 1 10-31-2008 04:34 AM
Any way to mount partitions of cloned drive without reboot? moklett Linux - Hardware 3 11-27-2007 06:12 PM
puzzling: NIC goes away if I use a cloned hard drive BrianK Linux - Hardware 5 03-12-2007 03:18 AM
Cloned drive yields Kernel Panic erolk7 Linux - Newbie 3 12-13-2006 06:39 PM


All times are GMT -5. The time now is 02:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration