All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ma Begaj <derliebegott@gmail.com>
To: dm-crypt@saout.de
Subject: Re: [dm-crypt] WD20EARS (4KB sector size) lost Luks header after reboot
Date: Thu, 16 Sep 2010 09:30:34 +0200	[thread overview]
Message-ID: <AANLkTi=7qptpPdwxxy=bgLJUQ3oMFFfxsPbqXALVUwOY@mail.gmail.com> (raw)
In-Reply-To: <20100915140913.GA22205@tansi.org>

2010/9/15 Arno Wagner <arno@wagner.name>:
> On Wed, Sep 15, 2010 at 01:02:25AM +0200, Ma Begaj wrote:
>> >> > This confirms that you did create the LUKS container at the
>> >> > right place, namely the LUKS header is at 64 x 512 B offset.
>> >>
>> >> 64x512 =32768
>> >> 32768 ?!= ?32256
>> >>
>> >> 512 bytes is partition table? should it be 32780?
>> >> I am probably missing something.
>> >
>> > No, you see what I missed. Your LUKS sector is at 63 sectors
>> > offset, not 64. However the partition starts at 64 and therefore
>> > the LUKS sector is not at its start.
>> >
>> > I don't know what went wrong here, but partitions 1-4 are special in
>> > that you can change them without any changes to the disk except
>> > in the first sector (for partitions >= a chained partition sector
>> > is writte to disk and that can kill a LUKS header and do other dmage).
>> >
>> > This smeans you can just delete the partiton with fdisk and create
>> > a new one, which will the start at sector 63 and should have
>> > your LUKS container in it. It will not be 4kB alingned, though.
>> > You should unplug and replug the disk after the partition creation.
>> >
>> > If this goes wrong, you still have the first 100MB as backup.
>>
>> ;-)). you are the man :).
>>
>> Working like a charm.  Deleted partition, created new starting at 63,
>> unplug/plug and luks partition is there. Thanks.
>>
>> I owe you at least a drink.
>
> You are welcome. Made my now day too ;-)
>
>> >> I don't know enough about partition tables and headers but it looks like
>> >> /dev/sdm1 is starting little bit too far and LUKS header stays before the
>> >> beginning of /dev/sdm1 (first partition).
>> >
>> > Indeed.
>> >
>> >> Only obvious reason (at lease for me) ?for this could be in this 4Kb
>> >> sector size.
>> >
>> > I think something has gone wrong when you did the alignment.
>> > Did you first create a not-4kB aligned partition and delete
>> > that again? If so the kernel would could remembered the partition
>> > but not that it got deleted and replaced (that needs a disk unplug).
>> > The reason is that the kernel sees partition changes only under some
>> > circumstances.
>>
>> Wow great assumption. I did exactly that. I was doing this remotely
>> (I was not able to unplug) and I forgot first time to set 4kB sector size.
>> I deleted partition (which already was luksFormated too) and recreated
>> it again but this time in 4kB format.
>
> Its easy to have the idea when you already messed that up yourself
> once ;-)

Well, I will not forget my experience either ;-).


>
>> Thanks a lot.
>>
>>
>> One more question because this is going pretty well now :) :
>>
>> Do you have an idea how could I recreate 4kB aligned partition
>> without deleting data from the disk? This is more facultative question,
>> because I know have my data.
>
> Difficult. You would need to shift the wole partitoon by
> one sector.
>
>> I thought about shrinking this partition, creating a second parition
>>  with 500gb to copy all data on this new partition, creating first paritition
>> in 4kB aligned format, copying all data back to this partition etc.
>
> That would work if you can shrink. At least my standard
> tool (Gnu parted) cannot do much with XFS.
>
> Best option would be if you could temporary store all the date
> somewhere else on the machine and repartition.
>
> The other option is to live with it, USB2 is very slow anyways,
> sector alignment may not even matter that much.

Well, I was "pre-thinking" (this word sounds nice ;-) ) and I bought a USB3
case for the HDD although my old server still only have USB2 ports.



>> That could maybe  even work if XFS would support shrinking. But it
>> does not as I can remember ;-). Could partition start be moved from
>> sector 63 to sector 64 and keep working filesystem (of couse at the same
>> time risking to destroy some of the data)? Or is this (if possible) would
>> destroy filesystem totally?
>
> Well, you could either use dd_rescue or write a program in C that
> moves the raw partition. From your fdisk -ul output, I conclude
> that there is no space left at the end of the disk, so you would
> have to move the start from sector 63 to sector 60. That
> should still work. Another option is to do away with partitioning
> and move the start from sector 63 to 0. Your filesystem is then
> on /dev/sdm.
>
> A possible commandline for dd_rescue would be something like this
> (moving the partition to the start of the disk)
>
>  dd_rescue -s 63 -S 0 -b /dev/sdm /dev/sdm
>
> Looks good, but better assume a 99% probability of complete data
> loss. Connection problems, read errors, all can kill the data.
> And this will take something like > 10 days for 2TB on USB2.

Good that I was not patient enough ;-). I backed up everything, deleted
and recreated partition again.


Thanks.

M.

p.s.: I should contact you for a drink when I visit which city? ;-)

      reply	other threads:[~2010-09-16  7:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-14 16:55 [dm-crypt] WD20EARS (4KB sector size) lost Luks header after reboot Ma Begaj
2010-09-14 17:33 ` Arno Wagner
2010-09-14 18:50   ` Ma Begaj
2010-09-14 20:32     ` Arno Wagner
2010-09-14 21:37       ` Ma Begaj
2010-09-14 22:13         ` Arno Wagner
2010-09-14 23:02           ` Ma Begaj
2010-09-15 10:29             ` Heinz Diehl
2010-09-15 11:21               ` Ma Begaj
2010-09-15 14:09             ` Arno Wagner
2010-09-16  7:30               ` Ma Begaj [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='AANLkTi=7qptpPdwxxy=bgLJUQ3oMFFfxsPbqXALVUwOY@mail.gmail.com' \
    --to=derliebegott@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.