How do I list all connected (including unmounted) devices on OpenBSD?

I'm looking for something similar to lsblk for Linux or camcontrol devlist for FreeBSD:

# List devices on FreeBSD

$ camcontrol devlist
<VBOX HARDDISK 1.0>   at scbus0 target 0 lun 0 (ada0,pass0)
<VBOX CD-ROM 1.0>     at scbus1 target 0 lun 0 (pass1,cd0)

# List devices on Linux
$ lsblk

/dev/sda      8:0    0 465.8G  0 disk 
├─/dev/sda1   8:1    0  1007K  0 part 
├─/dev/sda2   8:2    0   256M  0 part /boot
├─/dev/sda3   8:3    0   9.8G  0 part [SWAP]
├─/dev/sda4   8:4    0  29.3G  0 part /
├─/dev/sda5   8:5    0  29.3G  0 part /var
├─/dev/sda6   8:6    0 297.6G  0 part /home
└─/dev/sda9   8:9    0  16.3G  0 part 
/dev/sr0     11:0    1  1024M  0 rom  

None of these commands seem to exist or be available in the (default) repos for OpenBSD.
Not even pciinfo, kldstat, or geom are available.

4 Answers 4


The sysctl command can list devices attached to the system. sysctl gets or sets kernel state.

To list how many disks you have:

sysctl hw.diskcount

To list disk names:

sysctl hw.disknames

Or sysctl -a | grep -i disk

  • While this does show what devices should be available, it doesn't however tell me the /dev interface for said devices. For example, it lists cd0, however mount /dev/cd0 /mnt/cd0 fails complaining that either /dev/cd0 or /mnt/cd0 don't exist. Nov 22, 2017 at 1:35
  • did you create a /mnt/cd0 directory? In a default OpenBSD install the /mnt/ directory has no subdirectories. So I have created a /mnt/cd directory and added the following entry /dev/cd0a /mnt/cd cd9660 rw,noauto,nodev,nosuid 0 0 to the /etc/fstab file, now to mount a cd I only have to do mount /mnt/cd hth
    – fcbsd
    Nov 22, 2017 at 11:27
  • Yeah /mnt/cd0 existed: I'm guessing that cd0 doesn't actually point to a device and that I'd need to mount one of the cd0<LETTER> devices? Nov 22, 2017 at 15:04
  • 1
    @AlexejMagura - I think that cd0a and cd0c should both be there be default as well as the raw devices rcd0a and rcd0c the letter after the node number is usually the partition - the c parition is always the whole disk - and as CD's are usually a single disk you tend to have an a partition that usually matches the whole disk on CD's as well so either would normally be okay for CD's.
    – fcbsd
    Nov 22, 2017 at 15:23
  • 1
    disklabel(8) explains the 15 configurable partitions that any disk can have.
    – fcbsd
    Nov 22, 2017 at 15:27
dmesg | egrep '^(cd|wd|sd|fd). at '
  • I was wondering if you could shorten it even more - I managed dmesg|egrep '^([cswf]d). '
    – fcbsd
    Nov 21, 2017 at 22:24
  • dmesg shows ALL devices that have been attached, so if you plug in a flash drive, remove it, this command will show it as present. That's why dmesg is a really bad data source, it's static data, not dynamic, that is, it's a history of all events until the present.
    – Lizardx
    Mar 27, 2021 at 23:39

OpenBSD doesn't have a similar tool. You can see the disks in the dmesg or running sysctl hw.disknames. Also, disklabel and fdisk can show info about the partitions.


lsblk is a nice tool but not available on OpenBSD. There are other ways of achieving similar:

1. To show the names of disks available on the system:

sysctl hw.disknames

This produces a list of disks on one line, separated by commas:


Disk identifiers are highlighted above in bold (for use in the next step).

2. Use the disklabel utility to show more about each disk (needs to be run as root):

doas disklabel -h <disk identifier>

This gives you more info about the disk in -h human readable format - i.e. megabytes, gigabytes etc.

3. See info (including size and free space) about already mounted filesystems

(I know this may not strictly answer the question but I've included it for completeness)

If you have already mounted the filesystem, your disk will be included in the information displayed by: df -h

4. Review system messages if still unsure:

dmesg outputs messages from the kernel as hardware is detected. Use this with grep if you still can't find your disk:

dmesg | grep -i 'scsi'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.