From owner-freebsd-hackers Wed Apr 19 22:43:38 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from rover.village.org (rover.village.org [204.144.255.49]) by hub.freebsd.org (Postfix) with ESMTP id CA6E637BD90 for ; Wed, 19 Apr 2000 22:43:31 -0700 (PDT) (envelope-from imp@billy-club.village.org) Received: from billy-club.village.org (billy-club.village.org [10.0.0.3]) by rover.village.org (8.9.3/8.9.3) with ESMTP id XAA64099; Wed, 19 Apr 2000 23:43:30 -0600 (MDT) (envelope-from imp@billy-club.village.org) Received: from billy-club.village.org (localhost.village.org [127.0.0.1]) by billy-club.village.org (8.9.3/8.8.3) with ESMTP id XAA11246; Wed, 19 Apr 2000 23:42:34 -0600 (MDT) Message-Id: <200004200542.XAA11246@billy-club.village.org> To: "J.D. Falk" Subject: Re: Corrupted disk label and related issues (fwd) Cc: freebsd-hackers@FreeBSD.ORG In-reply-to: Your message of "Wed, 19 Apr 2000 21:48:39 PDT." <20000419214839.B13391@mail-abuse.org> References: <20000419214839.B13391@mail-abuse.org> Date: Wed, 19 Apr 2000 23:42:34 -0600 From: Warner Losh Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In message <20000419214839.B13391@mail-abuse.org> "J.D. Falk" writes: : I sent this to freebsd-questions yesterday, and didn't get any : responses...looks like Andrew had a similar situation about a : month ago, and found a solution which I'm trying to adapt to : my own problem. Thing is, I can't even get to the individual : partitions like he did -- I keep getting "Device not configured" : and the like. Any advice? Well, you might be able to use the following program, supplied on an as is basis, to recover your disklabel. I wrote it when I accidentally overwrote the first 32k of my drive. Good thing only the disklabel and fdisk partition happened to be there :-(. I've not verified this program recently, so I have no clue if it will work for you. Oh, I dumped the disk to tape with dd before messing with it. Backup any critical data before you attempt to use this program (although it doesn't actually try to write anything you never know). You are definitely on your own here and anything bad this program does is not my fault, so don't whine to me if you ruin your already busted disk with it. Disclaimer, stolen from a darkendeavors promo spot: use only as directed. Side effects may include incapacitation from nausea and incessant hiccups, sporadic nostril insect infestation, terminal Tarzanian Foot Fungus, excessively elongated ear lobes, contagious reptilian laughter, digit loss, hemorrhagic episodes, full frontal nudity, and an uncontrollable passion for DOS batch files. Pregnant women should not skydive while listening. Read instructions at the website: darkendeavors.com. Warner #include #include #include #include #include #include #include #include void usage() { errx(1, "reclab fn"); } ssize_t read_good(int fd, void *addr, size_t sz) { ssize_t rv; rv = read(fd, addr, sz); if (rv < 0) err(1, "read_good"); return rv; } int search(int fd) { char buf[SBSIZE]; struct fs *fs = (struct fs *) buf; off_t i = 0; char ch = 'a'; while (read_good(fd, (void *) &buf, SBSIZE) == SBSIZE) { if (i % 2048 == 0) { printf("%qd MB\r", i/2048); fflush(stdout); } i++; lseek(fd, i * 512, SEEK_SET); if (fs->fs_magic != FS_MAGIC) continue; printf("%c: %d %qd 4.2BSD 0 0 0 # %s %d\n", ch, fs->fs_size * 2, i - 1 - 16, fs->fs_fsmnt, fs->fs_sblkno); ch++; if (ch == 'b') ch = 'd'; i += 2 * fs->fs_size - 1; lseek(fd, i * 512, SEEK_SET); } return (1); } int main(int argc, char **argv) { int fd; if (argc != 2) usage(); fd = open(argv[1], O_RDONLY); if (fd < 0) err(1, "open"); search(fd); close(fd); return 0; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message