Adding new disk in FreeBSD

Check if the disks are being detected. There are multiple ways to do it, but the most simplest is to check a sysctl variable.
# sysctl kern.disks

Disk types are displayed in the following format: SAS & SCSI are designated “da” while IDE & SATA (including SSD) drives are “ada“. Disk types are followed by numbers, i.e. da0, ada0, ada1 etc. To check which disks are being used currently, use “df -h” command. It should list out all the currently used disks.

Once you have determined which disk you need to attach, use the following commands. The examples below assume the disk to be configured is at ada1. Change it as per your configuration.
Re-initialize the disk with all zero’s
# dd if=/dev/zero of=/dev/ada1 bs=1k count=2
Label the disk. If you use auto parameter, the disk would be labeled from a, i.e. ada1a
# bsdlabel -Bw ada1 auto
Format the new parition
# newfs /dev/ada1a
Create the directory where you would like to mount the new disk / partition
# mkdir -p /usr/local/disk2
To mount the disk temporarily
# mount /dev/ada1a /usr/local/disk2

For auto mounting the disk across reboot, make the following entries in your “/etc/fstab” file
/dev/ada1a /usr/local/disk2 ufs rw 2 2

Keep in mind that these disks will not be readable by any other os’s (Windows). To make the disks compatible with other os, you need to create a slice before labeling it. Also, the above code has been tested in FreeBSD 9.0, earlier versions might differ in commands or outputs.


One thought on “Adding new disk in FreeBSD

Comments are closed.