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