FreeBSD Mount Hard Drive Disk Command

See all FreeBSD related FAQ
How do I mount a hard disk in FreeBSD Unix using the command line options?

It would be best if you used the mount command to mount local or remote (network-based share such as NFS or CIFS) onto the FreeBSD file system tree. This page explains how to mount hard disk drive on FreeBSD.
Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements FreeBSD terminal
Category Disk Management
OS compatibility FreeBSD Jails Unix
Est. reading time 2 minutes
Advertisement

Syntax to mount hard drive disk on FreeBSD

The general syntax is as follows:
# mount /dev/DEVICE /path/to/mount/point
# mount [options] /dev/DEVICE /path/to/mount/point

Where,

  • /dev/DEVICE is actual FreeBSD disk partition name.

Mounting a hard disk on FreeBSD

Use the following command to list all detected hard disks on FreeBSD including cdrom and partitions using the grep command or egrep command:

grep -E 'ad[0-9]|cd[0-9]' /var/run/dmesg.boot
## OR ##
grep -E 'ad[0-9]|cd[0-9]' /var/run/dmesg.boot

Sample outputs:

ad0: 5120MB  at ata0-master WDMA2
acd0: CDROM  at ata1-master WDMA2
Trying to mount root from ufs:/dev/ad0s1a
ad0: 5120MB  at ata0-master WDMA2
acd0: CDROM  at ata1-master WDMA2
Trying to mount root from ufs:/dev/ad0s1a
ad0: 5120MB  at ata0-master WDMA2
acd0: CDROM  at ata1-master WDMA2
Trying to mount root from ufs:/dev/ad0s1a
ad0: 5120MB  at ata0-master WDMA2
acd0: CDROM  at ata1-master WDMA2
Trying to mount root from ufs:/dev/ad0s1a

Other FreeBSD commands to list disks

The following provides much cleaner output:
# atacontrol list
Sample outputs:

ATA channel 0:
    Master:  ad0  ATA/ATAPI revision 7
    Slave:       no device present
ATA channel 1:
    Master: acd0  ATA/ATAPI revision 4
    Slave:       no device present

On modern FreeBSD server use the camcontrol command instead:
# camcontrol devlist
Sample outputs:

    at scbus0 target 0 lun 0 (ada0,pass0)
    at scbus1 target 0 lun 0 (ada1,pass1)

To list partitions of FreeBSD detected disk, try:
# gpart show {DISK}
# gpart show ada1
# gpart show ada2

FreeBSD mounting commands

To mount a partition called /dev/ad1s1d at /data, create an empty directory using the mkdir command:
# mkdir /data
To mount device /dev/ad1s1d on /data/ directory, type:
# mount /dev/ad6s1d /data/
Verify new mounted file system either with df command or mount command:
# mount
# df -h

How do I automatically mount on boot up?

Edit the /etc/fstab and append entry as follows so that /dev/ad6s1d get mounted automatically when FreeBSD boots:

/dev/ad6s1d     /data       ufs     rw           2       2

Save and close the file. For testing purpose reboot your FreeBSD box:
# reboot

How to unmount a filesystem on FreeBSD

Use umount command as follows for un mounting an device mounted at /data/ directory:
# umount /data/
### verification ##
# df -H
# mount

Of course, you can give actual disk path too. For instance:
# umount /dev/DEVICE
For example, if the device name is /dev/ada2p1, then:
# umount /dev/ada2p1
# verification #
# df | grep ada2p1
# mount | grep ada2p1

Summing up

You learned how to mount and unmount FreeBSD disk partitions using the command-line options. The commands are:

# 1. List FreeBSD disks
camcontrol devlist
 
# 2. Get a list of FreeBSD partitions (ada2 is disk)
gpart show ada2
 
# 3. Mount it (mount ada2p1)
mount /dev/ada2p1 /data/
 
# 4. Verify it 
mount | grep ada2p1
df  | grep data
cd /data/
ls 
pwd
rsync -avr /home/vivek/* /data/
 
# 5. Unmount it (optional)
cd /
umount /data/
mount | grep ada2p1
How to mount disk paritions on FreeBSD Unix operating system

Mounting disk partitions on FreeBSD Unix machine

Do read the following man pages using the help command/man command:
# man mount
# man umount
# man camcontrol

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

5 comments… add one
  • aaa Jan 26, 2014 @ 10:25

    What I shoud on live cd?
    I can`t it.

  • FreeBSD USER Feb 15, 2015 @ 15:05

    $ atacontrol list
    -bash: atacontrol: command not found

    Great! thanks!

    • FreeBSD Nov 4, 2015 @ 17:18

      camcontrol devlist

  • Anonymous Aug 31, 2023 @ 16:38

    gpart show ada0
    ada0 GPT
    ada1 efi
    ada2 free-bsd-zfs
    ada3 freebsd-swap

    mount /dev/ada0p1 /mnt/ada
    => invalid fstype: invalid argument

    • 🛡️ Vivek Gite (Author and Admin) Vivek Gite Aug 31, 2023 @ 19:06

      You need to do zfs import and zfs mount for zfs filesystem.

Leave a Reply

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

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.