xref: /dragonfly/sbin/disklabel32/disklabel32.8 (revision 37de577a)
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 DISKLABEL32 8
36.Os
37.Sh NAME
38.Nm disklabel32
39.Nd read and write 32 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.Nm
93.Fl f Ar slice_start_lba
94.Oo Ar options Oc
95.Sh DESCRIPTION
96The
97.Nm
98utility
99installs, examines or modifies a 32 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 Ar disktype Ns / Ns Cm auto
193.Oo Ar packid Oc
194.Pp
195The required arguments to
196.Nm
197are the drive to be labeled and the drive type as described in the
198.Xr disktab 5
199file.
200The drive parameters and partitions are taken from that file.
201If
202different disks of the same physical type are to have different partitions, it
203will be necessary to have separate disktab entries describing each, or to edit
204the label after installation as described below.
205The optional argument is a
206pack identification string, up to 16 characters long.
207The pack id must be
208quoted if it contains blanks.
209.Pp
210If the
211.Fl n
212flag is given, no data will be written to the device, and instead the
213disklabel that would have been written will be printed to stdout.
214.Pp
215If the
216.Fl r
217flag is given, the disk sectors containing the label and bootstrap
218will be written directly.
219A side-effect of this is that any existing bootstrap code will be overwritten
220and the disk rendered unbootable.
221See the boot options below for a method of
222writing the label and the bootstrap at the same time.
223If
224.Fl r
225is not specified,
226the existing label will be updated via the in-core copy and any bootstrap
227code will be unaffected.
228If the disk does not already have a label, the
229.Fl r
230flag must be used.
231In either case, the kernel's in-core label is replaced.
232.Pp
233For a virgin disk that is not known to
234.Xr disktab 5 ,
235.Ar disktype
236can be specified as
237.Cm auto .
238In this case, the driver is requested to produce a virgin label for the
239disk.
240This might or might not be successful, depending on whether the
241driver for the disk is able to get the required data without reading
242anything from the disk at all.
243It will likely succeed for all SCSI
244disks, most IDE disks, and vnode devices.
245Writing a label to the
246disk is the only supported operation, and the
247.Ar disk
248itself must be provided as the canonical name, i.e.\& not as a full
249path name.
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 UFS 5
363file system.
364If you are creating a
365.Dq dangerously-dedicated
366slice for compatibility with older PC systems,
367you generally want to specify the compatibility slice, such as
368.Pa da0s0 .
369If you are creating a label within an existing DOS slice,
370you should specify
371the slice name such as
372.Pa da0s1 .
373Making a slice bootable can be tricky.
374If you are using a normal DOS
375slice you typically install (or leave) a standard MBR on the base disk and
376then install the
377.Dx
378bootblocks in the slice.
379.Pp
380.Nm
381.Fl B
382.Oo
383.Fl b Ar boot1
384.Fl s Ar boot2
385.Oc
386.Ar disk
387.Oo Ar disktype Ns / Ns Cm auto Oc
388.Pp
389This form installs the bootstrap only.
390It does not change the disk label.
391You should never use this command on the compatibility slice unless you
392intend to create a
393.Dq dangerously-dedicated
394disk, such as
395.Ar da0s0 .
396This command is typically run on a
397.Bx
398slice such as
399.Ar da0s1 .
400.Pp
401.Nm
402.Fl w
403.Fl B
404.Op Fl n
405.Oo
406.Fl b Ar boot1
407.Fl s Ar boot2
408.Oc
409.Ar disk Ar disktype Ns / Ns Cm auto
410.Oo Ar packid Oc
411.Pp
412This form corresponds to the
413.Dq write label
414command described above.
415In addition to writing a new volume label, it also installs the bootstrap.
416If run on the compatibility slice this command will create a
417.Dq dangerously-dedicated
418label.
419This command is normally run on a
420.Bx
421slice rather than the compatibility slice.
422If
423.Fl n
424is used, no data will be written to the device, and instead the
425disklabel that would have been written will be printed to stdout.
426.Pp
427.Nm
428.Fl R
429.Fl B
430.Op Fl n
431.Oo
432.Fl b Ar boot1
433.Fl s Ar boot2
434.Oc
435.Ar disk Ar protofile
436.Oo Ar disktype Ns / Ns Cm auto Oc
437.Pp
438This form corresponds to the
439.Dq restore label
440command described above.
441In addition to restoring the volume label, it also installs the bootstrap.
442If run on the compatibility slice this command will create a
443.Dq dangerously-dedicated
444label.
445This command is normally run on a
446.Bx
447slice rather than the compatibility
448slice.
449.Pp
450The bootstrap commands always access the disk directly,
451so it is not necessary to specify the
452.Fl r
453flag.
454If
455.Fl n
456is used, no data will be written to the device, and instead the
457disklabel that would have been written will be printed to stdout.
458.Pp
459The bootstrap code is comprised of two boot programs.
460Specify the name of the
461boot programs to be installed in one of these ways:
462.Bl -enum
463.It
464Specify the names explicitly with the
465.Fl b
466and
467.Fl s
468flags.
469.Fl b
470indicates the primary boot program and
471.Fl s
472the secondary boot program.
473The boot programs are normally located in
474.Pa /boot .
475.It
476If the
477.Fl b
478and
479.Fl s
480flags are not specified, but
481.Ar disktype
482was specified, the names of the programs are taken from the
483.Dq b0
484and
485.Dq b1
486parameters of the
487.Xr disktab 5
488entry for the disk if the disktab entry exists and includes those parameters.
489.It
490Otherwise, the default boot image names are used:
491.Pa /boot/boot1
492and
493.Pa /boot/boot2
494for the standard stage1 and stage2 boot images.
495.El
496.Ss Initializing/Formatting a bootable disk from scratch
497To initialize a disk from scratch the following sequence is recommended.
498Please note that this will wipe everything that was previously on the disk,
499including any
500.No non- Ns Dx
501slices.
502.Bl -enum
503.It
504Use
505.Xr gpt 8
506or
507.Xr fdisk 8
508to initialize the hard disk, and create a GPT or MBR slice table,
509referred to as the
510.Dq "partition table"
511in
512.Tn DOS .
513.It
514Use
515.Nm
516or
517.Xr disklabel64 8
518to define partitions on
519.Dx
520slices created in the previous step.
521.It
522Finally use
523.Xr newfs_hammer 8
524or
525.Xr newfs 8
526to create file systems on new partitions.
527.El
528.Pp
529A typical partitioning scheme would be to have an
530.Ql a
531partition
532of approximately 512MB to hold the root file system, a
533.Ql b
534partition for
535swap (usually 4GB), a
536.Ql d
537partition for
538.Pa /var
539(usually 2GB), an
540.Ql e
541partition for
542.Pa /var/tmp
543(usually 2GB), an
544.Ql f
545partition for
546.Pa /usr
547(usually around 4GB),
548and finally a
549.Ql g
550partition for
551.Pa /home
552(usually all remaining space).
553If you are tight on space all sizes can be halved.
554Your mileage may vary.
555.Pp
556.Dl "fdisk -BI da0"
557.Dl "disklabel32 -w -B da0s1 auto"
558.Dl "disklabel32 -e da0s1"
559.Ss Manual offset
560.Dx
561no longer snoop-adjusts the on-disk label when reading or writing
562raw labels.
563.Nm
564is now responsible for adjusting the label when operating in raw mode.
565Traditional (32 bit,
566.Bx )
567disklabels store offsets as absolute block numbers
568rather than slice-relative block numbers.
569If
570.Nm
571is unable to issue the
572.Dv DIOCGPART
573ioctl to get slice information it will
574refuse to read or write the label in raw mode.
575The
576.Fl f
577option may be used to force the operation by supplying a manual offset.
578.Sh FILES
579.Bl -tag -width ".Pa /etc/disktab" -compact
580.It Pa /boot/boot1
581Default stage1 boot image.
582.It Pa /boot/boot2
583Default stage2 boot image.
584.It Pa /etc/disktab
585Disk description file.
586.El
587.Sh SAVED FILE FORMAT
588The
589.Nm
590utility uses an
591.Tn ASCII
592version of the label when examining, editing, or restoring a disk label.
593The format is:
594.Bd -literal -offset 4n
595# /dev/ad4s4:
596type: unknown
597disk: amnesiac
598label: fictitious
599flags:
600bytes/sector: 512
601sectors/track: 63
602tracks/cylinder: 24
603sectors/cylinder: 1512
604cylinders: 161098
605sectors/unit: 243581184
606rpm: 3600
607interleave: 1
608trackskew: 0
609cylinderskew: 0
610headswitch: 0		# milliseconds
611track-to-track seek: 0	# milliseconds
612drivedata: 0
613
61416 partitions:
615#          size     offset    fstype
616  a:    1048560         16    4.2BSD	#     511.992MB
617  b:    8388608    1048576      swap	#    4096.000MB
618  c:  243581184          0    unused	#  118936.125MB
619  d:    4194304    9437184    4.2BSD	#    2048.000MB
620  e:    4194304   13631488    4.2BSD	#    2048.000MB
621  f:    8388608   17825792    4.2BSD	#    4096.000MB
622  h:  196395264   26214400    HAMMER	#   95896.125MB
623  i:   10485760  222609664       ccd	#    5120.000MB
624  j:   10485760  233095424     vinum	#    5120.000MB
625.Ed
626.Pp
627Lines starting with a
628.Ql #
629mark are comments.
630Most of the other specifications are no longer used.
631The ones which must still be set correctly are:
632.Bl -inset
633.It Ar label
634is an optional label, set by the
635.Ar packid
636option when writing a label.
637.It Ar flags
638may be
639.Cm removable , ecc
640or
641.Cm badsect .
642.Cm removable
643is set for removable media drives, but no current
644.Dx
645driver evaluates this
646flag.
647.Cm ecc
648is no longer supported;
649.Cm badsect
650specifies that the drive can perform bad sector remapping.
651.It Ar sectors/unit
652describes the total size of the disk.
653This value must be correct.
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 .
671By convention, partition
672.Ql c
673is reserved to describe the entire disk.
674.It Ar size
675The size of the partition in sectors,
676.Cm K
677(kilobytes - 1024),
678.Cm M
679(megabytes - 1024*1024),
680.Cm G
681(gigabytes - 1024*1024*1024),
682.Cm T
683(gigabytes - 1024*1024*1024*1024),
684.Cm %
685(percentage of free space
686.Em after
687removing any fixed-size partitions other than partition
688.Ql c ) ,
689or
690.Cm *
691(all remaining free space
692.Em after
693fixed-size and percentage partitions).
694For partition
695.Ql c ,
696a size of
697.Cm *
698indicates the entire disk.
699Lowercase versions of
700.Cm K , M , G ,
701and
702.Cm T
703are allowed.
704Size and type should be specified without any spaces between them.
705.Pp
706Example: 2097152, 1G, 1024M and 1048576K are all the same size
707(assuming 512-byte sectors).
708.It Ar offset
709The offset of the start of the partition from the beginning of the
710drive in sectors, or
711.Cm *
712to have
713.Nm
714calculate the correct offset to use (the end of the previous partition plus
715one, ignoring partition
716.Ql c .
717For partition
718.Ql c ,
719.Cm *
720will be interpreted as an offset of 0.
721.It Ar fstype
722Describes the purpose of the partition.
723The example shows all currently used partition types.
724For
725.Xr UFS 5
726file systems, use type
727.Cm 4.2BSD .
728For
729.Xr HAMMER 5
730file systems, use type
731.Cm HAMMER .
732For
733.Xr ccd 4
734partitions, use type
735.Cm ccd .
736For Vinum drives, use type
737.Cm vinum .
738Other common types are
739.Cm swap
740and
741.Cm unused .
742By convention, partition
743.Ql c
744represents the entire slice and should be of type
745.Cm unused ,
746though
747.Nm
748does not enforce this convention.
749The
750.Nm
751utility
752also knows about a number of other partition types,
753none of which are in current use.
754(See
755.Dv fstypenames
756in
757.In sys/dtype.h
758for more details).
759.El
760.Pp
761The remainder of the line is a comment and shows the size of
762the partition in MB.
763.Sh EXAMPLES
764.Dl "disklabel32 da0s1"
765.Pp
766Display the in-core label for the first slice of the
767.Pa da0
768disk, as obtained via
769.Pa /dev/da0s1 .
770(If the disk is
771.Dq dangerously-dedicated ,
772the compatibility slice name should be specified, such as
773.Pa da0s0 . )
774.Pp
775.Dl "disklabel32 da0s1 > savedlabel"
776.Pp
777Save the in-core label for
778.Pa da0s1
779into the file
780.Pa savedlabel .
781This file can be used with the
782.Fl R
783option to restore the label at a later date.
784.Pp
785.Dl "disklabel32 -w -r /dev/da0s1 da2212 foo"
786.Pp
787Create a label for
788.Pa da0s1
789based on information for
790.Dq da2212
791found in
792.Pa /etc/disktab .
793Any existing bootstrap code will be clobbered
794and the disk rendered unbootable.
795.Pp
796.Dl "disklabel32 -e -r da0s1"
797.Pp
798Read the on-disk label for
799.Pa da0s1 ,
800edit it, and reinstall in-core as well as on-disk.
801Existing bootstrap code is unaffected.
802.Pp
803.Dl "disklabel32 -e -r -n da0s1"
804.Pp
805Read the on-disk label for
806.Pa da0s1 ,
807edit it, and display what the new label would be (in sectors).
808It does
809.Em not
810install the new label either in-core or on-disk.
811.Pp
812.Dl "disklabel32 -r -w da0s1 auto"
813.Pp
814Try to auto-detect the required information from
815.Pa da0s1 ,
816and write a new label to the disk.
817Use another
818.Nm Fl e
819command to edit the
820partitioning and file system information.
821.Pp
822.Dl "disklabel32 -R da0s1 savedlabel"
823.Pp
824Restore the on-disk and in-core label for
825.Pa da0s1
826from information in
827.Pa savedlabel .
828Existing bootstrap code is unaffected.
829.Pp
830.Dl "disklabel32 -R -n da0s1 label_layout"
831.Pp
832Display what the label would be for
833.Pa da0s1
834using the partition layout in
835.Pa label_layout .
836This is useful for determining how much space would be allotted for various
837partitions with a labelling scheme using
838.Cm % Ns -based
839or
840.Cm *
841partition sizes.
842.Pp
843.Dl "disklabel32 -B da0s1"
844.Pp
845Install a new bootstrap on
846.Pa da0s1 .
847The boot code comes from
848.Pa /boot/boot1
849and possibly
850.Pa /boot/boot2 .
851On-disk and in-core labels are unchanged.
852.Pp
853.Dl "disklabel32 -w -B /dev/da0s1 -b newboot1 -s newboot2 da2212"
854.Pp
855Install a new label and bootstrap.
856The label is derived from disktab information for
857.Dq da2212
858and installed both in-core and on-disk.
859The bootstrap code comes from the files
860.Pa newboot1
861and
862.Pa newboot2 .
863.Pp
864.Dl "dd if=/dev/zero of=/dev/da0 bs=512 count=32"
865.Dl "fdisk -BI da0"
866.Dl "dd if=/dev/zero of=/dev/da0s1 bs=512 count=32"
867.Dl "disklabel32 -w -B da0s1 auto"
868.Dl "disklabel32 -e da0s1"
869.Pp
870Completely wipe any prior information on the disk, creating a new bootable
871disk with a DOS partition table containing one
872.Dq whole-disk
873slice.
874Then
875initialize the slice, then edit it to your needs.
876The
877.Pa dd
878commands are optional, but may be necessary for some BIOSes to properly
879recognize the disk.
880.Pp
881.Dl "disklabel32 -W da0s1"
882.Dl "dd if=/dev/zero of=/dev/da0s1 bs=512 count=32"
883.Dl "disklabel64 -r -w da0s1 auto"
884.Dl "disklabel64 -N da0s1"
885.Pp
886Completely wipe any prior information on the slice,
887changing label format to 64 bit.
888The wiping is needed as
889.Nm disklabel64
890and
891.Nm ,
892as a safety measure,
893won't do any operations if label with other format is already installed.
894.Pp
895This is an example disklabel that uses some of the new partition size types
896such as
897.Cm % , M , G ,
898and
899.Cm * ,
900which could be used as a source file for
901.Pp
902.Dl "disklabel32 -R ad0s1 new_label_file"
903.Bd -literal -offset 4n
904# /dev/ad0s1:
905type: ESDI
906disk: ad0s1
907label:
908flags:
909bytes/sector: 512
910sectors/track: 63
911tracks/cylinder: 16
912sectors/cylinder: 1008
913cylinders: 40633
914sectors/unit: 40959009
915rpm: 3600
916interleave: 1
917trackskew: 0
918cylinderskew: 0
919headswitch: 0		# milliseconds
920track-to-track seek: 0	# milliseconds
921drivedata: 0
922
92316 partitions:
924#          size     offset    fstype
925  a:       400M          0    4.2BSD
926  b:         1G          *      swap
927  c:          *          *    unused
928  e:     204800          *    4.2BSD
929  f:         5g          *    4.2BSD
930  g:          *          *    4.2BSD
931.Ed
932.Sh DIAGNOSTICS
933The kernel device drivers will not allow the size of a disk partition
934to be decreased or the offset of a partition to be changed while it is open.
935Some device drivers create a label containing only a single large partition
936if a disk is unlabeled; thus, the label must be written to the
937.Ql a
938partition of the disk while it is open.
939This sometimes requires the desired
940label to be set in two steps, the first one creating at least one other
941partition, and the second setting the label on the new partition while
942shrinking the
943.Ql a
944partition.
945.Pp
946On some machines the bootstrap code may not fit entirely in the area
947allocated for it by some file systems.
948As a result, it may not be possible to have file systems on some partitions
949of a
950.Dq bootable
951disk.
952When installing bootstrap code,
953.Nm
954checks for these cases.
955If the installed boot code would overlap a partition of type
956.Dv FS_UNUSED
957it is marked as type
958.Dv FS_BOOT .
959The
960.Xr newfs 8
961utility will disallow creation of file systems on
962.Dv FS_BOOT
963partitions.
964Conversely, if a partition has a type other than
965.Dv FS_UNUSED
966or
967.Dv FS_BOOT ,
968.Nm
969will not install bootstrap code that overlaps it.
970.Sh COMPATIBILITY
971Due to
972.Xr disklabel32 5
973storing sector numbers in 32 bit format
974.Nm
975is restricted to 2TB, using the prevalent sector size of 512B.
976.Xr disklabel64 5
977labels should be used to partition larger disks.
978.Pp
979The various
980.Bx Ns s
981use slightly different versions of
982.Bx
983disklabels
984and are not generally compatible.
985The
986.Dx
987kernel can often use labels from other
988.Bx Ns s
989for read-only operation.
990.Sh SEE ALSO
991.Xr dd 1 ,
992.Xr ccd 4 ,
993.Xr disklabel32 5 ,
994.Xr disktab 5 ,
995.Xr boot0cfg 8 ,
996.Xr diskinfo 8 ,
997.Xr disklabel64 8 ,
998.Xr fdisk 8 ,
999.Xr gpt 8 ,
1000.Xr newfs 8 ,
1001.Xr newfs_hammer 8 ,
1002.Xr vinum 8
1003.Sh BUGS
1004The
1005.Nm
1006utility
1007does not perform all possible error checking.
1008Warning
1009.Em is
1010given if partitions
1011overlap; if an absolute offset does not match the expected offset; if the
1012.Ql c
1013partition does not start at 0 or does not cover the entire slice; if a
1014partition runs past the end of the device; and a number of other errors; but
1015no warning is given if space remains unused.
1016