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