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