BSD DevCenter
oreilly.comSafari Books Online.Conferences.


FreeBSD Basics

Dividing Your Data


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:

           Microsoft Windows 95
         Fixed Disk Setup Program
 (C)Copyright Microsoft Corp/ 1983 - 1995

FDISK Options

Current fixed disk drive: 1

Choose one of the following:

1. Create DOS partition or Logical DOS Drive
2. Set active partition
3. Delete partition or Logical DOS Drive
4. Display partition information

Enter choice: [4]

Here we've entered the main menu of the DOS fdisk utility. I don't want to change the BIOS partition table, so I'll choose option 4 to display the partition information.

Display Partition Information

Current fixed disk drive: 1

Partition Status Type Volume Label Mbytes System Usage
C: 1 A PRI DOS 204 FAT16 3%
2 Non-DOS 3193 52%
3 EXT DOS 2753 45%

Total disk space is 6150 Mbytes (1 Mbyte = 1048576 bytes)

The Extended DOS Partition contains Logical DOS Drives.
Do you want to display the logical drive information (Y?N)......?[Y]

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:

Display Logical DOS Drive Information

Drv Volume Label Mbytes System Usage
D: 1396 FAT16 51%
E: 361 FAT16 13%

Total Extended DOS Partition size is 2753 Mbytes (1 Mbyte = 1048576 bytes)

Pages: 1, 2, 3

Next Pagearrow

Sponsored by: