OpenBSD Mount And Use a USB Flash Drive

Posted on in Categories , , , last updated May 19, 2014

How do I mount and use a USB pen or hard disk under OpenBSD operating systems using ksh/bash/sh shell prompt?

OpenBSD does supports USB storage devices such as pen and hard disk via emulated SCSI drives. You need to login as root user to mount USB pen/disk.

Finding out your USB device name on an OpenBSD based system

First, insert your your USB flash drive in USB socket. Type the following command to list device names:

# sysctl hw.disknames
Sample outputs:

hw.disknames=wd0:3af96a8b7d621ab2,cd0:,sd0:

To get more info about sd0 (my usb pen), type:
# dmesg | grep sd0
Sample outputs:

sd0 at scsibus1 targ 1 lun 0:  SCSI2 0/direct removable
sd0: 1956MB, 512 bytes/sector, 4005888 sectors
sd0 detached
sd0 at scsibus1 targ 1 lun 0:  SCSI2 0/direct removable
sd0: 1956MB, 512 bytes/sector, 4005888 sectors

The following command shows more information about sd0
# disklabel sd0
Sample outputs:

# /dev/rsd0c:
type: vnd
disk: vnd device
label: fictitious
duid: 97d41b01a9d85387
flags:
bytes/sector: 512
sectors/track: 100
tracks/cylinder: 1
sectors/cylinder: 100
cylinders: 5120
total sectors: 4005888
boundstart: 0
boundend: 512000
drivedata: 0 

16 partitions:
#                size           offset  fstype [fsize bsize  cpg]
  a:           512000                0  4.2BSD   2048 16384    1 
  c:          4005888                0  unused                   
# 

Mounting USB Pen/Hard Disk on an OpenBSD

Type the following command to create a directory (mount point), enter:
# mkdir /mnt/pen

Mount the flash drive using mount command at /mnt/pen, enter:
# mount /dev/sd0i /mnt/pen
You may need to replace /dev/sd0i with actual device name. Now, you can access the files at /mnt/pen:
# cd /mnt/pen
# ls -l
# cp filename /path/to/dir

Finally, unmount the flash filesystem using the following command:
# umount /mnt/pen

5 comment

  1. “You may need to replace /dev/sd0i with actual device name.”

    For people new to OpenBSD, how do you find the actual device name?

Leave a Comment