Date: Tue, 23 Oct 2001 10:00:16 -0700 (PDT) From: David Kirchner <davidk@accretivetg.com> To: Oscar-Ivan Lepe-Aldama <oscar.lepe@acm.org> Cc: <questions@FreeBSD.ORG> Subject: Re: Disklabel lost Message-ID: <20011023093846.X85958-200000@localhost> In-Reply-To: <3BD518C9.5898BF24@acm.org>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --]
On Tue, 23 Oct 2001, Oscar-Ivan Lepe-Aldama wrote:
> To mount the root (bsd) partition of the damage disk I did a guess on
> its size and with sysinstall/label wrote a disklabel. (My guess was that
> the root partition was 100Megs large.) Then I succesfully mounted that
> guessed root partition, as I have said before. (Then I found out that my
> guess was wrong when I peek at root's mbox file, and change the
> disklabel to reflect the actula size of the root partition. Again, I
> have been able to succesfully mount this second guessed root partition.)
>
> But from here I have no ideas on how to complete the disklabel for the
> rest of the partitions. I know there are a couple more, one for swap and
> one for /usr. About the swap partiton I don't know nothing, neither its
> size nor where it starts. About the /usr partition I know its size but I
> don't know where it starts.
If you installed using the defaults, swap will be 2X your physical RAM. I
don't recall what the other partitions are sized at by default.
If you didn't delete your last few daily output mails, you may still have
the df output there, such as:
Disk status:
Filesystem 1K-blocks Used Avail Capacity Mounted on
/dev/wd0s2a 124015 26338 87756 23% /
/dev/wd0s2f 2480982 627548 1654956 27% /usr
/dev/wd0s2g 7103813 21826 6513682 0% /usr/local
/dev/wd0s2e 297663 1350 272500 0% /var
procfs 4 4 0 100% /proc
I have a program which could help you recover that particular message.
I've attached the C file here. Please note I am offering it without any
warranty whatsoever. :-) I'm certain there are better ways to do it than
byte-by-byte matching.
Its usage is as follows:
./search "string" file-or-device mask.%s
For example, in this case you could do:
./search "Disk status:" /dev/wd0s1c /root/df.%s
(I've lost the original e-mail, so I don't recall if this is IDE or SCSI.
Either way, you want to search partition c.)
It takes a long time to run, but it will notify you when it gets matches
so you can possibly abort it prematurely. In this example, it would save
the output in /root/df.0000001 and up. Btw, if you wanted to recover the
entire root mailbox, search for "From " (with the extra space)
[-- Attachment #2 --]
/*
* "greps" for a string, and writes out any matches (up to a NULL)
* useful for extrating scripts and html from otherwise unusable
* drives.
*
* future enhancements:
* regular expression matching
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
static char ident[] = "$Id: search.c,v 1.2 2001/08/24 16:35:41 davidk Exp $";
int
main (argc, argv)
int argc;
char *argv[];
{
char *search;
char *fname;
char *outputmask;
char ofname[4096];
int match = 0;
char match_s[8];
int fd;
int ofd;
char buf[2];
char *ptr;
long long loc = 0;
if (argc != 4) {
fprintf (stderr, "usage: search \"string\" file outputmask\n");
exit (1);
}
search = argv[1];
fname = argv[2];
outputmask = argv[3];
if (outputmask[0] == '\0' || !strstr (outputmask, "%s")) {
fprintf (stderr, "outputmask must contain one %%s\n");
exit (1);
}
fd = open (fname, O_RDONLY);
if (fd < 0) {
fprintf (stderr, "%s: %s\n", fname, strerror (errno));
exit (1);
}
ptr = search;
while ((read (fd, buf, 1)) > 0) {
if (buf[0] == *ptr) {
ptr++;
if (*ptr == '\0') {
/* we found a match */
printf ("match (%s)!\n", search);
match++;
sprintf (match_s, "%07d", match);
sprintf (ofname, outputmask, match_s);
printf ("writing to %s\n", ofname);
ofd = open (ofname, O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR);
if (ofd < 0) {
fprintf (stderr, "%s: %s\n", ofname, strerror (errno));
}
if ((write (ofd, search, strlen (search))) < 0) {
fprintf (stderr, "%s: %s\n", ofname, strerror (errno));
}
while (read (fd, buf, 1) > 0 && buf[0] != '\0') {
if ((write (ofd, buf, 1)) < 0) {
fprintf (stderr, "%s: %s\n", ofname, strerror (errno));
}
loc++;
}
close (ofd);
ptr = search;
}
} else {
ptr = search;
}
if (loc % 16384 == 0) {
if (loc % 1048576 == 0) {
fprintf (stderr, ".%ld", loc);
} else {
fputc ('.', stderr);
}
}
loc++;
}
}
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011023093846.X85958-200000>
