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