Merge branch 'vendor/OPENSSL'
[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 August 3, 2012
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 .Fl w
46 .Op Fl r
47 .Op Fl n
48 .Ar disk Ar disktype Ns / Ns Cm auto
49 .Oo Ar packid Oc
50 .Nm
51 .Fl e
52 .Op Fl r
53 .Op Fl n
54 .Ar disk
55 .Nm
56 .Fl R
57 .Op Fl r
58 .Op Fl n
59 .Ar disk Ar protofile
60 .Nm
61 .Op Fl NW
62 .Ar disk
63 .Pp
64 .Nm
65 .Fl B
66 .Oo
67 .Fl b Ar boot1
68 .Fl s Ar boot2
69 .Oc
70 .Ar disk
71 .Oo Ar disktype Ns / Ns Cm auto Oc
72 .Nm
73 .Fl w
74 .Fl B
75 .Op Fl n
76 .Oo
77 .Fl b Ar boot1
78 .Fl s Ar boot2
79 .Oc
80 .Ar disk Ar disktype Ns / Ns Cm auto
81 .Oo Ar packid Oc
82 .Nm
83 .Fl R
84 .Fl B
85 .Op Fl n
86 .Oo
87 .Fl b Ar boot1
88 .Fl s Ar boot2
89 .Oc
90 .Ar disk Ar protofile
91 .Oo Ar disktype Ns / Ns Cm auto Oc
92 .Sh DESCRIPTION
93 The
94 .Nm
95 utility
96 installs, examines or modifies a 64 bit label on a disk drive or pack.
97 When writing
98 the label, it can be used to change the drive identification, the disk
99 partitions on the drive, or to replace a damaged label.
100 There are several forms
101 of the command that read (display), install or edit the label on a disk.
102 In
103 addition,
104 .Nm
105 can install bootstrap code.
106 .Ss Raw or in-core label
107 The disk label resides close to or at the beginning of each disk slice.
108 For faster access, the kernel maintains a copy in core at all times.
109 By
110 default, most forms of the
111 .Nm
112 command access the in-core copy of the label.
113 To access the raw (on-disk)
114 copy, use the
115 .Fl r
116 option.
117 This option allows a label to be installed on a disk without kernel
118 support for a label, such as when labels are first installed on a system; it
119 must be used when first installing a label on a disk.
120 The specific effect of
121 .Fl r
122 is described under each command.
123 .Ss Disk device name
124 All
125 .Nm
126 forms require a disk device name, which should always be the raw
127 device name representing the disk or slice.
128 .Dx
129 uses the following scheme for slice numbering:
130 If the disk doesn't use GPT (typically laid out by
131 .Xr gpt 8 ) ,
132 but e.g.\& MBR (typically laid out by
133 .Xr fdisk 8 ) ,
134 then slice 0, e.g.\&
135 .Pa da0s0 ,
136 represents the entire disk regardless of any DOS partitioning.
137 Slice 0 is called the compatibility slice,
138 and slice 1 and onward, e.g.\&
139 .Pa da0s1 ,
140 represents a
141 .Bx
142 slice.
143 If the disk does use GPT, then all slices are
144 .Bx
145 slices, slice 0 isn't special, it is just the first slice on the disk.
146 You do not have to include the
147 .Pa /dev/
148 path prefix when specifying the device.
149 The
150 .Nm
151 utility will automatically prepend it.
152 .Ss Reading the disk label
153 To examine the label on a disk drive, use
154 .Nm
155 without options:
156 .Pp
157 .Nm
158 .Op Fl r
159 .Ar disk
160 .Pp
161 .Ar disk
162 represents the raw disk in question, and may be in the form
163 .Pa da0s1
164 or
165 .Pa /dev/da0s1 .
166 It will display all of the parameters associated with the drive and its
167 partition layout.
168 Unless the
169 .Fl r
170 flag is given,
171 the kernel's in-core copy of the label is displayed;
172 if the disk has no label, or the partition types on the disk are incorrect,
173 the kernel may have constructed or modified the label.
174 If the
175 .Fl r
176 flag is given,
177 .Nm
178 reads the label from the raw disk and displays it.
179 Both versions are usually
180 identical except in the case where a label has not yet been initialized or
181 is corrupt.
182 .Ss Writing a standard label
183 To write a standard label, use the form
184 .Pp
185 .Nm
186 .Fl w
187 .Op Fl r
188 .Op Fl n
189 .Ar disk Ar disktype Ns / Ns Cm auto
190 .Oo Ar packid Oc
191 .Pp
192 The required arguments to
193 .Nm
194 are the drive to be labeled and the drive type as described in the
195 .Xr disktab 5
196 file.
197 The drive parameters and partitions are taken from that file.
198 If
199 different disks of the same physical type are to have different partitions, it
200 will be necessary to have separate disktab entries describing each, or to edit
201 the label after installation as described below.
202 The optional argument is a
203 pack identification string, up to 16 characters long.
204 The pack id must be
205 quoted if it contains blanks.
206 .Pp
207 If the
208 .Fl n
209 flag is given, no data will be written to the device, and instead the
210 disklabel that would have been written will be printed to stdout.
211 .Pp
212 If the
213 .Fl r
214 flag is given, the disk sectors containing the label and bootstrap
215 will be written directly.
216 A side-effect of this is that any existing bootstrap code will be overwritten
217 and the disk rendered unbootable.
218 See the boot options below for a method of
219 writing the label and the bootstrap at the same time.
220 If
221 .Fl r
222 is not specified,
223 the existing label will be updated via the in-core copy and any bootstrap
224 code will be unaffected.
225 If the disk does not already have a label, the
226 .Fl r
227 flag must be used.
228 In either case, the kernel's in-core label is replaced.
229 .Pp
230 For a virgin disk that is not known to
231 .Xr disktab 5 ,
232 .Ar disktype
233 can be specified as
234 .Cm auto .
235 In this case, the driver is requested to produce a virgin label for the
236 disk.
237 This might or might not be successful, depending on whether the
238 driver for the disk is able to get the required data without reading
239 anything from the disk at all.
240 It will likely succeed for all SCSI
241 disks, most IDE disks, and vnode devices.
242 Writing a label to the
243 disk is the only supported operation, and the
244 .Ar disk
245 itself must be provided as the canonical name, i.e.\& not as a full
246 path name.
247 .Pp
248 For most harddisks, a label based on percentages for most partitions (and
249 one partition with a size of
250 .Ql * )
251 will produce a reasonable configuration.
252 .Pp
253 PC-based systems have special requirements in order for the BIOS to properly
254 recognize a
255 .Dx
256 disklabel.
257 Older systems may require what is known as a
258 .Dq dangerously dedicated
259 disklabel, which creates a fake DOS partition to work around problems older
260 BIOSes have with modern disk geometries.
261 On newer systems you generally want
262 to create a normal DOS partition using
263 .Ar fdisk
264 and then create a
265 .Dx
266 disklabel within that slice.
267 This is described
268 later on in this page.
269 .Pp
270 Installing a new disklabel does not in of itself allow your system to boot
271 a kernel using that label.
272 You must also install boot blocks, which is
273 described later on in this manual page.
274 .Ss Editing an existing disk label
275 To edit an existing disk label, use the form
276 .Pp
277 .Nm
278 .Fl e
279 .Op Fl r
280 .Op Fl n
281 .Ar disk
282 .Pp
283 This command reads the label from the in-core kernel copy, or directly from the
284 disk if the
285 .Fl r
286 flag is also specified.
287 The label is written to a file in ASCII and then
288 supplied to an editor for changes.
289 If no editor is specified in an
290 .Ev EDITOR
291 environment variable,
292 .Xr vi 1
293 is used.
294 When the editor terminates, the label file is used to rewrite the disk label.
295 Existing bootstrap code is unchanged regardless of whether
296 .Fl r
297 was specified.
298 If
299 .Fl n
300 is specified, no data will be written to the device, and instead the
301 disklabel that would have been written will be printed to stdout.
302 This is
303 useful to see how a partitioning scheme will work out for a specific disk.
304 .Ss Restoring a disk label from a file
305 To restore a disk label from a file, use the form
306 .Pp
307 .Nm
308 .Fl R
309 .Op Fl r
310 .Op Fl n
311 .Ar disk Ar protofile
312 .Pp
313 .Nm
314 is capable of restoring a disk label that was previously saved in a file
315 in ASCII format.
316 The prototype file used to create the label should be in the same format
317 as that produced when reading or editing a label.
318 Comments are delimited by
319 .Ql #
320 and newline.
321 As when writing a new label, any existing bootstrap code will be
322 clobbered if
323 .Fl r
324 is specified and will be unaffected otherwise.
325 See the boot options below for a
326 method of restoring the label and writing the bootstrap at the same time.
327 If
328 .Fl n
329 is used, no data will be written to the device, and instead the
330 disklabel that would have been written will be printed to stdout.
331 This is
332 useful to see how a partitioning scheme will work out for a specific disk.
333 .Ss Enabling and disabling writing to the disk label area
334 By default, it is not possible to write to the disk label area at the beginning
335 of a disk.
336 The disk driver arranges for
337 .Xr write 2
338 and similar system calls
339 to return
340 .Er EROFS
341 on any attempt to do so.
342 If you need
343 to write to this area (for example, to obliterate the label), use the form
344 .Pp
345 .Nm
346 .Fl W
347 .Ar disk
348 .Pp
349 To disallow writing to the label area after previously allowing it,
350 use the command
351 .Pp
352 .Nm
353 .Fl N
354 .Ar disk
355 .Ss Installing bootstraps
356 The final three forms of
357 .Nm
358 are used to install bootstrap code, which allows boot from a
359 .Xr HAMMER 5
360 or
361 .Xr UFS 5
362 file system.
363 If you are creating a
364 .Dq dangerously-dedicated
365 slice for compatibility with older PC systems,
366 you generally want to specify the compatibility slice, such as
367 .Pa da0s0 .
368 If you are creating a label within an existing DOS slice,
369 you should specify
370 the slice name such as
371 .Pa da0s1 .
372 Making a slice bootable can be tricky.
373 If you are using a normal DOS
374 slice you typically install (or leave) a standard MBR on the base disk and
375 then install the
376 .Dx
377 bootblocks in the slice.
378 .Pp
379 .Nm
380 .Fl B
381 .Oo
382 .Fl b Ar boot1
383 .Fl s Ar boot2
384 .Oc
385 .Ar disk
386 .Oo Ar disktype Ns / Ns Cm auto Oc
387 .Pp
388 This form installs the bootstrap only.
389 It does not change the disk label.
390 You should never use this command on the compatibility slice unless you
391 intend to create a
392 .Dq dangerously-dedicated
393 disk, such as
394 .Ar da0s0 .
395 This command is typically run on a
396 .Bx
397 slice such as
398 .Ar da0s1 .
399 .Pp
400 .Nm
401 .Fl w
402 .Fl B
403 .Op Fl n
404 .Oo
405 .Fl b Ar boot1
406 .Fl s Ar boot2
407 .Oc
408 .Ar disk Ar disktype Ns / Ns Cm auto
409 .Oo Ar packid Oc
410 .Pp
411 This form corresponds to the
412 .Dq write label
413 command described above.
414 In addition to writing a new volume label, it also installs the bootstrap.
415 If run on the compatibility slice this command will create a
416 .Dq dangerously-dedicated
417 label.
418 This command is normally run on a
419 .Bx
420 slice rather than the compatibility slice.
421 If
422 .Fl n
423 is used, no data will be written to the device, and instead the
424 disklabel that would have been written will be printed to stdout.
425 .Pp
426 .Nm
427 .Fl R
428 .Fl B
429 .Op Fl n
430 .Oo
431 .Fl b Ar boot1
432 .Fl s Ar boot2
433 .Oc
434 .Ar disk Ar protofile
435 .Oo Ar disktype Ns / Ns Cm auto Oc
436 .Pp
437 This form corresponds to the
438 .Dq restore label
439 command described above.
440 In addition to restoring the volume label, it also installs the bootstrap.
441 If run on the compatibility slice this command will create a
442 .Dq dangerously-dedicated
443 label.
444 This command is normally run on a
445 .Bx
446 slice rather than the compatibility
447 slice.
448 .Pp
449 The bootstrap commands always access the disk directly,
450 so it is not necessary 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 normally 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_64
491 and
492 .Pa /boot/boot2_64
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 gpt 8
505 or
506 .Xr fdisk 8
507 to initialize the hard disk, and create a GPT or MBR slice table,
508 referred to as the
509 .Dq "partition table"
510 in
511 .Tn DOS .
512 .It
513 Use
514 .Nm
515 or
516 .Xr disklabel32 8
517 to define partitions on
518 .Dx
519 slices created in the previous step.
520 .It
521 Finally use
522 .Xr newfs_hammer 8
523 or
524 .Xr newfs 8
525 to create file systems on new partitions.
526 .El
527 .Pp
528 A typical partitioning scheme would be to have an
529 .Ql a
530 partition
531 of approximately 512MB to hold the root file system, a
532 .Ql b
533 partition for
534 swap (usually 4GB), a
535 .Ql d
536 partition for
537 .Pa /var
538 (usually 2GB), an
539 .Ql e
540 partition for
541 .Pa /var/tmp
542 (usually 2GB), an
543 .Ql f
544 partition for
545 .Pa /usr
546 (usually around 4GB),
547 and finally a
548 .Ql g
549 partition for
550 .Pa /home
551 (usually all remaining space).
552 If you are tight on space all sizes can be halved.
553 Your mileage may vary.
554 .Pp
555 .Dl "gpt create da0"
556 .Dl "gpt add da0"
557 .Dl "disklabel64 -B -r -w da0s0 auto"
558 .Dl "disklabel64 -e da0s0"
559 .Sh ALIGNMENT
560 When a virgin disklabel64 is laid down a
561 .Dx 2.5
562 or later kernel will align the partition start offset relative to the
563 physical drive instead of relative to the slice start.
564 This overcomes the issue of fdisk creating a badly aligned slice by default.
565 The kernel will use a 1MiB (1024 * 1024 byte) alignment.
566 The purpose of this alignment is to match swap and cluster operations
567 against the physical block size of the underlying device.
568 .Pp
569 Even though nearly all devices still report a logical sector size of 512,
570 newer hard drives are starting to use larger physical sector sizes
571 and, in particular, solid state drives (SSDs) use a physical block size
572 of 64K (SLC) or 128K (MLC).  We choose a 1 megabyte alignment to cover our
573 bases down the road.  64-bit disklabels are not designed to be put on
574 ultra-tiny storage devices.
575 .Pp
576 It is worth noting that aligning cluster operations is particularly
577 important for SSDs and doubly so when
578 .Xr swapcache 8
579 is used with a SSD.
580 Swapcache is able to use large bulk writes which greatly reduces the degree
581 of write magnification on SSD media and it is possible to get upwards of
582 5x more endurance out of the device than the vendor spec sheet indicates.
583 .Sh FILES
584 .Bl -tag -width ".Pa /boot/boot2_64" -compact
585 .It Pa /boot/boot1_64
586 Default stage1 boot image.
587 .It Pa /boot/boot2_64
588 Default stage2 boot image.
589 .It Pa /etc/disktab
590 Disk description file.
591 .El
592 .Sh SAVED FILE FORMAT
593 The
594 .Nm
595 utility uses an
596 .Tn ASCII
597 version of the label when examining, editing, or restoring a disk label.
598 The format is:
599 .Bd -literal -offset 4n
600 # /dev/ad4s4:
601 #
602 # Informational fields calculated from the above
603 # All byte equivalent offsets must be aligned
604 #
605 # boot space:      32768 bytes
606 # data space:  121790552 blocks # 118936.09 MB (124713525248 bytes)
607 #
608 diskid: 5e3ef4db-4e24-11dd-8318-010e0cd0bad1
609 label:
610 boot2 data base:      0x000000001000
611 partitions data base: 0x000000009000
612 partitions data stop: 0x001d0981f000
613 backup label:         0x001d0981f000
614 total size:           0x001d09820000    # 118936.12 MB
615 alignment: 4096
616 display block size: 1024        # for partition display only
617
618 16 partitions:
619 #          size     offset    fstype   fsuuid
620   a:     524288          0    4.2BSD    #     512.000MB
621   b:    4194304     524288      swap    #    4096.000MB
622   d:    2097152    4718592    4.2BSD    #    2048.000MB
623   e:    2097152    6815744    4.2BSD    #    2048.000MB
624   f:    4194304    8912896    4.2BSD    #    4096.000MB
625   g:    4194304   13107200    4.2BSD    #    4096.000MB
626   h:   94003288   17301504    HAMMER    #   91800.086MB
627   i:    5242880  111304792       ccd    #    5120.000MB
628   j:    5242880  116547672     vinum    #    5120.000MB
629   a-stor_uuid: 4370efdb-4e25-11dd-8318-010e0cd0bad1
630   b-stor_uuid: 4370eff4-4e25-11dd-8318-010e0cd0bad1
631   d-stor_uuid: 4370f00b-4e25-11dd-8318-010e0cd0bad1
632   e-stor_uuid: 4370f024-4e25-11dd-8318-010e0cd0bad1
633   f-stor_uuid: 4370f03a-4e25-11dd-8318-010e0cd0bad1
634   g-stor_uuid: 4370f053-4e25-11dd-8318-010e0cd0bad1
635   h-stor_uuid: 4370f06a-4e25-11dd-8318-010e0cd0bad1
636   i-stor_uuid: 4370f083-4e25-11dd-8318-010e0cd0bad1
637   j-stor_uuid: 4370f099-4e25-11dd-8318-010e0cd0bad1
638 .Ed
639 .Pp
640 Lines starting with a
641 .Ql #
642 mark are comments.
643 The specifications which can be changed are:
644 .Bl -inset
645 .It Ar label
646 is an optional label, set by the
647 .Ar packid
648 option when writing a label.
649 .It Ar "the partition table"
650 is the
651 .Ux
652 partition table, not the
653 .Tn DOS
654 partition table described in
655 .Xr fdisk 8 .
656 .El
657 .Pp
658 The partition table can have up to 16 entries.
659 It contains the following information:
660 .Bl -tag -width indent
661 .It Ar #
662 The partition identifier is a single letter in the range
663 .Ql a
664 to
665 .Ql p .
666 .It Ar size
667 The size of the partition in sectors,
668 .Cm K
669 (kilobytes - 1024),
670 .Cm M
671 (megabytes - 1024*1024),
672 .Cm G
673 (gigabytes - 1024*1024*1024),
674 .Cm T
675 (terabytes - 1024*1024*1024*1024),
676 .Cm %
677 (percentage of free space
678 .Em after
679 removing any fixed-size partitions),
680 .Cm *
681 (all remaining free space
682 .Em after
683 fixed-size and percentage partitions).
684 Lowercase versions of
685 .Cm K , M , G ,
686 and
687 .Cm T
688 are allowed.
689 Size and type should be specified without any spaces between them.
690 .Pp
691 Example: 2097152, 1G, 1024M and 1048576K are all the same size
692 (assuming 512-byte sectors).
693 .It Ar offset
694 The offset of the start of the partition from the beginning of the
695 drive in sectors, or
696 .Cm *
697 to have
698 .Nm
699 calculate the correct offset to use (the end of the previous partition plus
700 one.
701 .It Ar fstype
702 Describes the purpose of the partition.
703 The example shows all currently used partition types.
704 For
705 .Xr UFS 5
706 file systems, use type
707 .Cm 4.2BSD .
708 For
709 .Xr HAMMER 5
710 file systems, use type
711 .Cm HAMMER .
712 For
713 .Xr ccd 4
714 partitions, use type
715 .Cm ccd .
716 For Vinum drives, use type
717 .Cm vinum .
718 Other common types are
719 .Cm swap
720 and
721 .Cm unused .
722 The
723 .Nm
724 utility
725 also knows about a number of other partition types,
726 none of which are in current use.
727 (See
728 .Dv fstypenames
729 in
730 .In sys/dtype.h
731 for more details).
732 .El
733 .Pp
734 The remainder of the line is a comment and shows the size of
735 the partition in MB.
736 .Sh EXAMPLES
737 .Dl "disklabel64 da0s1"
738 .Pp
739 Display the in-core label for the first slice of the
740 .Pa da0
741 disk, as obtained via
742 .Pa /dev/da0s1 .
743 (If the disk is
744 .Dq dangerously-dedicated ,
745 the compatibility slice name should be specified, such as
746 .Pa da0s0 . )
747 .Pp
748 .Dl "disklabel64 da0s1 > savedlabel"
749 .Pp
750 Save the in-core label for
751 .Pa da0s1
752 into the file
753 .Pa savedlabel .
754 This file can be used with the
755 .Fl R
756 option to restore the label at a later date.
757 .Pp
758 .Dl "disklabel64 -w -r /dev/da0s1 da2212 foo"
759 .Pp
760 Create a label for
761 .Pa da0s1
762 based on information for
763 .Dq da2212
764 found in
765 .Pa /etc/disktab .
766 Any existing bootstrap code will be clobbered
767 and the disk rendered unbootable.
768 .Pp
769 .Dl "disklabel64 -e -r da0s1"
770 .Pp
771 Read the on-disk label for
772 .Pa da0s1 ,
773 edit it, and reinstall in-core as well as on-disk.
774 Existing bootstrap code is unaffected.
775 .Pp
776 .Dl "disklabel64 -e -r -n da0s1"
777 .Pp
778 Read the on-disk label for
779 .Pa da0s1 ,
780 edit it, and display what the new label would be (in sectors).
781 It does
782 .Em not
783 install the new label either in-core or on-disk.
784 .Pp
785 .Dl "disklabel64 -r -w da0s1 auto"
786 .Pp
787 Try to auto-detect the required information from
788 .Pa da0s1 ,
789 and write a new label to the disk.
790 Use another
791 .Nm Fl e
792 command to edit the partitioning information.
793 .Pp
794 .Dl "disklabel64 -R da0s1 savedlabel"
795 .Pp
796 Restore the on-disk and in-core label for
797 .Pa da0s1
798 from information in
799 .Pa savedlabel .
800 Existing bootstrap code is unaffected.
801 .Pp
802 .Dl "disklabel64 -R -n da0s1 label_layout"
803 .Pp
804 Display what the label would be for
805 .Pa da0s1
806 using the partition layout in
807 .Pa label_layout .
808 This is useful for determining how much space would be allotted for various
809 partitions with a labelling scheme using
810 .Cm % Ns -based
811 or
812 .Cm *
813 partition sizes.
814 .Pp
815 .Dl "disklabel64 -B da0s1"
816 .Pp
817 Install a new bootstrap on
818 .Pa da0s1 .
819 The boot code comes from
820 .Pa /boot/boot1_64
821 and possibly
822 .Pa /boot/boot2_64 .
823 On-disk and in-core labels are unchanged.
824 .Pp
825 .Dl "disklabel64 -w -B /dev/da0s1 -b newboot1 -s newboot2 da2212"
826 .Pp
827 Install a new label and bootstrap.
828 The label is derived from disktab information for
829 .Dq da2212
830 and installed both in-core and on-disk.
831 The bootstrap code comes from the files
832 .Pa newboot1
833 and
834 .Pa newboot2 .
835 .Pp
836 .Dl "dd if=/dev/zero of=/dev/da0 bs=512 count=32"
837 .Dl "fdisk -BI da0"
838 .Dl "dd if=/dev/zero of=/dev/da0s1 bs=512 count=32"
839 .Dl "disklabel64 -w -B da0s1 auto"
840 .Dl "disklabel64 -e da0s1"
841 .Pp
842 Completely wipe any prior information on the disk, creating a new bootable
843 disk with a DOS partition table containing one
844 .Dq whole-disk
845 slice.
846 Then
847 initialize the slice, then edit it to your needs.
848 The
849 .Pa dd
850 commands are optional, but may be necessary for some BIOSes to properly
851 recognize the disk.
852 .Pp
853 .Dl "disklabel64 -W da0s1"
854 .Dl "dd if=/dev/zero of=/dev/da0s1 bs=512 count=32"
855 .Dl "disklabel -r -w da0s1 auto"
856 .Dl "disklabel -N da0s1"
857 .Pp
858 Completely wipe any prior information on the slice,
859 changing label format to 32 bit.
860 The wiping is needed as
861 .Nm disklabel
862 and
863 .Nm ,
864 as a safety measure,
865 won't do any operations if label with other format is already installed.
866 .Pp
867 This is an example disklabel that uses some of the new partition size types
868 such as
869 .Cm % , M , G ,
870 and
871 .Cm * ,
872 which could be used as a source file for
873 .Pp
874 .Dl "disklabel64 -R ad0s1 new_label_file"
875 .Bd -literal -offset 4n
876 # /dev/ad4s4:
877 #
878 # Informational fields calculated from the above
879 # All byte equivalent offsets must be aligned
880 #
881 # boot space:      32768 bytes
882 # data space:  121790552 blocks # 118936.09 MB (124713525248 bytes)
883 #
884 diskid: b1db58a3-4e26-11dd-8318-010e0cd0bad1
885 label:
886 boot2 data base:      0x000000001000
887 partitions data base: 0x000000009000
888 partitions data stop: 0x001d0981f000
889 backup label:         0x001d0981f000
890 total size:           0x001d09820000    # 118936.12 MB
891 alignment: 4096
892 display block size: 1024        # for partition display only
893
894 16 partitions:
895 #          size     offset    fstype   fsuuid
896   a:       512M          0    4.2BSD
897   b:         4G          *      swap
898   d:         2G          *    4.2BSD
899   e:      2048M          *    4.2BSD
900   f:         4G          *    4.2BSD
901   g:         4G          *    4.2BSD
902   h:          *          *    HAMMER
903   i:         5g          *       ccd
904   j:      5120m          *     vinum
905 .Ed
906 .Sh DIAGNOSTICS
907 The kernel device drivers will not allow the size of a disk partition
908 to be decreased or the offset of a partition to be changed while it is open.
909 Some device drivers create a label containing only a single large partition
910 if a disk is unlabeled; thus, the label must be written to the
911 .Ql a
912 partition of the disk while it is open.
913 This sometimes requires the desired
914 label to be set in two steps, the first one creating at least one other
915 partition, and the second setting the label on the new partition while
916 shrinking the
917 .Ql a
918 partition.
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 disklabel32 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 The
935 .Nm
936 utility
937 does not perform all possible error checking.
938 Warning
939 .Em is
940 given if partitions
941 overlap; if an absolute offset does not match the expected offset; if a
942 partition runs past the end of the device; and a number of other errors; but
943 no warning is given if space remains unused.