From owner-freebsd-questions Thu Jun 7 17:33:54 2001 Delivered-To: freebsd-questions@freebsd.org Received: from salmon.maths.tcd.ie (salmon.maths.tcd.ie [134.226.81.11]) by hub.freebsd.org (Postfix) with SMTP id 490A837B403 for ; Thu, 7 Jun 2001 17:33:50 -0700 (PDT) (envelope-from iedowse@maths.tcd.ie) Received: from walton.maths.tcd.ie by salmon.maths.tcd.ie with SMTP id ; 8 Jun 2001 01:33:49 +0100 (BST) To: Rick@DataRecoveryLink.Com Cc: questions@freebsd.org Subject: Re: Superblock question In-Reply-To: Your message of "Thu, 07 Jun 2001 14:55:13 MDT." <000201c0ef94$27d8ece0$6a00a8c0@drlreception> Date: Fri, 08 Jun 2001 01:33:49 +0100 From: Ian Dowse Message-ID: <200106080133.aa91564@salmon.maths.tcd.ie> Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In message <000201c0ef94$27d8ece0$6a00a8c0@drlreception>, Rick Powell writes: >like. I did the calculation of 512 bytes per sector and 8192 bytes per >logical block equals 16 sectors per logical block. I then multiply 16 >sectors by 32 blocks should equal 512 sectors should be the start of the >backup superblock. I can't see anything at this location that looks like >data. I am doing this on a working freebsd drive so I can find the first >few charactors of the superblock and then do a search for those on the bad >drive. Am I doing this correctly? The first backup superblock usually begins at sector 32 on the partition (i.e. 32 * 512 bytes from the start of the partition). This is actually right after the master superblock, which begins at sector 16. There is one backup superblock in each cylinder group, and in the first cylinder group it begins in the first usable block, so it is easy to find (filesystems with a >16k fragment size are probably different because the first usable block is not at sector 32). Locating later superblocks is more tricky, because you really need to know many superblock paramaters to know where to look. It's probably easier to just search for the "54 19 01 00" magic number at offset 0x55c in each 8k block on the disk. The actual byte offset from the start of the partition of the superblock in cylinder group N is given by (fs_fpg * N + fs_cgoffset * (N & ~fs_cgmask) + fs_sblkno) * fs_fsize where all the fs_* values are stored in the superblock! I think for this reason, it used to be recommended that you write down some of the block numbers printed by newfs when a filesystem is created, though I doubt too many people do that now. Ian To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message