1disks(1M) System Administration Commands disks(1M)
2
3
4
6 disks - creates /dev entries for hard disks attached to the system
7
9 /usr/sbin/disks [-C] [-r rootdir]
10
11
13 devfsadm(1M) is now the preferred command for /dev and should be used
14 instead of disks.
15
16
17 disks creates symbolic links in the /dev/dsk and /dev/rdsk directories
18 pointing to the actual disk device special files under the /devices
19 directory tree. It performs the following steps:
20
21 1. disks searches the kernel device tree to see what hard disks
22 are attached to the system. It notes the /devices pathnames
23 for the slices on the drive and determines the physical com‐
24 ponent of the corresponding /dev/dsk or /dev/rdsk name.
25
26 2. The /dev/dsk and /dev/rdsk directories are checked for disk
27 entries − that is, symbolic links with names of the form
28 cN[tN]dNsN, or cN[tN]dNpN, where N represents a decimal num‐
29 ber. cN is the logical controller number, an arbitrary num‐
30 ber assigned by this program to designate a particular disk
31 controller. The first controller found on the first occasion
32 this program is run on a system, is assigned number 0. tN is
33 the bus-address number of a subsidiary controller attached
34 to a peripheral bus such as SCSI or IPI (the target number
35 for SCSI, and the facility number for IPI controllers). dN
36 is the number of the disk attached to the controller. sN is
37 the slice number on the disk. pN is the FDISK partition num‐
38 ber used by fdisk(1M). (x86 Only)
39
40 3. If only some of the disk entries are found in /dev/dsk for a
41 disk that has been found under the /devices directory tree,
42 disks creates the missing symbolic links. If none of the
43 entries for a particular disk are found in /dev/dsk, disks
44 checks to see if any entries exist for other disks attached
45 to the same controller, and if so, creates new entries using
46 the same controller number as used for other disks on the
47 same controller. If no other /dev/dsk entries are found for
48 slices of disks belonging to the same physical controller as
49 the current disk, disks assigns the lowest-unused controller
50 number and creates entries for the disk slices using this
51 newly-assigned controller number.
52
53
54 disks is run automatically each time a reconfiguration-boot is per‐
55 formed or when add_drv(1M) is executed. When invoking disks manually,
56 first run drvconfig(1M) to ensure /devices is consistent with the cur‐
57 rent device configuration.
58
59 Notice to Driver Writers
60 disks considers all devices with a node type of DDI_NT_BLOCK,
61 DDI_NT_BLOCK_CHAN, DDI_NT_CD, DDI_NT_BLOCK_WWN or DDI_NT_CD_CHAN to be
62 disk devices. disks requires the minor name of disk devices obey the
63 following format conventions.
64
65
66 The minor name for block interfaces consists of a single lowercase
67 ASCII character, a through u, representing the slices and the primary
68 partitions. The minor name for logical drive block interfaces consists
69 of the strings p5 through p36. The minor name for character (raw)
70 interfaces consists of a single lowercase ASCII character, a through a,
71 followed by the string ,raw, representing the slices and the primary
72 partitions. The minor name for logical drive character (raw) interfaces
73 consists of the string p5 through p36 followed by ,raw.
74
75
76 disks performs the following translations:
77
78 o a through p to s0 through s15
79
80 o q through u to p0 through p4
81
82 o p5 through p36 to p5 through p36
83
84
85 SPARC drivers should only use the first eight slices: a through h,
86 while x86 drivers can use a through u, with q through u corresponding
87 to fdisk(1M) primary partitions. q represents the entire disk, while r,
88 s, t, and u represent up to four additional primary partitions. For
89 logical drives, p5 to p36 correspond to the 32 logical drives that are
90 supported. The device nodes for logical drives change dynamically as
91 and when they are created or deleted.
92
93
94 To prevent disks from attempting to automatically generate links for a
95 device, drivers must specify a private node type and refrain from using
96 a node type: DDI_NT_BLOCK, DDI_NT_BLOCK_CHAN, DDI_NT_CD, or
97 DDI_NT_CD_CHAN when calling ddi_create_minor_node(9F).
98
100 The following options are supported:
101
102 -C Causes disks to remove any invalid links after adding any
103 new entries to /dev/dsk and /dev/rdsk. Invalid links are
104 links which refer to non-existent disk nodes that have
105 been removed, powered off, or are otherwise inaccessible.
106
107
108 -r rootdir Causes disks to presume that the /dev/dsk, /dev/rdsk and
109 /devices directory trees are found under rootdir, not
110 directly under /.
111
112
114 If disks finds entries of a particular logical controller linked to
115 different physical controllers, it prints an error message and exits
116 without making any changes to the /dev directory, since it cannot
117 determine which of the two alternative logical-to-physical mappings is
118 correct. The links should be manually corrected or removed before
119 another reconfiguration-boot is performed.
120
122 Example 1 Creating Block and Character Minor Devices
123
124
125 The following example demonstrates creating the block and character
126 minor devices from within the xkdisk driver's attach(9E) function.
127
128
129 #include <sys/dkio.h>
130 /*
131 * Create the minor number by combining the instance number
132 * with the slice number.
133 */
134 #define MINOR_NUM(i, s) ((i) << 4 | (s))
135
136 int
137 xkdiskattach(dev_info_t *dip, ddi_attach_cmd_t cmd)
138 {
139 int instance, slice;
140 char name[8];
141
142 /* other stuff in attach... */
143
144 instance = ddi_get_instance(dip);
145 for (slice = 0; slice < V_NUMPAR; slice++) {
146 /*
147 * create block device interface
148 */
149 sprintf(name, "%c", slice + 'a');
150 ddi_create_minor_node(dip, name, S_IFBLK,
151 MINOR_NUM(instance, slice), DDI_NT_BLOCK_CHAN, 0);
152
153 /*
154 * create the raw (character) device interface
155 */
156 sprintf(name,"%c,raw", slice + 'a');
157 ddi_create_minor_node(dip, name, S_IFCHR,
158 MINOR_NUM(instance, slice), DDI_NT_BLOCK_CHAN, 0);
159 }
160 }
161
162
163
164 Installing the xkdisk disk driver on a Sun Fire 4800, with the driver
165 controlling a SCSI disk (target 3 attached to an isp(7D) SCSI HBA) and
166 performing a reconfiguration-boot (causing disks to be run) creates the
167 following special files in /devices.
168
169
170 # ls -l /devices/ssm@0,0/pci@18,700000/pci@1/SUNW,isptwo@4/
171 brw-r----- 1 root sys 32, 16 Aug 29 00:02 xkdisk@3,0:a
172 crw-r----- 1 root sys 32, 16 Aug 29 00:02 xkdisk@3,0:a,raw
173 brw-r----- 1 root sys 32, 17 Aug 29 00:02 xkdisk@3,0:b
174 crw-r----- 1 root sys 32, 17 Aug 29 00:02 xkdisk@3,0:b,raw
175 brw-r----- 1 root sys 32, 18 Aug 29 00:02 xkdisk@3,0:c
176 crw-r----- 1 root sys 32, 18 Aug 29 00:02 xkdisk@3,0:c,raw
177 brw-r----- 1 root sys 32, 19 Aug 29 00:02 xkdisk@3,0:d
178 crw-r----- 1 root sys 32, 19 Aug 29 00:02 xkdisk@3,0:d,raw
179 brw-r----- 1 root sys 32, 20 Aug 29 00:02 xkdisk@3,0:e
180 crw-r----- 1 root sys 32, 20 Aug 29 00:02 xkdisk@3,0:e,raw
181 brw-r----- 1 root sys 32, 21 Aug 29 00:02 xkdisk@3,0:f
182 crw-r----- 1 root sys 32, 21 Aug 29 00:02 xkdisk@3,0:f,raw
183 brw-r----- 1 root sys 32, 22 Aug 29 00:02 xkdisk@3,0:g
184 crw-r----- 1 root sys 32, 22 Aug 29 00:02 xkdisk@3,0:g,raw
185 brw-r----- 1 root sys 32, 23 Aug 29 00:02 xkdisk@3,0:h
186 crw-r----- 1 root sys 32, 23 Aug 29 00:02 xkdisk@3,0:h,raw
187
188
189
190 /dev/dsk will contain the disk entries to the block device nodes in
191 /devices
192
193
194 # ls -l /dev/dsk
195 /dev/dsk/c0t3d0s0 -> ../../devices/[...]/xkdisk@3,0:a
196 /dev/dsk/c0t3d0s1 -> ../../devices/[...]/xkdisk@3,0:b
197 /dev/dsk/c0t3d0s2 -> ../../devices/[...]/xkdisk@3,0:c
198 /dev/dsk/c0t3d0s3 -> ../../devices/[...]/xkdisk@3,0:d
199 /dev/dsk/c0t3d0s4 -> ../../devices/[...]/xkdisk@3,0:e
200 /dev/dsk/c0t3d0s5 -> ../../devices/[...]/xkdisk@3,0:f
201 /dev/dsk/c0t3d0s6 -> ../../devices/[...]/xkdisk@3,0:g
202 /dev/dsk/c0t3d0s7 -> ../../devices/[...]/xkdisk@3,0:h
203
204
205
206 and /dev/rdsk will contain the disk entries for the character device
207 nodes in /devices
208
209
210 # ls -l /dev/rdsk
211 /dev/rdsk/c0t3d0s0 -> ../../devices/[...]/xkdisk@3,0:a,raw
212 /dev/rdsk/c0t3d0s1 -> ../../devices/[...]/xkdisk@3,0:b,raw
213 /dev/rdsk/c0t3d0s2 -> ../../devices/[...]/xkdisk@3,0:c,raw
214 /dev/rdsk/c0t3d0s3 -> ../../devices/[...]/xkdisk@3,0:d,raw
215 /dev/rdsk/c0t3d0s4 -> ../../devices/[...]/xkdisk@3,0:e,raw
216 /dev/rdsk/c0t3d0s5 -> ../../devices/[...]/xkdisk@3,0:f,raw
217 /dev/rdsk/c0t3d0s6 -> ../../devices/[...]/xkdisk@3,0:g,raw
218 /dev/rdsk/c0t3d0s7 -> ../../devices/[...]/xkdisk@3,0:h,raw
219
220
222 /dev/dsk/* Disk entries (block device interface)
223
224
225 /dev/rdsk/* Disk entries (character device interface)
226
227
228 /devices/* Device special files (minor device nodes)
229
230
232 See attributes(5) for descriptions of the following attributes:
233
234
235
236
237 ┌─────────────────────────────┬─────────────────────────────┐
238 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
239 ├─────────────────────────────┼─────────────────────────────┤
240 │Availability │SUNWcsu │
241 └─────────────────────────────┴─────────────────────────────┘
242
244 add_drv(1M), devfsadm(1M), fdisk(1M), attributes(5), isp(7D),
245 devfs(7FS), dkio(7I), attach(9E), ddi_create_minor_node(9F)
246
247
248
249
251 disks silently ignores malformed minor device names.
252
253
254
255SunOS 5.11 2 Jul 2009 disks(1M)