Q. How do I add a second hard disk to my FreeBSD server? How do I partition, label and mount a new hard disk under FreeBSD for backup or additional data?
A. There are two ways to install a new hard disk under FreeBSD system. You can use all command line utilities such as fdisk,bsdlabel and newfs to create partitions, label and format it. This method requires complete understanding of BSD partitions and other stuff.
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.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:
- A disk can have up to eight partitions, labeled a-h.
- 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.
- The b partition is used for swap partitions, and you may have many disks with swap partitions.
- The c partition addresses the entire disk in dedicated mode, or the entire FreeBSD slice in slice mode.
- 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
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop

![freebsd-post-install-disk1 Fig.01: Scroll down to Configure and press [enter]](http://files.cyberciti.biz/uploads/faq/2008/08/freebsd-post-install-disk1.png)
![freebsd-post-install-disk2 Fig.02: Select Fdisk and press [enter]](http://files.cyberciti.biz/uploads/faq/2008/08/freebsd-post-install-disk2.png)
![freebsd-post-install-disk3 Fig.03: Select the appropriate drive and press [enter]](http://files.cyberciti.biz/uploads/faq/2008/08/freebsd-post-install-disk3.png)












{ 13 comments… read them below or add one }
Hey thanks for this write up, all went exactly as you have explained. I am left with one question. I would like to be able to access my new drive /disk2 via ftp. I tried to symbolically link a directory I created on new drive to my home folder. Error said too many levels of symbolic links. Should I just change mount mount to a new directory within my home directory. Ex. Home2. Sorry for newb question but thank you for this tutorial.
Thank you!!!! I just started changing my servers to run FreeBSD and tutorials like these are the reason why. This was awesome.
Great info. Now I want to move an existing partition like /usr to the new drive. I could copy everything from the existing /usr to the new partition, then delete it and create a symbolic link to the new location. But is there a better way?
There is no easy solution to your problem. Vinum could have saved your time, if it was implemented in first place.
Loved this article, actually used it to for a local computer meeting dealing with this exact issue. Worked out like a charm.
Joe Poniatowsk, To move /usr to another partition.
First thing to do is put the new disk in the system, once this is completed boot from the installation cd (any of them) use sysinstall to create a directory called /usr0 on that disk. dont use ‘q’ use ‘w’ at every stage, then reboot the system do not install.
when the system reboots choose to go to single usermode, do the following:
mount -w /
mount -r /usr
mkdir /usr0
mount -w /dev/ /usr0
Now you just need to copy your /usr to /usr0 preserving partitions!
cp -rpP /usr/* /usr0/
now just alter fstab to use the new drive for /usr (the one that is currently mounted as /usr0) and wallah. reboot
make that ‘cp -RpP /usr/* /usr0/’
Thanks for the great article. Worked fine with FreeBSD 8.0.
You could do:
cp -a /usr/* /usr0/
This would be the same as defining -RpP.
install FBSD 8.2 release, try sysinstall, but something prevent me from formating 2nd harddisk. better address this issue.
Thanks for this.. You are a life saver! FreeBSD has a steep learning curve when most of your experience is with RedHat.
Worked great
Thanks
Great article, everything worked completely as described for me, first time. Couldn’t do a write up for this better myself! (thanks!).