From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,b9c917a92adbc2ee X-Google-Attributes: gidfee84,public From: alan@nabeth.cxo.dec.com (Alan Rollow - Dr. File System's Home for Wayward Inodes.) Subject: Re: Wrote over the RZ26L disklabel Date: 1996/04/12 Message-ID: <4km2ma$14m@nntpd.lkg.dec.com>#1/1 X-Deja-AN: 147150285 distribution: world references: <316D7FCA.41C6@globalcom.net> organization: Digital Equipment Corporation reply-to: alan@nabeth.cxo.dec.com (Alan Rollow - Dr. File System's Home for Wayward Inodes.) newsgroups: comp.unix.osf.osf1 In article <316D7FCA.41C6@globalcom.net>, John Sanders writes: >I distroyed the disklabel on the RZ26L I was using as the system disk on >my AlphaStation 400. I dodnt remember exactly how the disk was >configured. I used disklabel to put a new label on the disk and edited >it to show the BSD file system. The "a" partition works fine - mounts >just fine - but I need the "g" partition where the /usr stuff is >located. fsck just complains about the "magic number" of the superblocks >being fouled up. Probably because the start of the partition or its size >is wrong. Is there anything I can do to find the start and extent of the >"g" partition on this disk? If the file systems on the disk are UFS, then it may be possible to reconstruct enough of the partition table. It may be possible with AdvFS, but the on-disk format is too under-documented. A UNIX File System starts with space for a boot block. 8 KB of space is set aside for it, even when the partition isn't bootable. The next 8 KB is the primary superblock. The next 8 KB is the backup superblock. Since superblocks have magic numbers and other fields that can help uniquely identify them as superblocks all you need to do is: 1. Open the raw device. 2. Read 8 KB and see if it is a superblock. If so, read the next 8 KB and see if it is a superblock. Once you have to superblock back to back, then you probably have the primary and first backup. The start of the partition is 8 KB back from the start of the first one. The (used) size of the partition is one of the fields in the superblock. Note: I said *used* size because the newfs command supports a -s option to explicitly set the size. Since newfs verifies that it can write the last sector of a partition, you can't lie and use a larger size. But you can use a SMALLER size. The actual partition may be larger. 3. If the first 8 KB from #2 isn't a superblock, advance the offset one sector and repeat step #2. 4. If you think other filesystem may be on the disk, you can either continue the search from the last superblock pair found, in case those weren't a file system or from the end of the file system you did find. Hints for writing such a program: 1. You'll need to include and anything it requires. It so happens that on Digital UNIX V3.0, is sufficient. 2. The data structure for the superblock may be larger or smaller than 8 KB. Use SBSIZE for doing I/O, not the size of (struct fs). > >Thanks in advance - > >-- >_____________________________________ >john sanders > > >- it can be done -< > >------------------------------------- > -- Alan Rollow alan@nabeth.cxo.dec.com