tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* SUMMARY: Disklabel disappeared
@ 1996-03-28 11:34 Henrik Johansson
  0 siblings, 0 replies; only message in thread
From: Henrik Johansson @ 1996-03-28 11:34 UTC (permalink / raw)
  To: tru64-unix-managers

Hi, my question was if it was possible to get the disklabel back, or somehow
reconstructure it if it disappeared, and the answer is yes, if you are using
UFS.

I include the answer I got from Harald Lundberg <hl@tekla.fi>:

------------------Included answer--------------------------------------

try this - it tries to find superblocks from disk data (it scans the
whole disk for superblocks, (it will not find the swap, but you can
probably have a swap partition 'in between' and can thus calculate
it's size and offset. It also works only for ufs filesystes - can't
help you with advfs....

--- clip --- (t.c)
#include <stdio.h>
char buff[65536];
char str[] = {0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 24, 0, 0, 0};

main(ac, av)
char *av[];
{
        int adr = 0;
        int last = 0;
        int fd = open(av[1], 0);
        if (fd < 0)
                perror(av[1]);
        while (read(fd, buff, 65536) > 0) {
                int i;
                for (i = 0; i < 65536; i+=512) {
                        if (memcmp(buff+i, str, 16) == 0)
                                if ((adr+i-last) == 8192)
                                        fprintf(stderr, "%d\n",
(adr+i-16384)/512);
                                else
                                        last = adr + i;
                }
                adr+=65536;
        }
}
--- clip ---

for me it gave:
# ./t /dev/rrz2c
-16
552960

which kind of matches my disklabel:
  a:   122880        0    4.2BSD     1024  8192    16   # (Cyl.    0 - 39)
  b:   430080   122880    unused     1024  8192         # (Cyl.   40 - 179)
  c:  4110480        0    unused     1024  8192         # (Cyl.    0 - 1338*)
  d:        0        0    unused        0     0         # (Cyl.    0 - -1)
  e:        0        0    unused        0     0         # (Cyl.    0 - -1)
  f:        0        0    unused        0     0         # (Cyl.    0 - -1)
  g:  9833472   552960    4.2BSD     1024  8192    16   # (Cyl.  180 - 3380)
  h:        0        0    unused        0     0         # (Cyl.    0 - -1)
#
the offset -16 is due to the disklabel being before the 'a' partition.

As you probably don't have overlapping partitions, you can calculate the
sizes accordingly.

You might need to run the fsck for the 'a' partition with the 'alternate
superblock' specified - i.e. fsck -b 32 /dev/....

Hope this helps...

--------------------End included answer---------------------------------


Thanks to all who responded so quickly to my question, you all saved me lots
of time (plus encouraged me to get my backup system up and running as quick as
possible :-)

Here follows the names of thos who helped me:

Harald Lundberg <hl@tekla.fi>
Alan Rollow <alan@nabeth.cxo.dec.com>
Alonso Numez <alonso@msiw42.msi.se>
Benoit Maillard <maillard@fgt.dec.com>
Knut Hellebo <Knut.Hellebo@nbo.hydro.com>




Sincerly



Henrik Johansson
Internet One

-- 
  -----=<->=-----=<|>=-----=<+>=-----=<|>=-----=<->=-----=<+>=-----=<|>=-----
 /   Henrik Johansson    mobil: 0706-26 15 45   tel (arb): 031-775 00 80    /
/   -=>Internet One<=-   email: hj@one.se       fax (arb): 031-775 00 85   /
-----=<->=-----=<|>=-----=<+>=-----=<|>=-----=<->=-----=<+>=-----=<|>=-----

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1996-03-28 11:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-03-28 11:34 SUMMARY: Disklabel disappeared Henrik Johansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox