1.\" $OpenBSD: disklabel.5,v 1.19 2007/05/31 19:19:43 jmc 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: May 31 2007 $ 37.Dt DISKLABEL 5 38.Os 39.Sh NAME 40.Nm disklabel 41.Nd disk pack label 42.Sh SYNOPSIS 43.Fd #include <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. 70The disk sector containing the label is normally made read-only 71so that it is not accidentally overwritten by pack-to-pack copies 72or swap operations; 73the 74.Dv DIOCWLABEL 75.Xr ioctl 2 , 76which is done as needed by the 77.Xr disklabel 8 78program, allows modification of the label sector. 79.Pp 80A copy of the in-core label for a disk can be obtained with the 81.Dv DIOCGDINFO 82.Em ioctl ; 83this works with a file descriptor for a block or character 84.Pq Dq raw 85device for any partition of the disk. 86The in-core copy of the label is set by the 87.Dv DIOCSDINFO 88.Em ioctl . 89The offset of a partition cannot generally be changed while it is open, 90nor can it be made smaller while it is open. 91One exception is that any change is allowed if no label was found 92on the disk, and the driver was able to construct only a skeletal label 93without partition information. 94The 95.Dv DIOCWDINFO 96.Em ioctl 97operation sets the in-core label and then updates the on-disk label; 98there must be an existing label on the disk for this operation to succeed. 99Thus, the initial label for a disk or disk pack must be installed 100by writing to the raw disk. 101The 102.Dv DIOCGPDINFO 103.Em ioctl 104operation gets the default label for a disk. 105This simulates the case 106where there is no physical label on the disk itself and can be used to 107see the label the kernel would construct in that case. 108The 109.Dv DIOCRLDINFO 110.Em ioctl 111operation causes the kernel to update its copy of the label based on the 112physical label on the disk. 113It can be used when the on-disk version 114of the label was changed directly or, if there is no physical label, 115to update the kernel's skeletal label if some variable affecting label 116generation has changed (e.g. the fdisk partition table). 117All of these operations are normally done using 118.Xr disklabel 8 . 119.Pp 120Note that when a disk has no real BSD disklabel the kernel creates a 121default label so that the disk can be used. 122This default label will include other partitions found on the disk if 123they are supported on your architecture. 124For example, on systems that support 125.Xr fdisk 8 126partitions the default label will also include DOS and Linux partitions. 127However, these entries are not dynamic, they are fixed at the time 128.Xr disklabel 8 129is run. 130That means that subsequent changes that affect non-OpenBSD 131partitions will not be present in the default label, though you 132may update them by hand. 133To see the default label, run 134.Xr disklabel 8 135with the 136.Fl d 137flag. 138You can then run 139.Xr disklabel 8 140with the 141.Fl e 142flag and paste any entries you want from the default label into the real 143one. 144.Sh SEE ALSO 145.Xr disktab 5 , 146.Xr disklabel 8 147.Sh CAVEATS 148.Nm 149only supports up to a maximum of 15 partitions, 150.Sq a 151through 152.Sq p , 153excluding 154.Sq c . 155The 156.Sq c 157partition is reserved for the entire physical disk. 158By convention, the 159.Sq a 160partition of the boot disk is the root partition, and the 161.Sq b 162partition of the boot disk is the swap partition, 163but all other letters can be used in any order for any other 164partitions as desired. 165