2.7. Allocating Disk Space

There are four ways to allocate disk space for FreeBSD. Guided partitioning automatically sets up disk partitions, while Manual partitioning allows advanced users to create customized partitions. The ZFS option, only available in FreeBSD 10 and later, will create an optionally encrypted root-on-ZFS system with support for Boot Environments. Finally, there's the option of starting a shell where command-line programs like gpart(8), fdisk(8), and bsdlabel(8) can be used directly.

Figure 2.11. Selecting Guided, Manual or Shell Partitioning
Selecting Guided, Manual or Shell Partitioning

Figure 2.12. Selecting Guided, Manual, Shell or ZFS Partitioning
Selecting Guided, Manual, Shell or ZFS Partitioning

This section describes what to consider when laying out the disk partitions. It then demonstrates how to use both the Guided Partitioning and Manual Partitioning screens.

2.7.1. Designing the Partition Layout

When laying out file systems, remember that hard drives transfer data faster from the outer tracks to the inner. Thus, smaller and heavier-accessed file systems should be closer to the outside of the drive, while larger partitions like /usr should be placed toward the inner parts of the disk. It is a good idea to create partitions in an order similar to: /, swap, /var, and /usr.

The size of the /var partition reflects the intended machine's usage. This partition is used to hold mailboxes, log files, and printer spools. Mailboxes and log files can grow to unexpected sizes depending on the number of users and how long log files are kept. On average, most users rarely need more than about a gigabyte of free disk space in /var.


Sometimes, a lot of disk space is required in /var/tmp. When new software is installed, the packaging tools extract a temporary copy of the packages under /var/tmp. Large software packages, like Firefox, OpenOffice or LibreOffice may be tricky to install if there is not enough disk space under /var/tmp.

The /usr partition holds many of the files which support the system, including the FreeBSD Ports Collection and system source code. At least 2 gigabytes is recommended for this partition.

When selecting partition sizes, keep the space requirements in mind. Running out of space in one partition while barely using another can be a hassle.

As a rule of thumb, the swap partition should be about double the size of physical memory (RAM). Systems with minimal RAM may perform better with more swap. Configuring too little swap can lead to inefficiencies in the VM page scanning code and might create issues later if more memory is added.

On larger systems with multiple SCSI disks or multiple IDE disks operating on different controllers, it is recommended that swap be configured on each drive, up to four drives. The swap partitions should be approximately the same size. The kernel can handle arbitrary sizes but internal data structures scale to 4 times the largest swap partition. Keeping the swap partitions near the same size will allow the kernel to optimally stripe swap space across disks. Large swap sizes are fine, even if swap is not used much. It might be easier to recover from a runaway program before being forced to reboot.

By properly partitioning a system, fragmentation introduced in the smaller write heavy partitions will not bleed over into the mostly read partitions. Keeping the write loaded partitions closer to the disk's edge will increase I/O performance in the partitions where it occurs the most. While I/O performance in the larger partitions may be needed, shifting them more toward the edge of the disk will not lead to a significant performance improvement over moving /var to the edge.

2.7.2. Guided Partitioning

If multiple disks are connected, choose the one where FreeBSD is to be installed.

Figure 2.13. Selecting from Multiple Disks
Selecting from Multiple Disks

The entire disk or a portion of it can be allocated to FreeBSD. If [ Entire Disk ] is chosen, a general partition layout filling the whole disk is created. Selecting [ Partition ] creates a partition layout in unused space on the disk.

Figure 2.14. Selecting Entire Disk or Partition
Selecting Entire Disk or Partition

After the partition layout has been created, review it carefully for accuracy. If a mistake has been made, selecting [ Revert ] will reset the partitions as they were previously, or [ Auto ] will recreate the automatic FreeBSD partitions. Partitions can be manually created, modified, or deleted. When the partitioning is correct, select [ Finish ] to continue with the installation.

