[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::digital_unix

Title:DIGITAL UNIX(FORMERLY KNOWN AS DEC OSF/1)
Notice:Welcome to the Digital UNIX Conference
Moderator:SMURF::DENHAM
Created:Thu Mar 16 1995
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:10068
Total number of notes:35879

8812.0. "How to determine Unix disk by reading boot block?" by METALX::SWANSON (Victim of Changes) Wed Feb 12 1997 14:30

    Hi,
    
    I need to be able to determine if a disk contains Digital Unix on it 
    from information contained in the boot block.
    
    This will be done on an NT system, and is for the purpose of making
    sure any Unix disks that happen to be on the NT system don't get written
    to during disk tests.  (i.e.  the test engineer wants to keep the
    system dual-boot).
    
    Using SCU, I can see that at offset 0x100 on the boot block, there
    is "WEV" followed by some control codes.  This data seems to be on all
    Unix disks.  (It may be on *all* disks, but I doubt it... haven't
    checked yet)
    
    Now, I could check for those three bytes at offset 0x100 on the first
    sector of the disk, but I'm hoping somebody can provide me with a
    better method!
    
    Does anyone know what the format is of a Digital Unix boot block?
    
    -Ken
    
    
T.RTitleUserPersonal
Name
DateLines
8812.1NABETH::alanDr. File System's Home for Wayward Inodes.Wed Feb 12 1997 15:1410
	It is very likely that a disk with a Digital UNIX root file
	system on it will be labeled.  This may not be true for other
	file systems and data.  If the disk is labeled it is very
	likely that the first 32 bit field of the label is the magic
	number for the label.  The data structure of the label is
	described in /usr/include/sys/disklabel.h.

	For non-labeled UFS, it should be sufficient to check the magic
	number in the superblock, which is the 2nd 8 KB chunk of space
	on the disk.
8812.2METALX::SWANSONVictim of ChangesWed Feb 12 1997 15:436
Okay, I see the magic number 0x82564557 64 bytes into the first sector on the
disk.  

Will this number always be the same, and always start at the 64th byte?

Ken
8812.3SSDEVO::ROLLOWDr. File System's Home for Wayward Inodes.Thu Feb 13 1997 00:276
	Look through the disklabel.h include file to see if you
	can find a constant that plausibly corresponds to the
	64 byte offset.  Once you know where the offset comes
	from, it will be easier to determine just how static it
	is.  The magic number is unlikely to change, unless the
	format of the label changes significantly.
8812.4SMURF::KNIGHTFred KnightThu Feb 13 1997 10:024
I think the 64 byte offset is based on skipping over the old
ULTRIX partition table.  If so, it is pretty unlikely that
the old ULTRIX partition table will EVER change!  My guess
would be a 0.0% chance of change!
8812.5SSDEVO::ROLLOWDr. File System's Home for Wayward Inodes.Thu Feb 13 1997 10:292
	The ULTRIX partition table lived at the end of the super-
	block.
8812.6Turn the question round: what does FAT or NTFS look like??????BBPBV1::WALLACEjohn wallace @ bbp. +44 860 675093Thu Feb 13 1997 13:3223
    Is there another way of handling this, using NT's built in facilities ?
    
    If you run NT Disk Administrator, it offers to "write a signature" on
    all the disks it sees. Any you don't write a signature on become
    invisible to ordinary NT apps. DiskAdmin doesn't stop you inadvertently
    "writing a signature" to UFS or Files11 or anything it doesn't
    recognise, and if you do "write a signature" to UFS (and presumably
    AdvFS etc) or Files11, your data is no longer available next time you
    boot the alternate OS. Many people including me know this only too well
    :-(
    
    So if you check for the NT administrator disk signature, you know it is
    an NT disk (FAT, NTFS, whatever) and can safely access it, and you
    already know that Disk Admin has locked out inadvertent disk access to
    the Unix stuff.
    
    Even more simply, why not check the disk under test for FAT or NTFS
    signatures, which are documented in the MSDN Knowledge Base ? That way,
    you don't even need to risk someone making a mistake with DiskAdmin. Or
    is there something I've missed ?
    
    regards
    john
8812.7METALX::SWANSONVictim of ChangesFri Feb 14 1997 16:4235
Thanks for the replies.

The "magic number" method worked perfectly.  

re: .4

I'm glad you think there's a 0.0% chance of change.  Reading the comment
section in disklabel.h right before the magic number and offset are defined,
it says:

                   "The stuff below is totally a crock. To start, 
                    it assumes that the label is in the same
                    location on all disks which is bogus, and that 
                    the position of the label is invariant
                    with sector size which is also bogus. For instance, 
                    here at Apollo, we must have it
                    at either 1kbytes from the beginning of the disk 
                    or at 12k from the beginning regardless
                    of the sector size. So I'm just gonna change
                    offset and hold the sector constant."

It doesn't sound like the the chances are 0% to me, but if it changes,
someone else can worry about it when the time comes  :')

re: .6

>Even more simply, why not check the disk under test for FAT or NTFS signatures

That would work except that I want the disk to be write-tested if it has no
filesystem on it at all.

Thanks again,

ken

8812.8disklabel = Digital UNIQUESMURF::KNIGHTFred KnightMon Feb 17 1997 11:4114
All that disklabel stuff is DIGITAL specific; the Magic number,
the contents of the header, all of it.  The stuff right before
the magic number is even ULTRIX specific (and that is what I
said wouldn't change).  ULTRIX is in maintenance mode, and we've
even already announced when support will be terminated.  So,
it's not likely we'll change anything there.

As for the comment, if you want to support the finding of Apollo
or Sun, or HP disks, then you've got a whole ton of other research
to do.  Each vendor is free to do that stuff pretty much however
they want.  All that is guaranteed to be correct in that file is
the Digital stuff.

	Fred Knight
8812.9METALX::SWANSONVictim of ChangesTue Feb 18 1997 15:198
>All that is guaranteed to be correct in that file is
>the Digital stuff.

Okay, that's all I'm concerned with.

Thanks again,

Ken