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