How To Add A Second Hard Disk on FreeBSD
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 operating system for backup or to store additional data?
There are two ways to install a new hard disk under FreeBSD operating system. You can use all command line utilities such as fdisk, bsdlabel, and newfs to create partitions, label and format it. This method requires a complete understanding of BSD partitions and other stuff.
FreeBSD add new disk using bsdinstall/sade (method # 1)
The bsdinstall utility is used for installing and configuring FreeBSD systems including hard disks. bsdinstall offers options to partition and label a new disk using its easy to use menus. Login as root user. Run bsdinstall and enter the Configure menu:
WARNING! These examples may result in 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) as per your setup. Please note that any existing data on the 2nd hard drive will get wiped out. Make sure you have a backup of all critical data and config files.
# bsdinstall partedit
OR# sade
The sade utility is used for various disk administration tasks on FreeBSD systems. The goal is to provide the same text interface for disk management in bsdinstall in the post-installation environment. Alternatively, use sudo command (if configured) to run bsdinstall or sade command:$ sudo bsdinstall partedit
OR$ sudo sade
Sample outputs:
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 da0. Use [Tab] key, [Up]/[Down]/[Left]/[Right] arrow keys to move. Press [Enter] to select desired option. The procedure to add a new hard disk on FreeBSD is as follows:
Step 1 – Add a new partition scheme
Make sure da0 selected. Select Create button and press [Enter] key. You must select a partition scheme for da0. I am going to select GPT and Select Ok:
Step 2 – Add a new partition
The GPT partition table has been successfully created. To create partition, select da0, and press Create button again. Make sure you type Mountpoint and label too and finally select Ok button:
Step 3 – Commit changes
After step #2, you should see something as follows:
Select the Finish button to bring confirmation dialog box on screen. Select the Commit button to confirm changes:
You should see progress as follows before returning to the shell prompt:
Step 4 – Mount disk
The sade command will also update your /etc/fstab file as follows:# cat /etc/fstab
Sample outputs:
# Device Mountpoint FStype Options Dump Pass# /dev/vtbd0p2 / ufs rw 1 1 /dev/vtbd0p3 none swap sw 0 0 /dev/da0p1 /data/ ufs rw 2 2
Use mkdir command to create /data/ directory:# mkdir /data/
Mount it by typing the following mount command:# mount -a
Verify it with df command:# df
Sample outputs:
Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/vtbd0p2 77175164 2944484 68056668 4% / devfs 1 1 0 100% /dev /dev/da0p1 5061584 32836 4623824 1% /data
Adding disk using the FreeBSD cli (method # 2)
Use the following command to find out your the new disk name:$ dmesg | grep -i disk
OR use grep command:$ grep -i disk /var/run/dmesg.boot
See “How to Find Out All Installed Hard Disk Information on FreeBSD” for more info.
Create a new partitioning scheme on a da0. The -s GPT option determines the scheme to use:# gpart create -s GPT da0
da0 created
Verify it:# gpart show da0
Sample outputs:
=> 40 10485680 da0 GPT (5.0G) 40 10485680 - free - (5.0G)
Make sure the partition is aligned to one megabyte boundaries for performance reasons and add a new partition:# gpart add -t freebsd-ufs -a 1M da0
da0p1 added
Verify it:# gpart show da0
Sample outputs:
=> 40 10485680 da0 GPT (5.0G) 40 2008 - free - (1.0M) 2048 10481664 1 freebsd-ufs (5.0G) 10483712 2008 - free - (1.0M)
Format /dev/da0p1 partition by typing the following command:k:# newfs -U /dev/da0p1
Sample outputs:
/dev/da0p1: 5118.0MB (10481664 sectors) block size 32768, fragment size 4096 using 9 cylinder groups of 626.09MB, 20035 blks, 80256 inodes. with soft updates super-block backups (for fsck_ffs -b #) at: 192, 1282432, 2564672, 3846912, 5129152, 6411392, 7693632, 8975872, 10258112 |
Finally create a new directory to mount file system:# mkdir /data/
# mount /dev/da0p1 /data/
# df
Update the /etc/fstab:# vi /etc/fstab
Append the following line:
/dev/da0p1 /data/ ufs rw 2 2
Save and close the file. For info see the following man pages:$ man newfs
$ man gpart
$ man sade
Source : https://www.cyberciti.biz/faq/freebsd-adding-second-hard-disk-howto/
Posted on: June 24, 2020, by : Julian's | 96 views