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