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