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.5.2.1 2008/08/04 20:35:47 thomas 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
96 .Oo Ar disktype/auto Oc
98 .Fl f Ar slice_start_lba
104 installs, examines or modifies a 64 bit label on a disk drive or pack.
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.
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)
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
130 is described under each command.
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
140 but e.g. MBR (typically laid out by
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.
151 If the disk does use GPT (typically laid out by
155 slices, slice 0 isn't special, it is just the first slice on the disk.
156 You do not have to include the
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
172 represents the raw disk in question, and may be in the form
176 It will display all of the parameters associated with the drive and its
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.
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
192 .Ss Writing a standard label
193 To write a standard label, use the form
199 .Ar disk Ar disktype/auto
209 The required arguments to
211 are the drive to be labeled and the drive type as described in the
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.
222 quoted if it contains blanks.
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.
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.
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
245 In either case, the kernel's in-core label is replaced.
247 For a virgin disk that is not known to
252 In this case, the driver is requested to produce a virgin label for the
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
262 itself must be provided as the canonical name, i.e.\& not as a full
265 For most harddisks, a label based on percentages for most partitions (and
266 one partition with a size of
268 will produce a reasonable configuration.
270 PC-based systems have special requirements in order for the BIOS to properly
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
283 disklabel within that slice.
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
300 This command reads the label from the in-core kernel copy, or directly from the
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
308 environment variable,
311 When the editor terminates, the label file is used to rewrite the disk
313 Existing bootstrap code is unchanged regardless of whether
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.
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
329 .Ar disk Ar protofile
332 is capable of restoring a disk label that was previously saved in a file
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
339 As when writing a new label, any existing bootstrap code will be
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.
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.
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
354 The disk driver arranges for
356 and similar system calls
359 on any attempt to do so.
361 to write to this area (for example, to obliterate the label), use the form
367 To disallow writing to the label area after previously allowing it, use the
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
382 If you are creating a label within an existing DOS slice,
384 the slice name such as
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
391 bootblocks in the slice.
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
406 .Dq dangerously-dedicated
409 This command is typically run on a
425 This form corresponds to the
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
432 This command is normally run on a
434 slice rather than the compatibility
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.
449 .Ar disk Ar protofile
452 This form corresponds to the
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
459 This command is normally run on a
461 slice rather than the compatibility
464 The bootstrap commands always access the disk directly, so it is not necessary
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:
478 Specify the names explicitly with the
484 indicates the primary boot program and
486 the secondary boot program.
487 The boot programs are located in
494 flags are not specified, but
496 was specified, the names of the programs are taken from the
502 entry for the disk if the disktab entry exists and includes those parameters.
504 Otherwise, the default boot image names are used:
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,
520 to initialize the hard disk, and create a slice table, referred to
522 .Dq "partition table"
528 to define partitions on
530 slices created in the previous step.
534 to create file systems on new partitions.
537 A typical partitioning scheme would be to have an
540 of approximately 512MB to hold the root file system, a
543 swap (usually 4GB), a
556 (usually around 4GB),
561 (usually all remaining space).
562 Your mileage may vary.
564 .Nm fdisk Fl BI Pa da0
575 .Bl -tag -width ".Pa /etc/disktab" -compact
577 Default stage1 boot image.
579 Default stage2 boot image.
581 Disk description file.
583 .Sh SAVED FILE FORMAT
589 version of the label when examining, editing, or restoring a disk
592 .Bd -literal -offset 4n
595 # Informational fields calculated from the above
596 # All byte equivalent offsets must be aligned
598 # boot space: 32768 bytes
599 # data space: 121790552 blocks # 118936.09 MB (124713525248 bytes)
601 diskid: 5e3ef4db-4e24-11dd-8318-010e0cd0bad1
603 boot2 data base: 0x000000001000
604 partitions data base: 0x000000009000
605 partitions data stop: 0x001d0981f000
606 backup label: 0x001d0981f000
607 total size: 0x001d09820000 # 118936.12 MB
609 display block size: 1024 # for partition display only
612 # size offset fstype fsuuid
613 a: 524288 0 4.2BSD # 512.000MB
614 b: 4194304 524288 swap # 4096.000MB
615 d: 2097152 4718592 4.2BSD # 2048.000MB
616 e: 2097152 6815744 4.2BSD # 2048.000MB
617 f: 4194304 8912896 4.2BSD # 4096.000MB
618 g: 4194304 13107200 4.2BSD # 4096.000MB
619 h: 94003288 17301504 HAMMER # 91800.086MB
620 i: 5242880 111304792 ccd # 5120.000MB
621 j: 5242880 116547672 vinum # 5120.000MB
622 a-stor_uuid: 4370efdb-4e25-11dd-8318-010e0cd0bad1
623 b-stor_uuid: 4370eff4-4e25-11dd-8318-010e0cd0bad1
624 d-stor_uuid: 4370f00b-4e25-11dd-8318-010e0cd0bad1
625 e-stor_uuid: 4370f024-4e25-11dd-8318-010e0cd0bad1
626 f-stor_uuid: 4370f03a-4e25-11dd-8318-010e0cd0bad1
627 g-stor_uuid: 4370f053-4e25-11dd-8318-010e0cd0bad1
628 h-stor_uuid: 4370f06a-4e25-11dd-8318-010e0cd0bad1
629 i-stor_uuid: 4370f083-4e25-11dd-8318-010e0cd0bad1
630 j-stor_uuid: 4370f099-4e25-11dd-8318-010e0cd0bad1
633 Lines starting with a
636 The specifications which can be changed are:
639 is an optional label, set by the
641 option when writing a label.
642 .It Ar "the partition table"
645 partition table, not the
647 partition table described in
651 The partition table can have up to 16 entries.
652 It contains the following information:
653 .Bl -tag -width indent
655 The partition identifier is a single letter in the range
659 By convention, partition
661 is reserved to describe the entire disk.
663 The size of the partition in sectors,
667 (megabytes - 1024*1024),
669 (gigabytes - 1024*1024*1024),
671 (percentage of free space
673 removing any fixed-size partitions),
675 (all remaining free space
677 fixed-size and percentage partitions).
678 Lowercase versions of
683 Size and type should be specified without any spaces between them.
685 Example: 2097152, 1G, 1024M and 1048576K are all the same size
686 (assuming 512-byte sectors).
688 The offset of the start of the partition from the beginning of the
693 calculate the correct offset to use (the end of the previous partition plus
696 Describes the purpose of the partition.
697 The example shows all currently used partition types.
700 file systems, use type
704 file systems, use type
710 For Vinum drives, use type
712 Other common types are
719 also knows about a number of other partition types,
720 none of which are in current use.
728 The remainder of the line is a comment and shows the size of the partition
732 no longer snoop-adjusts the on-disklabel when reading or writing
735 is now responsible for adjusting the label when operating in raw mode.
738 disklabels store offsets as absolute block numbers
739 rather than slice-relative block numbers.
742 is unable to issue the
744 ioctl to get slice information it will
745 refuse to read or write the label in raw mode.
748 option may be used to force the operation by supplying a manual offset.
750 .Dl "disklabel64 da0s1"
752 Display the in-core label for the first slice of the
754 disk, as obtained via
757 .Dq dangerously-dedicated ,
758 the compatibility slice name should be specified, such as
761 .Dl "disklabel64 da0s1 > savedlabel"
763 Save the in-core label for
767 This file can be used with the
769 option to restore the label at a later date.
771 .Dl "disklabel64 -w -r /dev/da0s1 da2212 foo"
775 based on information for
779 Any existing bootstrap code will be clobbered
780 and the disk rendered unbootable.
782 .Dl "disklabel64 -e -r da0s1"
784 Read the on-disk label for
786 edit it, and reinstall in-core as well as on-disk.
787 Existing bootstrap code is unaffected.
789 .Dl "disklabel64 -e -r -n da0s1"
791 Read the on-disk label for
793 edit it, and display what the new label would be (in sectors).
796 install the new label either in-core or on-disk.
798 .Dl "disklabel64 -r -w da0s1 auto"
800 Try to auto-detect the required information from
802 and write a new label to the disk.
806 partitioning and file system information.
808 .Dl "disklabel64 -R da0s1 savedlabel"
810 Restore the on-disk and in-core label for
814 Existing bootstrap code is unaffected.
816 .Dl "disklabel64 -R -n da0s1 label_layout"
818 Display what the label would be for
820 using the partition layout in
822 This is useful for determining how much space would be allotted for various
823 partitions with a labelling scheme using
829 .Dl disklabel64 -B da0s1
831 Install a new bootstrap on
833 The boot code comes from
837 On-disk and in-core labels are unchanged.
839 .Dl disklabel64 -w -B /dev/da0s1 -b newboot1 -s newboot2 da2212
841 Install a new label and bootstrap.
842 The label is derived from disktab information for
844 and installed both in-core and on-disk.
845 The bootstrap code comes from the files
850 .Dl dd if=/dev/zero of=/dev/da0 bs=512 count=32
852 .Dl dd if=/dev/zero of=/dev/da0s1 bs=512 count=32
853 .Dl disklabel64 -w -B da0s1 auto
854 .Dl disklabel64 -e da0s1
856 Completely wipe any prior information on the disk, creating a new bootable
857 disk with a DOS partition table containing one
861 initialize the slice, then edit it to your needs.
864 commands are optional, but may be necessary for some BIOSes to properly
867 This is an example disklabel that uses some of the new partition size types
872 which could be used as a source file for
874 .Dl disklabel64 -R ad0s1 new_label_file
875 .Bd -literal -offset 4n
878 # Informational fields calculated from the above
879 # All byte equivalent offsets must be aligned
881 # boot space: 32768 bytes
882 # data space: 121790552 blocks # 118936.09 MB (124713525248 bytes)
884 diskid: b1db58a3-4e26-11dd-8318-010e0cd0bad1
886 boot2 data base: 0x000000001000
887 partitions data base: 0x000000009000
888 partitions data stop: 0x001d0981f000
889 backup label: 0x001d0981f000
890 total size: 0x001d09820000 # 118936.12 MB
892 display block size: 1024 # for partition display only
895 # size offset fstype fsuuid
907 The kernel device drivers will not allow the size of a disk partition
908 to be decreased or the offset of a partition to be changed while it is open.
909 Some device drivers create a label containing only a single large partition
910 if a disk is unlabeled; thus, the label must be written to the
912 partition of the disk while it is open.
913 This sometimes requires the desired
914 label to be set in two steps, the first one creating at least one other
915 partition, and the second setting the label on the new partition while
920 On some machines the bootstrap code may not fit entirely in the area
921 allocated for it by some file systems.
922 As a result, it may not be possible to have file systems on some partitions
926 When installing bootstrap code,
928 checks for these cases.
929 If the installed boot code would overlap a partition of type
935 utility will disallow creation of file systems on
938 Conversely, if a partition has a type other than
943 will not install bootstrap code that overlaps it.
958 label on a slice with a
960 label installed requires reboot. First the existing label
961 has to be overwritten, eg. by
963 see above, then a reboot is required before the new label can be installed.
965 For the i386 architecture, the primary bootstrap sector contains
971 utility takes care to not clobber it when installing a bootstrap only
973 or when editing an existing label
975 but it unconditionally writes the primary bootstrap program onto
982 table by the dummy one in the bootstrap program.
984 concern if the disk is fully dedicated, so that the
987 starts at absolute block 0 on the disk.
992 does not perform all possible error checking.
996 overlap; if an absolute offset does not match the expected offset;
998 partition runs past the end of the device; and a number of other errors; but
999 no warning is given if space remains unused.
1002 doesn't support booting from