Tested on OpenBSD 6.3 and 6.4 (amd64)
Make sure you are using the device name and partition you need,
destroy all your data run any destructive commands like dd(1).
You can address disk/partitions…
|by disklabel UID|
|or by full path|
||entire disk raw device
||entire disk same, but as a block device|
a raw device (or character device) is accessed directly, bypassing the operating system’s caches and buffers.
When to use block devices then?
“Use block dev only for mounting, use raw for anything else"
— Otto Moerbeek (@ottom6k)
There are programs like
disklabel(8), they accept
all kinds of names (
/dev/sd0, or even
parse them into full path
# disklabel sd1 # /dev/rsd1c: ... #
Some programs, like fdisk(8),
accept some abbreviations, like
sd1c, but refuse to work
with block devices.
# fdisk /dev/sd1c fdisk: /dev/sd1c is not a character device #
Other programs, for example, dd(1), just do what you told them to do.
Don’t repeat at home:
# dd if=/dev/zero of=/dev/sd3 bs=1m /: write failed, file system is full dd: /dev/sd3: No space left on device 919+0 records in 918+0 records out 962592768 bytes transferred in 2.466 secs (390316750 bytes/sec) #
dd creates the file
/dev/sd3 and fills up your root
$ sysctl hw.disknames hw.disknames=sd0:ew9w8ueO9m0t1wda,sd1:66160c68a67e00e6 $
sd0 is the device connected first, its DUID is
sd1 is the second and DUID is
These numbers (
sd1) may change after reboot or
pluging/unpluging USB devices, but DUIDs are persitent until you
rewrite it with disklabel.
If you are looking for a just connected USB drive, then grep(1) word
removable in the output of dmesg(1).
$ dmesg | grep removable | tail -1 sd1 at scsibus5 ... SCSI3 0/direct removable ... $
sd1 is what you are looking for.
Run disklabel(1) with a disk name or DUID.
# disklabel sd1 # /dev/rsd1c: type: SCSI disk: SCSI disk label: XXXXXXXXXX duid: 66160c68a67e00e6 flags: bytes/sector: 512 sectors/track: 63 tracks/cylinder: 255 sectors/cylinder: 16065 cylinders: 1945 total sectors: 31260672 boundstart: 0 boundend: 31260672 drivedata: 0 16 partitions: # size offset fstype [fsize bsize cpg] a: 31260672 0 4.2BSD 2048 16384 1 c: 31260672 0 unused #
If you are looking for OpenBSD partition (
4.2BSD) it’s the partition
The entire disk is represented as the partition
c (marked as
unused, because you can’t create a file system on this partition).
Thanks to Tim Chase, Devin Teske, Mischa Peters, Bryan Steele for reading drafts of this.
© RGZ.EE OÜ