1 .\" Copyright (c) 1987, 1988, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" This code is derived from software contributed to Berkeley by
5 .\" Symmetric Computer Systems.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
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.
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
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/disklabel64/disklabel64.8,v 1.11 2008/08/22 21:00:01 swildner Exp $
44 .Nd read and write 64 bit disk pack label
53 .Ar disk Ar disktype/auto
76 .\" .Oo Ar disktype/auto Oc
85 .\" .Ar disk Ar disktype/auto
95 .\" .Ar disk Ar protofile
96 .\" .Oo Ar disktype/auto Oc
101 installs, examines or modifies a 64 bit label on a disk drive or pack.
103 the label, it can be used to change the drive identification, the disk
104 partitions on the drive, or to replace a damaged label.
105 There are several forms
106 of the command that read (display), install or edit the label on a disk.
110 .\" can install bootstrap code.
111 .Ss Raw or in-core label
112 The disk label resides close to or at the beginning of each disk slice.
113 For faster access, the kernel maintains a copy in core at all times.
115 default, most forms of the
117 command access the in-core copy of the label.
118 To access the raw (on-disk)
122 This option allows a label to be installed on a disk without kernel
123 support for a label, such as when labels are first installed on a system; it
124 must be used when first installing a label on a disk.
125 The specific effect of
127 is described under each command.
131 forms require a disk device name, which should always be the raw
132 device name representing the disk or slice.
134 uses the following scheme for slice numbering:
135 If the disk doesn't use GPT (typically laid out by
137 but e.g.\& MBR (typically laid out by
141 represents the entire disk regardless of any DOS partitioning.
142 Slice 0 is called the compatibility slice,
143 and slice 1 and onward, e.g.\&
148 If the disk does use GPT then all slices are
150 slices, slice 0 isn't special, it is just the first slice on the disk.
151 You do not have to include the
153 path prefix when specifying the device.
156 utility will automatically prepend it.
157 .Ss Reading the disk label
158 To examine the label on a disk drive, use
167 represents the raw disk in question, and may be in the form
171 It will display all of the parameters associated with the drive and its
176 the kernel's in-core copy of the label is displayed;
177 if the disk has no label, or the partition types on the disk are incorrect,
178 the kernel may have constructed or modified the label.
183 reads the label from the raw disk and displays it.
184 Both versions are usually
185 identical except in the case where a label has not yet been initialized or
187 .Ss Writing a standard label
188 To write a standard label, use the form
194 .Ar disk Ar disktype/auto
204 The required arguments to
206 are the drive to be labeled and the drive type as described in the
209 The drive parameters and partitions are taken from that file.
211 different disks of the same physical type are to have different partitions, it
212 will be necessary to have separate disktab entries describing each, or to edit
213 the label after installation as described below.
214 The optional argument is a
215 pack identification string, up to 16 characters long.
217 quoted if it contains blanks.
221 flag is given, no data will be written to the device, and instead the
222 disklabel that would have been written will be printed to stdout.
226 flag is given, the disk sectors containing the label
228 will be written directly.
229 .\" A side-effect of this is that any existing bootstrap code will be overwritten
230 .\" and the disk rendered unbootable.
231 .\" See the boot options below for a method of
232 .\" writing the label and the bootstrap at the same time.
236 the existing label will be updated via the in-core copy.
237 .\" and any bootstrap code will be unaffected.
238 If the disk does not already have a label, the
241 In either case, the kernel's in-core label is replaced.
243 For a virgin disk that is not known to
248 In this case, the driver is requested to produce a virgin label for the
250 This might or might not be successful, depending on whether the
251 driver for the disk is able to get the required data without reading
252 anything from the disk at all.
253 It will likely succeed for all SCSI
254 disks, most IDE disks, and vnode devices.
255 Writing a label to the
256 disk is the only supported operation, and the
258 itself must be provided as the canonical name, i.e.\& not as a full
261 For most harddisks, a label based on percentages for most partitions (and
262 one partition with a size of
264 will produce a reasonable configuration.
266 PC-based systems have special requirements in order for the BIOS to properly
270 Older systems may require what is known as a
271 .Dq dangerously dedicated
272 disklabel, which creates a fake DOS partition to work around problems older
273 BIOSes have with modern disk geometries.
274 On newer systems you generally want
275 to create a normal DOS partition using
279 disklabel within that slice.
281 later on in this page.
283 .\" Installing a new disklabel does not in of itself allow your system to boot
284 .\" a kernel using that label.
285 .\" You must also install boot blocks, which is
286 .\" described later on in this manual page.
287 .Ss Editing an existing disk label
288 To edit an existing disk label, use the form
296 This command reads the label from the in-core kernel copy, or directly from the
299 flag is also specified.
300 The label is written to a file in ASCII and then
301 supplied to an editor for changes.
302 If no editor is specified in an
304 environment variable,
307 When the editor terminates, the label file is used to rewrite the disk
309 .\" Existing bootstrap code is unchanged regardless of whether
314 is specified, no data will be written to the device, and instead the
315 disklabel that would have been written will be printed to stdout.
317 useful to see how a partitioning scheme will work out for a specific disk.
318 .Ss Restoring a disk label from a file
319 To restore a disk label from a file, use the form
325 .Ar disk Ar protofile
328 is capable of restoring a disk label that was previously saved in a file
330 The prototype file used to create the label should be in the same format
331 as that produced when reading or editing a label.
332 Comments are delimited by
335 .\" As when writing a new label, any existing bootstrap code will be
338 .\" is specified and will be unaffected otherwise.
339 .\" See the boot options below for a
340 .\" method of restoring the label and writing the bootstrap at the same time.
343 is used, no data will be written to the device, and instead the
344 disklabel that would have been written will be printed to stdout.
346 useful to see how a partitioning scheme will work out for a specific disk.
347 .Ss Enabling and disabling writing to the disk label area
348 By default, it is not possible to write to the disk label area at the beginning
350 The disk driver arranges for
352 and similar system calls
355 on any attempt to do so.
357 to write to this area (for example, to obliterate the label), use the form
363 To disallow writing to the label area after previously allowing it, use the
369 .\" .Ss Installing bootstraps
370 .\" The final three forms of
372 .\" are used to install bootstrap code.
373 .\" If you are creating a
374 .\" .Dq dangerously-dedicated
375 .\" slice for compatibility with older PC systems,
376 .\" you generally want to specify the compatibility slice, such as
378 .\" If you are creating a label within an existing DOS slice,
379 .\" you should specify
380 .\" the slice name such as
382 .\" Making a slice bootable can be tricky.
383 .\" If you are using a normal DOS
384 .\" slice you typically install (or leave) a standard MBR on the base disk and
387 .\" bootblocks in the slice.
396 .\" .Oo Ar disktype Oc
398 .\" This form installs the bootstrap only.
399 .\" It does not change the disk label.
400 .\" You should never use this command on the compatibility slice unless you
401 .\" intend to create a
402 .\" .Dq dangerously-dedicated
405 .\" This command is typically run on a
418 .\" .Ar disk Ar disktype
421 .\" This form corresponds to the
423 .\" command described above.
424 .\" In addition to writing a new volume label, it also installs the bootstrap.
425 .\" If run on the compatibility slice this command will create a
426 .\" .Dq dangerously-dedicated
428 .\" This command is normally run on a
430 .\" slice rather than the compatibility
434 .\" is used, no data will be written to the device, and instead the
435 .\" disklabel that would have been written will be printed to stdout.
445 .\" .Ar disk Ar protofile
446 .\" .Oo Ar disktype Oc
448 .\" This form corresponds to the
449 .\" .Dq restore label
450 .\" command described above.
451 .\" In addition to restoring the volume label, it also installs the bootstrap.
452 .\" If run on the compatibility slice this command will create a
453 .\" .Dq dangerously-dedicated
455 .\" This command is normally run on a
457 .\" slice rather than the compatibility
460 .\" The bootstrap commands always access the disk directly, so it is not necessary
466 .\" is used, no data will be written to the device, and instead the
467 .\" disklabel that would have been written will be printed to stdout.
469 .\" The bootstrap code is comprised of two boot programs.
470 .\" Specify the name of the
471 .\" boot programs to be installed in one of these ways:
474 .\" Specify the names explicitly with the
480 .\" indicates the primary boot program and
482 .\" the secondary boot program.
483 .\" The boot programs are located in
490 .\" flags are not specified, but
492 .\" was specified, the names of the programs are taken from the
496 .\" parameters of the
498 .\" entry for the disk if the disktab entry exists and includes those parameters.
500 .\" Otherwise, the default boot image names are used:
504 .\" for the standard stage1 and stage2 boot images.
506 .\" .Ss Initializing/Formatting a bootable disk from scratch
507 .Ss Initializing/Formatting a disk from scratch
508 To initialize a disk from scratch the following sequence is recommended.
509 Please note that this will wipe everything that was previously on the disk,
519 to initialize the hard disk, and create a GPT or MBR slice table, referred to
521 .Dq "partition table"
527 to define partitions on
529 slices created in the previous step.
535 to create file systems on new partitions.
538 A typical partitioning scheme would be to have an
541 of approximately 512MB to hold the root file system, a
544 swap (usually 4GB), a
557 (usually around 4GB),
562 (usually all remaining space).
563 If you are tight on space all sizes can be halved.
564 Your mileage may vary.
566 .Nm gpt create Pa da0
580 .Bl -tag -width ".Pa /etc/disktab" -compact
581 .\" .It Pa /boot/boot1
582 .\" Default stage1 boot image.
583 .\" .It Pa /boot/boot2
584 .\" Default stage2 boot image.
586 Disk description file.
588 .Sh SAVED FILE FORMAT
594 version of the label when examining, editing, or restoring a disk
597 .Bd -literal -offset 4n
600 # Informational fields calculated from the above
601 # All byte equivalent offsets must be aligned
603 # boot space: 32768 bytes
604 # data space: 121790552 blocks # 118936.09 MB (124713525248 bytes)
606 diskid: 5e3ef4db-4e24-11dd-8318-010e0cd0bad1
608 boot2 data base: 0x000000001000
609 partitions data base: 0x000000009000
610 partitions data stop: 0x001d0981f000
611 backup label: 0x001d0981f000
612 total size: 0x001d09820000 # 118936.12 MB
614 display block size: 1024 # for partition display only
617 # size offset fstype fsuuid
618 a: 524288 0 4.2BSD # 512.000MB
619 b: 4194304 524288 swap # 4096.000MB
620 d: 2097152 4718592 4.2BSD # 2048.000MB
621 e: 2097152 6815744 4.2BSD # 2048.000MB
622 f: 4194304 8912896 4.2BSD # 4096.000MB
623 g: 4194304 13107200 4.2BSD # 4096.000MB
624 h: 94003288 17301504 HAMMER # 91800.086MB
625 i: 5242880 111304792 ccd # 5120.000MB
626 j: 5242880 116547672 vinum # 5120.000MB
627 a-stor_uuid: 4370efdb-4e25-11dd-8318-010e0cd0bad1
628 b-stor_uuid: 4370eff4-4e25-11dd-8318-010e0cd0bad1
629 d-stor_uuid: 4370f00b-4e25-11dd-8318-010e0cd0bad1
630 e-stor_uuid: 4370f024-4e25-11dd-8318-010e0cd0bad1
631 f-stor_uuid: 4370f03a-4e25-11dd-8318-010e0cd0bad1
632 g-stor_uuid: 4370f053-4e25-11dd-8318-010e0cd0bad1
633 h-stor_uuid: 4370f06a-4e25-11dd-8318-010e0cd0bad1
634 i-stor_uuid: 4370f083-4e25-11dd-8318-010e0cd0bad1
635 j-stor_uuid: 4370f099-4e25-11dd-8318-010e0cd0bad1
638 Lines starting with a
641 The specifications which can be changed are:
644 is an optional label, set by the
646 option when writing a label.
647 .It Ar "the partition table"
650 partition table, not the
652 partition table described in
656 The partition table can have up to 16 entries.
657 It contains the following information:
658 .Bl -tag -width indent
660 The partition identifier is a single letter in the range
665 The size of the partition in sectors,
669 (megabytes - 1024*1024),
671 (gigabytes - 1024*1024*1024),
673 (percentage of free space
675 removing any fixed-size partitions),
677 (all remaining free space
679 fixed-size and percentage partitions).
680 Lowercase versions of
685 Size and type should be specified without any spaces between them.
687 Example: 2097152, 1G, 1024M and 1048576K are all the same size
688 (assuming 512-byte sectors).
690 The offset of the start of the partition from the beginning of the
695 calculate the correct offset to use (the end of the previous partition plus
698 Describes the purpose of the partition.
699 The example shows all currently used partition types.
702 file systems, use type
706 file systems, use type
712 For Vinum drives, use type
714 Other common types are
721 also knows about a number of other partition types,
722 none of which are in current use.
730 The remainder of the line is a comment and shows the size of the partition
733 .Dl "disklabel64 da0s1"
735 Display the in-core label for the first slice of the
737 disk, as obtained via
740 .Dq dangerously-dedicated ,
741 the compatibility slice name should be specified, such as
744 .Dl "disklabel64 da0s1 > savedlabel"
746 Save the in-core label for
750 This file can be used with the
752 option to restore the label at a later date.
754 .Dl "disklabel64 -w -r /dev/da0s1 da2212 foo"
758 based on information for
762 .\" Any existing bootstrap code will be clobbered
763 .\" and the disk rendered unbootable.
765 .Dl "disklabel64 -e -r da0s1"
767 Read the on-disk label for
769 edit it, and reinstall in-core as well as on-disk.
770 .\" Existing bootstrap code is unaffected.
772 .Dl "disklabel64 -e -r -n da0s1"
774 Read the on-disk label for
776 edit it, and display what the new label would be (in sectors).
779 install the new label either in-core or on-disk.
781 .Dl "disklabel64 -r -w da0s1 auto"
783 Try to auto-detect the required information from
785 and write a new label to the disk.
788 command to edit the partitioning information.
790 .Dl "disklabel64 -R da0s1 savedlabel"
792 Restore the on-disk and in-core label for
796 .\" Existing bootstrap code is unaffected.
798 .Dl "disklabel64 -R -n da0s1 label_layout"
800 Display what the label would be for
802 using the partition layout in
804 This is useful for determining how much space would be allotted for various
805 partitions with a labelling scheme using
811 .\" .Dl disklabel64 -B da0s1
813 .\" Install a new bootstrap on
815 .\" The boot code comes from
818 .\" .Pa /boot/boot2 .
819 .\" On-disk and in-core labels are unchanged.
821 .\" .Dl disklabel64 -w -B /dev/da0s1 -b newboot1 -s newboot2 da2212
823 .\" Install a new label and bootstrap.
824 .\" The label is derived from disktab information for
826 .\" and installed both in-core and on-disk.
827 .\" The bootstrap code comes from the files
828 .\" .Pa /boot/newboot1
830 .\" .Pa /boot/newboot2 .
832 .\" .Dl dd if=/dev/zero of=/dev/da0 bs=512 count=32
833 .\" .Dl fdisk -BI da0
834 .\" .Dl dd if=/dev/zero of=/dev/da0s1 bs=512 count=32
835 .\" .Dl disklabel64 -w -B da0s1 auto
836 .\" .Dl disklabel64 -e da0s1
838 .\" Completely wipe any prior information on the disk, creating a new bootable
839 .\" disk with a DOS partition table containing one
843 .\" initialize the slice, then edit it to your needs.
846 .\" commands are optional, but may be necessary for some BIOSes to properly
847 .\" recognize the disk.
849 This is an example disklabel that uses some of the new partition size types
854 which could be used as a source file for
856 .Dl disklabel64 -R ad0s1 new_label_file
857 .Bd -literal -offset 4n
860 # Informational fields calculated from the above
861 # All byte equivalent offsets must be aligned
863 # boot space: 32768 bytes
864 # data space: 121790552 blocks # 118936.09 MB (124713525248 bytes)
866 diskid: b1db58a3-4e26-11dd-8318-010e0cd0bad1
868 boot2 data base: 0x000000001000
869 partitions data base: 0x000000009000
870 partitions data stop: 0x001d0981f000
871 backup label: 0x001d0981f000
872 total size: 0x001d09820000 # 118936.12 MB
874 display block size: 1024 # for partition display only
877 # size offset fstype fsuuid
889 The kernel device drivers will not allow the size of a disk partition
890 to be decreased or the offset of a partition to be changed while it is open.
891 Some device drivers create a label containing only a single large partition
892 if a disk is unlabeled; thus, the label must be written to the
894 partition of the disk while it is open.
895 This sometimes requires the desired
896 label to be set in two steps, the first one creating at least one other
897 partition, and the second setting the label on the new partition while
902 .\" On some machines the bootstrap code may not fit entirely in the area
903 .\" allocated for it by some file systems.
904 .\" As a result, it may not be possible to have file systems on some partitions
908 .\" When installing bootstrap code,
910 .\" checks for these cases.
911 .\" If the installed boot code would overlap a partition of type
913 .\" it is marked as type
917 .\" utility will disallow creation of file systems on
920 .\" Conversely, if a partition has a type other than
925 .\" will not install bootstrap code that overlaps it.
943 label on a slice with a
945 label installed requires reboot. First the existing label
946 has to be overwritten, eg. by
948 see above, then a reboot is required before the new label can be installed.
950 .\" For the i386 architecture, the primary bootstrap sector contains
956 .\" utility takes care to not clobber it when installing a bootstrap only
958 .\" or when editing an existing label
960 .\" but it unconditionally writes the primary bootstrap program onto
965 .\" thus replacing the
967 .\" table by the dummy one in the bootstrap program.
969 .\" concern if the disk is fully dedicated, so that the
972 .\" starts at absolute block 0 on the disk.
977 does not perform all possible error checking.
981 overlap; if an absolute offset does not match the expected offset;
983 partition runs past the end of the device; and a number of other errors; but
984 no warning is given if space remains unused.
987 doesn't support booting from