nrelease - fix/improve livecd
[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. Neither the name of the University nor the names of its contributors
16 .\"    may be used to endorse or promote products derived from this software
17 .\"    without specific prior written permission.
18 .\"
19 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 .\" SUCH DAMAGE.
30 .\"
31 .\"     @(#)disklabel.8 8.2 (Berkeley) 4/19/94
32 .\" $FreeBSD: src/sbin/disklabel/disklabel.8,v 1.15.2.22 2003/04/17 17:56:34 trhodes Exp $
33 .\"
34 .Dd July 21, 2018
35 .Dt DISKLABEL64 8
36 .Os
37 .Sh NAME
38 .Nm disklabel64
39 .Nd read and write 64 bit disk pack label
40 .Sh SYNOPSIS
41 .Nm
42 .Op Fl r
43 .Ar disk
44 .Nm
45 .Op Fl x
46 .Ar disk
47 .Nm
48 .Fl w
49 .Op Fl r
50 .Op Fl n
51 .Ar disk
52 .Op Ar disktype Ns / Ns Cm auto Op Ar packid
53 .Nm
54 .Fl e
55 .Op Fl r
56 .Op Fl n
57 .Ar disk
58 .Nm
59 .Fl R
60 .Op Fl r
61 .Op Fl n
62 .Ar disk Ar protofile
63 .Nm
64 .Op Fl NW
65 .Ar disk
66 .Pp
67 .Nm
68 .Fl B
69 .Oo
70 .Fl b Ar boot1
71 .Fl s Ar boot2
72 .Oc
73 .Ar disk
74 .Oo Ar disktype Ns / Ns Cm auto Oc
75 .Nm
76 .Fl w
77 .Fl B
78 .Op Fl n
79 .Oo
80 .Fl b Ar boot1
81 .Fl s Ar boot2
82 .Oc
83 .Ar disk
84 .Op Ar disktype Ns / Ns Cm auto Op Ar packid
85 .Nm
86 .Fl R
87 .Fl B
88 .Op Fl n
89 .Oo
90 .Fl b Ar boot1
91 .Fl s Ar boot2
92 .Oc
93 .Ar disk Ar protofile
94 .Oo Ar disktype Ns / Ns Cm auto Oc
95 .Sh DESCRIPTION
96 The
97 .Nm
98 utility
99 installs, examines or modifies a 64 bit label on a disk drive or pack.
100 When writing
101 the label, it can be used to change the drive identification, the disk
102 partitions on the drive, or to replace a damaged label.
103 There are several forms
104 of the command that read (display), install or edit the label on a disk.
105 In
106 addition,
107 .Nm
108 can install bootstrap code.
109 .Ss Raw or in-core label
110 The disk label resides close to or at the beginning of each disk slice.
111 For faster access, the kernel maintains a copy in core at all times.
112 By
113 default, most forms of the
114 .Nm
115 command access the in-core copy of the label.
116 To access the raw (on-disk)
117 copy, use the
118 .Fl r
119 option.
120 This option allows a label to be installed on a disk without kernel
121 support for a label, such as when labels are first installed on a system; it
122 must be used when first installing a label on a disk.
123 The specific effect of
124 .Fl r
125 is described under each command.
126 .Ss Disk device name
127 All
128 .Nm
129 forms require a disk device name, which should always be the raw
130 device name representing the disk or slice.
131 .Dx
132 uses the following scheme for slice numbering:
133 If the disk doesn't use GPT (typically laid out by
134 .Xr gpt 8 ) ,
135 but e.g.\& MBR (typically laid out by
136 .Xr fdisk 8 ) ,
137 then slice 0, e.g.\&
138 .Pa da0s0 ,
139 represents the entire disk regardless of any DOS partitioning.
140 Slice 0 is called the compatibility slice,
141 and slice 1 and onward, e.g.\&
142 .Pa da0s1 ,
143 represents a
144 .Bx
145 slice.
146 If the disk does use GPT, then all slices are
147 .Bx
148 slices, slice 0 isn't special, it is just the first slice on the disk.
149 You do not have to include the
150 .Pa /dev/
151 path prefix when specifying the device.
152 The
153 .Nm
154 utility will automatically prepend it.
155 .Ss Reading the disk label
156 To examine the label on a disk drive, use
157 .Nm
158 without options:
159 .Pp
160 .Nm
161 .Op Fl r
162 .Ar disk
163 .Pp
164 .Ar disk
165 represents the raw disk in question, and may be in the form
166 .Pa da0s1
167 or
168 .Pa /dev/da0s1 .
169 It will display all of the parameters associated with the drive and its
170 partition layout.
171 Unless the
172 .Fl r
173 flag is given,
174 the kernel's in-core copy of the label is displayed;
175 if the disk has no label, or the partition types on the disk are incorrect,
176 the kernel may have constructed or modified the label.
177 If the
178 .Fl r
179 flag is given,
180 .Nm
181 reads the label from the raw disk and displays it.
182 Both versions are usually
183 identical except in the case where a label has not yet been initialized or
184 is corrupt.
185 .Ss Writing a standard label
186 To write a standard label, use the form
187 .Pp
188 .Nm
189 .Fl w
190 .Op Fl r
191 .Op Fl n
192 .Ar disk
193 .Op Ar disktype Ns / Ns Cm auto Op Ar packid
194 .Pp
195 The required argument to
196 .Nm
197 is the drive to be labeled.
198 The first optional argument is the drive type as described in the
199 .Xr disktab 5
200 file, from which the drive parameters and partitions are taken.
201 If not specified, then the
202 .Cm auto
203 type is assumed to make a virgin label for the disk as described below.
204 If
205 different disks of the same physical type are to have different partitions, it
206 will be necessary to have separate disktab entries describing each, or to edit
207 the label after installation as described below.
208 The optional argument is a
209 pack identification string, up to 63 characters long.
210 The pack id must be
211 quoted if it contains blanks.
212 .Pp
213 If the
214 .Fl n
215 flag is given, no data will be written to the device, and instead the
216 disklabel that would have been written will be printed to stdout.
217 .Pp
218 If the
219 .Fl r
220 flag is given, the disk sectors containing the label 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 and any bootstrap
230 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.
250 .Pp
251 For most harddisks, a label based on percentages for most partitions (and
252 one partition with a size of
253 .Ql * )
254 will produce a reasonable configuration.
255 .Pp
256 PC-based systems have special requirements in order for the BIOS to properly
257 recognize a
258 .Dx
259 disklabel.
260 Older systems may require what is known as a
261 .Dq dangerously dedicated
262 disklabel, which creates a fake DOS partition to work around problems older
263 BIOSes have with modern disk geometries.
264 On newer systems you generally want
265 to create a normal DOS partition using
266 .Ar fdisk
267 and then create a
268 .Dx
269 disklabel within that slice.
270 This is described
271 later on in this page.
272 .Pp
273 Installing a new disklabel does not in of itself allow your system to boot
274 a kernel using that label.
275 You must also install boot blocks, which is
276 described later on in this manual page.
277 .Ss Editing an existing disk label
278 To edit an existing disk label, use the form
279 .Pp
280 .Nm
281 .Fl e
282 .Op Fl r
283 .Op Fl n
284 .Ar disk
285 .Pp
286 This command reads the label from the in-core kernel copy, or directly from the
287 disk if the
288 .Fl r
289 flag is also specified.
290 The label is written to a file in ASCII and then
291 supplied to an editor for changes.
292 If no editor is specified in an
293 .Ev EDITOR
294 environment variable,
295 .Xr vi 1
296 is used.
297 When the editor terminates, the label file is used to rewrite the disk label.
298 Existing bootstrap code is unchanged regardless of whether
299 .Fl r
300 was specified.
301 If
302 .Fl n
303 is specified, no data will be written to the device, and instead the
304 disklabel that would have been written will be printed to stdout.
305 This is
306 useful to see how a partitioning scheme will work out for a specific disk.
307 .Ss Restoring a disk label from a file
308 To restore a disk label from a file, use the form
309 .Pp
310 .Nm
311 .Fl R
312 .Op Fl r
313 .Op Fl n
314 .Ar disk Ar protofile
315 .Pp
316 .Nm
317 is capable of restoring a disk label that was previously saved in a file
318 in ASCII format.
319 The prototype file used to create the label should be in the same format
320 as that produced when reading or editing a label.
321 Comments are delimited by
322 .Ql #
323 and newline.
324 As when writing a new label, any existing bootstrap code will be
325 clobbered if
326 .Fl r
327 is specified and will be unaffected otherwise.
328 See the boot options below for a
329 method of restoring the label and writing the bootstrap at the same time.
330 If
331 .Fl n
332 is used, no data will be written to the device, and instead the
333 disklabel that would have been written will be printed to stdout.
334 This is
335 useful to see how a partitioning scheme will work out for a specific disk.
336 .Ss Enabling and disabling writing to the disk label area
337 By default, it is not possible to write to the disk label area at the beginning
338 of a disk.
339 The disk driver arranges for
340 .Xr write 2
341 and similar system calls
342 to return
343 .Er EROFS
344 on any attempt to do so.
345 If you need
346 to write to this area (for example, to obliterate the label), use the form
347 .Pp
348 .Nm
349 .Fl W
350 .Ar disk
351 .Pp
352 To disallow writing to the label area after previously allowing it,
353 use the command
354 .Pp
355 .Nm
356 .Fl N
357 .Ar disk
358 .Ss Installing bootstraps
359 The final three forms of
360 .Nm
361 are used to install bootstrap code, which allows boot from a
362 .Xr HAMMER 5 ,
363 .Xr HAMMER2 5 ,
364 or
365 .Xr UFS 5
366 file system.
367 If you are creating a
368 .Dq dangerously-dedicated
369 slice for compatibility with older PC systems,
370 you generally want to specify the compatibility slice, such as
371 .Pa da0s0 .
372 If you are creating a label within an existing DOS slice,
373 you should specify
374 the slice name such as
375 .Pa da0s1 .
376 Making a slice bootable can be tricky.
377 If you are using a normal DOS
378 slice you typically install (or leave) a standard MBR on the base disk and
379 then install the
380 .Dx
381 bootblocks in the slice.
382 .Pp
383 .Nm
384 .Fl B
385 .Oo
386 .Fl b Ar boot1
387 .Fl s Ar boot2
388 .Oc
389 .Ar disk
390 .Oo Ar disktype Ns / Ns Cm auto Oc
391 .Pp
392 This form installs the bootstrap only.
393 It does not change the disk label.
394 You should never use this command on the compatibility slice unless you
395 intend to create a
396 .Dq dangerously-dedicated
397 disk, such as
398 .Ar da0s0 .
399 This command is typically run on a
400 .Bx
401 slice such as
402 .Ar da0s1 .
403 .Pp
404 .Nm
405 .Fl w
406 .Fl B
407 .Op Fl n
408 .Oo
409 .Fl b Ar boot1
410 .Fl s Ar boot2
411 .Oc
412 .Ar disk
413 .Op Ar disktype Ns / Ns Cm auto Op Ar packid
414 .Pp
415 This form corresponds to the
416 .Dq write label
417 command described above.
418 In addition to writing a new volume label, it also installs the bootstrap.
419 If run on the compatibility slice this command will create a
420 .Dq dangerously-dedicated
421 label.
422 This command is normally run on a
423 .Bx
424 slice rather than the compatibility 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,
454 so it is not necessary 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 normally 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_64
495 and
496 .Pa /boot/boot2_64
497 for the standard stage1 and stage2 boot images.
498 .El
499 .Ss Initializing/Formatting a bootable disk from scratch
500 To initialize a disk from scratch the following sequence is recommended.
501 Please note that this will wipe everything that was previously on the disk,
502 including any
503 .No non- Ns Dx
504 slices.
505 .Bl -enum
506 .It
507 Use
508 .Xr gpt 8
509 or
510 .Xr fdisk 8
511 to initialize the hard disk, and create a GPT or MBR slice table,
512 referred to as the
513 .Dq "partition table"
514 in
515 .Tn DOS .
516 .It
517 Use
518 .Nm
519 or
520 .Xr disklabel32 8
521 to define partitions on
522 .Dx
523 slices created in the previous step.
524 .It
525 Finally use
526 .Xr newfs_hammer 8 ,
527 .Xr newfs_hammer2 8 ,
528 or
529 .Xr newfs 8
530 to create file systems on new partitions.
531 .El
532 .Pp
533 A typical partitioning scheme would be to have an
534 .Ql a
535 partition of approximately 1 GB for
536 .Pa /boot
537 to hold the current, old (and backup) kernels and modules, a
538 .Ql b
539 partition for swap (suggested to be at least the same size as the
540 physical memory),
541 and finally a
542 .Ql d
543 partition for the root file system (usually all remaining space).
544 Your mileage may vary.
545 .Pp
546 .Dl "gpt init -f -B da0"
547 .Dl "disklabel64 -B -r -w da0s1"
548 .Dl "disklabel64 -e da0s1"
549 .Ss Expanding the disklabel
550 The
551 .Fl x[x]
552 option may be used to expand an existing disklabel to cover an expanded
553 storage device.  This is useful when an image is copied to larger underlying
554 storage.  If specified twice, the last partition will also be expanded to
555 fill the area.  Mounted HAMMER2 filesystems can also be expanded to cover
556 the new space in the partition.
557 .Pp
558 .Dl "gpt expand da0"
559 .Dl "disklabel64 -xx da0s1"
560 .Dl "hammer2 growfs /blahblah"
561 .Sh ALIGNMENT
562 When a virgin disklabel64 is laid down a
563 .Dx 2.5
564 or later kernel will align the partition start offset relative to the
565 physical drive instead of relative to the slice start.
566 This overcomes the issue of fdisk creating a badly aligned slice by default.
567 The kernel will use a 1MiB (1024 * 1024 byte) alignment.
568 The purpose of this alignment is to match swap and cluster operations
569 against the physical block size of the underlying device.
570 .Pp
571 Even though nearly all devices still report a logical sector size of 512,
572 newer hard drives are starting to use larger physical sector sizes
573 and, in particular, solid state drives (SSDs) use a physical block size
574 of 64K (SLC) or 128K (MLC).  We choose a 1 megabyte alignment to cover our
575 bases down the road.  64-bit disklabels are not designed to be put on
576 ultra-tiny storage devices.
577 .Pp
578 It is worth noting that aligning cluster operations is particularly
579 important for SSDs and doubly so when
580 .Xr swapcache 8
581 is used with a SSD.
582 Swapcache is able to use large bulk writes which greatly reduces the degree
583 of write magnification on SSD media and it is possible to get upwards of
584 5x more endurance out of the device than the vendor spec sheet indicates.
585 .Sh FILES
586 .Bl -tag -width ".Pa /boot/boot2_64" -compact
587 .It Pa /boot/boot1_64
588 Default stage1 boot image.
589 .It Pa /boot/boot2_64
590 Default stage2 boot image.
591 .It Pa /etc/disktab
592 Disk description file.
593 .El
594 .Sh SAVED FILE FORMAT
595 The
596 .Nm
597 utility uses an
598 .Tn ASCII
599 version of the label when examining, editing, or restoring a disk label.
600 An example shows as below:
601 .Bd -literal -offset 4n
602 # /dev/ad0s1:
603 #
604 # Calculated informational fields for the slice:
605 #
606 # boot space:    1012224 bytes
607 # data space:  156286976 blocks # 152624.00 MB (160037863424 bytes)
608 #
609 # NOTE: The partition data base and stop are physically
610 #       aligned instead of slice-relative aligned.
611 #
612 # All byte equivalent offsets must be aligned.
613 #
614 diskid: 5dc53a64-c5e5-11e7-8aec-011d0988acd3
615 label:
616 boot2 data base:      0x000000001000
617 partitions data base: 0x0000000f8200
618 partitions data stop: 0x0025430f8200
619 backup label:         0x002543157200
620 total size:           0x002543158200    # 152625.34 MB
621 alignment: 4096
622 display block size: 1024        # for partition display and edit only
623
624 16 partitions:
625 #          size     offset    fstype   fsuuid
626   a:    1048576          0    4.2BSD    #    1024.000MB
627   b:   16777216    1048576      swap    #   16384.000MB
628   d:  138461184   17825792    HAMMER    #  135216.000MB
629   a-stor_uuid: 7f1ff0ee-c5ec-11e7-8aec-011d0988acd3
630   b-stor_uuid: 7f1ff0fc-c5ec-11e7-8aec-011d0988acd3
631   d-stor_uuid: 7f1ff108-c5ec-11e7-8aec-011d0988acd3
632 .Ed
633 .Pp
634 Lines starting with a
635 .Ql #
636 mark are comments.
637 The specifications which can be changed are:
638 .Bl -inset
639 .It Ar label
640 is an optional label, set by the
641 .Ar packid
642 option when writing a label.
643 .It Ar "the partition table"
644 is the
645 .Ux
646 partition table, not the
647 .Tn DOS
648 partition table described in
649 .Xr fdisk 8 .
650 .El
651 .Pp
652 The partition table can have up to 16 entries.
653 It contains the following information:
654 .Bl -tag -width indent
655 .It Ar #
656 The partition identifier is a single letter in the range
657 .Ql a
658 to
659 .Ql p .
660 .It Ar size
661 The size of the partition in sectors,
662 .Cm K
663 (kilobytes - 1024),
664 .Cm M
665 (megabytes - 1024*1024),
666 .Cm G
667 (gigabytes - 1024*1024*1024),
668 .Cm T
669 (terabytes - 1024*1024*1024*1024),
670 .Cm %
671 (percentage of free space
672 .Em after
673 removing any fixed-size partitions),
674 .Cm *
675 (all remaining free space
676 .Em after
677 fixed-size and percentage partitions).
678 Lowercase versions of
679 .Cm K , M , G ,
680 and
681 .Cm T
682 are allowed.
683 Size and type should be specified without any spaces between them.
684 .Pp
685 Example: 2097152, 1G, 1024M and 1048576K are all the same size
686 (assuming 512-byte sectors).
687 .It Ar offset
688 The offset of the start of the partition from the beginning of the
689 drive in sectors, or
690 .Cm *
691 to have
692 .Nm
693 calculate the correct offset to use (the end of the previous partition plus
694 one.
695 .It Ar fstype
696 The name of the filesystem type for the partition (case insensitive).
697 For
698 .Xr UFS 5
699 file systems, use type
700 .Cm 4.2BSD .
701 For
702 .Xr HAMMER 5
703 file systems, use type
704 .Cm HAMMER .
705 For
706 .Xr hammer2 8
707 file systems, use type
708 .Cm HAMMER2 .
709 For
710 .Xr ccd 4
711 partitions, use type
712 .Cm ccd .
713 For Vinum drives, use type
714 .Cm vinum .
715 Other common types are
716 .Cm swap
717 and
718 .Cm unused .
719 The
720 .Nm
721 utility
722 also knows about a number of other partition types,
723 none of which are in current use.
724 (See
725 .Dv fstypenames
726 in
727 .In sys/dtype.h
728 for more details).
729 .El
730 .Pp
731 The remainder of the line is a comment and shows the size of
732 the partition in MB.
733 .Sh EXAMPLES
734 .Dl "disklabel64 da0s1"
735 .Pp
736 Display the in-core label for the first slice of the
737 .Pa da0
738 disk, as obtained via
739 .Pa /dev/da0s1 .
740 (If the disk is
741 .Dq dangerously-dedicated ,
742 the compatibility slice name should be specified, such as
743 .Pa da0s0 . )
744 .Pp
745 .Dl "disklabel64 da0s1 > savedlabel"
746 .Pp
747 Save the in-core label for
748 .Pa da0s1
749 into the file
750 .Pa savedlabel .
751 This file can be used with the
752 .Fl R
753 option to restore the label at a later date.
754 .Pp
755 .Dl "disklabel64 -e -r da0s1"
756 .Pp
757 Read the on-disk label for
758 .Pa da0s1 ,
759 edit it, and reinstall in-core as well as on-disk.
760 Existing bootstrap code is unaffected.
761 .Pp
762 .Dl "disklabel64 -e -r -n da0s1"
763 .Pp
764 Read the on-disk label for
765 .Pa da0s1 ,
766 edit it, and display what the new label would be.
767 It does
768 .Em not
769 install the new label either in-core or on-disk.
770 .Pp
771 .Dl "disklabel64 -r -w da0s1"
772 .Pp
773 Try to auto-detect the required information from
774 .Pa da0s1 ,
775 and write a new label to the disk.
776 Use another
777 .Nm Fl e
778 command to edit the partitioning information.
779 .Pp
780 .Dl "disklabel64 -R da0s1 savedlabel"
781 .Pp
782 Restore the on-disk and in-core label for
783 .Pa da0s1
784 from information in
785 .Pa savedlabel .
786 Existing bootstrap code is unaffected.
787 .Pp
788 .Dl "disklabel64 -R -n da0s1 label_layout"
789 .Pp
790 Display what the label would be for
791 .Pa da0s1
792 using the partition layout in
793 .Pa label_layout .
794 This is useful for determining how much space would be allotted for various
795 partitions with a labelling scheme using
796 .Cm % Ns -based
797 or
798 .Cm *
799 partition sizes.
800 .Pp
801 .Dl "disklabel64 -B da0s1"
802 .Pp
803 Install a new bootstrap on
804 .Pa da0s1 .
805 The boot code comes from
806 .Pa /boot/boot1_64
807 and possibly
808 .Pa /boot/boot2_64 .
809 On-disk and in-core labels are unchanged.
810 .Pp
811 .Dl "disklabel64 -w -B /dev/da0s1 -b newboot1 -s newboot2"
812 .Pp
813 Install a new label and bootstrap, with bootstrap code comes from the files
814 .Pa newboot1
815 and
816 .Pa newboot2 .
817 .Pp
818 .Dl "dd if=/dev/zero of=/dev/da0 bs=512 count=32"
819 .Dl "fdisk -BI da0"
820 .Dl "dd if=/dev/zero of=/dev/da0s1 bs=512 count=32"
821 .Dl "disklabel64 -w -B da0s1"
822 .Dl "disklabel64 -e da0s1"
823 .Pp
824 Completely wipe any prior information on the disk, creating a new bootable
825 disk with a DOS partition table containing one
826 .Dq whole-disk
827 slice.
828 Then
829 initialize the slice, then edit it to your needs.
830 The
831 .Pa dd
832 commands are optional, but may be necessary for some BIOSes to properly
833 recognize the disk.
834 .Pp
835 .Dl "disklabel64 -W da0s1"
836 .Dl "dd if=/dev/zero of=/dev/da0s1 bs=512 count=32"
837 .Dl "disklabel32 -r -w da0s1"
838 .Dl "disklabel32 -N da0s1"
839 .Pp
840 Completely wipe any prior information on the slice,
841 and install the old 32-bit label.
842 The wiping is needed because both
843 .Nm disklabel32
844 and
845 .Nm ,
846 as a safety measure,
847 won't do any operations if label with other format is already installed.
848 .Pp
849 This is an example disklabel that uses some of the new partition size types
850 such as
851 .Cm % , M , G , T ,
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/ad0s1:
859 #
860 # Calculated informational fields for the slice:
861 #
862 # boot space:    1012224 bytes
863 # data space:  156286976 blocks # 152624.00 MB (160037863424 bytes)
864 #
865 # NOTE: The partition data base and stop are physically
866 #       aligned instead of slice-relative aligned.
867 #
868 # All byte equivalent offsets must be aligned.
869 #
870 diskid: 5dc53a64-c5e5-11e7-8aec-011d0988acd3
871 label:
872 boot2 data base:      0x000000001000
873 partitions data base: 0x0000000f8200
874 partitions data stop: 0x0025430f8200
875 backup label:         0x002543157200
876 total size:           0x002543158200    # 152625.34 MB
877 alignment: 4096
878 display block size: 1024        # for partition display and edit only
879
880 16 partitions:
881 #          size     offset    fstype   fsuuid
882   a:      1024M          0    4.2BSD
883   b:         4G          *      swap
884   d:         2G          *    4.2BSD
885   e:      2048M          *    4.2BSD
886   f:         4G          *    4.2BSD
887   g:         4G          *    4.2BSD
888   h:        50G          *    HAMMER
889   i:          *          *    HAMMER2
890   j:         5g          *       ccd
891   k:      5120m          *     vinum
892 .Ed
893 .Sh DIAGNOSTICS
894 The kernel device drivers will not allow the size of a disk partition
895 to be decreased or the offset of a partition to be changed while it is open.
896 Some device drivers create a label containing only a single large partition
897 if a disk is unlabeled; thus, the label must be written to the
898 .Ql a
899 partition of the disk while it is open.
900 This sometimes requires the desired
901 label to be set in two steps, the first one creating at least one other
902 partition, and the second setting the label on the new partition while
903 shrinking the
904 .Ql a
905 partition.
906 .Sh SEE ALSO
907 .Xr dd 1 ,
908 .Xr uuid 3 ,
909 .Xr ccd 4 ,
910 .Xr disklabel64 5 ,
911 .Xr disktab 5 ,
912 .Xr boot0cfg 8 ,
913 .Xr diskinfo 8 ,
914 .Xr disklabel32 8 ,
915 .Xr fdisk 8 ,
916 .Xr gpt 8 ,
917 .Xr hammer2 8 ,
918 .Xr newfs 8 ,
919 .Xr newfs_hammer 8 ,
920 .Xr newfs_hammer2 8 ,
921 .Xr vinum 8
922 .Sh BUGS
923 The
924 .Nm
925 utility
926 does not perform all possible error checking.
927 Warning
928 .Em is
929 given if partitions
930 overlap; if an absolute offset does not match the expected offset; if a
931 partition runs past the end of the device; and a number of other errors; but
932 no warning is given if space remains unused.
933 .Pp
934 The
935 .Xr disktab 5
936 support is not implemented.