Dividing Your Data

02/21/2001

In the next few articles, I'll look at how FreeBSD stores data on your hard disk. To store data on a hard drive, the drive must first be divided into logical storage units, and each unit must be assigned an address. The file system will save data to these storage units and keep track of which storage units contain which files.

Like any other version of Unix, FreeBSD uses "inode" (index number) tables to record where files are physically located on disk. Before any inode tables can be created, the disk storage units must be created and given addresses. Let's summarize the steps involved in this process:

The fdisk utility is used to view and create the BIOS partition table which defines up to four disk "slices."

The disklabel utility is used to view and create the Unix partition table which defines up to eight Unix "partitions."

The newfs utility is used to actually create a "filesystem" on each Unix partition.

Every filesystem will then maintain its own inode table.

Notice that your FreeBSD system contains both a BIOS partition table and a Unix partition table. This is necessary as FreeBSD is a Unix operating system, meaning it understands the Unix partition table; however, FreeBSD is also an operating system which runs on a PC (personal computer). PCs require software known as the BIOS in order to initialize the computer, discover the physical geometry of the drives, and locate the software that will boot the desired operating system.

One of the instructions in the BIOS is to look at the contents of the first sector of the first hard disk. This sector is 512 bytes in size; out of those 512 bytes, 64 bytes have been set aside for the BIOS partition table. Every entry in the BIOS partition table consists of 16 bytes, therefore there is only enough room to describe four BIOS partitions.

The BIOS partition table can be viewed or changed using an fdisk utility. If you change the BIOS partition table, you are actually "slicing" your physical disk into as many as four logical disks. FreeBSD users prefer to call these logical disks "slices" so they won't be confused with the "partitions" described by the Unix partition table.

You may be familiar with the DOS fdisk utility; I'd like to compare it to the FreeBSD fdisk utility so you can see the similarities between the two programs. I'll start by showing the output from one of my PCs; I booted this PC with a DOS boot disk, then ran fdisk from the floppy prompt:

Notice that I have "sliced" up my hard drive into three slices, which DOS calls "partitions." The first slice has a status of A for active, meaning that it contains boot code in order to boot an operating system. It is 204 Mbytes in size and has been formatted with the FAT16 file system.

The second slice is 3,193 Mbytes and contains my FreeBSD partitions. This file type is not recognized by the DOS fdisk utility and has been simply labeled as non-DOS.

The third slice is a 2,753-Mbyte extended partition. Notice that you must enter another screen to see the layout of the extended partition. Extended partitions were designed to allow you to slice your hard drive into more than four slices; the extended partition is simply a pointer to another area on disk which contains yet another table to describe the layout of the "logical" partitions contained within the "extended" partition. Unfortunately, these logical partitions are truly "logical" as they cannot contain boot code, and many operating systems will not install on an extended partition. I'll press Y to enter into the screen that will show these logical partitions: