Discussion:
How to list available all hard disks in OpenBSD
Indunil Jayasooriya
2012-12-21 03:17:27 UTC
Permalink
HI,

I would like to know How to list available all hard disks in OpenBSD ?

If I run below 2 commands, it will give an output.

dmesg |grep wd0

fdisk wd0


If I install a new Hard Disk, How to get to know whether it is wd1 or
anything eles?

In Linux, Fdisk -l show all the available hard disks. In OpenBSD what's the
command for it?
--
Thank you
Indunil Jayasooriya
Nick Holland
2012-12-21 04:28:20 UTC
Permalink
Post by Indunil Jayasooriya
HI,
I would like to know How to list available all hard disks in OpenBSD ?
If I run below 2 commands, it will give an output.
dmesg |grep wd0
fdisk wd0
If you want USEFUL, you might use:

dmesg |grep "^[sw]d"

if you care about floppies and/or cdrom drives, add a "cf" in there,
too. actually, if you want to script it, you will want to lock it down a
lot further...but that gives a nice view for humans to read.
Post by Indunil Jayasooriya
If I install a new Hard Disk, How to get to know whether it is wd1 or
anything eles?
well, the numbers aren't picked randomly -- see start of
http://www.openbsd.org/faq/faq14.html
If you know your computer (and read that article a few times with no
preconceptions), you can predict what the next hard disk name will be.
Post by Indunil Jayasooriya
In Linux, Fdisk -l show all the available hard disks. In OpenBSD what's the
command for it?
One of linux's many non-charming displays.


Try this:

$ sysctl hw.diskcount
hw.diskcount=9

$ sysctl hw.disknames
hw.disknames=sd0:4b8432d7819c0c85,cd0:,sd1:954c43c63da1e128,sd2:d9f3f58824ed9e20,sd3:4b8432d7819c0c85,sd4:ef8be159ad6b717f,sd5:eb3971fada5612b9,sd6:e4fc87e6abfa5e45,sd7:e92e54806f9e4124

In case you are wondering...that's a six physical disks and a couple
softraid disks on a sun e250.

(do a "sysctl hw" on your machine...in many cases, you will be amazed)

Or use duids, and don't worry 'bout names. Keep reading in the above
link. :)

Nick.
Wesley
2012-12-21 04:37:39 UTC
Permalink
Hi,

you can try this :


/usr/sbin/sysctl hw.disknames

Cheers,
Wesley
Post by Indunil Jayasooriya
HI,
I would like to know How to list available all hard disks in OpenBSD ?
If I run below 2 commands, it will give an output.
dmesg |grep wd0
fdisk wd0
If I install a new Hard Disk, How to get to know whether it is wd1 or
anything eles?
In Linux, Fdisk -l show all the available hard disks. In OpenBSD what's the
command for it?
Indunil Jayasooriya
2012-12-21 04:46:04 UTC
Permalink
Hi misc

Thanks a lot
Post by Wesley
Hi,
/usr/sbin/sysctl hw.disknames
Cheers,
Wesley
HI,
Post by Indunil Jayasooriya
I would like to know How to list available all hard disks in OpenBSD ?
If I run below 2 commands, it will give an output.
dmesg |grep wd0
fdisk wd0
If I install a new Hard Disk, How to get to know whether it is wd1 or
anything eles?
In Linux, Fdisk -l show all the available hard disks. In OpenBSD what's the
command for it?
--
Thank you
Indunil Jayasooriya
Raymond Lillard
2012-12-21 05:16:26 UTC
Permalink
Hi,

Sometimes I just can't let well enough alone ;-)

Add this to your .profile

Fdisk-l () { sysctl hw.disknames | sed -e 's/[,=]/\
/g' ; }



From my laptop command line:

***@smag {~} Fdisk-l
hw.disknames
sd0:f07ccfaba910bc8e
cd0:
sd1:21a268bf64300a23
***@smag {~} vi .profile


just to feel at home ;-)

BTW, I've never seen the command "Fdisk -l" and the
"fdisk -l" I know requires a device name to list
the device's partition table.

Knowing Linux though, it wouldn't surprise me to
hear that some distro has a Fdisk command that
behaves as you describe.

Best,
Ray
Post by Indunil Jayasooriya
Hi misc
Thanks a lot
Post by Wesley
Hi,
/usr/sbin/sysctl hw.disknames
Cheers,
Wesley
HI,
Post by Indunil Jayasooriya
I would like to know How to list available all hard disks in OpenBSD ?
If I run below 2 commands, it will give an output.
dmesg |grep wd0
fdisk wd0
If I install a new Hard Disk, How to get to know whether it is wd1 or
anything eles?
In Linux, Fdisk -l show all the available hard disks. In OpenBSD what's the
command for it?
--
Thank you
Indunil Jayasooriya
Alexander Hall
2012-12-21 06:29:31 UTC
Permalink
Post by Indunil Jayasooriya
HI,
I would like to know How to list available all hard disks in OpenBSD ?
If I run below 2 commands, it will give an output.
dmesg |grep wd0
fdisk wd0
If I install a new Hard Disk, How to get to know whether it is wd1 or
anything eles?
In Linux, Fdisk -l show all the available hard disks. In OpenBSD what's the
command for it?
$ sysctl -n hw.disknames
cd0:,sd0:3ae78cd65d4ba8f8

$ sysctl -n hw.disknames | sed 's/:[^,]*//g;s/,/ /'
cd0 sd0

and also see hotplugd(8)

/Alexander
Alexander Hall
2012-12-21 09:23:12 UTC
Permalink
Post by Indunil Jayasooriya
Post by Indunil Jayasooriya
HI,
I would like to know How to list available all hard disks in OpenBSD
?
Post by Indunil Jayasooriya
If I run below 2 commands, it will give an output.
dmesg |grep wd0
fdisk wd0
If I install a new Hard Disk, How to get to know whether it is wd1 or
anything eles?
In Linux, Fdisk -l show all the available hard disks. In OpenBSD
what's the
Post by Indunil Jayasooriya
command for it?
$ sysctl -n hw.disknames
cd0:,sd0:3ae78cd65d4ba8f8
$ sysctl -n hw.disknames | sed 's/:[^,]*//g;s/,/ /'
cd0 sd0
and also see hotplugd(8)
...and add a 'g' at the appropriate place in the sed expression...
Continue reading on narkive:
Loading...