For the complete documentation index, see llms.txt. This page is also available as Markdown.

27.2 Adding UFS Disks

This section describes how to add a new NVMe Solid-State Drive (SSD) to a computer that currently has only one disk. First, power off the computer and install the disk according to the instructions from the computer, controller, and disk manufacturers. Restart the system and switch to the root user.

Check the /var/run/dmesg.boot file to ensure the new disk has been recognized.

nda1 at nvme0 bus 0 scbus2 target 0 lun 2
nda1: <VMware Virtual NVMe Disk 1.4 VMware NVME_0000>
nda1: Serial Number VMware NVME_0000
nda1: nvme version 1.4
nda1: 10240MB (20971520 512 byte sectors)

...other irrelevant output omitted...

In this example, the newly added 10G NVMe disk appears as nda1.

Creating a Partition Table

This example creates a single partition on the new disk. The GPT partition scheme is preferred over the less flexible MBR scheme.

Note

If the disk to be added is not empty, you can use gpart delete to remove old partition information.

Example 1 Delete partition 1 on disk nda1:

# gpart delete -i 1 nda1

Example 2 Destroy the entire partition table and all partitions on disk nda1:

# gpart destroy -F nda1

Create a GPT partition table for nda1:

Creating a Single Partition

Then add a partition. To improve performance on disks with larger hardware block sizes, the partition is aligned to a 1MB boundary:

Tip

The -t option here only writes the partition type GUID; it does not perform actual formatting and is unrelated to the file system being formatted.

You can use gpart show to view disk partition information:

The above commands created a GPT partition table and a new 10G disk partition nda1p1 using the UFS file system.

Creating Multiple Partitions

For convenience, multiple partitions can be created.

The following creates 4 partitions on disk nda1 with capacities of 1GB, 2GB, 3GB, and 4GB respectively. Use the -s parameter to specify partition sizes (supports units such as G and M).

  • Create the 1st partition: 1G

  • Create the 2nd partition: 2G

  • Create the 3rd partition: 3G

  • Create the 4th partition using all remaining capacity:

You can use gpart show to view disk partition information:

The above commands created partitions nda1p1, nda1p2, nda1p3, and nda1p4 respectively.

Formatting the File System

Create a file system on the new partition of the new disk:

Format /dev/nda1p1, /dev/nda1p2, /dev/nda1p3, and /dev/nda1p4 all at once:

Mounting the File System

Create an empty directory as a mount point, which is the location in the original disk's file system where the new disk will be mounted:

Temporarily mount /dev/nda1p3 to /mnt/newdisk:

Perform a write test:

Finally, add an entry in /etc/fstab to automatically mount the new disk at startup:

You can manually mount the new disk without restarting the system:

Verify the mount:

Use the mount command to verify (without any arguments)

You can also use the df command to verify the mount:

View the contents of the mounted file system:

Last updated