MFC: following 4 commits:
[dragonfly.git] / sbin / disklabel / disklabel.8
blob3f0dce66e7d5535fb503689ea08839011845bc71
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.1 2008/08/04 20:31:36 thomas Exp $
38 .\"
39 .Dd July 27, 2008
40 .Dt DISKLABEL 8
41 .Os
42 .Sh NAME
43 .Nm disklabel
44 .Nd read and write 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/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/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/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/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
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 this is called the compatibility slice,
146 and slice 1 and onward, e.g.
147 .Pa da0s1 ,
148 represents a
150 slice.
151 If the disk does use GPT (typically laid out by
152 .Xr gpt 8 ) ,
153 then all slices are
155 slices, slice 0 isn't special, it is just the first slice on the disk.
156 You do not have to include the
157 .Pa /dev/
158 path prefix when specifying the device.
161 utility will automatically prepend it.
162 .Ss Reading the disk label
163 To examine the label on a disk drive, use
165 without options:
168 .Op Fl r
169 .Ar disk
171 .Ar disk
172 represents the raw disk in question, and may be in the form
173 .Pa da0s1
175 .Pa /dev/da0s1 .
176 It will display all of the parameters associated with the drive and its
177 partition layout.
178 Unless the
179 .Fl r
180 flag is given,
181 the kernel's in-core copy of the label is displayed;
182 if the disk has no label, or the partition types on the disk are incorrect,
183 the kernel may have constructed or modified the label.
184 If the
185 .Fl r
186 flag is given,
188 reads the label from the raw disk and displays it.
189 Both versions are usually
190 identical except in the case where a label has not yet been initialized or
191 is corrupt.
192 .Ss Writing a standard label
193 To write a standard label, use the form
196 .Fl w
197 .Op Fl r
198 .Op Fl n
199 .Ar disk Ar disktype/auto
200 .Oo Ar packid Oc
203 .Fl w
204 .Op Fl r
205 .Op Fl n
206 .Ar disk
207 auto
209 The required arguments to
211 are the drive to be labeled and the drive type as described in the
212 .Xr disktab 5
213 file.
214 The drive parameters and partitions are taken from that file.
216 different disks of the same physical type are to have different partitions, it
217 will be necessary to have separate disktab entries describing each, or to edit
218 the label after installation as described below.
219 The optional argument is a
220 pack identification string, up to 16 characters long.
221 The pack id must be
222 quoted if it contains blanks.
224 If the
225 .Fl n
226 flag is given, no data will be written to the device, and instead the
227 disklabel that would have been written will be printed to stdout.
229 If the
230 .Fl r
231 flag is given, the disk sectors containing the label and bootstrap
232 will be written directly.
233 A side-effect of this is that any existing bootstrap code will be overwritten
234 and the disk rendered unbootable.
235 See the boot options below for a method of
236 writing the label and the bootstrap at the same time.
238 .Fl r
239 is not specified,
240 the existing label will be updated via the in-core copy and any bootstrap
241 code will be unaffected.
242 If the disk does not already have a label, the
243 .Fl r
244 flag must be used.
245 In either case, the kernel's in-core label is replaced.
247 For a virgin disk that is not known to
248 .Xr disktab 5 ,
249 .Ar disktype
250 can be specified as
251 .Dq auto .
252 In this case, the driver is requested to produce a virgin label for the
253 disk.
254 This might or might not be successful, depending on whether the
255 driver for the disk is able to get the required data without reading
256 anything from the disk at all.
257 It will likely succeed for all SCSI
258 disks, most IDE disks, and vnode devices.
259 Writing a label to the
260 disk is the only supported operation, and the
261 .Ar disk
262 itself must be provided as the canonical name, i.e.\& not as a full
263 path name.
265 For most harddisks, a label based on percentages for most partitions (and
266 one partition with a size of
267 .Ql * )
268 will produce a reasonable configuration.
270 PC-based systems have special requirements in order for the BIOS to properly
271 recognize a
273 disklabel.
274 Older systems may require what is known as a
275 .Dq dangerously dedicated
276 disklabel, which creates a fake DOS partition to work around problems older
277 BIOSes have with modern disk geometries.
278 On newer systems you generally want
279 to create a normal DOS partition using
280 .Ar fdisk
281 and then create a
283 disklabel within that slice.
284 This is described
285 later on in this page.
287 Installing a new disklabel does not in of itself allow your system to boot
288 a kernel using that label.
289 You must also install boot blocks, which is
290 described later on in this manual page.
291 .Ss Editing an existing disk label
292 To edit an existing disk label, use the form
295 .Fl e
296 .Op Fl r
297 .Op Fl n
298 .Ar disk
300 This command reads the label from the in-core kernel copy, or directly from the
301 disk if the
302 .Fl r
303 flag is also specified.
304 The label is written to a file in ASCII and then
305 supplied to an editor for changes.
306 If no editor is specified in an
307 .Ev EDITOR
308 environment variable,
309 .Xr vi 1
310 is used.
311 When the editor terminates, the label file is used to rewrite the disk
312 label.
313 Existing bootstrap code is unchanged regardless of whether
314 .Fl r
315 was specified.
317 .Fl n
318 is specified, no data will be written to the device, and instead the
319 disklabel that would have been written will be printed to stdout.
320 This is
321 useful to see how a partitioning scheme will work out for a specific disk.
322 .Ss Restoring a disk label from a file
323 To restore a disk label from a file, use the form
326 .Fl R
327 .Op Fl r
328 .Op Fl n
329 .Ar disk Ar protofile
332 is capable of restoring a disk label that was previously saved in a file
333 in ASCII format.
334 The prototype file used to create the label should be in the same format
335 as that produced when reading or editing a label.
336 Comments are delimited by
337 .Ar \&#
338 and newline.
339 As when writing a new label, any existing bootstrap code will be
340 clobbered if
341 .Fl r
342 is specified and will be unaffected otherwise.
343 See the boot options below for a
344 method of restoring the label and writing the bootstrap at the same time.
346 .Fl n
347 is used, no data will be written to the device, and instead the
348 disklabel that would have been written will be printed to stdout.
349 This is
350 useful to see how a partitioning scheme will work out for a specific disk.
351 .Ss Enabling and disabling writing to the disk label area
352 By default, it is not possible to write to the disk label area at the beginning
353 of a disk.
354 The disk driver arranges for
355 .Xr write 2
356 and similar system calls
357 to return
358 .Er EROFS
359 on any attempt to do so.
360 If you need
361 to write to this area (for example, to obliterate the label), use the form
364 .Fl W
365 .Ar disk
367 To disallow writing to the label area after previously allowing it, use the
368 command
371 .Fl N
372 .Ar disk
373 .Ss Installing bootstraps
374 The final three forms of
376 are used to install bootstrap code.
377 If you are creating a
378 .Dq dangerously-dedicated
379 slice for compatibility with older PC systems,
380 you generally want to specify the compatibility slice, such as
381 .Pa da0s0 .
382 If you are creating a label within an existing DOS slice,
383 you should specify
384 the slice name such as
385 .Pa da0s1 .
386 Making a slice bootable can be tricky.
387 If you are using a normal DOS
388 slice you typically install (or leave) a standard MBR on the base disk and
389 then install the
391 bootblocks in the slice.
394 .Fl B
396 .Fl b Ar boot1
397 .Fl s Ar boot2
399 .Ar disk
400 .Oo Ar disktype Oc
402 This form installs the bootstrap only.
403 It does not change the disk label.
404 You should never use this command on the compatibility slice unless you
405 intend to create a
406 .Dq dangerously-dedicated
407 disk, such as
408 .Ar da0s0 .
409 This command is typically run on a
411 slice such as
412 .Ar da0s1 .
415 .Fl w
416 .Fl B
417 .Op Fl n
419 .Fl b Ar boot1
420 .Fl s Ar boot2
422 .Ar disk Ar disktype
423 .Oo Ar packid Oc
425 This form corresponds to the
426 .Dq write label
427 command described above.
428 In addition to writing a new volume label, it also installs the bootstrap.
429 If run on the compatibility slice this command will create a
430 .Dq dangerously-dedicated
431 label.
432 This command is normally run on a
434 slice rather than the compatibility
435 slice.
437 .Fl n
438 is used, no data will be written to the device, and instead the
439 disklabel that would have been written will be printed to stdout.
442 .Fl R
443 .Fl B
444 .Op Fl n
446 .Fl b Ar boot1
447 .Fl s Ar boot2
449 .Ar disk Ar protofile
450 .Oo Ar disktype Oc
452 This form corresponds to the
453 .Dq restore label
454 command described above.
455 In addition to restoring the volume label, it also installs the bootstrap.
456 If run on the compatibility slice this command will create a
457 .Dq dangerously-dedicated
458 label.
459 This command is normally run on a
461 slice rather than the compatibility
462 slice.
464 The bootstrap commands always access the disk directly, so it is not necessary
465 to specify the
466 .Fl r
467 flag.
469 .Fl n
470 is used, no data will be written to the device, and instead the
471 disklabel that would have been written will be printed to stdout.
473 The bootstrap code is comprised of two boot programs.
474 Specify the name of the
475 boot programs to be installed in one of these ways:
476 .Bl -enum
478 Specify the names explicitly with the
479 .Fl b
481 .Fl s
482 flags.
483 .Fl b
484 indicates the primary boot program and
485 .Fl s
486 the secondary boot program.
487 The boot programs are located in
488 .Pa /boot .
490 If the
491 .Fl b
493 .Fl s
494 flags are not specified, but
495 .Ar disktype
496 was specified, the names of the programs are taken from the
497 .Dq b0
499 .Dq b1
500 parameters of the
501 .Xr disktab 5
502 entry for the disk if the disktab entry exists and includes those parameters.
504 Otherwise, the default boot image names are used:
505 .Pa /boot/boot1
507 .Pa /boot/boot2
508 for the standard stage1 and stage2 boot images.
510 .Ss Initializing/Formatting a bootable disk from scratch
511 To initialize a disk from scratch the following sequence is recommended.
512 Please note that this will wipe everything that was previously on the disk,
513 including any
514 .No non- Ns Dx
515 slices.
516 .Bl -enum
519 .Xr fdisk 8
520 to initialize the hard disk, and create a slice table, referred to
521 as the
522 .Dq "partition table"
524 .Tn DOS .
528 to define partitions on
530 slices created in the previous step.
532 Finally use
533 .Xr newfs 8
534 to create file systems on new partitions.
537 A typical partitioning scheme would be to have an
538 .Ql a
539 partition
540 of approximately 512MB to hold the root file system, a
541 .Ql b
542 partition for
543 swap (usually 4GB), a
544 .Ql d
545 partition for
546 .Pa /var
547 (usually 2GB), an
548 .Ql e
549 partition
551 .Pa /var/tmp
552 (usually 2GB), an
553 .Ql f
554 partition for
555 .Pa /usr
556 (usually around 4GB),
557 and finally a
558 .Ql g
559 partition for
560 .Pa /home
561 (usually all remaining space).
562 Your mileage may vary.
564 .Nm fdisk Fl BI Pa da0
567 .Fl w B
568 .Pa da0s1
569 .Cm auto
572 .Fl e
573 .Pa da0s1
574 .Sh FILES
575 .Bl -tag -width ".Pa /etc/disktab" -compact
576 .It Pa /boot/boot1
577 Default stage1 boot image.
578 .It Pa /boot/boot2
579 Default stage2 boot image.
580 .It Pa /etc/disktab
581 Disk description file.
583 .Sh SAVED FILE FORMAT
586 utility
587 uses an
588 .Tn ASCII
589 version of the label when examining, editing, or restoring a disk
590 label.
591 The format is:
592 .Bd -literal -offset 4n
593 # /dev/ad4s4:
594 type: unknown
595 disk: amnesiac
596 label: fictitious
597 flags:
598 bytes/sector: 512
599 sectors/track: 63
600 tracks/cylinder: 24
601 sectors/cylinder: 1512
602 cylinders: 161098
603 sectors/unit: 243581184
604 rpm: 3600
605 interleave: 1
606 trackskew: 0
607 cylinderskew: 0
608 headswitch: 0           # milliseconds
609 track-to-track seek: 0  # milliseconds
610 drivedata: 0
612 16 partitions:
613 #          size     offset    fstype
614   a:    1048560         16    4.2BSD    #     511.992MB
615   b:    8388608    1048576      swap    #    4096.000MB
616   c:  243581184          0    unused    #  118936.125MB
617   d:    4194304    9437184    4.2BSD    #    2048.000MB
618   e:    4194304   13631488    4.2BSD    #    2048.000MB
619   f:    8388608   17825792    4.2BSD    #    4096.000MB
620   h:  196395264   26214400    HAMMER    #   95896.125MB
621   i:   10485760  222609664       ccd    #    5120.000MB
622   j:   10485760  233095424     vinum    #    5120.000MB
625 Lines starting with a
626 .Ql #
627 mark are comments.
628 Most of the other specifications are no longer used.
629 The ones which must still be set correctly are:
630 .Bl -inset
631 .It Ar label
632 is an optional label, set by the
633 .Ar packid
634 option when writing a label.
635 .It Ar flags
636 may be
637 .Cm removable , ecc
639 .Cm badsect .
640 .Cm removable
641 is set for removable media drives, but no current
643 driver evaluates this
644 flag.
645 .Cm ecc
646 is no longer supported;
647 .Cm badsect
648 specifies that the drive can perform bad sector remapping.
649 .It Ar sectors/unit
650 describes the total size of the disk.
651 This value must be correct.
652 .It Ar "the partition table"
653 is the
655 partition table, not the
656 .Tn DOS
657 partition table described in
658 .Xr fdisk 8 .
661 The partition table can have up to 16 entries.
662 It contains the following information:
663 .Bl -tag -width indent
664 .It Ar #
665 The partition identifier is a single letter in the range
666 .Ql a
668 .Ql p .
669 By convention, partition
670 .Ql c
671 is reserved to describe the entire disk.
672 .It Ar size
673 The size of the partition in sectors,
674 .Cm K
675 (kilobytes - 1024),
676 .Cm M
677 (megabytes - 1024*1024),
678 .Cm G
679 (gigabytes - 1024*1024*1024),
680 .Cm %
681 (percentage of free space
682 .Em after
683 removing any fixed-size partitions other than partition
684 .Ql c ) ,
686 .Cm *
687 (all remaining free space
688 .Em after
689 fixed-size and percentage partitions).
690 For partition
691 .Ql c ,
692 a size of
693 .Cm *
694 indicates the entire disk.
695 Lowercase versions of
696 .Cm K , M ,
698 .Cm G
699 are allowed.
700 Size and type should be specified without any spaces between them.
702 Example: 2097152, 1G, 1024M and 1048576K are all the same size
703 (assuming 512-byte sectors).
704 .It Ar offset
705 The offset of the start of the partition from the beginning of the
706 drive in sectors, or
707 .Cm *
708 to have
710 calculate the correct offset to use (the end of the previous partition plus
711 one, ignoring partition
712 .Ql c .
713 For partition
714 .Ql c ,
715 .Cm *
716 will be interpreted as an offset of 0.
717 .It Ar fstype
718 Describes the purpose of the partition.
719 The example shows all currently used partition types.
721 .Tn UFS
722 file systems, use type
723 .Cm 4.2BSD .
725 .Xr HAMMER 5
726 file systems, use type
727 .Cm HAMMER .
729 .Xr ccd 4
730 partitions, use type
731 .Cm ccd .
732 For Vinum drives, use type
733 .Cm vinum .
734 Other common types are
735 .Cm swap
737 .Cm unused .
738 By convention, partition
739 .Ql c
740 represents the entire slice and should be of type
741 .Cm unused ,
742 though
744 does not enforce this convention.
747 utility
748 also knows about a number of other partition types,
749 none of which are in current use.
750 (See
751 .Dv fstypenames
753 .In sys/dtype.h
754 for more details).
757 The remainder of the line is a comment and shows the size of the partition
758 in MB.
761 no longer snoop-adjusts the on-disklabel when reading or writing
762 raw labels.
764 is now responsible for adjusting the label when operating in raw mode.
765 Traditional (32 bit
766 .Bx )
767 disklabels store offsets as absolute block numbers
768 rather than slice-relative block numbers.
771 is unable to issue the
772 .Dv DIOCGPART
773 ioctl to get slice information it will
774 refuse to read or write the label in raw mode.
776 .Fl f
777 option may be used to force the operation by supplying a manual offset.
778 .Sh EXAMPLES
779 .Dl "disklabel da0s1"
781 Display the in-core label for the first slice of the
782 .Pa da0
783 disk, as obtained via
784 .Pa /dev/da0s1 .
785 (If the disk is
786 .Dq dangerously-dedicated ,
787 the compatibility slice name should be specified, such as
788 .Pa da0s0 . )
790 .Dl "disklabel da0s1 > savedlabel"
792 Save the in-core label for
793 .Pa da0s1
794 into the file
795 .Pa savedlabel .
796 This file can be used with the
797 .Fl R
798 option to restore the label at a later date.
800 .Dl "disklabel -w -r /dev/da0s1 da2212 foo"
802 Create a label for
803 .Pa da0s1
804 based on information for
805 .Dq da2212
806 found in
807 .Pa /etc/disktab .
808 Any existing bootstrap code will be clobbered
809 and the disk rendered unbootable.
811 .Dl "disklabel -e -r da0s1"
813 Read the on-disk label for
814 .Pa da0s1 ,
815 edit it, and reinstall in-core as well as on-disk.
816 Existing bootstrap code is unaffected.
818 .Dl "disklabel -e -r -n da0s1"
820 Read the on-disk label for
821 .Pa da0s1 ,
822 edit it, and display what the new label would be (in sectors).
823 It does
824 .Em not
825 install the new label either in-core or on-disk.
827 .Dl "disklabel -r -w da0s1 auto"
829 Try to auto-detect the required information from
830 .Pa da0s1 ,
831 and write a new label to the disk.
832 Use another
833 .Nm Fl e
834 command to edit the
835 partitioning and file system information.
837 .Dl "disklabel -R da0s1 savedlabel"
839 Restore the on-disk and in-core label for
840 .Pa da0s1
841 from information in
842 .Pa savedlabel .
843 Existing bootstrap code is unaffected.
845 .Dl "disklabel -R -n da0s1 label_layout"
847 Display what the label would be for
848 .Pa da0s1
849 using the partition layout in
850 .Pa label_layout .
851 This is useful for determining how much space would be allotted for various
852 partitions with a labelling scheme using
853 .Cm % Ns -based
855 .Cm *
856 partition sizes.
858 .Dl disklabel -B da0s1
860 Install a new bootstrap on
861 .Pa da0s1 .
862 The boot code comes from
863 .Pa /boot/boot1
864 and possibly
865 .Pa /boot/boot2 .
866 On-disk and in-core labels are unchanged.
868 .Dl disklabel -w -B /dev/da0s1 -b newboot1 -s newboot2 da2212
870 Install a new label and bootstrap.
871 The label is derived from disktab information for
872 .Dq da2212
873 and installed both in-core and on-disk.
874 The bootstrap code comes from the files
875 .Pa /boot/newboot1
877 .Pa /boot/newboot2 .
879 .Dl dd if=/dev/zero of=/dev/da0 bs=512 count=32
880 .Dl fdisk -BI da0
881 .Dl dd if=/dev/zero of=/dev/da0s1 bs=512 count=32
882 .Dl disklabel -w -B da0s1 auto
883 .Dl disklabel -e da0s1
885 Completely wipe any prior information on the disk, creating a new bootable
886 disk with a DOS partition table containing one
887 .Dq whole-disk
888 slice.
889 Then
890 initialize the slice, then edit it to your needs.
892 .Pa dd
893 commands are optional, but may be necessary for some BIOSes to properly
894 recognize the disk.
896 This is an example disklabel that uses some of the new partition size types
897 such as
898 .Cm % , M , G ,
900 .Cm * ,
901 which could be used as a source file for
903 .Dl disklabel -R ad0s1 new_label_file
904 .Bd -literal -offset 4n
905 # /dev/ad0s1:
906 type: ESDI
907 disk: ad0s1
908 label:
909 flags:
910 bytes/sector: 512
911 sectors/track: 63
912 tracks/cylinder: 16
913 sectors/cylinder: 1008
914 cylinders: 40633
915 sectors/unit: 40959009
916 rpm: 3600
917 interleave: 1
918 trackskew: 0
919 cylinderskew: 0
920 headswitch: 0           # milliseconds
921 track-to-track seek: 0  # milliseconds
922 drivedata: 0
924 16 partitions:
925 #          size     offset    fstype
926   a:       400M          0    4.2BSD
927   b:         1G          *      swap
928   c:          *          *    unused
929   e:     204800          *    4.2BSD
930   f:         5g          *    4.2BSD
931   g:          *          *    4.2BSD
933 .Sh DIAGNOSTICS
934 The kernel device drivers will not allow the size of a disk partition
935 to be decreased or the offset of a partition to be changed while it is open.
936 Some device drivers create a label containing only a single large partition
937 if a disk is unlabeled; thus, the label must be written to the
938 .Dq a
939 partition of the disk while it is open.
940 This sometimes requires the desired
941 label to be set in two steps, the first one creating at least one other
942 partition, and the second setting the label on the new partition while
943 shrinking the
944 .Dq a
945 partition.
947 On some machines the bootstrap code may not fit entirely in the area
948 allocated for it by some file systems.
949 As a result, it may not be possible to have file systems on some partitions
950 of a
951 .Dq bootable
952 disk.
953 When installing bootstrap code,
955 checks for these cases.
956 If the installed boot code would overlap a partition of type
957 .Dv FS_UNUSED
958 it is marked as type
959 .Dv FS_BOOT .
961 .Xr newfs 8
962 utility will disallow creation of file systems on
963 .Dv FS_BOOT
964 partitions.
965 Conversely, if a partition has a type other than
966 .Dv FS_UNUSED
968 .Dv FS_BOOT ,
970 will not install bootstrap code that overlaps it.
971 .Sh COMPATIBILITY
972 Due to
973 .Xr disklabel 5
974 storing sector numbers in 32 bit format
976 is restricted to 2TB, using the prevalent sector size of 512B.
977 .Xr disklabel64 5 labels should be used to partition larger disks.
979 The various
980 .Bx Ns s
981 use slightly different versions of
983 disklabels
984 and are not generally compatible.
987 kernel can often use labels from other
988 .Bx Ns s
989 for read-only operation.
990 .Sh SEE ALSO
991 .Xr ccd 4 ,
992 .Xr disklabel 5 ,
993 .Xr disktab 5 ,
994 .Xr boot0cfg 8 ,
995 .Xr diskinfo 8 ,
996 .Xr disklabel64 8 ,
997 .Xr fdisk 8 ,
998 .Xr gpt 8 ,
999 .Xr vinum 8
1000 .Sh BUGS
1001 Installing a
1002 .Xr disklabel64 8
1003 label on a slice with a
1005 label installed requires reboot. First the existing label
1006 has to be overwritten, e.g. by
1007 .Xr dd 1 ,
1008 see above, then a reboot is required before the new label can be installed.
1010 For the i386 architecture, the primary bootstrap sector contains
1011 an embedded
1012 .Em fdisk
1013 table.
1016 utility takes care to not clobber it when installing a bootstrap only
1017 .Pq Fl B ,
1018 or when editing an existing label
1019 .Pq Fl e ,
1020 but it unconditionally writes the primary bootstrap program onto
1021 the disk for
1022 .Fl w
1024 .Fl R ,
1025 thus replacing the
1026 .Em fdisk
1027 table by the dummy one in the bootstrap program.
1028 This is only of
1029 concern if the disk is fully dedicated, so that the
1031 disklabel
1032 starts at absolute block 0 on the disk.
1036 utility
1037 does not perform all possible error checking.
1038 Warning
1039 .Em is
1040 given if partitions
1041 overlap; if an absolute offset does not match the expected offset; if the
1042 .Dq c
1043 partition does not start at 0 or does not cover the entire slice; if a
1044 partition runs past the end of the device; and a number of other errors; but
1045 no warning is given if space remains unused.