MFC r1.6 r1.30 r1.28 (HEAD):
[dragonfly.git] / sbin / disklabel / disklabel.8
blobd256b49f7f98c272e0e90d6dcc34a2f65f3ee3c5
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/disklabel/disklabel.8,v 1.22.2.2 2008/09/16 21:54:32 thomas Exp $
38 .\"
39 .Dd August 21, 2008
40 .Dt DISKLABEL 8
41 .Os
42 .Sh NAME
43 .Nm disklabel
44 .Nd read and write 32 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 .Nm
98 .Fl f Ar slice_start_lba
99 .Oo Ar options Oc
100 .Sh DESCRIPTION
103 utility
104 installs, examines or modifies the label on a disk drive or pack.
105 When writing
106 the label, it can be used to change the drive identification, the disk
107 partitions on the drive, or to replace a damaged label.
108 There are several forms
109 of the command that read (display), install or edit the label on a disk.
111 addition,
113 can install bootstrap code.
114 .Ss Raw or in-core label
115 The disk label resides close to or at the beginning of each disk slice.
116 For faster access, the kernel maintains a copy in core at all times.
118 default, most forms of the
120 command access the in-core copy of the label.
121 To access the raw (on-disk)
122 copy, use the
123 .Fl r
124 option.
125 This option allows a label to be installed on a disk without kernel
126 support for a label, such as when labels are first installed on a system; it
127 must be used when first installing a label on a disk.
128 The specific effect of
129 .Fl r
130 is described under each command.
131 .Ss Disk device name
134 forms require a disk device name, which should always be the raw
135 device name representing the disk or slice.
137 uses the following scheme for slice numbering:
138 If the disk doesn't use GPT (typically laid out by
139 .Xr gpt 8 ) ,
140 but e.g.\& MBR (typically laid out by
141 .Xr fdisk 8 ) ,
142 then slice 0, e.g.\&
143 .Pa da0s0 ,
144 represents the entire disk regardless of any DOS partitioning.
145 Slice 0 is called the compatibility slice,
146 and slice 1 and onward, e.g.\&
147 .Pa da0s1 ,
148 represent
150 slices.
151 If the disk does use GPT, then all slices are
153 slices, slice 0 isn't special, it is just the first slice on the disk.
154 You do not have to include the
155 .Pa /dev/
156 path prefix when specifying the device.
159 utility will automatically prepend it.
160 .Ss Reading the disk label
161 To examine the label on a disk drive, use
163 without options:
166 .Op Fl r
167 .Ar disk
169 .Ar disk
170 represents the raw disk in question, and may be in the form
171 .Pa da0s1
173 .Pa /dev/da0s1 .
174 It will display all of the parameters associated with the drive and its
175 partition layout.
176 Unless the
177 .Fl r
178 flag is given,
179 the kernel's in-core copy of the label is displayed;
180 if the disk has no label, or the partition types on the disk are incorrect,
181 the kernel may have constructed or modified the label.
182 If the
183 .Fl r
184 flag is given,
186 reads the label from the raw disk and displays it.
187 Both versions are usually
188 identical except in the case where a label has not yet been initialized or
189 is corrupt.
190 .Ss Writing a standard label
191 To write a standard label, use the form
194 .Fl w
195 .Op Fl r
196 .Op Fl n
197 .Ar disk Ar disktype Ns / Ns Cm auto
198 .Oo Ar packid Oc
200 The required arguments to
202 are the drive to be labeled and the drive type as described in the
203 .Xr disktab 5
204 file.
205 The drive parameters and partitions are taken from that file.
207 different disks of the same physical type are to have different partitions, it
208 will be necessary to have separate disktab entries describing each, or to edit
209 the label after installation as described below.
210 The optional argument is a
211 pack identification string, up to 16 characters long.
212 The pack id must be
213 quoted if it contains blanks.
215 If the
216 .Fl n
217 flag is given, no data will be written to the device, and instead the
218 disklabel that would have been written will be printed to stdout.
220 If the
221 .Fl r
222 flag is given, the disk sectors containing the label and bootstrap
223 will be written directly.
224 A side-effect of this is that any existing bootstrap code will be overwritten
225 and the disk rendered unbootable.
226 See the boot options below for a method of
227 writing the label and the bootstrap at the same time.
229 .Fl r
230 is not specified,
231 the existing label will be updated via the in-core copy and any bootstrap
232 code will be unaffected.
233 If the disk does not already have a label, the
234 .Fl r
235 flag must be used.
236 In either case, the kernel's in-core label is replaced.
238 For a virgin disk that is not known to
239 .Xr disktab 5 ,
240 .Ar disktype
241 can be specified as
242 .Cm auto .
243 In this case, the driver is requested to produce a virgin label for the
244 disk.
245 This might or might not be successful, depending on whether the
246 driver for the disk is able to get the required data without reading
247 anything from the disk at all.
248 It will likely succeed for all SCSI
249 disks, most IDE disks, and vnode devices.
250 Writing a label to the
251 disk is the only supported operation, and the
252 .Ar disk
253 itself must be provided as the canonical name, i.e.\& not as a full
254 path name.
256 For most harddisks, a label based on percentages for most partitions (and
257 one partition with a size of
258 .Ql * )
259 will produce a reasonable configuration.
261 PC-based systems have special requirements in order for the BIOS to properly
262 recognize a
264 disklabel.
265 Older systems may require what is known as a
266 .Dq dangerously dedicated
267 disklabel, which creates a fake DOS partition to work around problems older
268 BIOSes have with modern disk geometries.
269 On newer systems you generally want
270 to create a normal DOS partition using
271 .Ar fdisk
272 and then create a
274 disklabel within that slice.
275 This is described
276 later on in this page.
278 Installing a new disklabel does not in of itself allow your system to boot
279 a kernel using that label.
280 You must also install boot blocks, which is
281 described later on in this manual page.
282 .Ss Editing an existing disk label
283 To edit an existing disk label, use the form
286 .Fl e
287 .Op Fl r
288 .Op Fl n
289 .Ar disk
291 This command reads the label from the in-core kernel copy, or directly from the
292 disk if the
293 .Fl r
294 flag is also specified.
295 The label is written to a file in ASCII and then
296 supplied to an editor for changes.
297 If no editor is specified in an
298 .Ev EDITOR
299 environment variable,
300 .Xr vi 1
301 is used.
302 When the editor terminates, the label file is used to rewrite the disk
303 label.
304 Existing bootstrap code is unchanged regardless of whether
305 .Fl r
306 was specified.
308 .Fl n
309 is specified, no data will be written to the device, and instead the
310 disklabel that would have been written will be printed to stdout.
311 This is
312 useful to see how a partitioning scheme will work out for a specific disk.
313 .Ss Restoring a disk label from a file
314 To restore a disk label from a file, use the form
317 .Fl R
318 .Op Fl r
319 .Op Fl n
320 .Ar disk Ar protofile
323 is capable of restoring a disk label that was previously saved in a file
324 in ASCII format.
325 The prototype file used to create the label should be in the same format
326 as that produced when reading or editing a label.
327 Comments are delimited by
328 .Ql #
329 and newline.
330 As when writing a new label, any existing bootstrap code will be
331 clobbered if
332 .Fl r
333 is specified and will be unaffected otherwise.
334 See the boot options below for a
335 method of restoring the label and writing the bootstrap at the same time.
337 .Fl n
338 is used, no data will be written to the device, and instead the
339 disklabel that would have been written will be printed to stdout.
340 This is
341 useful to see how a partitioning scheme will work out for a specific disk.
342 .Ss Enabling and disabling writing to the disk label area
343 By default, it is not possible to write to the disk label area at the beginning
344 of a disk.
345 The disk driver arranges for
346 .Xr write 2
347 and similar system calls
348 to return
349 .Er EROFS
350 on any attempt to do so.
351 If you need
352 to write to this area (for example, to obliterate the label), use the form
355 .Fl W
356 .Ar disk
358 To disallow writing to the label area after previously allowing it, use the
359 command
362 .Fl N
363 .Ar disk
364 .Ss Installing bootstraps
365 The final three forms of
367 are used to install bootstrap code.
368 If you are creating a
369 .Dq dangerously-dedicated
370 slice for compatibility with older PC systems,
371 you generally want to specify the compatibility slice, such as
372 .Pa da0s0 .
373 If you are creating a label within an existing DOS slice,
374 you should specify
375 the slice name such as
376 .Pa da0s1 .
377 Making a slice bootable can be tricky.
378 If you are using a normal DOS
379 slice you typically install (or leave) a standard MBR on the base disk and
380 then install the
382 bootblocks in the slice.
385 .Fl B
387 .Fl b Ar boot1
388 .Fl s Ar boot2
390 .Ar disk
391 .Oo Ar disktype Oc
393 This form installs the bootstrap only.
394 It does not change the disk label.
395 You should never use this command on the compatibility slice unless you
396 intend to create a
397 .Dq dangerously-dedicated
398 disk, such as
399 .Ar da0s0 .
400 This command is typically run on a
402 slice such as
403 .Ar da0s1 .
406 .Fl w
407 .Fl B
408 .Op Fl n
410 .Fl b Ar boot1
411 .Fl s Ar boot2
413 .Ar disk Ar disktype Ns / Ns Cm auto
414 .Oo Ar packid Oc
416 This form corresponds to the
417 .Dq write label
418 command described above.
419 In addition to writing a new volume label, it also installs the bootstrap.
420 If run on the compatibility slice this command will create a
421 .Dq dangerously-dedicated
422 label.
423 This command is normally run on a
425 slice rather than the compatibility
426 slice.
428 .Fl n
429 is used, no data will be written to the device, and instead the
430 disklabel that would have been written will be printed to stdout.
433 .Fl R
434 .Fl B
435 .Op Fl n
437 .Fl b Ar boot1
438 .Fl s Ar boot2
440 .Ar disk Ar protofile
441 .Oo Ar disktype Ns / Ns Cm auto Oc
443 This form corresponds to the
444 .Dq restore label
445 command described above.
446 In addition to restoring the volume label, it also installs the bootstrap.
447 If run on the compatibility slice this command will create a
448 .Dq dangerously-dedicated
449 label.
450 This command is normally run on a
452 slice rather than the compatibility
453 slice.
455 The bootstrap commands always access the disk directly, so it is not necessary
456 to specify the
457 .Fl r
458 flag.
460 .Fl n
461 is used, no data will be written to the device, and instead the
462 disklabel that would have been written will be printed to stdout.
464 The bootstrap code is comprised of two boot programs.
465 Specify the name of the
466 boot programs to be installed in one of these ways:
467 .Bl -enum
469 Specify the names explicitly with the
470 .Fl b
472 .Fl s
473 flags.
474 .Fl b
475 indicates the primary boot program and
476 .Fl s
477 the secondary boot program.
478 The boot programs are located in
479 .Pa /boot .
481 If the
482 .Fl b
484 .Fl s
485 flags are not specified, but
486 .Ar disktype
487 was specified, the names of the programs are taken from the
488 .Dq b0
490 .Dq b1
491 parameters of the
492 .Xr disktab 5
493 entry for the disk if the disktab entry exists and includes those parameters.
495 Otherwise, the default boot image names are used:
496 .Pa /boot/boot1
498 .Pa /boot/boot2
499 for the standard stage1 and stage2 boot images.
501 .Ss Initializing/Formatting a bootable disk from scratch
502 To initialize a disk from scratch the following sequence is recommended.
503 Please note that this will wipe everything that was previously on the disk,
504 including any
505 .No non- Ns Dx
506 slices.
507 .Bl -enum
510 .Xr fdisk 8
511 to initialize the hard disk, and create a slice table, referred to
512 as the
513 .Dq "partition table"
515 .Tn DOS .
519 to define partitions on
521 slices created in the previous step.
523 Finally use
524 .Xr newfs 8
525 to create file systems on new partitions.
528 A typical partitioning scheme would be to have an
529 .Ql a
530 partition
531 of approximately 512MB to hold the root file system, a
532 .Ql b
533 partition for
534 swap (usually 4GB), a
535 .Ql d
536 partition for
537 .Pa /var
538 (usually 2GB), an
539 .Ql e
540 partition
542 .Pa /var/tmp
543 (usually 2GB), an
544 .Ql f
545 partition for
546 .Pa /usr
547 (usually around 4GB),
548 and finally a
549 .Ql g
550 partition for
551 .Pa /home
552 (usually all remaining space).
553 Your mileage may vary.
555 .Nm fdisk Fl BI Pa da0
558 .Fl w B
559 .Pa da0s1
560 .Cm auto
563 .Fl e
564 .Pa da0s1
565 .Ss Manual offset
567 no longer snoop-adjusts the on-disk label when reading or writing
568 raw labels.
570 is now responsible for adjusting the label when operating in raw mode.
571 Traditional (32 bit
572 .Bx )
573 disklabels store offsets as absolute block numbers
574 rather than slice-relative block numbers.
577 is unable to issue the
578 .Dv DIOCGPART
579 ioctl to get slice information it will
580 refuse to read or write the label in raw mode.
582 .Fl f
583 option may be used to force the operation by supplying a manual offset.
584 .Sh FILES
585 .Bl -tag -width ".Pa /etc/disktab" -compact
586 .It Pa /boot/boot1
587 Default stage1 boot image.
588 .It Pa /boot/boot2
589 Default stage2 boot image.
590 .It Pa /etc/disktab
591 Disk description file.
593 .Sh SAVED FILE FORMAT
596 utility
597 uses an
598 .Tn ASCII
599 version of the label when examining, editing, or restoring a disk
600 label.
601 The format is:
602 .Bd -literal -offset 4n
603 # /dev/ad4s4:
604 type: unknown
605 disk: amnesiac
606 label: fictitious
607 flags:
608 bytes/sector: 512
609 sectors/track: 63
610 tracks/cylinder: 24
611 sectors/cylinder: 1512
612 cylinders: 161098
613 sectors/unit: 243581184
614 rpm: 3600
615 interleave: 1
616 trackskew: 0
617 cylinderskew: 0
618 headswitch: 0           # milliseconds
619 track-to-track seek: 0  # milliseconds
620 drivedata: 0
622 16 partitions:
623 #          size     offset    fstype
624   a:    1048560         16    4.2BSD    #     511.992MB
625   b:    8388608    1048576      swap    #    4096.000MB
626   c:  243581184          0    unused    #  118936.125MB
627   d:    4194304    9437184    4.2BSD    #    2048.000MB
628   e:    4194304   13631488    4.2BSD    #    2048.000MB
629   f:    8388608   17825792    4.2BSD    #    4096.000MB
630   h:  196395264   26214400    HAMMER    #   95896.125MB
631   i:   10485760  222609664       ccd    #    5120.000MB
632   j:   10485760  233095424     vinum    #    5120.000MB
635 Lines starting with a
636 .Ql #
637 mark are comments.
638 Most of the other specifications are no longer used.
639 The ones which must still be set correctly are:
640 .Bl -inset
641 .It Ar label
642 is an optional label, set by the
643 .Ar packid
644 option when writing a label.
645 .It Ar flags
646 may be
647 .Cm removable , ecc
649 .Cm badsect .
650 .Cm removable
651 is set for removable media drives, but no current
653 driver evaluates this
654 flag.
655 .Cm ecc
656 is no longer supported;
657 .Cm badsect
658 specifies that the drive can perform bad sector remapping.
659 .It Ar sectors/unit
660 describes the total size of the disk.
661 This value must be correct.
662 .It Ar "the partition table"
663 is the
665 partition table, not the
666 .Tn DOS
667 partition table described in
668 .Xr fdisk 8 .
671 The partition table can have up to 16 entries.
672 It contains the following information:
673 .Bl -tag -width indent
674 .It Ar #
675 The partition identifier is a single letter in the range
676 .Ql a
678 .Ql p .
679 By convention, partition
680 .Ql c
681 is reserved to describe the entire disk.
682 .It Ar size
683 The size of the partition in sectors,
684 .Cm K
685 (kilobytes - 1024),
686 .Cm M
687 (megabytes - 1024*1024),
688 .Cm G
689 (gigabytes - 1024*1024*1024),
690 .Cm %
691 (percentage of free space
692 .Em after
693 removing any fixed-size partitions other than partition
694 .Ql c ) ,
696 .Cm *
697 (all remaining free space
698 .Em after
699 fixed-size and percentage partitions).
700 For partition
701 .Ql c ,
702 a size of
703 .Cm *
704 indicates the entire disk.
705 Lowercase versions of
706 .Cm K , M ,
708 .Cm G
709 are allowed.
710 Size and type should be specified without any spaces between them.
712 Example: 2097152, 1G, 1024M and 1048576K are all the same size
713 (assuming 512-byte sectors).
714 .It Ar offset
715 The offset of the start of the partition from the beginning of the
716 drive in sectors, or
717 .Cm *
718 to have
720 calculate the correct offset to use (the end of the previous partition plus
721 one, ignoring partition
722 .Ql c .
723 For partition
724 .Ql c ,
725 .Cm *
726 will be interpreted as an offset of 0.
727 .It Ar fstype
728 Describes the purpose of the partition.
729 The example shows all currently used partition types.
731 .Tn UFS
732 file systems, use type
733 .Cm 4.2BSD .
735 .Xr HAMMER 5
736 file systems, use type
737 .Cm HAMMER .
739 .Xr ccd 4
740 partitions, use type
741 .Cm ccd .
742 For Vinum drives, use type
743 .Cm vinum .
744 Other common types are
745 .Cm swap
747 .Cm unused .
748 By convention, partition
749 .Ql c
750 represents the entire slice and should be of type
751 .Cm unused ,
752 though
754 does not enforce this convention.
757 utility
758 also knows about a number of other partition types,
759 none of which are in current use.
760 (See
761 .Dv fstypenames
763 .In sys/dtype.h
764 for more details).
767 The remainder of the line is a comment and shows the size of the partition
768 in MB.
769 .Sh EXAMPLES
770 .Dl "disklabel da0s1"
772 Display the in-core label for the first slice of the
773 .Pa da0
774 disk, as obtained via
775 .Pa /dev/da0s1 .
776 (If the disk is
777 .Dq dangerously-dedicated ,
778 the compatibility slice name should be specified, such as
779 .Pa da0s0 . )
781 .Dl "disklabel da0s1 > savedlabel"
783 Save the in-core label for
784 .Pa da0s1
785 into the file
786 .Pa savedlabel .
787 This file can be used with the
788 .Fl R
789 option to restore the label at a later date.
791 .Dl "disklabel -w -r /dev/da0s1 da2212 foo"
793 Create a label for
794 .Pa da0s1
795 based on information for
796 .Dq da2212
797 found in
798 .Pa /etc/disktab .
799 Any existing bootstrap code will be clobbered
800 and the disk rendered unbootable.
802 .Dl "disklabel -e -r da0s1"
804 Read the on-disk label for
805 .Pa da0s1 ,
806 edit it, and reinstall in-core as well as on-disk.
807 Existing bootstrap code is unaffected.
809 .Dl "disklabel -e -r -n da0s1"
811 Read the on-disk label for
812 .Pa da0s1 ,
813 edit it, and display what the new label would be (in sectors).
814 It does
815 .Em not
816 install the new label either in-core or on-disk.
818 .Dl "disklabel -r -w da0s1 auto"
820 Try to auto-detect the required information from
821 .Pa da0s1 ,
822 and write a new label to the disk.
823 Use another
824 .Nm Fl e
825 command to edit the
826 partitioning and file system information.
828 .Dl "disklabel -R da0s1 savedlabel"
830 Restore the on-disk and in-core label for
831 .Pa da0s1
832 from information in
833 .Pa savedlabel .
834 Existing bootstrap code is unaffected.
836 .Dl "disklabel -R -n da0s1 label_layout"
838 Display what the label would be for
839 .Pa da0s1
840 using the partition layout in
841 .Pa label_layout .
842 This is useful for determining how much space would be allotted for various
843 partitions with a labelling scheme using
844 .Cm % Ns -based
846 .Cm *
847 partition sizes.
849 .Dl disklabel -B da0s1
851 Install a new bootstrap on
852 .Pa da0s1 .
853 The boot code comes from
854 .Pa /boot/boot1
855 and possibly
856 .Pa /boot/boot2 .
857 On-disk and in-core labels are unchanged.
859 .Dl disklabel -w -B /dev/da0s1 -b newboot1 -s newboot2 da2212
861 Install a new label and bootstrap.
862 The label is derived from disktab information for
863 .Dq da2212
864 and installed both in-core and on-disk.
865 The bootstrap code comes from the files
866 .Pa /boot/newboot1
868 .Pa /boot/newboot2 .
870 .Dl dd if=/dev/zero of=/dev/da0 bs=512 count=32
871 .Dl fdisk -BI da0
872 .Dl dd if=/dev/zero of=/dev/da0s1 bs=512 count=32
873 .Dl disklabel -w -B da0s1 auto
874 .Dl disklabel -e da0s1
876 Completely wipe any prior information on the disk, creating a new bootable
877 disk with a DOS partition table containing one
878 .Dq whole-disk
879 slice.
880 Then
881 initialize the slice, then edit it to your needs.
883 .Pa dd
884 commands are optional, but may be necessary for some BIOSes to properly
885 recognize the disk.
887 .Dl disklabel -W da0s1
888 .Dl dd if=/dev/zero of=/dev/da0s1 bs=512 count=32
889 .Dl disklabel64 -r -w da0s1 auto
890 .Dl disklabel64 -N da0s1
892 Completely wipe any prior information on the slice,
893 changing label format to 64 bit.
894 The wiping is needed as
895 .Nm disklabel64
897 .Nm ,
898 as a safety measure,
899 won't do any operations if label with other format is already installed.
901 This is an example disklabel that uses some of the new partition size types
902 such as
903 .Cm % , M , G ,
905 .Cm * ,
906 which could be used as a source file for
908 .Dl disklabel -R ad0s1 new_label_file
909 .Bd -literal -offset 4n
910 # /dev/ad0s1:
911 type: ESDI
912 disk: ad0s1
913 label:
914 flags:
915 bytes/sector: 512
916 sectors/track: 63
917 tracks/cylinder: 16
918 sectors/cylinder: 1008
919 cylinders: 40633
920 sectors/unit: 40959009
921 rpm: 3600
922 interleave: 1
923 trackskew: 0
924 cylinderskew: 0
925 headswitch: 0           # milliseconds
926 track-to-track seek: 0  # milliseconds
927 drivedata: 0
929 16 partitions:
930 #          size     offset    fstype
931   a:       400M          0    4.2BSD
932   b:         1G          *      swap
933   c:          *          *    unused
934   e:     204800          *    4.2BSD
935   f:         5g          *    4.2BSD
936   g:          *          *    4.2BSD
938 .Sh DIAGNOSTICS
939 The kernel device drivers will not allow the size of a disk partition
940 to be decreased or the offset of a partition to be changed while it is open.
941 Some device drivers create a label containing only a single large partition
942 if a disk is unlabeled; thus, the label must be written to the
943 .Ql a
944 partition of the disk while it is open.
945 This sometimes requires the desired
946 label to be set in two steps, the first one creating at least one other
947 partition, and the second setting the label on the new partition while
948 shrinking the
949 .Ql a
950 partition.
952 On some machines the bootstrap code may not fit entirely in the area
953 allocated for it by some file systems.
954 As a result, it may not be possible to have file systems on some partitions
955 of a
956 .Dq bootable
957 disk.
958 When installing bootstrap code,
960 checks for these cases.
961 If the installed boot code would overlap a partition of type
962 .Dv FS_UNUSED
963 it is marked as type
964 .Dv FS_BOOT .
966 .Xr newfs 8
967 utility will disallow creation of file systems on
968 .Dv FS_BOOT
969 partitions.
970 Conversely, if a partition has a type other than
971 .Dv FS_UNUSED
973 .Dv FS_BOOT ,
975 will not install bootstrap code that overlaps it.
976 .Sh COMPATIBILITY
977 Due to
978 .Xr disklabel 5
979 storing sector numbers in 32 bit format
981 is restricted to 2TB, using the prevalent sector size of 512B.
982 .Xr disklabel64 5
983 labels should be used to partition larger disks.
985 The various
986 .Bx Ns s
987 use slightly different versions of
989 disklabels
990 and are not generally compatible.
993 kernel can often use labels from other
994 .Bx Ns s
995 for read-only operation.
996 .Sh SEE ALSO
997 .Xr ccd 4 ,
998 .Xr disklabel 5 ,
999 .Xr disktab 5 ,
1000 .Xr boot0cfg 8 ,
1001 .Xr diskinfo 8 ,
1002 .Xr disklabel64 8 ,
1003 .Xr fdisk 8 ,
1004 .Xr gpt 8 ,
1005 .Xr vinum 8
1006 .Sh BUGS
1007 For the i386 architecture, the primary bootstrap sector contains
1008 an embedded
1009 .Em fdisk
1010 table.
1013 utility takes care to not clobber it when installing a bootstrap only
1014 .Pq Fl B ,
1015 or when editing an existing label
1016 .Pq Fl e ,
1017 but it unconditionally writes the primary bootstrap program onto
1018 the disk for
1019 .Fl w
1021 .Fl R ,
1022 thus replacing the
1023 .Em fdisk
1024 table by the dummy one in the bootstrap program.
1025 This is only of
1026 concern if the disk is fully dedicated, so that the
1028 disklabel
1029 starts at absolute block 0 on the disk.
1033 utility
1034 does not perform all possible error checking.
1035 Warning
1036 .Em is
1037 given if partitions
1038 overlap; if an absolute offset does not match the expected offset; if the
1039 .Ql c
1040 partition does not start at 0 or does not cover the entire slice; if a
1041 partition runs past the end of the device; and a number of other errors; but
1042 no warning is given if space remains unused.