From owner-freebsd-questions Sat Mar 7 16:09:44 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id QAA01809 for freebsd-questions-outgoing; Sat, 7 Mar 1998 16:09:44 -0800 (PST) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from bogslab.ucdavis.edu (root@bogslab.ucdavis.edu [128.120.162.26]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id QAA01644 for ; Sat, 7 Mar 1998 16:09:25 -0800 (PST) (envelope-from greg@bogslab.ucdavis.edu) Received: from myrtle1.bogs.org (root@myrtle1.bogs.org [198.137.203.39]) by bogslab.ucdavis.edu (8.7.4/8.7.3) with ESMTP id QAA23952 for ; Sat, 7 Mar 1998 16:09:20 -0800 (PST) Received: from myrtle1.bogs.org (greg@localhost [127.0.0.1]) by myrtle1.bogs.org (8.6.12/8.6.12) with ESMTP id QAA11292 for ; Sat, 7 Mar 1998 16:07:37 -0800 Message-Id: <199803080007.QAA11292@myrtle1.bogs.org> To: questions@FreeBSD.ORG X-To: Greg Shenaut X-Sender: owner-freebsd-questions@FreeBSD.ORG Subject: using fdisk and disklabel to determine raw disk layout In-reply-to: Your message of "Sat, 07 Mar 1998 13:50:45 PST." <199803072151.NAA11174@myrtle1.bogs.org> Reply-To: gkshenaut@ucdavis.edu Date: Sat, 07 Mar 1998 16:07:14 -0800 From: Greg Shenaut Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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