Which disk device to use for fdisk?

OpenSolaris uses quite an interesting format to describe disk devices which originates from the SPARC world and it may be very confusing to anyone who tries to understand Solaris disk devices on x86 or x64. You've probably seen strings such as "c0t0d0s0" before. Until recently I had a hard time to figure out which devices are available on my computer. For example if I want to run fdisk, I need to know the disk device file name. So I studied the format of the string and found out that:

c# - this is the number of the controller (you need to find out which number it is on your machine)
t# - this is the target number (number of the device on controller - with IDE this is generally determined by the device's position on the IDE cable, it may be left out completely e.g. on SATA drives)
d# - this is the logical unit (used for SCSI, 0 for IDE disk drives)
s# - number of the slice (used on SPARC), on PC IDE drives p# is used instead to specify a partition number (p0 = all partitions, p1 = partition 1, etc.)

So I learned all the theory but still had little success when finding out what is the device name of my hard disk drive on my laptop. Finally I found out that I can use the format command to see all available disk devices:

$ pfexec format

The output is following on my laptop:

Searching for disks...done

       0. c6d0 <DEFAULT cyl 10114 alt 2 hd 255 sec 63>
Specify disk (enter its number):

So I can see that my controller number is 6 and my logical number is 0. Right now I could have guessed that the device I am looking for is c6d0p0, but I verify my assumption by running:

$ ls -l /dev/rdsk/c6\*p0

(give me all devices on controller 6 with partition p0 - whole disk devices only)

The output is:

lrwxrwxrwx 1 root root 55 2008-04-22 23:21 /dev/rdsk/c6d0p0 -> ../../devices/pci@0,0/pci-ide@1f,2/ide@0/cmdk@0,0:q,raw

So the disk device to use for fdisk is /dev/rdsk/c6d0p0 - that denotes the whole c6d0 disk. Hurray, I found out which disk device to use for fdisk!

Btw, you may have noticed that I am using /dev/rdsk for fdisk, not /dev/dsk. For every disk device, there are usually two device files - the block device and the character ("raw") device. In general:

  • block devices are generally stored under /dev/dsk and used for filesystem type access (e.g mount)
  • character devices are generally stored under /dev/rdsk used for everything else (e.g. fsck, fdisk, etc..)
Hopefully this gives you some insights about the strange disk device names in OpenSolaris (and note there are some differences on SPARC - this blog discusses only x86 or x64 systems).

rmformat(1) is the equivalent of format(1M) for removable media - just mentioning in case you guys think it might be an interesting follow up post ;)

Posted by Rafael Vanoni on July 08, 2008 at 05:40 AM GMT #

Thanks for the suggestion, yes, rmformat is definitely interesting for a follow-up post :)

Posted by Roman Strobl on July 08, 2008 at 05:43 AM GMT #


N.B. iostat -En

As a side note, we could prob sync our ideas between our blog's as we seem to be writing about the same topics to the same kind of audience? See URL \^\^

Best Regards,

Posted by EdwardOCallaghan on July 08, 2008 at 05:52 AM GMT #

Hmm, iostat -En gives even vendor names, cool :) How do you want to sync the ideas?

Posted by Roman Strobl on July 08, 2008 at 06:14 AM GMT #

# format -e
also see the disks as seen via rmformat

Posted by guest on July 08, 2008 at 08:48 AM GMT #

This is a really good guide to disk devices on Solaris. Can I include it on my little Solaris website? Obviously I would credit you. The address is sites.google.com/solarium .

Posted by andrewk8 on July 10, 2008 at 12:12 PM GMT #

Sure, you can include it, just provide a link back to The Observatory.

Posted by Roman Strobl on July 10, 2008 at 02:42 PM GMT #

Above you state:

s# - number of the slice (used on SPARC)

However, if I run a zpool status, it shows the disk in use as C4d0s0. Shouldn't it be C4d0p0? What gives?


Posted by Brian Leonard on July 15, 2008 at 08:56 AM GMT #

No idea.

Posted by Roman Strobl on July 15, 2008 at 09:36 AM GMT #

In reference to Brian Leonard's comment, the s# stuff is not only used on SPARC. The s# token in the device name refers to a subdivision (slice) of the fdisk partition (in this case c4d0p0) containing Solaris. On my OpenSolaris 2008.05 there are three slices (s0 contains the ZFS filesystem, s1 the swap area and s8 the "boot" partition).

Posted by Rand Huntzinger on July 21, 2008 at 06:39 AM GMT #

test comment

Posted by guest on July 23, 2008 at 11:11 AM GMT #

FYI, another excellent resource on this topic is by Johan Hartzenberg: http://initialprogramload.blogspot.com/2008/07/how-solaris-disk-device-names-work.html

Posted by Gregg Sporar on August 05, 2008 at 08:35 AM GMT #

Post a Comment:
  • HTML Syntax: NOT allowed

The Observatory is a blog for users of Oracle Solaris. Tune in here for tips, tricks and more as we explore the Solaris operating system from Oracle.

Connect with Oracle Solaris:


« April 2014