Figure 2.15. Review Created Partitions
Review Created Partitions

2.7.3. Manual Partitioning

Manual partitioning goes straight to the partition editor.

Figure 2.16. Manually Create Partitions
Manually Create Partitions

Highlighting a drive (ada0 in this example) and selecting [ Create ] displays a menu for choosing the type of partitioning scheme.

Figure 2.17. Manually Create Partitions
Manually Create Partitions

GPT partitioning is usually the most appropriate choice for PC-compatible computers. Older PC operating systems that are not compatible with GPT may require MBR partitioning instead. The other partitioning schemes are generally used for uncommon or older computer systems.

Table 2.1. Partitioning Schemes
APMApple Partition Map, used by PowerPC® Macintosh® (http://support.apple.com/kb/TA21692).
BSDBSD Labels without an MBR, sometimes called dangerously dedicated mode. See bsdlabel(8).
GPTGUID Partition Table (http://en.wikipedia.org/wiki/GUID_Partition_Table).
MBRMaster Boot Record (http://en.wikipedia.org/wiki/Master_boot_record).
PC98MBR ariant used by NEC PC-98 computers (http://en.wikipedia.org/wiki/Pc9801).
VTOC8Volume Table Of Contents used by Sun SPARC64 and UltraSPARC computers.

After the partitioning scheme has been selected and created, selecting [ Create ] again will create new partitions.

Figure 2.18. Manually Create Partitions
Manually Create Partitions

A standard FreeBSD GPT installation uses at least three partitions:

Standard FreeBSD GPT Partitions
  • freebsd-boot - FreeBSD boot code.

  • freebsd-ufs - A FreeBSD UFS file system.

  • freebsd-swap - FreeBSD swap space.

Another partition type worth noting is freebsd-zfs, used for partitions that will contain a FreeBSD ZFS file system. Section 20.2, “The Z File System (ZFS)”. gpart(8) shows more of the available GPT partition types.

Multiple file system partitions can be used, and some people may prefer a traditional layout with separate partitions for the /, /var, /tmp, and /usr file systems. See Example 2.3, “Creating Traditional Split File System Partitions” for an example.

Size may be entered with common abbreviations: K for kilobytes, M for megabytes, or G for gigabytes.


Proper sector alignment provides the best performance, and making partition sizes even multiples of 4K bytes helps to ensure alignment on drives with either 512-byte or 4K-byte sectors. Generally, using partition sizes that are even multiples of 1M or 1G is the easiest way to make sure every partition starts at an even multiple of 4K. One exception: at present, the freebsd-boot partition should be no larger than 512K due to boot code limitations.

A mountpoint is needed if this partition will contain a file system. If only a single UFS partition will be created, the mountpoint should be /.

A label is also requested. A label is a name by which this partition will be known. Drive names or numbers can change if the drive is connected to a different controller or port, but the partition label does not change. Referring to labels instead of drive names and partition numbers in files like /etc/fstab makes the system more tolerant of changing hardware. GPT labels appear in /dev/gpt/ when a disk is attached. Other partitioning schemes have different label capabilities, and their labels appear in different directories in /dev/.


Use a unique label on every file system to avoid conflicts from identical labels. A few letters from the computer's name, use, or location can be added to the label. For instance, labroot or rootfs-lab for the UFS root partition on the lab's computer.

Example 2.3. Creating Traditional Split File System Partitions

For a traditional partition layout where the /, /var, /tmp, and /usr directories are separate file systems on their own partitions, create a GPT partitioning scheme, then create the partitions as shown. Partition sizes shown are typical for a 20G target disk. If more space is available on the target disk, larger swap or /var partitions may be useful. Labels shown here are prefixed with ex for example, but readers should use other unique label values as described above.

By default, FreeBSD's gptboot expects the first UFS partition found to be the / partition.

Partition TypeSizeMountpointLabel
freebsd-swap4G exswap
freebsd-ufsaccept the default (remainder of the disk)/usrexusrfs

After the custom partitions have been created, select [ Finish ] to continue with the installation.

2.7.4. Root-on-ZFS Automatic Partitioning

Support for automatic creation of root-on-ZFS installations was added in FreeBSD 10.0-RELEASE. This partitioning mode only works with whole disks and will erase the contents of the entire disk. The installer will automatically create partitions aligned to 4k boundaries, as well as force ZFS to use 4k sectors. This is safe even with 512 byte sector disks, and has the added benefit of ensuring that pools created on 512 byte disks will be able to have 4k sector disks added to them in the future, for additional storage space, or as replacements for failed disks. The installer can also optionally employ GELI disk encryption as described in Section 18.13.2, “Disk Encryption with geli. If encryption is enabled, a 2 GB unencrypted boot pool is created that contains the /boot directory, which holds the kernel and other files necessary to boot the system. A swap partition of a user selectable size is also created, and all remaining space is used for the ZFS pool.

The main ZFS menu in the installer offers a number of options to control the creation of the pool.

Figure 2.19. ZFS Partitioning Menu
ZFS Partitioning Menu

The most important option is selecting the vdev type and one or more disks that will make up the vdev that will constitute the pool. The automatic ZFS installer currently only supports the creation of a single top level vdev, except in stripe mode. To create more complex pools, use the instructions in Section 2.7.5, “Shell Mode Partitioning” to create the pool. The installer supports the creation of various pool types, including stripe (not recommended, no redundancy), mirror (best performance, least usable space), and RAID-Z 1, 2, and 3 (with the capability to withstand the concurrent failure of 1, 2, and 3 disks, respectively). A tooltip across the bottom of the screen while selecting the pool type provides advice about the number of required disks for each type, and in the case of RAID-Z, the optimal number of disks for each configuration.

Figure 2.20. ZFS Pool Type
ZFS Pool Type

Once a pool type has been selected, a list of available disks is displayed, and the user is prompted to select one or more disks to make up the pool. The configuration is then validated, to ensure enough disks were selected. If not, select <Change Selection> to return to the list of disks, or <Cancel> to change the pool type.

Figure 2.21. Disk Selection
Disk Selection

Figure 2.22. Invalid Selection
Invalid Selection

If one or more disks are missing from the list, or if disks were attached after the installer was started, select - Rescan Devices to repopulate the list of available disks. To ensure that the correct disk is selected, so as not to accidently destroy the wrong disks, the - Disk Info menu can be used to inspect each disk, including its partition table, and various other information, including the device model number and serial number, if available.

Figure 2.23. Analysing a Disk
Analysing a Disk

The menu also allows the user to enter a name for the pool, disable forcing 4k sectors, enable or disable encryption, switch between GPT (recommended) and MBR partition table types, and select the desired amount of swap space. Once all options have been set to the desired values, select the >>> Install option at the top of the menu.

If geli(8) disk encryption was enabled, the installer will prompt twice for the passphrase to be used to encrypt the disks.

Figure 2.24. Disk Encryption Password
Disk Encryption Password

The installer then offers a last chance to cancel before the contents of the selected drives are destroyed to create the ZFS pool.

Figure 2.25. Last Chance
Last Chance

The installation then proceeds normally.

2.7.5. Shell Mode Partitioning

When creating advanced installations the basic interface of bsdinstall may not provide the level of flexibility required. Selecting the Shell option from the partitioning menu will drop the user to a shell. The user is expected to partition the drives and create the desired file system(s), populate an fstab(5) file in /tmp/bsdinstall_etc/fstab, and mount the file systems under /mnt. Once this is done, running exit will return to bsdinstall and continue the installation, starting with the extraction of the distribution sets.

All FreeBSD documents are available for download at http://ftp.FreeBSD.org/pub/FreeBSD/doc/

Questions that are not answered by the documentation may be sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.