6f6090b0a4551c566b62c8d9e3737f9a347ea5a0
[dragonfly.git] / sbin / disklabel / disklabel.8
1 .\" Copyright (c) 1987, 1988, 1991, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" This code is derived from software contributed to Berkeley by
5 .\" Symmetric Computer Systems.
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\"    notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\"    notice, this list of conditions and the following disclaimer in the
14 .\"    documentation and/or other materials provided with the distribution.
15 .\" 3. All advertising materials mentioning features or use of this software
16 .\"    must display the following acknowledgment:
17 .\"     This product includes software developed by the University of
18 .\"     California, Berkeley and its contributors.
19 .\" 4. Neither the name of the University nor the names of its contributors
20 .\"    may be used to endorse or promote products derived from this software
21 .\"    without specific prior written permission.
22 .\"
23 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 .\" SUCH DAMAGE.
34 .\"
35 .\"     @(#)disklabel.8 8.2 (Berkeley) 4/19/94
36 .\" $FreeBSD: src/sbin/disklabel/disklabel.8,v 1.15.2.22 2003/04/17 17:56:34 trhodes Exp $
37 .\" $DragonFly: src/sbin/disklabel/disklabel.8,v 1.7 2006/02/17 19:33:32 swildner Exp $
38 .\"
39 .Dd July 30, 1999
40 .Dt DISKLABEL 8
41 .Os
42 .Sh NAME
43 .Nm disklabel
44 .Nd read and write disk pack label
45 .Sh SYNOPSIS
46 .Nm
47 .Op Fl r
48 .Ar disk
49 .Nm
50 .Fl w
51 .Op Fl r
52 .Op Fl n
53 .Ar disk Ar disktype/auto
54 .Oo Ar packid Oc
55 .Nm
56 .Fl e
57 .Op Fl r
58 .Op Fl n
59 .Ar disk
60 .Nm
61 .Fl R
62 .Op Fl r
63 .Op Fl n
64 .Ar disk Ar protofile
65 .Nm
66 .Op Fl NW
67 .Ar disk
68 .Pp
69 .Nm
70 .Fl B
71 .Oo
72 .Fl b Ar boot1
73 .Fl s Ar boot2
74 .Oc
75 .Ar disk
76 .Oo Ar disktype/auto Oc
77 .Nm
78 .Fl w
79 .Fl B
80 .Op Fl n
81 .Oo
82 .Fl b Ar boot1
83 .Fl s Ar boot2
84 .Oc
85 .Ar disk Ar disktype/auto
86 .Oo Ar packid Oc
87 .Nm
88 .Fl R
89 .Fl B
90 .Op Fl n
91 .Oo
92 .Fl b Ar boot1
93 .Fl s Ar boot2
94 .Oc
95 .Ar disk Ar protofile
96 .Oo Ar disktype/auto Oc
97 .Sh DESCRIPTION
98 The
99 .Nm
100 utility
101 installs, examines or modifies the label on a disk drive or pack.  When writing
102 the label, it can be used to change the drive identification, the disk
103 partitions on the drive, or to replace a damaged label.  There are several forms
104 of the command that read (display), install or edit the label on a disk.  In
105 addition,
106 .Nm
107 can install bootstrap code.
108 .Ss Raw or in-core label
109 The disk label resides close to or at the beginning of each disk slice.
110 For faster access, the kernel maintains a copy in core at all times.  By
111 default, most forms of the
112 .Nm
113 command access the in-core copy of the label.  To access the raw (on-disk)
114 copy, use the
115 .Fl r
116 option.  This option allows a label to be installed on a disk without kernel
117 support for a label, such as when labels are first installed on a system; it
118 must be used when first installing a label on a disk.  The specific effect of
119 .Fl r
120 is described under each command.
121 .Pp
122 .Ss Disk device name
123 All
124 .Nm
125 forms require a disk device name, which should always be the raw
126 device name representing the disk or slice.  For example
127 .Pa da0
128 represents the entire disk regardless of any DOS partitioning,
129 and
130 .Pa da0s1
131 represents a slice.  Some devices, most notably
132 .Ar ccd ,
133 require that the
134 .Dq whole-disk
135 (or
136 .Dq c )
137 partition be specified.  For example
138 .Pa ccd0c .
139 You do not have to include the
140 .Pa /dev/
141 path prefix when specifying the device.
142 The
143 .Nm
144 utility will automatically prepend it.
145 .Ss Reading the disk label
146 To examine the label on a disk drive, use
147 .Nm
148 without options:
149 .Pp
150 .Nm
151 .Op Fl r
152 .Ar disk
153 .Pp
154 .Ar disk
155 represents the raw disk in question, and may be in the form
156 .Pa da0
157 or
158 .Pa /dev/da0c .
159 It will display all of the parameters associated with the drive and its
160 partition layout.  Unless the
161 .Fl r
162 flag is given,
163 the kernel's in-core copy of the label is displayed;
164 if the disk has no label, or the partition types on the disk are incorrect,
165 the kernel may have constructed or modified the label.
166 If the
167 .Fl r
168 flag is given,
169 .Nm
170 reads the label from the raw disk and displays it.  Both versions are usually
171 identical except in the case where a label has not yet been initialized or
172 is corrupt.
173 .Ss Writing a standard label
174 To write a standard label, use the form
175 .Pp
176 .Nm
177 .Fl w
178 .Op Fl r
179 .Op Fl n
180 .Ar disk Ar disktype/auto
181 .Oo Ar packid Oc
182 .Pp
183 .Nm
184 .Fl w
185 .Op Fl r
186 .Op Fl n
187 .Ar disk
188 auto
189 .Pp
190 The required arguments to
191 .Nm
192 are the drive to be labeled and the drive type as described in the
193 .Xr disktab 5
194 file.  The drive parameters and partitions are taken from that file.  If
195 different disks of the same physical type are to have different partitions, it
196 will be necessary to have separate disktab entries describing each, or to edit
197 the label after installation as described below.  The optional argument is a
198 pack identification string, up to 16 characters long.  The pack id must be
199 quoted if it contains blanks.
200 .Pp
201 If the
202 .Fl n
203 flag is given, no data will be written to the device, and instead the
204 disklabel that would have been written will be printed to stdout.
205 .Pp
206 If the
207 .Fl r
208 flag is given, the disk sectors containing the label and bootstrap
209 will be written directly.
210 A side-effect of this is that any existing bootstrap code will be overwritten
211 and the disk rendered unbootable.  See the boot options below for a method of
212 writing the label and the bootstrap at the same time.
213 If
214 .Fl r
215 is not specified,
216 the existing label will be updated via the in-core copy and any bootstrap
217 code will be unaffected.
218 If the disk does not already have a label, the
219 .Fl r
220 flag must be used.
221 In either case, the kernel's in-core label is replaced.
222 .Pp
223 For a virgin disk that is not known to
224 .Xr disktab 5 ,
225 .Ar disktype
226 can be specified as
227 .Dq auto .
228 In this case, the driver is requested to produce a virgin label for the
229 disk.  This might or might not be successful, depending on whether the
230 driver for the disk is able to get the required data without reading
231 anything from the disk at all.  It will likely succeed for all SCSI
232 disks, most IDE disks, and vnode devices.  Writing a label to the
233 disk is the only supported operation, and the
234 .Ar disk
235 itself must be provided as the canonical name, i.e. not as a full
236 path name.
237 .Pp
238 For most harddisks, a label based on percentages for most partitions (and
239 one partition with a size of
240 .Ql * )
241 will produce a reasonable configuration.
242 .Pp
243 PC-based systems have special requirements in order for the BIOS to properly
244 recognize a
245 .Dx
246 disklabel.  Older systems may require what is known as a
247 .Dq dangerously dedicated
248 disklabel, which creates a fake DOS partition to work around problems older
249 BIOSes have with modern disk geometries.
250 On newer systems you generally want
251 to create a normal DOS partition using
252 .Ar fdisk
253 and then create a
254 .Dx
255 disklabel within that slice.  This is described
256 later on in this page.
257 .Pp
258 Installing a new disklabel does not in of itself allow your system to boot
259 a kernel using that label.  You must also install boot blocks, which is
260 described later on in this manual page.
261 .Ss Editing an existing disk label
262 To edit an existing disk label, use the form
263 .Pp
264 .Nm
265 .Fl e
266 .Op Fl r
267 .Op Fl n
268 .Ar disk
269 .Pp
270 This command reads the label from the in-core kernel copy, or directly from the
271 disk if the
272 .Fl r
273 flag is also specified.  The label is written to a file in ASCII and then
274 supplied to an editor for changes.  If no editor is specified in an
275 .Ev EDITOR
276 environment variable,
277 .Xr vi 1
278 is used.  When the editor terminates, the label file is used to rewrite the disk
279 label.  Existing bootstrap code is unchanged regardless of whether
280 .Fl r
281 was specified.  If
282 .Fl n
283 is specified, no data will be written to the device, and instead the
284 disklabel that would have been written will be printed to stdout.  This is
285 useful to see how a partitioning scheme will work out for a specific disk.
286 .Ss Restoring a disk label from a file
287 To restore a disk label from a file, use the form
288 .Pp
289 .Nm
290 .Fl R
291 .Op Fl r
292 .Op Fl n
293 .Ar disk Ar protofile
294 .Pp
295 .Nm
296 is capable of restoring a disk label that was previously saved in a file in ASCII format.
297 The prototype file used to create the label should be in the same format as that
298 produced when reading or editing a label.  Comments are delimited by
299 .Ar \&#
300 and newline.  As when writing a new label, any existing bootstrap code will be
301 clobbered if
302 .Fl r
303 is specified and will be unaffected otherwise.  See the boot options below for a
304 method of restoring the label and writing the bootstrap at the same time.
305 If
306 .Fl n
307 is used, no data will be written to the device, and instead the
308 disklabel that would have been written will be printed to stdout.  This is
309 useful to see how a partitioning scheme will work out for a specific disk.
310 .Ss Enabling and disabling writing to the disk label area
311 By default, it is not possible to write to the disk label area at the beginning
312 of a disk.  The disk driver arranges for
313 .Xr write 2
314 and similar system calls
315 to return
316 .Er EROFS
317 on any attempt to do so.  If you need
318 to write to this area (for example, to obliterate the label), use the form
319 .Pp
320 .Nm
321 .Fl W
322 .Ar disk
323 .Pp
324 To disallow writing to the label area after previously allowing it, use the
325 command
326 .Pp
327 .Nm
328 .Fl N
329 .Ar disk
330 .Ss Installing bootstraps
331 The final three forms of
332 .Nm
333 are used to install bootstrap code.  If you are creating a
334 .Dq dangerously-dedicated
335 slice for compatibility with older PC systems,
336 you generally want to specify the raw disk name such as
337 .Pa da0 .
338 If you are creating a label within an existing DOS slice,
339 you should specify
340 the partition name such as
341 .Pa da0s1a .
342 Making a slice bootable can be tricky.  If you are using a normal DOS
343 slice you typically install (or leave) a standard MBR on the base disk and
344 then install the
345 .Dx
346 bootblocks in the slice.
347 .Pp
348 .Nm
349 .Fl B
350 .Oo
351 .Fl b Ar boot1
352 .Fl s Ar boot2
353 .Oc
354 .Ar disk
355 .Oo Ar disktype Oc
356 .Pp
357 This form installs the bootstrap only.  It does not change the disk label.
358 You should never use this command on a base disk unless you intend to create a
359 .Dq dangerously-dedicated
360 disk, such as
361 .Ar da0 .
362 This command is typically run on a slice such as
363 .Ar da0s1 .
364 .Pp
365 .Nm
366 .Fl w
367 .Fl B
368 .Op Fl n
369 .Oo
370 .Fl b Ar boot1
371 .Fl s Ar boot2
372 .Oc
373 .Ar disk Ar disktype
374 .Oo Ar packid Oc
375 .Pp
376 This form corresponds to the
377 .Dq write label
378 command described above.
379 In addition to writing a new volume label, it also installs the bootstrap.
380 If run on a base disk this command will create a
381 .Dq dangerously-dedicated
382 label.  This command is normally run on a slice rather than a base disk.
383 If
384 .Fl n
385 is used, no data will be written to the device, and instead the
386 disklabel that would have been written will be printed to stdout.
387 .Pp
388 .Nm
389 .Fl R
390 .Fl B
391 .Op Fl n
392 .Oo
393 .Fl b Ar boot1
394 .Fl s Ar boot2
395 .Oc
396 .Ar disk Ar protofile
397 .Oo Ar disktype Oc
398 .Pp
399 This form corresponds to the
400 .Dq restore label
401 command described above.
402 In addition to restoring the volume label, it also installs the bootstrap.
403 If run on a base disk this command will create a
404 .Dq dangerously-dedicated
405 label.  This command is normally run on a slice rather than a base disk.
406 .Pp
407 The bootstrap commands always access the disk directly, so it is not necessary
408 to specify the
409 .Fl r
410 flag.  If
411 .Fl n
412 is used, no data will be written to the device, and instead the
413 disklabel that would have been written will be printed to stdout.
414 .Pp
415 The bootstrap code is comprised of two boot programs.  Specify the name of the
416 boot programs to be installed in one of these ways:
417 .Bl -enum
418 .It
419 Specify the names explicitly with the
420 .Fl b
421 and
422 .Fl s
423 flags.
424 .Fl b
425 indicates the primary boot program and
426 .Fl s
427 the secondary boot program.  The boot programs are located in
428 .Pa /boot .
429 .It
430 If the
431 .Fl b
432 and
433 .Fl s
434 flags are not specified, but
435 .Ar disktype
436 was specified, the names of the programs are taken from the
437 .Dq b0
438 and
439 .Dq b1
440 parameters of the
441 .Xr disktab 5
442 entry for the disk if the disktab entry exists and includes those parameters.
443 .It
444 Otherwise, the default boot image names are used:
445 .Pa /boot/boot1
446 and
447 .Pa /boot/boot2
448 for the standard stage1 and stage2 boot images (details may vary
449 on architectures like the Alpha, where only a single-stage boot is used).
450 .El
451 .Ss Initializing/Formatting a bootable disk from scratch
452 To initialize a disk from scratch the following sequence is recommended.
453 Please note that this will wipe everything that was previously on the disk,
454 including any
455 .No non- Ns Dx
456 slices.
457 .Bl -enum
458 .It
459 Use
460 .Xr fdisk 8
461 to initialize the hard disk, and create a slice table, referred to
462 as the
463 .Dq "partition table"
464 in
465 .Tn DOS .
466 .It
467 Use
468 .Nm
469 to define partitions on
470 .Dx
471 slices created in the previous step.
472 .It
473 Finally use
474 .Xr newfs 8
475 to create file systems on new partitions.
476 .El
477 .Pp
478 A typical partitioning scheme would be to have an
479 .Ql a
480 partition
481 of approximately 128MB to hold the root file system, a
482 .Ql b
483 partition for
484 swap, a
485 .Ql d
486 partition for
487 .Pa /var
488 (usually 128MB), an
489 .Ql e
490 partition
491 for
492 .Pa /var/tmp
493 (usually 128MB), an
494 .Ql f
495 partition for
496 .Pa /usr
497 (usually around 2GB),
498 and finally a
499 .Ql g
500 partition for
501 .Pa /home
502 (usually all remaining space).
503 Your mileage may vary.
504 .Pp
505 .Nm fdisk Fl BI Pa da0
506 .Pp
507 .Nm
508 .Fl w B
509 .Pa da0s1
510 .Cm auto
511 .Pp
512 .Nm
513 .Fl e
514 .Pa da0s1
515 .Sh FILES
516 .Bl -tag -width ".Pa /etc/disktab" -compact
517 .It Pa /boot/boot
518 Default boot image.
519 .It Pa /etc/disktab
520 Disk description file.
521 .El
522 .Sh SAVED FILE FORMAT
523 The
524 .Nm
525 utility
526 uses an
527 .Tn ASCII
528 version of the label when examining, editing, or restoring a disk
529 label.
530 The format is:
531 .Bd -literal -offset 4n
532 # /dev/da1c:
533 type: SCSI
534 disk: da0s1
535 label:
536 flags:
537 bytes/sector: 512
538 sectors/track: 51
539 tracks/cylinder: 19
540 sectors/cylinder: 969
541 cylinders: 1211
542 sectors/unit: 1173930
543 rpm: 3600
544 interleave: 1
545 trackskew: 0
546 cylinderskew: 0
547 headswitch: 0           # milliseconds
548 track-to-track seek: 0  # milliseconds
549 drivedata: 0
550
551 8 partitions:
552 #        size   offset    fstype   [fsize bsize bps/cpg]
553   a:    81920        0    4.2BSD     1024  8192    16   # (Cyl.    0 - 84*)
554   b:   160000    81920      swap                        # (Cyl.   84* - 218*)
555   c:  1173930        0    unused        0     0         # (Cyl.    0 - 1211*)
556   h:   962010   211920     vinum                        # (Cyl.  218*- 1211*)
557 .Ed
558 .Pp
559 Lines starting with a
560 .Ql #
561 mark are comments.
562 Most of the other specifications are no longer used.
563 The ones which must still be set correctly are:
564 .Pp
565 .Bl -inset
566 .It Ar label
567 is an optional label, set by the
568 .Ar packid
569 option when writing a label.
570 .It Ar flags
571 may be
572 .Cm removable , ecc
573 or
574 .Cm badsect .
575 .Cm removable
576 is set for removable media drives, but no current
577 .Dx
578 driver evaluates this
579 flag.
580 .Cm ecc
581 is no longer supported;
582 .Cm badsect
583 specifies that the drive can perform bad sector remapping.
584 .It Ar sectors/unit
585 describes the total size of the disk.
586 This value must be correct.
587 .It Ar "the partition table"
588 is the
589 .Ux
590 partition table, not the
591 .Tn DOS
592 partition table described in
593 .Xr fdisk 8 .
594 .El
595 .Pp
596 The partition table can have up to 8 entries.
597 It contains the following information:
598 .Bl -tag -width indent
599 .It Ar #
600 The partition identifier is a single letter in the range
601 .Ql a
602 to
603 .Ql h .
604 By convention, partition
605 .Ql c
606 is reserved to describe the entire disk.
607 .It Ar size
608 The size of the partition in sectors,
609 .Cm K
610 (kilobytes - 1024),
611 .Cm M
612 (megabytes - 1024*1024),
613 .Cm G
614 (gigabytes - 1024*1024*1024),
615 .Cm %
616 (percentage of free space
617 .Em after
618 removing any fixed-size partitions other than partition
619 .Ql c ) ,
620 or
621 .Cm *
622 (all remaining free space
623 .Em after
624 fixed-size and percentage partitions).
625 For partition
626 .Ql c ,
627 a size of
628 .Cm *
629 indicates the entire disk.
630 Lowercase versions of
631 .Cm K , M ,
632 and
633 .Cm G
634 are allowed.
635 Size and type should be specifed without any spaces between them.
636 .Pp
637 Example: 2097152, 1G, 1024M and 1048576K are all the same size
638 (assuming 512-byte sectors).
639 .It Ar offset
640 The offset of the start of the partition from the beginning of the
641 drive in sectors, or
642 .Cm *
643 to have
644 .Nm
645 calculate the correct offset to use (the end of the previous partition plus
646 one, ignoring partition
647 .Ql c .
648 For partition
649 .Ql c ,
650 .Cm *
651 will be interpreted as an offset of 0.
652 .It Ar fstype
653 Describes the purpose of the partition.
654 The example shows all currently used partition types.
655 For
656 .Tn UFS
657 file systems and
658 .Xr ccd 4
659 partitions, use type
660 .Cm 4.2BSD .
661 For Vinum drives, use type
662 .Cm vinum .
663 Other common types are
664 .Cm swap
665 and
666 .Cm unused .
667 By convention, partition
668 .Ql c
669 represents the entire slice and should be of type
670 .Cm unused ,
671 though
672 .Nm
673 does not enforce this convention.
674 The
675 .Nm
676 utility
677 also knows about a number of other partition types,
678 none of which are in current use.
679 (See the definitions starting with
680 .Dv FS_UNUSED
681 in
682 .Aq Pa sys/disklabel.h
683 for more details).
684 .It Ar fsize
685 For
686 .Cm 4.2BSD
687 and
688 .Tn LFS
689 file systems only, the fragment size.
690 Defaults to 1024 for partitions smaller than 1GB,
691 2048 for partitions 1GB or larger.
692 .It Ar bsize
693 For
694 .Cm 4.2BSD
695 and
696 .Tn LFS
697 file systems only, the block size.
698 Defaults to 8192 for partitions smaller than 1GB,
699 16384 for partitions 1GB or larger.
700 .It Ar bps/cpg
701 For
702 .Cm 4.2BSD
703 file systems, the number of cylinders in a cylinder group.
704 For
705 .Tn LFS
706 file systems, the segment shift value.
707 Defaults to 16 for partitions smaller than 1GB,
708 64 for partitions 1GB or larger.
709 .El
710 .Pp
711 The remainder of the line is a comment and shows the cylinder allocations based
712 on the obsolete (but possibly correct) geometry information about the drive.
713 The asterisk
714 .Pq Ql *
715 indicates that the partition does not begin or end exactly on a
716 cylinder boundary.
717 .Sh EXAMPLES
718 .Dl "disklabel da0s1"
719 .Pp
720 Display the in-core label for the first slice of the
721 .Pa da0
722 disk, as obtained via
723 .Pa /dev/da0s1 .
724 (If the disk is
725 .Dq dangerously-dedicated ,
726 the base disk name should be specified, such as
727 .Pa da0 . )
728 .Pp
729 .Dl "disklabel da0s1 > savedlabel"
730 .Pp
731 Save the in-core label for
732 .Pa da0s1
733 into the file
734 .Pa savedlabel .
735 This file can be used with the
736 .Fl R
737 option to restore the label at a later date.
738 .Pp
739 .Dl "disklabel -w -r /dev/da0s1 da2212 foo"
740 .Pp
741 Create a label for
742 .Pa da0s1
743 based on information for
744 .Dq da2212
745 found in
746 .Pa /etc/disktab .
747 Any existing bootstrap code will be clobbered
748 and the disk rendered unbootable.
749 .Pp
750 .Dl "disklabel -e -r da0s1"
751 .Pp
752 Read the on-disk label for
753 .Pa da0s1 ,
754 edit it, and reinstall in-core as well as on-disk.
755 Existing bootstrap code is unaffected.
756 .Pp
757 .Dl "disklabel -e -r -n da0s1"
758 .Pp
759 Read the on-disk label for
760 .Pa da0s1 ,
761 edit it, and display what the new label would be (in sectors).
762 It does
763 .Em not
764 install the new label either in-core or on-disk.
765 .Pp
766 .Dl "disklabel -r -w da0s1 auto"
767 .Pp
768 Try to auto-detect the required information from
769 .Pa da0s1 ,
770 and write a new label to the disk.
771 Use another
772 .Nm Fl e
773 command to edit the
774 partitioning and file system information.
775 .Pp
776 .Dl "disklabel -R da0s1 savedlabel"
777 .Pp
778 Restore the on-disk and in-core label for
779 .Pa da0s1
780 from information in
781 .Pa savedlabel .
782 Existing bootstrap code is unaffected.
783 .Pp
784 .Dl "disklabel -R -n da0s1 label_layout"
785 .Pp
786 Display what the label would be for
787 .Pa da0s1
788 using the partition layout in
789 .Pa label_layout .
790 This is useful for determining how much space would be alloted for various
791 partitions with a labelling scheme using
792 .Cm % Ns -based
793 or
794 .Cm *
795 partition sizes.
796 .Pp
797 .Dl disklabel -B da0s1
798 .Pp
799 Install a new bootstrap on
800 .Pa da0s1 .
801 The boot code comes from
802 .Pa /boot/boot1
803 and possibly
804 .Pa /boot/boot2 .
805 On-disk and in-core labels are unchanged.
806 .Pp
807 .Dl disklabel -w -B /dev/da0s1 -b newboot1 -s newboot2 da2212
808 .Pp
809 Install a new label and bootstrap.
810 The label is derived from disktab information for
811 .Dq da2212
812 and installed both in-core and on-disk.
813 The bootstrap code comes from the files
814 .Pa /boot/newboot1
815 and
816 .Pa /boot/newboot2 .
817 .Pp
818 .Dl dd if=/dev/zero of=/dev/da0 bs=512 count=32
819 .Dl fdisk -BI da0
820 .Dl dd if=/dev/zero of=/dev/da0s1 bs=512 count=32
821 .Dl disklabel -w -B da0s1 auto
822 .Dl disklabel -e da0s1
823 .Pp
824 Completely wipe any prior information on the disk, creating a new bootable
825 disk with a DOS partition table containing one
826 .Dq whole-disk
827 slice.  Then
828 initialize the slice, then edit it to your needs.  The
829 .Pa dd
830 commands are optional, but may be necessary for some BIOSes to properly
831 recognize the disk.
832 .Pp
833 This is an example disklabel that uses some of the new partition size types
834 such as
835 .Cm % , M , G ,
836 and
837 .Cm * ,
838 which could be used as a source file for
839 .Pp
840 .Dl disklabel -R ad0s1c new_label_file
841 .Bd -literal -offset 4n
842 # /dev/ad0s1c:
843 type: ESDI
844 disk: ad0s1
845 label:
846 flags:
847 bytes/sector: 512
848 sectors/track: 63
849 tracks/cylinder: 16
850 sectors/cylinder: 1008
851 cylinders: 40633
852 sectors/unit: 40959009
853 rpm: 3600
854 interleave: 1
855 trackskew: 0
856 cylinderskew: 0
857 headswitch: 0           # milliseconds
858 track-to-track seek: 0  # milliseconds
859 drivedata: 0
860
861 8 partitions:
862 #        size   offset    fstype   [fsize bsize bps/cpg]
863   a:   400M        0    4.2BSD     4096 16384    75     # (Cyl.    0 - 812*)
864   b:     1G        *      swap
865   c:      *        *    unused
866   e: 204800        *    4.2BSD
867   f:     5g        *    4.2BSD
868   g:      *        *    4.2BSD
869 .Ed
870 .Sh DIAGNOSTICS
871 The kernel device drivers will not allow the size of a disk partition
872 to be decreased or the offset of a partition to be changed while it is open.
873 Some device drivers create a label containing only a single large partition
874 if a disk is unlabeled; thus, the label must be written to the
875 .Dq a
876 partition of the disk while it is open.  This sometimes requires the desired
877 label to be set in two steps, the first one creating at least one other
878 partition, and the second setting the label on the new partition while shrinking
879 the
880 .Dq a
881 partition.
882 .Pp
883 On some machines the bootstrap code may not fit entirely in the area
884 allocated for it by some file systems.
885 As a result, it may not be possible to have file systems on some partitions
886 of a
887 .Dq bootable
888 disk.
889 When installing bootstrap code,
890 .Nm
891 checks for these cases.
892 If the installed boot code would overlap a partition of type FS_UNUSED
893 it is marked as type FS_BOOT.
894 The
895 .Xr newfs 8
896 utility will disallow creation of file systems on FS_BOOT partitions.
897 Conversely, if a partition has a type other than FS_UNUSED or FS_BOOT,
898 .Nm
899 will not install bootstrap code that overlaps it.
900 .Sh SEE ALSO
901 .Xr ccd 4 ,
902 .Xr disklabel 5 ,
903 .Xr disktab 5 ,
904 .Xr boot0cfg 8 ,
905 .Xr fdisk 8 ,
906 .Xr vinum 8
907 .Sh BUGS
908 When a disk name is given without a full pathname,
909 the constructed device name uses the
910 .Dq c
911 partition.
912 .Pp
913 For the i386 architecture, the primary bootstrap sector contains
914 an embedded
915 .Em fdisk
916 table.
917 The
918 .Nm
919 utility takes care to not clobber it when installing a bootstrap only
920 .Pq Fl B ,
921 or when editing an existing label
922 .Pq Fl e ,
923 but it unconditionally writes the primary bootstrap program onto
924 the disk for
925 .Fl w
926 or
927 .Fl R ,
928 thus replacing the
929 .Em fdisk
930 table by the dummy one in the bootstrap program.  This is only of
931 concern if the disk is fully dedicated, so that the
932 .Bx
933 disklabel
934 starts at absolute block 0 on the disk.
935 .Pp
936 The
937 .Nm
938 utility
939 does not perform all possible error checking.  Warning *is* given if partitions
940 overlap; if an absolute offset does not match the expected offset; if the
941 .Dq c
942 partition does not start at 0 or does not cover the entire slice; if a
943 partition runs past the end of the device; and a number of other errors; but
944 no warning is given if space remains unused.