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