Subject: Re: Partition table on x86 trashed. Any ideas?
To: Gerald Heinig <>
From: Giles Lean <>
List: netbsd-users
Date: 09/09/2001 06:57:23
------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <>

> My question is: how do I resurrect my partition table?

I've not had to do that precisely, but I have had to locate
filesystems within a NetBSD partition which I did by looking for
blocks with FS_MAGIC at the right offset.

Perhaps you could work out a suitable partition table by working out
where the filesystems are?  For what it's worth, findsb.c is below.

Good luck,


------- =_aaaaaaaaaa0
Content-Type: text/plain; name="findsb.c"; charset="us-ascii"
Content-ID: <>

 * Find superblocks on a BSD FFS filesystem.

#include <sys/param.h>
#include <sys/types.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>

#include <fcntl.h>
#include <stdio.h>

 * If this is smaller than the filesystem block size expect
 * more false matches.
#define BLOCKSIZE (4 * 1024)

main(int argc, char *argv[])
	char            block[BLOCKSIZE];
	int             fd;
	struct fs      *filesys;
	int             n;
	int             blockno;

	blockno = 0;
	filesys = (struct fs *) block;

	if (argc != 2) {
		fprintf(stderr, "usage: findsb raw_device\n");

	if ((fd = open(argv[1], O_RDONLY)) < 0) {

	while ((n = read(fd, block, BLOCKSIZE)) == BLOCKSIZE) {
		if (filesys->fs_magic == FS_MAGIC)
			printf("%d\n", blockno * (BLOCKSIZE / 512));

------- =_aaaaaaaaaa0--