[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: recover partition table



On Sat, 26 Mar 2011 13:42:15 -0400 (EDT), Geronimo wrote:
> 
> I don't want to offend you, but all that you wrote I already
> found from google and friends. 
> 
> What I did not find is some info about partman logging.
> Searching debian MLs for partman has millions of hits,
> so its the same like no hits - can't read all that.
> 
> As partman is internal to d-i, where can I find some info
> about the numbers shown around partition informations?

Sorry.  I guess I didn't understand what you were asking for.
In answer to your question, probably nowhere.  But I can make
some educated guesses.  For example, here's an excerpt from my
/var/log/installer/partman file:

-----

.
.
.
/lib/partman/choose_partition/35crypto/choices: IN: PARTITIONS =dev=hda
parted_server: Read command: PARTITIONS
parted_server: command_partitions()
parted_server: Opening outfifo
parted_server: OUT: OK


parted_server: OUT: 1   32256-526417919 526385664       primary linux-swap
/dev/hda1


parted_server: OUT: 2   526417920-37523727359   36997309440     primary ext3
/dev/hda2


parted_server: OUT: 3   37523727360-39999536639 2475809280      primary ext3
/dev/hda3


parted_server: Partitions printed

.
.
.

-----

The first number after "OUT" is probably the partition number.
Next is two numbers separated by a hyphen.  I'm guessing that that
is the starting and ending sector numbers.  Then comes a third
number.  I'm guessing that that is the total number of sectors
in the partition.  Next comes the partition type (primary) and
the type of file system in the partition (ext3).  Now if my
guesses are correct, then the ending sector number minus the
starting sector number plus one should equal the number of sectors
in the partition.  Let's see.  Hmm.  Yes, the math holds up in
all the above examples.  Let's double check that with the current
output of "parted /dev/sda unit s print free".  Hmm.  No, these
are not sector numbers, these are byte offsets.  Converting them
to sector numbers gives

1  63-1028159 1028097 primary linux-swap
2  1028160-73288529 72260370 primary ext3
3  73285530-78124094 4835565 primary ext3

And this agrees with the output of "parted /dev/sda unit s print free".
(To convert the starting byte offset to the starting sector number,
simply divide by 512.  The same procedure works to convert the number
of bytes to the number of sectors: simply divide by 512.  To convert
an ending byte offset to an ending sector number, the formula is a
little more complicated: add 1, divide by 512, then subtract 1.)

The corresponding commands to create these partitions would be:

parted /dev/sda unit s mkpart primary linux-swap 63 1028159
parted /dev/sda unit s mkpart primary ext3 1028160 73288529
parted /dev/sda unit s mkpart primary ext3 73285530 78124094

It's a "seat of the pants" kind of thing.  You won't likely find any
official documentation on it.

Hmm.  I just discovered a "rescue" command in parted.  It's
description is "rescue a lost partition".  The corresponding syntax
for "rescue" is

parted /dev/sda unit s rescue 63 1028159
parted /dev/sda unit s rescue 1028160 73288529
parted /dev/sda unit s rescue 73285530 78124094

I would think "rescue" would be safer to use than "mkpart".
Obviously if you're going to rescue a partition, you wouldn't
want any blocks of binary zeros written to the beginning, now
would you?  Of course, you only want to "rescue" partitions
that are not already defined.  And rescuing a partition may
change the numbers of existing partitions, so watch out for
that.

-- 
  .''`.     Stephen Powell    
 : :'  :
 `. `'`
   `-


Reply to: