aboutsummaryrefslogtreecommitdiff
path: root/sbin/bsdlabel/bsdlabel.8
blob: 17df6d00c79aedda1c958e31656ad34cfe60a29d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
.\" Copyright (c) 1987, 1988, 1991, 1993
.\"	The Regents of the University of California.  All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" Symmetric Computer Systems.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\"    must display the following acknowledgment:
.\"	This product includes software developed by the University of
.\"	California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\"    may be used to endorse or promote products derived from this software
.\"    without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\"	@(#)disklabel.8	8.2 (Berkeley) 4/19/94
.\" $FreeBSD$
.\"
.Dd March 15, 2003
.Dt BSDLABEL 8
.Os
.Sh NAME
.Nm bsdlabel
.Nd read and write disk pack label
.Sh SYNOPSIS
.Nm
.Op Fl A
.Ar disk
.Nm
.Fl w
.Op Fl \&An
.Op Fl B Op Fl b Ar boot
.Op Fl m Ar machine
.Ar disk
.Op Ar type
.Nm
.Fl e
.Op Fl \&An
.Op Fl B Op Fl b Ar boot
.Op Fl m Ar machine
.Ar disk
.Nm
.Fl R
.Op Fl \&An
.Op Fl B Op Fl b Ar boot
.Op Fl m Ar machine
.Ar disk protofile
.Sh DESCRIPTION
The
.Nm
utility
installs, examines or modifies the
.Bx
label on a disk partition.
In addition,
.Nm
can install bootstrap code.
.Ss Disk Device Name
When specifying the device,
the
.Pa /dev/
path prefix may be omitted;
the
.Nm
utility will automatically prepend it.
.Ss General Options
The
.Fl A
option enables processing of the historical parts of the
.Bx
label.
If the option is not given, suitable values are set for these fields.
.Pp
The
.Fl n
stops the
.Nm
program right before the disk would have been modified, and displays
the result instead of writing it.
.Pp
The
.Fl m Ar machine
argument instructs
.Nm
to use the layout suitable for the specified machine.
.Ss Reading the Disk Label
To examine the label on a disk drive, use
.Nm
without options:
.Pp
.Nm
.Op Fl A
.Op Fl m Ar machine
.Ar disk
.Pp
.Ar disk
represents the disk in question, and may be in the form
.Pa da0
or
.Pa /dev/da0 .
It will display the partition layout.
.Ss Writing a Standard Label
To write a standard label, use the form
.Pp
.Nm
.Fl w
.Op Fl \&An
.Op Fl m Ar machine
.Ar disk
.Op Ar type
.Pp
If the drive type is specified, the entry of that name in the
.Xr disktab 5
file is used; otherwise a default layout is used.
.Ss Editing an Existing Disk Label
To edit an existing disk label, use the form
.Pp
.Nm
.Fl e
.Op Fl \&An
.Op Fl m Ar machine
.Ar disk
.Pp
This command opens the disk label in the default editor, and when the editor
exits, the label is validated and if OK written to disk.
.Ss Restoring a Disk Label From a File
To restore a disk label from a file, use the form
.Pp
.Nm
.Fl R
.Op Fl \&An
.Op Fl m Ar machine
.Ar disk protofile
.Pp
.Nm
is capable of restoring a disk label that was previously saved in a file in
.Tn ASCII
format.
The prototype file used to create the label should be in the same format as that
produced when reading or editing a label.
Comments are delimited by
.Ql #
and newline.
.Ss Installing Bootstraps
If the
.Fl B
argument is specified, bootstrap code will be read from the file
.Pa /boot/boot
and written to the disk.
The
.Fl b Ar boot
argument allows a different file to be used.
.Sh FILES
.Bl -tag -width ".Pa /etc/disktab" -compact
.It Pa /boot/boot
Default boot image.
.It Pa /etc/disktab
Disk description file.
.El
.Sh SAVED FILE FORMAT
The
.Nm
utility
uses an
.Tn ASCII
version of the label when examining, editing, or restoring a disk
label.
The format is:
.Bd -literal -offset 4n

8 partitions:
#        size   offset    fstype   [fsize bsize bps/cpg]
  a:    81920        0    4.2BSD     1024  8192    16
  b:   160000    81920      swap
  c:  1173930        0    unused        0     0         # "raw" part, don't edit
.Ed
.Pp
If the
.Fl A
option is specified, the format is:
.Bd -literal -offset 4n
# /dev/da1c:
type: SCSI
disk: da0s1
label:
flags:
bytes/sector: 512
sectors/track: 51
tracks/cylinder: 19
sectors/cylinder: 969
cylinders: 1211
sectors/unit: 1173930
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0           # milliseconds
track-to-track seek: 0  # milliseconds
drivedata: 0

8 partitions:
#        size   offset    fstype   [fsize bsize bps/cpg]
  a:    81920        0    4.2BSD     1024  8192    16
  b:   160000    81920      swap
  c:  1173930        0    unused        0     0         # "raw" part, don't edit
.Ed
.Pp
Lines starting with a
.Ql #
mark are comments.
.Pp
The partition table can have up to 8 entries.
It contains the following information:
.Bl -tag -width indent
.It Ar #
The partition identifier is a single letter in the range
.Ql a
to
.Ql h .
By convention, partition
.Ql c
is reserved to describe the entire disk.
.It Ar size
The size of the partition in sectors,
.Cm K
(kilobytes - 1024),
.Cm M
(megabytes - 1024*1024),
.Cm G
(gigabytes - 1024*1024*1024),
.Cm %
(percentage of free space
.Em after
removing any fixed-size partitions other than partition
.Ql c ) ,
or
.Cm *
(all remaining free space
.Em after
fixed-size and percentage partitions).
For partition
.Ql c ,
a size of
.Cm *
indicates the entire disk.
Lowercase versions of
.Cm K , M ,
and
.Cm G
are allowed.
Size and type should be specifed without any spaces between them.
.Pp
Example: 2097152, 1G, 1024M and 1048576K are all the same size
(assuming 512-byte sectors).
.It Ar offset
The offset of the start of the partition from the beginning of the
drive in sectors, or
.Cm *
to have
.Nm
calculate the correct offset to use (the end of the previous partition plus
one, ignoring partition
.Ql c .
For partition
.Ql c ,
.Cm *
will be interpreted as an offset of 0.
.It Ar fstype
Describes the purpose of the partition.
The example shows all currently used partition types.
For
.Tn UFS
file systems and
.Xr ccd 4
partitions, use type
.Cm 4.2BSD .
For Vinum drives, use type
.Cm vinum .
Other common types are
.Cm swap
and
.Cm unused .
By convention, partition
.Ql c
represents the entire slice and should be of type
.Cm unused ,
though
.Nm
does not enforce this convention.
The
.Nm
utility
also knows about a number of other partition types,
none of which are in current use.
(See the definitions starting with
.Dv FS_UNUSED
in
.Aq Pa sys/disklabel.h
for more details.)
.It Ar fsize
For
.Cm 4.2BSD
and
.Tn LFS
file systems only, the fragment size.
Defaults to 1024 for partitions smaller than 1GB,
4096 for partitions 1GB or larger.
.It Ar bsize
For
.Cm 4.2BSD
and
.Tn LFS
file systems only, the block size.
Defaults to 8192 for partitions smaller than 1GB,
16384 for partitions 1GB or larger.
.It Ar bps/cpg
For
.Cm 4.2BSD
file systems, the number of cylinders in a cylinder group.
For
.Tn LFS
file systems, the segment shift value.
Defaults to 16 for partitions smaller than 1GB,
64 for partitions 1GB or larger.
.El
.Sh EXAMPLES
.Dl "bsdlabel da0s1"
.Pp
Display the label for the first slice of the
.Pa da0
disk, as obtained via
.Pa /dev/da0s1 .
.Pp
.Dl "bsdlabel da0s1 > savedlabel"
.Pp
Save the in-core label for
.Pa da0s1
into the file
.Pa savedlabel .
This file can be used with the
.Fl R
option to restore the label at a later date.
.Pp
.Dl "bsdlabel -w /dev/da0s1"
.Pp
Create a label for
.Pa da0s1 .
.Pp
.Dl "bsdlabel -e da0s1"
.Pp
Read the label for
.Pa da0s1 ,
edit it, and install the result.
.Pp
.Dl "bsdlabel -e -n da0s1"
.Pp
Read the on-disk label for
.Pa da0s1 ,
edit it, and display what the new label would be (in sectors).
It does
.Em not
install the new label either in-core or on-disk.
.Pp
.Dl "bsdlabel -w da0s1"
.Pp
Write a default label on
.Pa da0s1 .
Use another
.Nm Fl e
command to edit the
partitioning and file system information.
.Pp
.Dl "bsdlabel -R da0s1 savedlabel"
.Pp
Restore the on-disk and in-core label for
.Pa da0s1
from information in
.Pa savedlabel .
.Pp
.Dl "bsdlabel -R -n da0s1 label_layout"
.Pp
Display what the label would be for
.Pa da0s1
using the partition layout in
.Pa label_layout .
This is useful for determining how much space would be alloted for various
partitions with a labelling scheme using
.Cm % Ns -based
or
.Cm *
partition sizes.
.Pp
.Dl "bsdlabel -B da0s1"
.Pp
Install a new bootstrap on
.Pa da0s1 .
The boot code comes from
.Pa /boot/boot .
.Pp
.Dl "bsdlabel -w -B -b newboot /dev/da0s1"
.Pp
Install a new label and bootstrap.
The bootstrap code comes from the file
.Pa newboot
in the current working directory.
.Bd -literal -offset indent
dd if=/dev/zero of=/dev/da0 bs=512 count=32
fdisk -BI da0
dd if=/dev/zero of=/dev/da0s1 bs=512 count=32
bsdlabel -w -B da0s1
bsdlabel -e da0s1
.Ed
.Pp
Completely wipe any prior information on the disk, creating a new bootable
disk with a
.Tn DOS
partition table containing one slice, covering the whole disk.
Initialize the label on this slice,
then edit it.
The
.Xr dd 1
commands are optional, but may be necessary for some
.Tn BIOS Ns es
to properly
recognize the disk.
.Pp
This is an example disk label that uses some of the new partition size types
such as
.Cm % , M , G ,
and
.Cm * ,
which could be used as a source file for
.Dq Li "bsdlabel -R ad0s1c new_label_file" :
.Bd -literal -offset 4n
# /dev/ad0s1c:

8 partitions:
#        size   offset    fstype   [fsize bsize bps/cpg]
  a:   400M        0    4.2BSD     4096 16384    75 	# (Cyl.    0 - 812*)
  b:     1G        *      swap
  c:      *        *    unused
  e: 204800        *    4.2BSD
  f:     5g        *    4.2BSD
  g:      *        *    4.2BSD
.Ed
.Sh SEE ALSO
.Xr ccd 4 ,
.Xr geom 4 ,
.Xr md 4 ,
.\" Xr bsdlabel 5 ,
.Xr disktab 5 ,
.Xr boot0cfg 8 ,
.Xr fdisk 8
.Sh DIAGNOSTICS
The kernel device drivers will not allow the size of a disk partition
to be decreased or the offset of a partition to be changed while it is open.