Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 31 Oct 2004 12:42:10 +0100
From:      "Christoph P. Kukulies" <kuku@kukulies.org>
To:        hackers@freebsd.org
Subject:   finding alternate superblocks in ffs
Message-ID:  <20041031114210.GA46741@kukulies.org>

next in thread | raw e-mail | index | archive | help
Yesterday a major desaster happened: I stumbled across the power cable of my
Dell Inspiron notebook. The notebook fell to the floor. FreeBSD was running
at that time. Nothing seemed to got damaged, just a palm rest popped off.

Ah yes, the HD bay sprung off and in a moment of reflex I pushed it
in again in the running system. After that I tried to mount the
disk (which had not been mounted at that point of time). Anyway,
trying to

# fsck_ffs /dev/ad2s1e
** /dev/ad2s1e
Cannot find file system superblock

LOOK FOR ALTERNATE SUPERBLOCKS? [yn] y

32 is not a file system superblock
89808 is not a file system superblock
179584 is not a file system superblock
269360 is not a file system superblock
359136 is not a file system superblock
448912 is not a file system superblock
538688 is not a file system superblock
628464 is not a file system superblock
718240 is not a file system superblock
808016 is not a file system superblock

....
20813728 is not a file system superblock
20903504 is not a file system superblock
20993280 is not a file system superblock
21083056 is not a file system superblock
21172832 is not a file system superblock
21262608 is not a file system superblock
SEARCH FOR ALTERNATE SUPER-BLOCK FAILED. YOU MUST USE THE
-b OPTION TO FSCK TO SPECIFY THE LOCATION OF AN ALTERNATE
SUPER-BLOCK TO SUPPLY NEEDED INFORMATION; SEE fsck(8).
# 

Any idea what I can do now?

I wrote a little program that opens /dev/ad2s1e

#include <stdio.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <sys/time.h>
#include <sys/mount.h>
#include <sys/resource.h>
#include <sys/sysctl.h>
#include <sys/disklabel.h>

#include <ufs/ufs/dinode.h>
#include <ufs/ufs/ufsmount.h>
#include <ufs/ffs/fs.h>
 

#include <fcntl.h>
#include <ufs/ffs/fs.h>
main(){
  int fd;
  int k,i=0;
  int buf[512/(sizeof (int))];
  if((fd=open("/dev/ad2s1e",O_RDONLY)) < 0)
      printf("error opening device\n"),exit(2);
  printf("opened device\n");
  while(read(fd,buf,512)>0){
    for(k=0;k<(512/(sizeof (int)));k++){
       /*if(buf[k]==FS_UFS1_MAGIC)
           printf("UFS1 * %d\n",i),fflush(stdout); */
       if(buf[k]==FS_UFS2_MAGIC)
           printf("UFS2 * %d\n",i),fflush(stdout);
       i++;
     }
    }
}


I'm not sure whether my approach is correct. 
Anyway, the blocks I find with that method
aren't recognized as superblocks either.


--
Chris Christoph P. U. Kukulies kuku_at_kukulies.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041031114210.GA46741>