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_at_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_at_tekla.fi>
Alan Rollow <alan_at_nabeth.cxo.dec.com>
Alonso Numez <alonso_at_msiw42.msi.se>
Benoit Maillard <maillard_at_fgt.dec.com>
Knut Hellebo <Knut.Hellebo_at_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_at_one.se fax (arb): 031-775 00 85 /
-----=<->=-----=<|>=-----=<+>=-----=<|>=-----=<->=-----=<+>=-----=<|>=-----
Received on Thu Mar 28 1996 - 13:15:39 NZST