BSD DevCenter
oreilly.comSafari Books Online.Conferences.

advertisement


Dividing Your Data
Pages: 1, 2, 3

Let's summarize the information we've gleaned out of the DOS fdisk utility. This PC has one hard drive of 6,150 Mbytes. It has been sliced up and labeled as follows:

DOS slice name DOS slice type Slice size Filesystem
C: primary 204 Mbytes FAT16
D: logical 1,396 Mbytes FAT16
E: logical 361 Mbytes FAT16
none unknown 3,193 Mbytes unknown

DOS uses the following naming scheme for its slices:



  • Primary slices are labeled first, starting with the letter C as the letters A and B are reserved for floppy drives.
  • Once the primary slices have been labeled, the logical slices are then labeled.
  • Extended slices and unknown slices are not labeled.

Let's compare this to the output from FreeBSD's fdisk utility. If you just type fdisk at a prompt, it will display the contents of the BIOS partition table. However, if you try to run fdisk as a regular user, you'll receive this message:

fdisk 
fdisk: can't open device /dev/ad0
fdisk: cannot open disk /dev/ad0: Permission denied

Only the superuser has permission to access the device that represents my first IDE disk; this is a good thing, as all fdisk utilities give you the option to modify the slices that have been defined on a hard disk. If you modify a slice, you lose all the data on that slice. Don't worry, the superuser won't be able to modify a slice if he just types fdisk to view the BIOS partition table; the superuser has to actually specify a drive and a switch in order to change a slice. I'll become the superuser and try that view command again:

fdisk

******* Working on device /dev/ad0 *******
parameters extracted from in-core disklabel are:
cylinders=784 heads=255 sectors/track=63 (16065 blks/cyl)

parameters to be used for BIOS calculations are:
cylinders=784 heads=255 sectors/track=63 (16065 blks/cyl)

Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
sysid 6,(Primary "big" DOS (> 32MB))
start 63, size 417627 (203 Meg), flag 80 (active)
beg: cyl 0/ sector 1/ head 1;
end: cyl 25/ sector 63/ head 254
The data for partition 2 is:
sysid 165,(FreeBSD/NetBSD/386BSD)
start 417690, size 6538455 (3192 Meg), flag 0
beg: cyl 26/ sector 1/ head 0;
end: cyl 432/ sector 63/ head 254
The data for partition 3 is:
sysid 5,(Extended DOS)
start 6956145, size 5638815 (2753 Meg), flag 0
beg: cyl 433/ sector 1/ head 0;
end: cyl 783/ sector 63/ head 254
The data for partition 4 is:
<UNUSED>

If you take a close look at this output, you'll notice that FreeBSD's fdisk utility yields the same information as the DOS fdisk utility plus more detailed information regarding the physical layout of the disk. This information is always contained in the BIOS partition table, but not all of the information is displayed with the DOS fdisk utility.

Hard drives are divided into logical units known as cylinders and sectors. My FreeBSD slice (partition 2) starts at cylinder 26/sector 1 and ends at cylinder 432/sector 63. Since cylinders are comprised of 63 sectors, we've started at the beginning of cylinder 26 and ended at the end of cylinder 432, for a total of 407 cylinders. We'll see that cylinder information again when we look at the Unix partition table.

You can also use the fdisk utility to view a summary of the BIOS partition table if you include the s switch:

fdisk -s

/dev/ad0: 784 cyl 255 hd 63 sec
Part        Start        Size Type Flags
   1:          63      417627 0x06 0x80
   2:      417690     6538455 0xa5 0x00
   3:     6956145     5638815 0x05 0x00

This output again shows three defined slices. It also shows the starting address of each slice, and the size of each slice in sectors. The type of each slice is written in hex as hex values always begin with 0x. The hex value a5 is equivalent to the decimal number 165 which is the magic number used by FreeBSD; the hex value 06 is equivalent to the decimal number 6 which is the magic number for FAT16; the hex value 05 is equivalent to the decimal number 5 which is the magic number for a DOS extended partition. Only one flag can be set to 0x80 as this represents the active partition and a BIOS partition table can only have one active partition.

Pages: 1, 2, 3

Next Pagearrow





Sponsored by: