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. Neither the name of the University nor the names of its contributors
16 .\" may be used to endorse or promote products derived from this software
17 .\" without specific prior written permission.
19 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 .\" @(#)disklabel.8 8.2 (Berkeley) 4/19/94
32 .\" $FreeBSD: src/sbin/disklabel/disklabel.8,v 1.15.2.22 2003/04/17 17:56:34 trhodes Exp $
39 .Nd read and write 64 bit disk pack label
49 .Op Ar disktype Ns / Ns Cm auto Op Ar packid
71 .Oo Ar disktype Ns / Ns Cm auto Oc
81 .Op Ar disktype Ns / Ns Cm auto Op Ar packid
91 .Oo Ar disktype Ns / Ns Cm auto Oc
96 installs, examines or modifies a 64 bit label on a disk drive or pack.
98 the label, it can be used to change the drive identification, the disk
99 partitions on the drive, or to replace a damaged label.
100 There are several forms
101 of the command that read (display), install or edit the label on a disk.
105 can install bootstrap code.
106 .Ss Raw or in-core label
107 The disk label resides close to or at the beginning of each disk slice.
108 For faster access, the kernel maintains a copy in core at all times.
110 default, most forms of the
112 command access the in-core copy of the label.
113 To access the raw (on-disk)
117 This option allows a label to be installed on a disk without kernel
118 support for a label, such as when labels are first installed on a system; it
119 must be used when first installing a label on a disk.
120 The specific effect of
122 is described under each command.
126 forms require a disk device name, which should always be the raw
127 device name representing the disk or slice.
129 uses the following scheme for slice numbering:
130 If the disk doesn't use GPT (typically laid out by
132 but e.g.\& MBR (typically laid out by
136 represents the entire disk regardless of any DOS partitioning.
137 Slice 0 is called the compatibility slice,
138 and slice 1 and onward, e.g.\&
143 If the disk does use GPT, then all slices are
145 slices, slice 0 isn't special, it is just the first slice on the disk.
146 You do not have to include the
148 path prefix when specifying the device.
151 utility will automatically prepend it.
152 .Ss Reading the disk label
153 To examine the label on a disk drive, use
162 represents the raw disk in question, and may be in the form
166 It will display all of the parameters associated with the drive and its
171 the kernel's in-core copy of the label is displayed;
172 if the disk has no label, or the partition types on the disk are incorrect,
173 the kernel may have constructed or modified the label.
178 reads the label from the raw disk and displays it.
179 Both versions are usually
180 identical except in the case where a label has not yet been initialized or
182 .Ss Writing a standard label
183 To write a standard label, use the form
190 .Op Ar disktype Ns / Ns Cm auto Op Ar packid
192 The required argument to
194 is the drive to be labeled.
195 The first optional argument is the drive type as described in the
197 file, from which the drive parameters and partitions are taken.
198 If not specified, then the
200 type is assumed to make a virgin label for the disk as described below.
202 different disks of the same physical type are to have different partitions, it
203 will be necessary to have separate disktab entries describing each, or to edit
204 the label after installation as described below.
205 The optional argument is a
206 pack identification string, up to 63 characters long.
208 quoted if it contains blanks.
212 flag is given, no data will be written to the device, and instead the
213 disklabel that would have been written will be printed to stdout.
217 flag is given, the disk sectors containing the label and bootstrap
218 will be written directly.
219 A side-effect of this is that any existing bootstrap code will be overwritten
220 and the disk rendered unbootable.
221 See the boot options below for a method of
222 writing the label and the bootstrap at the same time.
226 the existing label will be updated via the in-core copy and any bootstrap
227 code will be unaffected.
228 If the disk does not already have a label, the
231 In either case, the kernel's in-core label is replaced.
233 For a virgin disk that is not known to
238 In this case, the driver is requested to produce a virgin label for the
240 This might or might not be successful, depending on whether the
241 driver for the disk is able to get the required data without reading
242 anything from the disk at all.
243 It will likely succeed for all SCSI
244 disks, most IDE disks, and vnode devices.
245 Writing a label to the
246 disk is the only supported operation.
248 For most harddisks, a label based on percentages for most partitions (and
249 one partition with a size of
251 will produce a reasonable configuration.
253 PC-based systems have special requirements in order for the BIOS to properly
257 Older systems may require what is known as a
258 .Dq dangerously dedicated
259 disklabel, which creates a fake DOS partition to work around problems older
260 BIOSes have with modern disk geometries.
261 On newer systems you generally want
262 to create a normal DOS partition using
266 disklabel within that slice.
268 later on in this page.
270 Installing a new disklabel does not in of itself allow your system to boot
271 a kernel using that label.
272 You must also install boot blocks, which is
273 described later on in this manual page.
274 .Ss Editing an existing disk label
275 To edit an existing disk label, use the form
283 This command reads the label from the in-core kernel copy, or directly from the
286 flag is also specified.
287 The label is written to a file in ASCII and then
288 supplied to an editor for changes.
289 If no editor is specified in an
291 environment variable,
294 When the editor terminates, the label file is used to rewrite the disk label.
295 Existing bootstrap code is unchanged regardless of whether
300 is specified, no data will be written to the device, and instead the
301 disklabel that would have been written will be printed to stdout.
303 useful to see how a partitioning scheme will work out for a specific disk.
304 .Ss Restoring a disk label from a file
305 To restore a disk label from a file, use the form
311 .Ar disk Ar protofile
314 is capable of restoring a disk label that was previously saved in a file
316 The prototype file used to create the label should be in the same format
317 as that produced when reading or editing a label.
318 Comments are delimited by
321 As when writing a new label, any existing bootstrap code will be
324 is specified and will be unaffected otherwise.
325 See the boot options below for a
326 method of restoring the label and writing the bootstrap at the same time.
329 is used, no data will be written to the device, and instead the
330 disklabel that would have been written will be printed to stdout.
332 useful to see how a partitioning scheme will work out for a specific disk.
333 .Ss Enabling and disabling writing to the disk label area
334 By default, it is not possible to write to the disk label area at the beginning
336 The disk driver arranges for
338 and similar system calls
341 on any attempt to do so.
343 to write to this area (for example, to obliterate the label), use the form
349 To disallow writing to the label area after previously allowing it,
355 .Ss Installing bootstraps
356 The final three forms of
358 are used to install bootstrap code, which allows boot from a
364 If you are creating a
365 .Dq dangerously-dedicated
366 slice for compatibility with older PC systems,
367 you generally want to specify the compatibility slice, such as
369 If you are creating a label within an existing DOS slice,
371 the slice name such as
373 Making a slice bootable can be tricky.
374 If you are using a normal DOS
375 slice you typically install (or leave) a standard MBR on the base disk and
378 bootblocks in the slice.
387 .Oo Ar disktype Ns / Ns Cm auto Oc
389 This form installs the bootstrap only.
390 It does not change the disk label.
391 You should never use this command on the compatibility slice unless you
393 .Dq dangerously-dedicated
396 This command is typically run on a
410 .Op Ar disktype Ns / Ns Cm auto Op Ar packid
412 This form corresponds to the
414 command described above.
415 In addition to writing a new volume label, it also installs the bootstrap.
416 If run on the compatibility slice this command will create a
417 .Dq dangerously-dedicated
419 This command is normally run on a
421 slice rather than the compatibility slice.
424 is used, no data will be written to the device, and instead the
425 disklabel that would have been written will be printed to stdout.
435 .Ar disk Ar protofile
436 .Oo Ar disktype Ns / Ns Cm auto Oc
438 This form corresponds to the
440 command described above.
441 In addition to restoring the volume label, it also installs the bootstrap.
442 If run on the compatibility slice this command will create a
443 .Dq dangerously-dedicated
445 This command is normally run on a
447 slice rather than the compatibility
450 The bootstrap commands always access the disk directly,
451 so it is not necessary to specify the
456 is used, no data will be written to the device, and instead the
457 disklabel that would have been written will be printed to stdout.
459 The bootstrap code is comprised of two boot programs.
460 Specify the name of the
461 boot programs to be installed in one of these ways:
464 Specify the names explicitly with the
470 indicates the primary boot program and
472 the secondary boot program.
473 The boot programs are normally located in
480 flags are not specified, but
482 was specified, the names of the programs are taken from the
488 entry for the disk if the disktab entry exists and includes those parameters.
490 Otherwise, the default boot image names are used:
494 for the standard stage1 and stage2 boot images.
496 .Ss Initializing/Formatting a bootable disk from scratch
497 To initialize a disk from scratch the following sequence is recommended.
498 Please note that this will wipe everything that was previously on the disk,
508 to initialize the hard disk, and create a GPT or MBR slice table,
510 .Dq "partition table"
518 to define partitions on
520 slices created in the previous step.
524 .Xr newfs_hammer2 8 ,
527 to create file systems on new partitions.
530 A typical partitioning scheme would be to have an
532 partition of approximately 1 GB for
534 to hold the current, old (and backup) kernels and modules, a
536 partition for swap (suggested to be at least the same size as the
540 partition for the root file system (usually all remaining space).
541 Your mileage may vary.
545 .Dl "disklabel64 -B -r -w da0s0"
546 .Dl "disklabel64 -e da0s0"
548 When a virgin disklabel64 is laid down a
550 or later kernel will align the partition start offset relative to the
551 physical drive instead of relative to the slice start.
552 This overcomes the issue of fdisk creating a badly aligned slice by default.
553 The kernel will use a 1MiB (1024 * 1024 byte) alignment.
554 The purpose of this alignment is to match swap and cluster operations
555 against the physical block size of the underlying device.
557 Even though nearly all devices still report a logical sector size of 512,
558 newer hard drives are starting to use larger physical sector sizes
559 and, in particular, solid state drives (SSDs) use a physical block size
560 of 64K (SLC) or 128K (MLC). We choose a 1 megabyte alignment to cover our
561 bases down the road. 64-bit disklabels are not designed to be put on
562 ultra-tiny storage devices.
564 It is worth noting that aligning cluster operations is particularly
565 important for SSDs and doubly so when
568 Swapcache is able to use large bulk writes which greatly reduces the degree
569 of write magnification on SSD media and it is possible to get upwards of
570 5x more endurance out of the device than the vendor spec sheet indicates.
572 .Bl -tag -width ".Pa /boot/boot2_64" -compact
573 .It Pa /boot/boot1_64
574 Default stage1 boot image.
575 .It Pa /boot/boot2_64
576 Default stage2 boot image.
578 Disk description file.
580 .Sh SAVED FILE FORMAT
585 version of the label when examining, editing, or restoring a disk label.
586 An example shows as below:
587 .Bd -literal -offset 4n
590 # Calculated informational fields for the slice:
592 # boot space: 1012224 bytes
593 # data space: 156286976 blocks # 152624.00 MB (160037863424 bytes)
595 # NOTE: The partition data base and stop are physically
596 # aligned instead of slice-relative aligned.
598 # All byte equivalent offsets must be aligned.
600 diskid: 5dc53a64-c5e5-11e7-8aec-011d0988acd3
602 boot2 data base: 0x000000001000
603 partitions data base: 0x0000000f8200
604 partitions data stop: 0x0025430f8200
605 backup label: 0x002543157200
606 total size: 0x002543158200 # 152625.34 MB
608 display block size: 1024 # for partition display and edit only
611 # size offset fstype fsuuid
612 a: 1048576 0 4.2BSD # 1024.000MB
613 b: 16777216 1048576 swap # 16384.000MB
614 d: 138461184 17825792 HAMMER # 135216.000MB
615 a-stor_uuid: 7f1ff0ee-c5ec-11e7-8aec-011d0988acd3
616 b-stor_uuid: 7f1ff0fc-c5ec-11e7-8aec-011d0988acd3
617 d-stor_uuid: 7f1ff108-c5ec-11e7-8aec-011d0988acd3
620 Lines starting with a
623 The specifications which can be changed are:
626 is an optional label, set by the
628 option when writing a label.
629 .It Ar "the partition table"
632 partition table, not the
634 partition table described in
638 The partition table can have up to 16 entries.
639 It contains the following information:
640 .Bl -tag -width indent
642 The partition identifier is a single letter in the range
647 The size of the partition in sectors,
651 (megabytes - 1024*1024),
653 (gigabytes - 1024*1024*1024),
655 (terabytes - 1024*1024*1024*1024),
657 (percentage of free space
659 removing any fixed-size partitions),
661 (all remaining free space
663 fixed-size and percentage partitions).
664 Lowercase versions of
669 Size and type should be specified without any spaces between them.
671 Example: 2097152, 1G, 1024M and 1048576K are all the same size
672 (assuming 512-byte sectors).
674 The offset of the start of the partition from the beginning of the
679 calculate the correct offset to use (the end of the previous partition plus
682 The name of the filesystem type for the partition (case insensitive).
685 file systems, use type
689 file systems, use type
693 file systems, use type
699 For Vinum drives, use type
701 Other common types are
708 also knows about a number of other partition types,
709 none of which are in current use.
717 The remainder of the line is a comment and shows the size of
720 .Dl "disklabel64 da0s1"
722 Display the in-core label for the first slice of the
724 disk, as obtained via
727 .Dq dangerously-dedicated ,
728 the compatibility slice name should be specified, such as
731 .Dl "disklabel64 da0s1 > savedlabel"
733 Save the in-core label for
737 This file can be used with the
739 option to restore the label at a later date.
741 .Dl "disklabel64 -e -r da0s1"
743 Read the on-disk label for
745 edit it, and reinstall in-core as well as on-disk.
746 Existing bootstrap code is unaffected.
748 .Dl "disklabel64 -e -r -n da0s1"
750 Read the on-disk label for
752 edit it, and display what the new label would be.
755 install the new label either in-core or on-disk.
757 .Dl "disklabel64 -r -w da0s1"
759 Try to auto-detect the required information from
761 and write a new label to the disk.
764 command to edit the partitioning information.
766 .Dl "disklabel64 -R da0s1 savedlabel"
768 Restore the on-disk and in-core label for
772 Existing bootstrap code is unaffected.
774 .Dl "disklabel64 -R -n da0s1 label_layout"
776 Display what the label would be for
778 using the partition layout in
780 This is useful for determining how much space would be allotted for various
781 partitions with a labelling scheme using
787 .Dl "disklabel64 -B da0s1"
789 Install a new bootstrap on
791 The boot code comes from
795 On-disk and in-core labels are unchanged.
797 .Dl "disklabel64 -w -B /dev/da0s1 -b newboot1 -s newboot2"
799 Install a new label and bootstrap, with bootstrap code comes from the files
804 .Dl "dd if=/dev/zero of=/dev/da0 bs=512 count=32"
806 .Dl "dd if=/dev/zero of=/dev/da0s1 bs=512 count=32"
807 .Dl "disklabel64 -w -B da0s1"
808 .Dl "disklabel64 -e da0s1"
810 Completely wipe any prior information on the disk, creating a new bootable
811 disk with a DOS partition table containing one
815 initialize the slice, then edit it to your needs.
818 commands are optional, but may be necessary for some BIOSes to properly
821 .Dl "disklabel64 -W da0s1"
822 .Dl "dd if=/dev/zero of=/dev/da0s1 bs=512 count=32"
823 .Dl "disklabel -r -w da0s1"
824 .Dl "disklabel -N da0s1"
826 Completely wipe any prior information on the slice,
827 changing label format to 32 bit.
828 The wiping is needed as
833 won't do any operations if label with other format is already installed.
835 This is an example disklabel that uses some of the new partition size types
840 which could be used as a source file for
842 .Dl "disklabel64 -R ad0s1 new_label_file"
843 .Bd -literal -offset 4n
846 # Calculated informational fields for the slice:
848 # boot space: 1012224 bytes
849 # data space: 156286976 blocks # 152624.00 MB (160037863424 bytes)
851 # NOTE: The partition data base and stop are physically
852 # aligned instead of slice-relative aligned.
854 # All byte equivalent offsets must be aligned.
856 diskid: 5dc53a64-c5e5-11e7-8aec-011d0988acd3
858 boot2 data base: 0x000000001000
859 partitions data base: 0x0000000f8200
860 partitions data stop: 0x0025430f8200
861 backup label: 0x002543157200
862 total size: 0x002543158200 # 152625.34 MB
864 display block size: 1024 # for partition display and edit only
867 # size offset fstype fsuuid
880 The kernel device drivers will not allow the size of a disk partition
881 to be decreased or the offset of a partition to be changed while it is open.
882 Some device drivers create a label containing only a single large partition
883 if a disk is unlabeled; thus, the label must be written to the
885 partition of the disk while it is open.
886 This sometimes requires the desired
887 label to be set in two steps, the first one creating at least one other
888 partition, and the second setting the label on the new partition while
906 .Xr newfs_hammer2 8 ,
912 does not perform all possible error checking.
916 overlap; if an absolute offset does not match the expected offset; if a
917 partition runs past the end of the device; and a number of other errors; but
918 no warning is given if space remains unused.
922 support is not implemented.