]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - sbin/sunlabel/sunlabel.8
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / sbin / sunlabel / sunlabel.8
1 .\" Copyright (c) 2004
2 .\"     David E. O'Brien.  All rights reserved.
3 .\" Copyright (c) 2004, 2005
4 .\"     Joerg Wunsch.  All rights reserved.
5 .\"
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
8 .\" are met:
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\"    notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\"    notice, this list of conditions and the following disclaimer in the
13 .\"    documentation and/or other materials provided with the distribution.
14 .\"
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 .\" SUCH DAMAGE.
26 .\"
27 .\" $FreeBSD$
28 .\"
29 .Dd March 30, 2005
30 .Dt SUNLABEL 8
31 .Os
32 .Sh NAME
33 .Nm sunlabel
34 .Nd read and write disk pack label suitable for Sun's OpenBoot PROM
35 .Sh SYNOPSIS
36 .Nm
37 .Op Fl r
38 .Op Fl c No \&| Fl h
39 .Ar disk
40 .Nm
41 .Fl B
42 .Op Fl b Ar boot1
43 .Op Fl n
44 .Ar disk
45 .Nm
46 .Fl R
47 .Op Fl B Op Fl b Ar boot1
48 .Op Fl r
49 .Op Fl n
50 .Op Fl c
51 .Ar disk protofile
52 .Nm
53 .Fl e
54 .Op Fl B Op Fl b Ar boot1
55 .Op Fl r
56 .Op Fl n
57 .Op Fl c
58 .Ar disk
59 .Nm
60 .Fl w
61 .Op Fl B Op Fl b Ar boot1
62 .Op Fl r
63 .Op Fl n
64 .Op Fl c
65 .Ar disk type
66 .Sh DESCRIPTION
67 The
68 .Nm
69 utility
70 installs, examines or modifies the
71 .Em Sun OpenBoot PROM
72 label on a disk.
73 In addition,
74 .Nm
75 can install bootstrap code.
76 .Ss Introduction
77 The label occupies the first sector (i.e., 512 bytes) of each disk.
78 It starts with a textual description which by convention also mentions
79 the disk geometry in textual form (number of cylinders, alternate
80 cylinders, heads, and sectors per track), optionally followed by a
81 table of SVR4-compatible VTOC tags and flags per partition, followed
82 by the partition table itself.
83 Finally, a checksum is recorded to ensure the label has not been
84 tampered with.
85 .Pp
86 The
87 .Em Sun OpenBoot PROM
88 label allows for 8 disk partitions.
89 The partition table lists the starting cylinder of the partition,
90 plus the size of the partition in 512-byte sectors.
91 Thus, partitions in the
92 .Em Sun OpenBoot PROM
93 must always start at a cylinder boundary (for whatever geometry
94 emulation has been chosen).
95 .Pp
96 The optional SVR4-compatible VTOC tag and flags table is not used
97 by the
98 .Fx
99 kernel.
100 It is maintained solely for compatibilty with the
101 .Tn Solaris
102 operating system that might share disks with
103 .Fx
104 on the same hardware platform.
105 .Pp
106 The
107 .Em Sun OpenBoot PROM
108 label is natively understood by the underlying hardware, which can
109 bootstrap from a single partition entry, as opposed to the very first
110 block(s) of the entire disk as on many other hardware platforms.
111 .Pp
112 Note that the hardware platform mandates that two cylinders are set
113 aside as
114 .Em alternate cylinders
115 which are not available to user programs (and not even through the
116 .Dq Li backup
117 partition).
118 .Ss Options
119 Options are listed in alphabetical order here.
120 Note that only those option combinations listed under
121 .Sx SYNOPSIS
122 are allowable.
123 .Pp
124 .Bl -tag -width ".Fl b Ar bootpath"
125 .It Fl b Ar bootpath
126 Specify that
127 .Ar bootpath
128 is to be used as the boot image, rather than the default of
129 .Pa /boot/boot1 .
130 .It Fl B
131 Install bootstrap code onto the disk.
132 Note that since the underlying hardware platform bootstraps from
133 partitions, not disks, this operation is only useful if there is
134 a partition starting at offset 0.
135 .It Fl c
136 Use cylinders for partition size display rather than
137 (512-byte) sectors.
138 This also changes the default interpretation of the partition
139 size entries when editing the label, or reading from a prototype
140 file.
141 Thus, prototype files are only compatible when both, obtaining
142 the file and re-installing it is done using the same
143 .Fl c
144 option setting.
145 .It Fl e
146 Enter edit mode.
147 See
148 .Sx Edit mode
149 below for a more detailed explanation.
150 .It Fl h
151 When displaying the label, make the partition size and offset
152 values
153 .Dq human readable .
154 The displayed numbers will get a suffix of
155 .Ql B
156 for bytes,
157 .Ql K
158 for 1024 bytes each,
159 .Ql M
160 for 1048576 bytes each, or
161 .Ql G
162 for 1073741824 bytes each appended.
163 Note that due to possible rounding errors, prototype files
164 obtained using the
165 .Fl h
166 option are not suited for re-installing using the
167 .Fl R
168 option.
169 .It Fl n
170 No changes.
171 All operations, checks etc., are performed normally, but nothing
172 is written to disk.
173 .It Fl r
174 Obsolete option that used to indicate that the operation should
175 be done directly on disk, as opposed through the respective kernel
176 services.
177 Ignored.
178 .It Fl R
179 Restore label from the prototype in
180 .Ar protofile .
181 A prototype file is simply the textual representation of the
182 label as printed using the first form of the
183 .Nm
184 utility shown in the
185 .Sx SYNOPSIS .
186 Note that the
187 .Fl c
188 option used to obtain the prototype must match the option used
189 when restoring the label (both present, or both absent).
190 .It Fl w
191 Write mode.
192 Suitable to write an initial label to disk.
193 The
194 .Ar type
195 argument used to be an entry into a table of predefined labels,
196 but this functionality is not supported by
197 .Nm .
198 Instead, the only allowable
199 .Ar type
200 argument is the string
201 .Dq Li auto ,
202 indicating that an automatically created label should be written
203 to disk.
204 This automatism will try to create an initial label that fits as
205 best as possible into the available disk capacity.
206 .El
207 .Pp
208 If neither of the
209 .Fl e , R ,
210 or
211 .Fl w
212 options are present, the existing label for
213 .Ar disk
214 will be printed to standard output.
215 .Pp
216 The
217 .Ar disk
218 argument
219 must be given as a plain disk name, without any leading
220 .Pa /dev/ .
221 .Ss Edit mode
222 In edit mode, the existing label from
223 .Ar disk
224 will be read, and put into a template file.
225 The command referenced by the
226 .Ev EDITOR
227 environmental variable will be started to allow the user
228 to edit the label.
229 The label is then checked and examined for any errors.
230 If no errors have been found, the new label is written to disk.
231 If there were any errors, a message is printed to standard
232 error output, and the user is given the opportunity to edit
233 the template file again.
234 If accepted, editing starts over.
235 If declined, no changes will
236 be written to disk.
237 .Pp
238 The label presented for editing is the same as the standard
239 printout, with some added hints about the possible options to
240 specify the sector size and starting cylinder.
241 The following areas in the template can be edited:
242 .Bl -tag -width indent
243 .It Sy Textual label, geometry emulation
244 The line
245 .D1 Li text: Ar XXXX Li cyl Ar CC Li alt 2 hd Ar HH Li sec Ar SS
246 represents the label text.
247 It must be retained exactly in the form shown.
248 The editable text
249 .Ar XXXX
250 is a simple (non-whitespace) text describing the disk.
251 By convention, this text mentions the approximate size of the
252 disk, as in
253 .Dq Li SUN9.0G
254 for a 9 GB disk shipped by Sun.
255 .Pp
256 The values
257 .Ar CC ,
258 .Ar HH ,
259 and
260 .Ar SS
261 describe the number of cylinders, heads (tracks per
262 cylinder), and sectors per track respectively.
263 They might be modified to change the geometry emulation.
264 Each number must be between 1 and 65535.
265 The product
266 .D1 Em (CC + 2) * HH * SS
267 must be less than or equal to the total number of sectors of the
268 disk (which is given as a hint in a comment field).
269 .It Sy Volume name
270 The volume name (if present) is introduced by the string
271 .Dq "volume name:" .
272 It can be up to 8 characters long, and might be useful to distinguish
273 different disks in a system.
274 Note that volume names require the VTOC elements to be present, so
275 any of the VTOC constraints described below need to be obeyed as well
276 if a volume name is to be set.
277 Setting an empty volume name will delete it from the label.
278 .It Sy Partition entries
279 Partition entries start with a letter from
280 .Ql a
281 through
282 .Ql h ,
283 immediately followed by a colon, followed by the size of this
284 partition, and the starting cylinder of the partition.
285 The unit of the size field defaults to sectors, or to cylinders
286 if the
287 .Fl c
288 option is in effect.
289 Alternatively, a different unit may be specified by appending
290 .Ql s
291 for (512-byte) sectors,
292 .Ql c
293 for cylinders,
294 .Ql k
295 for kilobytes,
296 .Ql m
297 for megabytes, or
298 .Ql g
299 for gigabytes.
300 The last partition entry may specify the size as
301 .Ql *
302 to indicate that this entry should consume the rest of disk not
303 consumed by any other partition so far.
304 .Pp
305 The start of partition is always taken as a cylinder number (starting
306 at 0) since this is what the underlying hardware uses.
307 Alternatively, specifying it as
308 .Ql *
309 will make the computation automatically chose the nearest possible
310 cylinder boundary.
311 .Pp
312 Partition
313 .Ql c
314 must always be present, must start at 0, and must cover the entire
315 disk (without considering the alternate cylinders though).
316 .Pp
317 Optionally, each partition entry may be followed by an SVR4-compatible
318 VTOC tag name, and a flag description.
319 The following VTOC tag names are known:
320 .Bl -column -offset indent ".Li unassigned" ".Sy value" ".Sy comment"
321 .It Sy name Ta Sy value Ta Sy comment
322 .It Li unassigned Ta No 0x00
323 .It Li boot Ta No 0x01
324 .It Li root Ta No 0x02
325 .It Li swap Ta No 0x03
326 .It Li usr Ta No 0x04
327 .It Li backup Ta No 0x05 Ta c partition, entire disk
328 .It Li stand Ta No 0x06
329 .It Li var Ta No 0x07
330 .It Li home Ta No 0x08
331 .It Li altsctr Ta No 0x09 Ta alternate sector partition
332 .It Li cache Ta No 0x0a Ta Solaris cachefs partition
333 .It Li VxVM_pub Ta No 0x0e Ta VxVM public region
334 .It Li VxVM_priv Ta No 0x0f Ta VxVM private region
335 .El
336 .Pp
337 The following VTOC flags are known:
338 .Bl -column -offset indent ".Sy name" ".Sy value" ".Sy comment"
339 .It Sy name Ta Sy value Ta Sy comment
340 .It Li wm Ta No 0x00 Ta read/write, mountable
341 .It Li wu Ta No 0x01 Ta read/write, unmountable
342 .It Li rm Ta No 0x10 Ta read/only, mountable
343 .It Li ru Ta No 0x11 Ta read/only, unmountable
344 .El
345 .Pp
346 Optionally, both the tag and/or the flag name may be specified
347 numerically, using standard
348 .Ql C
349 numerial notation (prefix
350 .Ql 0x
351 for hexadecimal numbers,
352 .Ql 0
353 for octal numbers).
354 If the flag field is omitted, it defaults to
355 .Ql wm .
356 If the tag field is also omitted, it defaults to
357 .Dq Li unassigned .
358 If none of the partitions lists any VTOC tag/flags, no
359 SVR4-compatible VTOC elements will be written to disk.
360 If VTOC-style elements are present, partition
361 .Ql c
362 must be marked as
363 .Dq Li backup
364 (and should be marked
365 .Ql wu ) .
366 .El
367 .Pp
368 When checking the label, partition
369 .Ql c
370 is checked for presence, and for the mentioned restrictions.
371 All other partitions are checked for possible overlaps, as
372 well as for not extending past the end of unit.
373 If VTOC-style elements are present, overlaps of unmountable
374 partitions against other partitions will be warned still but
375 do not cause a rejection of the label.
376 That way,
377 .Em encapsulated disks
378 of volume management software are acceptable as long as the
379 volume management partitions are clearly marked as unmountable.
380 .Pp
381 Any other fields in the label template are informational only,
382 and will not be parsed when reading the label.
383 .Pp
384 Note that when changing the geometry emulation by editing the
385 textual description line, all partition entries will be
386 considered based on the new geometry emulation.
387 .Sh ENVIRONMENT
388 .Bl -tag -width ".Ev EDITOR" -compact
389 .It Ev EDITOR
390 Name of the command to edit the template file in edit-mode.
391 Defaults to
392 .Xr vi 1 .
393 .El
394 .Sh FILES
395 .Bl -tag -width ".Pa /boot/boot1" -compact
396 .It Pa /boot/boot1
397 Default boot image.
398 .El
399 .Sh SEE ALSO
400 .Xr vi 1 ,
401 .Xr geom 4 ,
402 .Xr bsdlabel 8
403 .Sh HISTORY
404 The
405 .Nm
406 utility appeared in
407 .Fx 5.1 .
408 .Sh AUTHORS
409 The
410 .Nm
411 utility was written by
412 .An Jake Burkholder ,
413 modeling it after the
414 .Xr bsdlabel 8
415 command available on other architectures.
416 .Pp
417 .An -nosplit
418 This man page was initially written by
419 .An David O'Brien ,
420 and later substantially updated by
421 .An J\(:org Wunsch .
422 .Sh BUGS
423 Installing bootstrap code onto an entire disk is merely pointless.
424 .Nm
425 should rather support installing bootstrap code into a partition
426 instead.
427 .Pp
428 The
429 .Dq auto
430 layout algorithm could be smarter.
431 By now, it tends to emulate fairly large cylinders which due to
432 the two reserved alternate cylinders causes a fair amount of
433 wasted disk space.