1.\" $OpenBSD: disklabel.5,v 1.22 2015/09/10 17:55:21 schwarze Exp $ 2.\" $NetBSD: disklabel.5,v 1.3 1995/03/18 14:54:36 cgd Exp $ 3.\" 4.\" Copyright (c) 1987, 1991, 1993 5.\" The Regents of the University of California. All rights reserved. 6.\" 7.\" This code is derived from software contributed to Berkeley by 8.\" Symmetric Computer Systems. 9.\" 10.\" Redistribution and use in source and binary forms, with or without 11.\" modification, are permitted provided that the following conditions 12.\" are met: 13.\" 1. Redistributions of source code must retain the above copyright 14.\" notice, this list of conditions and the following disclaimer. 15.\" 2. Redistributions in binary form must reproduce the above copyright 16.\" notice, this list of conditions and the following disclaimer in the 17.\" documentation and/or other materials provided with the distribution. 18.\" 3. Neither the name of the University nor the names of its contributors 19.\" may be used to endorse or promote products derived from this software 20.\" without specific prior written permission. 21.\" 22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32.\" SUCH DAMAGE. 33.\" 34.\" @(#)disklabel.5.5 8.1 (Berkeley) 6/5/93 35.\" 36.Dd $Mdocdate: September 10 2015 $ 37.Dt DISKLABEL 5 38.Os 39.Sh NAME 40.Nm disklabel 41.Nd disk pack label 42.Sh SYNOPSIS 43.In sys/disklabel.h 44.Sh DESCRIPTION 45Each disk or disk pack on a system may contain a disk label 46which provides detailed information 47about the geometry of the disk and the partitions into which the disk 48is divided. 49It should be initialized when the disk is formatted, 50and may be changed later with the 51.Xr disklabel 8 52program. 53This information is used by the system disk driver and by the bootstrap 54program to determine how to program the drive 55and where to find the filesystems on the disk partitions. 56Additional information is used by the filesystem in order 57to use the disk most efficiently and to locate important filesystem information. 58The description of each partition contains an identifier for the partition 59type (standard filesystem, swap area, etc.). 60The filesystem updates the in-core copy of the label if it contains 61incomplete information about the filesystem. 62.Pp 63The label is located in sector number 64.Dv LABELSECTOR 65of the drive, usually sector 0 where it may be found 66without any information about the disk geometry. 67It is at an offset 68.Dv LABELOFFSET 69from the beginning of the sector, to allow room for the initial bootstrap. 70.Pp 71A copy of the in-core label for a disk can be obtained with the 72.Dv DIOCGDINFO 73.Em ioctl ; 74this works with a file descriptor for a block or character 75.Pq Dq raw 76device for any partition of the disk. 77The in-core copy of the label is set by the 78.Dv DIOCSDINFO 79.Em ioctl . 80The offset of a partition cannot generally be changed while it is open, 81nor can it be made smaller while it is open. 82One exception is that any change is allowed if no label was found 83on the disk, and the driver was able to construct only a skeletal label 84without partition information. 85The 86.Dv DIOCWDINFO 87.Em ioctl 88operation sets the in-core label and then updates the on-disk label; 89there must be an existing label on the disk for this operation to succeed. 90Thus, the initial label for a disk or disk pack must be installed 91by writing to the raw disk. 92The 93.Dv DIOCGPDINFO 94.Em ioctl 95operation gets the default label for a disk. 96This simulates the case 97where there is no physical label on the disk itself and can be used to 98see the label the kernel would construct in that case. 99The 100.Dv DIOCRLDINFO 101.Em ioctl 102operation causes the kernel to update its copy of the label based on the 103physical label on the disk. 104It can be used when the on-disk version 105of the label was changed directly or, if there is no physical label, 106to update the kernel's skeletal label if some variable affecting label 107generation has changed (e.g. the fdisk partition table). 108All of these operations are normally done using 109.Xr disklabel 8 . 110.Pp 111Note that when a disk has no real 112.Bx 113disklabel the kernel creates a 114default label so that the disk can be used. 115This default label will include other partitions found on the disk if 116they are supported on your architecture. 117For example, on systems that support 118.Xr fdisk 8 119partitions the default label will also include DOS and Linux partitions. 120However, these entries are not dynamic, they are fixed at the time 121.Xr disklabel 8 122is run. 123That means that subsequent changes that affect 124.Pf non- Ox 125partitions will not be present in the default label, though you 126may update them by hand. 127To see the default label, run 128.Xr disklabel 8 129with the 130.Fl d 131flag. 132You can then run 133.Xr disklabel 8 134with the 135.Fl e 136flag and paste any entries you want from the default label into the real 137one. 138.Sh SEE ALSO 139.Xr disktab 5 , 140.Xr disklabel 8 141.Sh CAVEATS 142.Nm 143only supports up to a maximum of 15 partitions, 144.Sq a 145through 146.Sq p , 147excluding 148.Sq c . 149The 150.Sq c 151partition is reserved for the entire physical disk. 152By convention, the 153.Sq a 154partition of the boot disk is the root partition, and the 155.Sq b 156partition of the boot disk is the swap partition, 157but all other letters can be used in any order for any other 158partitions as desired. 159