xref: /freebsd/sbin/bsdlabel/bsdlabel.8 (revision 77b7cdf1999ee965ad494fddd184b18f532ac91a)
1.\" Copyright (c) 1987, 1988, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Symmetric Computer Systems.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
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.
22.\"
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
33.\" SUCH DAMAGE.
34.\"
35.\"	@(#)disklabel.8	8.2 (Berkeley) 4/19/94
36.\" $FreeBSD$
37.\"
38.Dd March 15, 2003
39.Dt BSDLABEL 8
40.Os
41.Sh NAME
42.Nm bsdlabel
43.Nd read and write disk pack label
44.Sh SYNOPSIS
45.Nm
46.Op Fl A
47.Ar disk
48.Nm
49.Fl w
50.Op Fl nA
51.Op Fl B Op Fl b Ar boot
52.Op Fl m Ar machine
53.Ar disk
54.Op Ar type
55.Nm
56.Fl e
57.Op Fl nA
58.Op Fl B Op Fl b Ar boot
59.Op Fl m Ar machine
60.Ar disk
61.Nm
62.Fl R
63.Op Fl nA
64.Op Fl B Op Fl b Ar boot
65.Op Fl m Ar machine
66.Ar disk protofile
67.Pp
68.Sh DESCRIPTION
69The
70.Nm
71utility
72installs, examines or modifies the BSD label on a disk partition.
73In addition,
74.Nm
75can install bootstrap code.
76.Ss Disk Device Name
77When specifying the device,
78the
79.Pa /dev/
80path prefix may be omitted;
81the
82.Nm
83utility will automatically prepend it.
84.Ss General options
85The
86.Fl A
87option enables processing of the historical parts of the BSD label.
88If the option is not given, suitable values are set for these fields.
89.Pp
90The
91.Fl n
92stops the
93.Nm
94program right before the disk would have been modified, and displays
95the result instead of writing it.
96.Pp
97The
98.Fl m Ar machine
99argument instructs
100.Nm
101to use the layout suitable for the specified machine.
102.Ss Reading the Disk Label
103To examine the label on a disk drive, use
104.Nm
105without options:
106.Pp
107.Nm
108.Op Fl A
109.Op Fl m Ar machine
110.Ar disk
111.Pp
112.Ar disk
113represents the disk in question, and may be in the form
114.Pa da0
115or
116.Pa /dev/da0 .
117It will display the partition layout.
118.Ss Writing a Standard Label
119To write a standard label, use the form
120.Pp
121.Nm
122.Fl w
123.Op Fl nA
124.Op Fl m Ar machine
125.Ar disk
126.Op Ar type
127.Pp
128If the drive type if specified the entry of that name in the
129.Xr disktab 5
130file is used, otherwise a default layout is used.
131.Ss Editing an Existing Disk Label
132To edit an existing disk label, use the form
133.Pp
134.Nm
135.Fl e
136.Op Fl nA
137.Op Fl m Ar machine
138.Ar disk
139.Pp
140This command opens the disklabel in the default editor and when the editor
141exits the label is validated and if OK written to disk.
142.Ss Restoring a Disk Label From a File
143To restore a disk label from a file, use the form
144.Pp
145.Nm
146.Fl R
147.Op Fl nA
148.Op Fl m Ar machine
149.Ar disk protofile
150.Pp
151.Nm
152is capable of restoring a disk label that was previously saved in a file in
153.Tn ASCII
154format.
155The prototype file used to create the label should be in the same format as that
156produced when reading or editing a label.
157Comments are delimited by
158.Ql #
159and newline.
160.Ss Installing Bootstraps
161If the
162.Fl B
163argument is specified, bootstrap code will be read from the file
164.Pa /boot/boot
165and written to the disk.
166The
167.Fl b Ar boot
168argument allows a different file to be used.
169.Sh FILES
170.Bl -tag -width ".Pa /etc/disktab" -compact
171.It Pa /boot/boot
172Default boot image.
173.It Pa /etc/disktab
174Disk description file.
175.El
176.Sh SAVED FILE FORMAT
177The
178.Nm
179utility
180uses an
181.Tn ASCII
182version of the label when examining, editing, or restoring a disk
183label.
184The format is:
185.Bd -literal -offset 4n
186
1878 partitions:
188#        size   offset    fstype   [fsize bsize bps/cpg]
189  a:    81920        0    4.2BSD     1024  8192    16
190  b:   160000    81920      swap
191  c:  1173930        0    unused        0     0         # "raw" part, don't edit
192.Ed
193.Pp
194If the
195.Fl A
196option is specified, the format is:
197.Bd -literal -offset 4n
198# /dev/da1c:
199type: SCSI
200disk: da0s1
201label:
202flags:
203bytes/sector: 512
204sectors/track: 51
205tracks/cylinder: 19
206sectors/cylinder: 969
207cylinders: 1211
208sectors/unit: 1173930
209rpm: 3600
210interleave: 1
211trackskew: 0
212cylinderskew: 0
213headswitch: 0           # milliseconds
214track-to-track seek: 0  # milliseconds
215drivedata: 0
216
2178 partitions:
218#        size   offset    fstype   [fsize bsize bps/cpg]
219  a:    81920        0    4.2BSD     1024  8192    16
220  b:   160000    81920      swap
221  c:  1173930        0    unused        0     0         # "raw" part, don't edit
222.Ed
223.Pp
224Lines starting with a
225.Ql #
226mark are comments.
227.Pp
228The partition table can have up to 8 entries.
229It contains the following information:
230.Bl -tag -width indent
231.It Ar #
232The partition identifier is a single letter in the range
233.Ql a
234to
235.Ql h .
236By convention, partition
237.Ql c
238is reserved to describe the entire disk.
239.It Ar size
240The size of the partition in sectors,
241.Cm K
242(kilobytes - 1024),
243.Cm M
244(megabytes - 1024*1024),
245.Cm G
246(gigabytes - 1024*1024*1024),
247.Cm %
248(percentage of free space
249.Em after
250removing any fixed-size partitions other than partition
251.Ql c ) ,
252or
253.Cm *
254(all remaining free space
255.Em after
256fixed-size and percentage partitions).
257For partition
258.Ql c ,
259a size of
260.Cm *
261indicates the entire disk.
262Lowercase versions of
263.Cm K , M ,
264and
265.Cm G
266are allowed.
267Size and type should be specifed without any spaces between them.
268.Pp
269Example: 2097152, 1G, 1024M and 1048576K are all the same size
270(assuming 512-byte sectors).
271.It Ar offset
272The offset of the start of the partition from the beginning of the
273drive in sectors, or
274.Cm *
275to have
276.Nm
277calculate the correct offset to use (the end of the previous partition plus
278one, ignoring partition
279.Ql c .
280For partition
281.Ql c ,
282.Cm *
283will be interpreted as an offset of 0.
284.It Ar fstype
285Describes the purpose of the partition.
286The example shows all currently used partition types.
287For
288.Tn UFS
289file systems and
290.Xr ccd 4
291partitions, use type
292.Cm 4.2BSD .
293For Vinum drives, use type
294.Cm vinum .
295Other common types are
296.Cm swap
297and
298.Cm unused .
299By convention, partition
300.Ql c
301represents the entire slice and should be of type
302.Cm unused ,
303though
304.Nm
305does not enforce this convention.
306The
307.Nm
308utility
309also knows about a number of other partition types,
310none of which are in current use.
311(See the definitions starting with
312.Dv FS_UNUSED
313in
314.Aq Pa sys/disklabel.h
315for more details.)
316.It Ar fsize
317For
318.Cm 4.2BSD
319and
320.Tn LFS
321file systems only, the fragment size.
322Defaults to 1024 for partitions smaller than 1GB,
3234096 for partitions 1GB or larger.
324.It Ar bsize
325For
326.Cm 4.2BSD
327and
328.Tn LFS
329file systems only, the block size.
330Defaults to 8192 for partitions smaller than 1GB,
33116384 for partitions 1GB or larger.
332.It Ar bps/cpg
333For
334.Cm 4.2BSD
335file systems, the number of cylinders in a cylinder group.
336For
337.Tn LFS
338file systems, the segment shift value.
339Defaults to 16 for partitions smaller than 1GB,
34064 for partitions 1GB or larger.
341.El
342.Sh EXAMPLES
343.Dl "bsdlabel da0s1"
344.Pp
345Display the label for the first slice of the
346.Pa da0
347disk, as obtained via
348.Pa /dev/da0s1 .
349.Pp
350.Dl "bsdlabel da0s1 > savedlabel"
351.Pp
352Save the in-core label for
353.Pa da0s1
354into the file
355.Pa savedlabel .
356This file can be used with the
357.Fl R
358option to restore the label at a later date.
359.Pp
360.Dl "bsdlabel -w /dev/da0s1"
361.Pp
362Create a label for
363.Pa da0s1
364.Pp
365.Dl "bsdlabel -e da0s1"
366.Pp
367Read the label for
368.Pa da0s1 ,
369edit it, and install the result.
370.Pp
371.Dl "bsdlabel -e -n da0s1"
372.Pp
373Read the on-disk label for
374.Pa da0s1 ,
375edit it, and display what the new label would be (in sectors).
376It does
377.Em not
378install the new label either in-core or on-disk.
379.Pp
380.Dl "bsdlabel -w da0s1"
381.Pp
382Write a default label on
383.Pa da0s1 .
384Use another
385.Nm Fl e
386command to edit the
387partitioning and file system information.
388.Pp
389.Dl "bsdlabel -R da0s1 savedlabel"
390.Pp
391Restore the on-disk and in-core label for
392.Pa da0s1
393from information in
394.Pa savedlabel .
395.Pp
396.Dl "bsdlabel -R -n da0s1 label_layout"
397.Pp
398Display what the label would be for
399.Pa da0s1
400using the partition layout in
401.Pa label_layout .
402This is useful for determining how much space would be alloted for various
403partitions with a labelling scheme using
404.Cm % Ns -based
405or
406.Cm *
407partition sizes.
408.Pp
409.Dl "bsdlabel -B da0s1"
410.Pp
411Install a new bootstrap on
412.Pa da0s1 .
413The boot code comes from
414.Pa /boot/boot .
415.Pp
416.Dl "bsdlabel -w -B -b newboot /dev/da0s1"
417.Pp
418Install a new label and bootstrap.
419The bootstrap code comes from the file
420.Pa newboot
421in the current working directory.
422.Bd -literal -offset indent
423dd if=/dev/zero of=/dev/da0 bs=512 count=32
424fdisk -BI da0
425dd if=/dev/zero of=/dev/da0s1 bs=512 count=32
426bsdlabel -w -B da0s1
427bsdlabel -e da0s1
428.Ed
429.Pp
430Completely wipe any prior information on the disk, creating a new bootable
431disk with a
432.Tn DOS
433partition table containing one slice, covering the whole disk.
434Initialize the label on this slice,
435then edit it.
436The
437.Xr dd 1
438commands are optional, but may be necessary for some
439.Tn BIOS Ns es
440to properly
441recognize the disk.
442.Pp
443This is an example disk label that uses some of the new partition size types
444such as
445.Cm % , M , G ,
446and
447.Cm * ,
448which could be used as a source file for
449.Dq Li "bsdlabel -R ad0s1c new_label_file" :
450.Bd -literal -offset 4n
451# /dev/ad0s1c:
452
4538 partitions:
454#        size   offset    fstype   [fsize bsize bps/cpg]
455  a:   400M        0    4.2BSD     4096 16384    75 	# (Cyl.    0 - 812*)
456  b:     1G        *      swap
457  c:      *        *    unused
458  e: 204800        *    4.2BSD
459  f:     5g        *    4.2BSD
460  g:      *        *    4.2BSD
461.Ed
462.Sh SEE ALSO
463.Xr geom 4 ,
464.Xr ccd 4 ,
465.Xr md 4 ,
466.Xr disklabel 5 ,
467.Xr disktab 5 ,
468.Xr boot0cfg 8 ,
469.Xr fdisk 8
470.Sh DIAGNOSTICS
471The kernel device drivers will not allow the size of a disk partition
472to be decreased or the offset of a partition to be changed while it is open.
473