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:

FreeBSD add a new disk using sade or bsdinstall command
Fig.01: bsdinstall/sade in action

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:

FreeBSD select a partition scheme for da0
Fig.02: Setting up a partition scheme to GPT

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:

FreeBSD add a new partition with partition editor
Fig.03: Adding a new partition

Step 3 – Commit changes

After step #2, you should see something as follows:

FreeBSD finish sade
Fig.04: My partition are ready for formatting

Select the Finish button to bring confirmation dialog box on screen. Select the Commit button to confirm changes:

FreeBSD confirmation box
Fig.05: Confirm changes to disk

You should see progress as follows before returning to the shell prompt:

FreeBSD initializing disk and writing partition tables for da0p1
Fig.06: sade initializing my disk

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 :  | 95 views
https://serang.ut.ac.id/css/css/slot88/ https://tinjut.bagkeu.dikdasmen.kemdikbud.go.id/slot-maxwin/ https://dpm.polinema.ac.id/slot-gacor/ https://akademik.ft.unm.ac.id/slot-dana/ https://ppdb.probolinggokab.go.id/slot-5000/ https://bkad.sulselprov.go.id/assets/ https://ojs.balidwipa.ac.id/docs/slot-gacor/ http://korpri.pekalongankab.go.id/api/slot-gacor/ https://elang.umpp.ac.id/foto/farmasi/-/asset/ http://rsud-kelet.jatengprov.go.id/wp-content/-/asset/ https://kusdhianto-fe.staff.ugm.ac.id/slot88/ http://ppdb.probolinggokab.go.id/judi-bola/ https://bapenda.labuhanbatukab.go.id/racikan-sbobet/ http://rsud-kelet.jatengprov.go.id/wp-content/-/data/ https://agenda.riau.go.id/-/judi-bola/ https://balapan.padang.go.id/sbobet88/ http://jdih.wakatobikab.go.id/sbobet88/ http://kph.menlhk.go.id/sbobet88/ https://bkad.sulselprov.go.id/data/ https://dpm.polinema.ac.id/slot-gacor/ https://dinkes.jemberkab.go.id/storage/attachments/