FreeBSD Find Out all Installed Hard Disk Information

by on February 6, 2008 · 6 comments· LAST UPDATED February 6, 2008

in , ,

Q. How do I find out all installed hard disk names under FreeBSD without rebooting the server? How do I use the equivalent of fdisk -l in Linux, with FreeBSD to list all hard disks?

A. The easiest way to find out detected hardware information under FreeBSD is go through /var/run/dmesg.boot file. This file is usually a snapshot of the buffer contents taken soon after file systems are mounted at startup time. It is not modified till system is rebooted. Just Linux, FreeBSD follows some sort of physical disk naming conventions:

a] IDE Hard disk names starts with ad - /dev/ad0 first IDE hard disk, /dev/ad1 second hard disk and so on

b] SCSI Hard disk names starts with da - /dev/da*

c] IDE CDROM/RW/DVD names starts with acd - /dev/acd*

d] SCSI CDROM/RW/DVD names starts with cd - /dev/cd*

List all detected hard disk / cdroms

Type the following command, enter:
# egrep 'ad[0-9]|cd[0-9]' /var/run/dmesg.boot
Output:

acd0: DVDROM  at ata0-slave UDMA33
ad4: 239372MB  at ata2-master SATA150
ad6: 239372MB  at ata3-master SATA150
Trying to mount root from ufs:/dev/ad4s1a

From above output it is clear that I've following storage installed:

  1. ad4 : My First hard disk connected to ATA channel 2
  2. ad6: My Second hard disk connected to ATA channel 3
  3. acd0 : My DVD ROM

atacontrol command

The atacontrol utility is a control program that provides the user access and control to the FreeBSD ata (IDE / SATA hard disk) subsystem.

WARNING! These examples may crash your computer and loss of data if executed improperly. Please exercise caution when using atacontrol command!

The list option can list all hard disk, enter:
# atacontrol list
Output:

ATA channel 0:
    Master:      no device present
    Slave:  acd0  ATA/ATAPI revision 7
ATA channel 1:
    Master:      no device present
    Slave:       no device present
ATA channel 2:
    Master:  ad4  Serial ATA II
    Slave:       no device present
ATA channel 3:
    Master:  ad6  Serial ATA II
    Slave:       no device present
TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 6 comments… read them below or add one }

1 Dmitriy July 11, 2009 at 11:33 am

Hi, i am from Russia, thanks.

Reply

2 Fabrice A. Marie January 28, 2010 at 2:16 pm

I found that gpart is more accurate. For example on my machine there
are other discs which names do not start with ad
# gpart show
=> 63 156310371 ad2 MBR (75G)
63 156309489 1 freebsd [active] (75G)
156309552 882 – free – (441K)

=> 63 488394963 ad4 MBR (233G)
63 472005702 1 !131 (225G)
472005765 16386300 2 !130 (7.8G)
488392065 2961 – free – (1.4M)

=> 63 398292804 twed0 MBR (190G)
63 163846872 1 !7 (78G)
163846935 234436545 2 !131 (112G)
398283480 9387 – free – (4.6M)

=> 0 156309489 ad2s1 BSD (75G)
0 1048576 1 freebsd-ufs (512M)
1048576 8315952 2 freebsd-swap (4.0G)
9364528 6254592 4 freebsd-ufs (3.0G)
15619120 1048576 5 freebsd-ufs (512M)
16667696 139641793 6 freebsd-ufs (67G)

Reply

3 Rumantic August 20, 2010 at 2:59 am

really nice topic.
and what about RAID info?

Reply

4 Olav May 19, 2012 at 12:05 pm

With FreeBSD 8 and 9 you can use
# camcontrol devlist

Reply

5 NIckolas Nolan March 12, 2014 at 4:29 pm

Works on FreeBSD10 as well.

It was also able to retrieve info for 4tb disks without partition tables.
gpart show omitted these for some reason; perhaps i’m missing something.

# camcontrol	devlist
  at scbus1 target 0 lun 0 (ada0,pass0)
  at scbus2 target 0 lun 0 (ada1,pass1)
  at scbus4 target 0 lun 0 (ada2,pass2)
  at scbus5 target 0 lun 0 (ada3,pass3)

Reply

6 Hongk September 4, 2013 at 6:06 am

Hi, can i check why I am unable to detect my second hard drive when i’ve already added it. I’m using Hyper-V, Added a second SCSI Controller, and added a hard drive, but i can’t seem to detect it.

Reply

Leave a Comment

Tagged as: , , , , , , , , , ,

Previous Faq:

Next Faq: