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