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