Adding a Second Drive

This article documents how to add a second drive to your FreeBSD system and format it as UFS.  If you have a system that allows hot-plugging (like the Dell line of servers) then this can be done live without shutting down the server.  If not, then you will have to shut down the server only to insert the drive.  In this article I am going to reference SCSI drive devices (da2) if you have SATA devices, then please not that the device ID will be different (ada2).  

 

 Insert the drive into the server and not the drive ID on startup.

If the drive is not blank (or is unknown), then it is a good diea to make sure that the patition table is cleared.

# dd if=/dev/zero of=/dev/da2 count=20 bs=512k

Next lets create a patition table and create the first pationtion to span the entire drive.

# gpart create -s GPT da2
# gpart add -t freebsd-ufs da2

You can view the disk partion withh the following command:

# gpart show da2
=>        34       286749413       da2     GPT (137G)
          34       286749413         1     freebsd-ufs (137G)

Now that we have a partition created, lets place a file system on it.  Note that da2p1 is the first partion on the drive.  Since we only added one partion then we will place the file system there.

# newfs -U /dev/da2p1

Create a directory to mount hte drive on.

# mkdir /newdisk

Finally add an entery to /etc/fstab so that the new disk will be mounted at boot:

/dev/da2p1        /newdisk    ufs    rw   2    2

You can now mount the new drive with the following command:

# mount /newdisk

 

Enjoy you new drive!

 

Leave a Comment

Your email address will not be published.