Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 07 Mar 1998 16:07:14 -0800
From:      Greg Shenaut <greg@bogslab.ucdavis.edu>
To:        questions@FreeBSD.ORG
Subject:   using fdisk and disklabel to determine raw disk layout
Message-ID:  <199803080007.QAA11292@myrtle1.bogs.org>
In-Reply-To: Your message of "Sat, 07 Mar 1998 13:50:45 PST." <199803072151.NAA11174@myrtle1.bogs.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
I hate looking like an idiot, but I am now thoroughly confused.
The disklabel(8) program only deals with a single fdisk(8) partition,
so the offsets it reports are only relevant to its partition.  Fdisk,
on the other hand, reports up to 4 fdisk partitions, but says nothing
about the contents of the partitions beyond its msdos code.

If I understand this correctly, it would actually be possible for
there to be 4 independent disk labels on a raw disk, each with 8
independent partitions; fdisk would report the layout of the 4
labeled partitions, while you would need 4 runs of disklabel to
see all of the possible bsd partitions.  Of course, there could be
non-bsd fdisk partitions which would not contain bsd labels; the
information reported by fdisk would probably suffice for them.
Furthermore, the first fdisk partition seems always to start on
cylinder boundary 1 rather than with the sector 0 of the physical
disk.  Potentially all of this information would need to be taken
into account before a map of the physical locations of the various
disk partition could be constructed.  Furthermore, since the first
fdisk partition doesn't include the lowest sectors, it isn't clear
how to read the lowest sectors of the physical disk, since they
are outside of the first fdisk partition.

So, lamentably, I need to reiterate my original question, which
was how to construct automatically a complete map of the physical
layout of a disk drive, incorporating all sectors of the drive,
including those classified by fdisk, by disklabel, and by neither.
Also, I must ask whether it is possible to read and write the entire
physical drive using a single /dev name, such as /dev/rwd0--I ask
this because of the fact that the fdisk table doesn't start with
block 0 (hopefully, rwd0 bypasses all partitioning and just accesses
the physical drive).

- -Greg

In message <199803072151.NAA11174@myrtle1.bogs.org>, Greg Shenaut cleopede:
>
>As you were--I found it: my old friend disklabel(8) spits
>out the needed info quite nicely.
>
>-Greg
>
>Greg Shenaut cleopede:
>>I am writing a script which needs to figure out the physical
>>locations of each of the /dev device names located on each disk.
>>That is, for each of the names, list the absolute offset in blocks,
>>the size in blocks, and perhaps the partition type code and some
>>other info.  The script is going to use this information to copy
>>selected regions for the purposes of baking them up or cloning
>>them, so it needs to be accurate and noninteractive.  If it can
>>be done using C library routines, this would also be OK.
>>
>>How can I get this information?

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



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