Adding a new Hard Drive in FreeBSD

Using sysinstall – Easy way to add a new hard disk

The sysinstall utility is used for installing and configuring FreeBSD systems including hard disks. sysinstall offers options to partition and label a new disk using its easy to use menus. Login as root user. Run sysinstall and enter the Configure menu. Within the FreeBSD Configuration Menu, scroll down and select the Fdisk option:
# sysinstall
Alternatively, use sudo (if configured) to run sysinstall:
$ sudo sysinstall

WARNING! These examples may result into data loss or crash your computer if executed without proper care. This FAQ assumes that you have added a hard disk to the system. Also, replace ad to da (if using SCSI hard disk). Please note that any existing data on 2nd hard disk will get wiped out. Make sure you have backup of all import data and config files.

Fig.01: Scroll down to Configure and press [enter]

Fig.02: Select Fdisk and press [enter]

Fig.03: Select the appropriate drive and press [enter]

The new drive will probably be the second in the list with a name like ad1 or ad2 and so on. In above example it is ad6.

Using fdisk

Once inside fdisk, pressing A will use the entire disk for FreeBSD. When asked if you want to “remain cooperative with any future possible operating systems”, answer YES. Write the changes to the disk using W. Now exit the FDISK editor by pressing Q. Next you will be asked about the “Master Boot Record”. Since you are adding a disk to an already running system, choose None. The next dialog will say that the operation was successful. Press [enter]. Type Q to quit FDISK.

Using disklable

Next, you need to exit sysinstall and start it again. Restart sysinstall by typing sysinstall:
# sysinstall
Select Configure and press [enter]. Select Label and press [enter]. A dialog asking you to select the drive will appear. Select the appropriate drive and press [enter].

This is where you will create the traditional BSD partitions:

  1. A disk can have up to eight partitions, labeled a-h.
  2. The a partition is used for the root partition (/). Thus only your system disk (e.g, the disk you boot from) should have an a partition.
  3. The b partition is used for swap partitions, and you may have many disks with swap partitions.
  4. The c partition addresses the entire disk in dedicated mode, or the entire FreeBSD slice in slice mode.
  5. The other partitions are for general use.

Now press C to create a partition.

  • Set partition size, to use the whole drive, press [enter].
  • Next, choose fs and press [enter].
  • Type /disk2 as mount point and press [enter] (don’t use the name of a directory that already exists because sysinstall will mount the new partition on top of it)
  • To finalize the changes, press W, select yes and press [enter].

Update /etc/fstab

The last step is to edit /etc/fstab to add an entry for your new disk, enter:
# vi /etc/fstab
Append entry like as follows (make sure you replace parition name with actual values):

/dev/ad6s1d     /disk2       ufs     rw           2       2

Here is my sample /etc/fstab file:

/dev/ad4s1a    520M    393M     85M    82%    /
devfs          1.0k    1.0k      0B   100%    /dev
/dev/ad6s1d    243G     75G    148G    34%    /disk2
/dev/ad4s1d    520M     22M    456M     5%    /tmp
/dev/ad4s1f    230G    4.6G    207G     2%    /usr
/dev/ad4s1e     10G    130M    9.4G     1%    /var
devfs          1.0k    1.0k      0B   100%    /var/named/dev
devfs          1.0k    1.0k      0B   100%    /usr/home/jail/www.example.com/dev

Save and close the file. The new drive should mount automatically at /disk2 after reboot. To mount it immediately, enter:
# mount -a
# df -H

 

This entry was posted in Linux How-To. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *