]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sbin/disklabel/disklabel.8
This commit was generated by cvs2svn to compensate for changes in r98567,
[FreeBSD/FreeBSD.git] / sbin / disklabel / disklabel.8
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 July 30, 1999
39 .Dt DISKLABEL 8
40 .Os
41 .Sh NAME
42 .Nm disklabel
43 .Nd read and write disk pack label
44 .Sh SYNOPSIS
45 .Nm
46 .Op Fl r
47 .Ar disk
48 .Nm
49 .Fl w
50 .Op Fl r
51 .Op Fl n
52 .Ar disk Ar disktype/auto
53 .Oo Ar packid Oc
54 .Nm
55 .Fl e
56 .Op Fl r
57 .Op Fl n
58 .Ar disk
59 .Nm
60 .Fl R
61 .Op Fl r
62 .Op Fl n
63 .Ar disk Ar protofile
64 .Nm
65 .Op Fl NW
66 .Ar disk
67 .Pp
68 .Nm
69 .Fl B
70 .Oo
71 .Fl b Ar boot1
72 .Fl s Ar boot2
73 .Oc
74 .Ar disk
75 .Oo Ar disktype/auto Oc
76 .Nm
77 .Fl w
78 .Fl B
79 .Op Fl n
80 .Oo
81 .Fl b Ar boot1
82 .Fl s Ar boot2
83 .Oc
84 .Ar disk Ar disktype/auto
85 .Oo Ar packid Oc
86 .Nm
87 .Fl R
88 .Fl B
89 .Op Fl n
90 .Oo
91 .Fl b Ar boot1
92 .Fl s Ar boot2
93 .Oc
94 .Ar disk Ar protofile
95 .Oo Ar disktype/auto Oc
96 .Sh DESCRIPTION
97 .Nm Disklabel
98 installs, examines or modifies the label on a disk drive or pack.  When writing
99 the label, it can be used to change the drive identification, the disk
100 partitions on the drive, or to replace a damaged label.  There are several forms
101 of the command that read (display), install or edit the label on a disk.  In
102 addition,
103 .Nm
104 can install bootstrap code.
105 .Ss Raw or in-core label
106 .Pp
107 The disk label resides close to or at the beginning of each disk slice.
108 For faster access, the kernel maintains a copy in core at all times.  By
109 default, most
110 .Nm
111 access the in-core copy of the label.  To access the raw (on-disk) copy, use the
112 .Fl r
113 option.  This option allows a label to be installed on a disk without kernel
114 support for a label, such as when labels are first installed on a system; it
115 must be used when first installing a label on a disk.  The specific effect of
116 .Fl r
117 is described under each command.
118 .Pp
119 .Ss Disk device name
120 .Pp
121 All
122 .Nm
123 forms require a disk device name, which should always be the raw
124 device name representing the disk or slice.  For example
125 .Pa da0
126 represents the entire disk regardless of any DOS partitioning,
127 and
128 .Pa da0s1
129 represents a slice.  Some devices, most notably
130 .Ar ccd ,
131 require that the
132 .Dq whole-disk
133 (or
134 .Dq c )
135 partition be specified.  For example
136 .Pa ccd0c .
137 You do not have to include the
138 .Pa /dev/
139 path prefix when specifying the device.
140 .Nm
141 will automatically prepend it.
142 .Ss Reading the disk label
143 .Pp
144 To examine the label on a disk drive, use
145 .Nm
146 without options:
147 .Pp
148 .Nm
149 .Op Fl r
150 .Ar disk
151 .Pp
152 .Ar disk
153 represents the raw disk in question, and may be in the form
154 .Pa da0
155 or
156 .Pa /dev/da0c .
157 It will display all of the parameters associated with the drive and its
158 partition layout.  Unless the
159 .Fl r
160 flag is given,
161 the kernel's in-core copy of the label is displayed;
162 if the disk has no label, or the partition types on the disk are incorrect,
163 the kernel may have constructed or modified the label.
164 If the
165 .Fl r
166 flag is given,
167 .Nm
168 reads the label from the raw disk and displays it.  Both versions are usually
169 identical except in the case where a label has not yet been initialized or
170 is corrupt.
171 .Ss Writing a standard label
172 .Pp
173 To write a standard label, use the form
174 .Pp
175 .Nm
176 .Fl w
177 .Op Fl r
178 .Op Fl n
179 .Ar disk Ar disktype/auto
180 .Oo Ar packid Oc
181 .Pp
182 .Nm
183 .Fl w
184 .Op Fl r
185 .Op Fl n
186 .Ar disk
187 auto
188 .Pp
189 The required arguments to
190 .Nm
191 are the drive to be labeled and the drive type as described in the
192 .Xr disktab 5
193 file.  The drive parameters and partitions are taken from that file.  If
194 different disks of the same physical type are to have different partitions, it
195 will be necessary to have separate disktab entries describing each, or to edit
196 the label after installation as described below.  The optional argument is a
197 pack identification string, up to 16 characters long.  The pack id must be
198 quoted if it contains blanks.
199 .Pp
200 If the
201 .Fl n
202 flag is given, no data will be written to the device, and instead the
203 disklabel that would have been written will be printed to stdout.
204 .Pp
205 If the
206 .Fl r
207 flag is given, the disk sectors containing the label and bootstrap
208 will be written directly.
209 A side-effect of this is that any existing bootstrap code will be overwritten
210 and the disk rendered unbootable.  See the boot options below for a method of
211 writing the label and the bootstrap at the same time.
212 If
213 .Fl r
214 is not specified,
215 the existing label will be updated via the in-core copy and any bootstrap
216 code will be unaffected.
217 If the disk does not already have a label, the
218 .Fl r
219 flag must be used.
220 In either case, the kernel's in-core label is replaced.
221 .Pp
222 For a virgin disk that is not known to
223 .Xr disktab 5 ,
224 .Ar disktype
225 can be specified as
226 .Dq auto .
227 In this case, the driver is requested to produce a virgin label for the
228 disk.  This might or might not be successful, depending on whether the
229 driver for the disk is able to get the required data without reading
230 anything from the disk at all.  It will likely succeed for all SCSI
231 disks, most IDE disks, and vnode devices.  Writing a label to the
232 disk is the only supported operation, and the
233 .Ar disk
234 itself must be provided as the canonical name, i.e. not as a full
235 path name.
236 .Pp
237 For most harddisks, a label based on percentages for most partitions (and
238 one partition with a size of
239 .Ql * )
240 will produce a reasonable configuration.
241 .Pp
242 PC-based systems have special requirements in order for the BIOS to properly
243 recognize a
244 .Fx
245 disklabel.  Older systems may require what is known as a
246 .Dq dangerously dedicated
247 disklabel, which creates a fake DOS partition to work around problems older
248 BIOSes have with modern disk geometries.
249 On newer systems you generally want
250 to create a normal DOS partition using
251 .Ar fdisk
252 and then create a
253 .Fx
254 disklabel within that slice.  This is described
255 later on in this page.
256 .Pp
257 Installing a new disklabel does not in of itself allow your system to boot
258 a kernel using that label.  You must also install boot blocks, which is
259 described later on in this manual page.
260 .Ss Editing an existing disk label
261 .Pp
262 To edit an existing disk label, use the form
263 .Pp
264 .Nm
265 .Fl e
266 .Op Fl r
267 .Op Fl n
268 .Ar disk
269 .Pp
270 This command reads the label from the in-core kernel copy, or directly from the
271 disk if the
272 .Fl r
273 flag is also specified.  The label is written to a file in ASCII and then
274 supplied to an editor for changes.  If no editor is specified in an
275 .Ev EDITOR
276 environment variable,
277 .Xr vi 1
278 is used.  When the editor terminates, the label file is used to rewrite the disk
279 label.  Existing bootstrap code is unchanged regardless of whether
280 .Fl r
281 was specified.  If
282 .Fl n
283 is specified, no data will be written to the device, and instead the
284 disklabel that would have been written will be printed to stdout.  This is
285 useful to see how a partitioning scheme will work out for a specific disk.
286 .Ss Restoring a disk label from a file
287 .Pp
288 To restore a disk label from a file, use the form
289 .Pp
290 .Nm
291 .Fl R
292 .Op Fl r
293 .Op Fl n
294 .Ar disk Ar protofile
295 .Pp
296 .Nm
297 is capable of restoring a disk label that was previously saved in a file in ASCII format.
298 The prototype file used to create the label should be in the same format as that
299 produced when reading or editing a label.  Comments are delimited by
300 .Ar \&#
301 and newline.  As when writing a new label, any existing bootstrap code will be
302 clobbered if
303 .Fl r
304 is specified and will be unaffected otherwise.  See the boot options below for a
305 method of restoring the label and writing the bootstrap at the same time.
306 If
307 .Fl n
308 is used, no data will be written to the device, and instead the
309 disklabel that would have been written will be printed to stdout.  This is
310 useful to see how a partitioning scheme will work out for a specific disk.
311 .Ss Enabling and disabling writing to the disk label area
312 .Pp
313 By default, it is not possible to write to the disk label area at the beginning
314 of a disk.  The disk driver silently ignores any attempt to do so.  If you need
315 to write to this area (for example, to obliterate the label), use the form
316 .Pp
317 .Nm
318 .Fl W
319 .Ar disk
320 .Pp
321 To disallow writing to the label area after previously allowing it, use the
322 command
323 .Pp
324 .Nm
325 .Fl N
326 .Ar disk
327 .Ss Installing bootstraps
328 .Pp
329 The final three forms of
330 .Nm
331 are used to install bootstrap code.  If you are creating a
332 .Dq dangerously-dedicated
333 slice for compatibility with older PC systems,
334 you generally want to specify the raw disk name such as
335 .Pa da0 .
336 If you are creating a label within an existing DOS slice,
337 you should specify
338 the partition name such as
339 .Pa da0s1a .
340 Making a slice bootable can be tricky.  If you are using a normal DOS
341 slice you typically install (or leave) a standard MBR on the base disk and
342 then install the
343 .Fx
344 bootblocks in the slice.
345 .Pp
346 .Nm
347 .Fl B
348 .Oo
349 .Fl b Ar boot1
350 .Fl s Ar boot2
351 .Oc
352 .Ar disk
353 .Oo Ar disktype Oc
354 .Pp
355 This form installs the bootstrap only.  It does not change the disk label.
356 You should never use this command on a base disk unless you intend to create a
357 .Dq dangerously-dedicated
358 disk, such as
359 .Ar da0 .
360 This command is typically run on a slice such as
361 .Ar da0s1 .
362 .Pp
363 .Nm
364 .Fl w
365 .Fl B
366 .Op Fl n
367 .Oo
368 .Fl b Ar boot1
369 .Fl s Ar boot2
370 .Oc
371 .Ar disk Ar disktype
372 .Oo Ar packid Oc
373 .Pp
374 This form corresponds to the
375 .Dq write label
376 command described above.
377 In addition to writing a new volume label, it also installs the bootstrap.
378 If run on a base disk this command will create a
379 .Dq dangerously-dedicated
380 label.  This command is normally run on a slice rather than a base disk.
381 If
382 .Fl n
383 is used, no data will be written to the device, and instead the
384 disklabel that would have been written will be printed to stdout.
385 .Pp
386 .Nm
387 .Fl R
388 .Fl B
389 .Op Fl n
390 .Oo
391 .Fl b Ar boot1
392 .Fl s Ar boot2
393 .Oc
394 .Ar disk Ar protofile
395 .Oo Ar disktype Oc
396 .Pp
397 This form corresponds to the
398 .Dq restore label
399 command described above.
400 In addition to restoring the volume label, it also installs the bootstrap.
401 If run on a base disk this command will create a
402 .Dq dangerously-dedicated
403 label.  This command is normally run on a slice rather than a base disk.
404 .Pp
405 The bootstrap commands always access the disk directly, so it is not necessary
406 to specify the
407 .Fl r
408 flag.  If
409 .Fl n
410 is used, no data will be written to the device, and instead the
411 disklabel that would have been written will be printed to stdout.
412 .Pp
413 The bootstrap code is comprised of two boot programs.  Specify the name of the
414 boot programs to be installed in one of these ways:
415 .Bl -enum
416 .It
417 Specify the names explicitly with the
418 .Fl b
419 and
420 .Fl s
421 flags.
422 .Fl b
423 indicates the primary boot program and
424 .Fl s
425 the secondary boot program.  The boot programs are located in
426 .Pa /boot .
427 .It
428 If the
429 .Fl b
430 and
431 .Fl s
432 flags are not specified, but
433 .Ar disktype
434 was specified, the names of the programs are taken from the
435 .Dq b0
436 and
437 .Dq b1
438 parameters of the
439 .Xr disktab 5
440 entry for the disk if the disktab entry exists and includes those parameters.
441 .It
442 Otherwise, the default boot image names are used:
443 .Pa /boot/boot1
444 and
445 .Pa /boot/boot2
446 for the standard stage1 and stage2 boot images (details may vary
447 on architectures like the Alpha, where only a single-stage boot is used).
448 .El
449 .Ss Initializing/Formatting a bootable disk from scratch
450 .Pp
451 To initialize a disk from scratch the following sequence is recommended.
452 Please note that this will wipe everything that was previously on the disk,
453 including any
454 .No non- Ns Fx
455 slices.
456 .Bl -enum
457 .It
458 Use
459 .Xr fdisk 8
460 to initialize the hard disk, and create a slice table, referred to
461 as the partition table in DOS.
462 Here you will define disk slices for your system.
463 .It
464 Use
465 .Xr disklabel 8
466 to define and write partitions and mount points.
467 You are not required to define the mount points here though,
468 they can be defined later using
469 .Xr mount 8 .
470 .It
471 Finally use
472 .Xr newfs 8
473 to create a filesystem on the new partition.
474 A typical partitioning scheme would be to have an
475 .Dq a
476 partition
477 of approximately 128MB to hold the root filesystem, a
478 .Dq b
479 partition for
480 swap, a
481 .Dq d
482 partition for /var (usually 128MB), an
483 .Dq e
484 partition
485 for /var/tmp (usually 128MB), an
486 .Dq f
487 partition for /usr (usually around 2G),
488 and finally a
489 .Dq g
490 partition for /home (usually all remaining space).
491 Your mileage may vary.
492 .El
493 .Pp
494 .Nm fdisk Fl BI Ar da0
495 .Pp
496 .Nm
497 .Fl w
498 .Fl B
499 .Ar da0s1
500 auto
501 .Pp
502 .Pp
503 .Nm
504 .Fl e
505 .Ar da0s1
506 .Sh FILES
507 .Bl -tag -width Pa -compact
508 .It Pa /etc/disktab
509 .It Pa /boot/
510 .It Pa /boot/boot<n>
511 .El
512 .Sh SAVED FILE FORMAT
513 .Nm
514 uses an ASCII version of the label when examining, editing or restoring a disk
515 label.  The format is:
516 .Bd -literal -offset 4n
517 # /dev/da1c:
518 type: SCSI
519 disk: da0s1
520 label:
521 flags:
522 bytes/sector: 512
523 sectors/track: 51
524 tracks/cylinder: 19
525 sectors/cylinder: 969
526 cylinders: 1211
527 sectors/unit: 1173930
528 rpm: 3600
529 interleave: 1
530 trackskew: 0
531 cylinderskew: 0
532 headswitch: 0           # milliseconds
533 track-to-track seek: 0  # milliseconds
534 drivedata: 0
535
536 8 partitions:
537 #        size   offset    fstype   [fsize bsize bps/cpg]
538   a:    81920        0    4.2BSD     1024  8192    16   # (Cyl.    0 - 84*)
539   b:   160000    81920      swap                        # (Cyl.   84* - 218*)
540   c:  1173930        0    unused        0     0         # (Cyl.    0 - 1211*)
541   h:   962010   211920     vinum                        # (Cyl.  218*- 1211*)
542 .Ed
543 .Pp
544 Lines starting with a # mark are comments.  Most of the other specifications are
545 no longer used.  The ones which must still be set correctly are:
546 .Pp
547 .Bl -hang -width 20n
548 .It Nm label
549 is an optional label, set by the
550 .Ar packid
551 option when writing a label.
552 .It Nm flags
553 Flags may be
554 .Ar removable ,
555 .Ar ecc
556 or
557 .Ar badsect .
558 .Ar removable
559 is set for removable media drives, but no current
560 .Fx
561 driver evaluates this
562 flag.
563 .Ar ecc
564 is no longer supported;
565 .Ar badsect
566 specifies that the drive can perform bad sector remapping.
567 .It Nm sectors/unit
568 describes the total size of the disk.  This value must be correct.
569 .It Nm the partition table
570 This is the
571 .Ux
572 partition table, not the Microsoft partition table described in
573 .Xr fdisk 8 .
574 .El
575 .Pp
576 The partition table can have up to 8 entries.  It contains the following
577 information:
578 .Bl -hang -width 10n
579 .It identifier
580 The partition identifier is a single letter in the range
581 .Dq a
582 to
583 .Dq h .
584 By convention, partition
585 .Dq c
586 is reserved to describe the entire disk.
587 .It size
588 is the size of the partition in sectors,
589 .Cm K
590 (kilobytes - 1024),
591 .Cm M
592 (megabytes - 1024*1024),
593 .Cm G
594 (gigabytes - 1024*1024*1024),
595 .Cm %
596 (percentage of free space AFTER removing any fixed-size partitions other
597 than partition
598 .Dq c) ,
599 or
600 .Cm *
601 (all remaining free space AFTER fixed-size and percentage
602 partitions).  For partition
603 .Dq c ,
604 a size of
605 .Cm *
606 indicates the entire disk.  Lowercase versions of
607 .Cm K , M ,
608 and
609 .Cm G
610 are allowed.
611 Size and type should be specifed without any spaces between them.
612 .Pp
613 Example: 2097152, 1g, 1024m and 1048576k are all the same size
614 (assuming 512-byte sectors).
615 .It offset
616 is the offset of the start of the partition from the beginning of the
617 drive in sectors, or
618 .Cm *
619 to have
620 .Nm
621 calculate the correct offset to use (the end of the previous partition plus
622 one, ignoring partition
623 .Dq c .
624 For partition
625 .Dq c ,
626 .Cm *
627 will be interpreted as an offset of 0.
628 .It fstype
629 describes the purpose of the partition.  The example shows all currently used
630 partition types.
631 For UFS filesystems and ccd partitions, use type
632 .Cm 4.2BSD .
633 For Vinum drives, use type
634 .Cm vinum .
635 Other common types are
636 .Cm unused
637 and
638 .Cm swap .
639 By convention, partition
640 .Dq c
641 represents the entire slice and should be of type
642 .Cm unused ,
643 though
644 .Nm
645 does not enforce this convention.
646 .Nm
647 also knows about a number of other partition types, none of which are in current
648 use.
649 See the definitions starting with
650 .Dv FS_UNUSED
651 in
652 .Pa /usr/include/sys/disklabel.h
653 for more details.
654 .It fsize
655 For
656 .Cm 4.2BSD
657 and LFS filesystems only, the fragment size.  Defaults to 1024 for
658 partitions smaller than 1 GB, 4096 for partitions 1GB or larger.
659 .It bsize
660 For
661 .Cm 4.2BSD
662 and LFS filesystems only, the block size.  Defaults to 8192 for
663 partitions smaller than 1 GB, 16384 for partitions 1GB or larger.
664 .It bps/cpg
665 For
666 .Cm 4.2BSD
667 filesystems, the number of cylinders in a cylinder group.  For LFS file
668 systems, the segment shift value.  Defaults to 16 for
669 partitions smaller than 1 GB, 64 for partitions 1GB or larger.
670 .El
671 .Pp
672 The remainder of the line is a comment and shows the cylinder allocations based
673 on the obsolete (but possibly correct) geometry information about the drive.
674 The asterisk (*) indicates that the partition does not begin or end exactly on a
675 cylinder boundary.
676 .Sh EXAMPLES
677 .Dl disklabel da0
678 .Pp
679 Display the in-core label for
680 .Pa da0s1
681 as obtained via
682 .Pa /dev/da0s1 .
683 When reading a label,
684 .Fx
685 will allow you to specify the base disk name
686 even if the label resides on a slice.  However, to be proper you should
687 specify the base disk name only if you are using a
688 .Dq dangerously-dedicated
689 label.  Normally you specify the slice.
690 .Pp
691 .Dl disklabel da0s1 > savedlabel
692 .Pp
693 Save the in-core label for
694 .Pa da0s1
695 into the file
696 .Pa savedlabel .
697 This file can be used with the
698 .Fl R
699 flag to restore the label at a later date.
700 .Pp
701 .Dl disklabel -w -r /dev/da0s1 da2212 foo
702 .Pp
703 Create a label for
704 .Pa da0s1
705 based on information for
706 .Dq da2212
707 found in
708 .Pa /etc/disktab .
709 Any existing bootstrap code will be clobbered.
710 .Pp
711 .Dl disklabel -e -r da0s1
712 .Pp
713 Read the on-disk label for
714 .Pa da0s1 ,
715 edit it and reinstall in-core as well as on-disk.  Existing bootstrap code is
716 unaffected.
717 .Pp
718 .Dl disklabel -e -r -n da0s1
719 .Pp
720 Read the on-disk label for
721 .Pa da0s1 ,
722 edit it, and display what the new label would be (in sectors).  It does
723 NOT install the new label either in-core or on-disk.
724 .Pp
725 .Dl disklabel -r -w da0s1 auto
726 .Pp
727 Try to auto-detect the required information from
728 .Pa da0s1 ,
729 and write a new label to the disk.  Use another disklabel -e command to edit the
730 partitioning and filesystem information.
731 .Pp
732 .Dl disklabel -R da0s1 savedlabel
733 .Pp
734 Restore the on-disk and in-core label for
735 .Pa da0s1
736 from information in
737 .Pa savedlabel .
738 Existing bootstrap code is unaffected.
739 .Pp
740 .Dl disklabel -R -n da0s1 label_layout
741 .Pp
742 Display what the label would be for
743 .Pa da0s1
744 using the partition layout in
745 .Pa label_layout .
746 This is useful for determining how much space would be alloted for various
747 partitions with a labelling scheme using
748 .Cm % Ns -based
749 or
750 .Cm *
751 partition sizes.
752 .Pp
753 .Dl disklabel -B da0s1
754 .Pp
755 Install a new bootstrap on
756 .Pa da0s1 .
757 The boot code comes from
758 .Pa /boot/boot1
759 and possibly
760 .Pa /boot/boot2 .
761 On-disk and in-core labels are unchanged.
762 .Pp
763 .Dl disklabel -w -B /dev/da0s1 -b newboot1 -s newboot2 da2212
764 .Pp
765 Install a new label and bootstrap.
766 The label is derived from disktab information for
767 .Dq da2212
768 and installed both in-core and on-disk.
769 The bootstrap code comes from the files
770 .Pa /boot/newboot1
771 and
772 .Pa /boot/newboot2 .
773 .Pp
774 .Dl dd if=/dev/zero of=/dev/da0 bs=512 count=32
775 .Dl fdisk -BI da0
776 .Dl dd if=/dev/zero of=/dev/da0s1 bs=512 count=32
777 .Dl disklabel -w -B da0s1 auto
778 .Dl disklabel -e da0s1
779 .Pp
780 Completely wipe any prior information on the disk, creating a new bootable
781 disk with a DOS partition table containing one
782 .Dq whole-disk
783 slice.  Then
784 initialize the slice, then edit it to your needs.  The
785 .Pa dd
786 commands are optional, but may be necessary for some BIOSes to properly
787 recognize the disk.
788 .Pp
789 This is an example disklabel that uses some of the new partition size types
790 such as
791 .Cm % , M , G ,
792 and
793 .Cm * ,
794 which could be used as a source file for
795 .Pp
796 .Dl disklabel -R ad0s1c new_label_file
797 .Bd -literal -offset 4n
798 # /dev/ad0s1c:
799 type: ESDI
800 disk: ad0s1
801 label:
802 flags:
803 bytes/sector: 512
804 sectors/track: 63
805 tracks/cylinder: 16
806 sectors/cylinder: 1008
807 cylinders: 40633
808 sectors/unit: 40959009
809 rpm: 3600
810 interleave: 1
811 trackskew: 0
812 cylinderskew: 0
813 headswitch: 0           # milliseconds
814 track-to-track seek: 0  # milliseconds
815 drivedata: 0
816
817 8 partitions:
818 #        size   offset    fstype   [fsize bsize bps/cpg]
819   a:   400M        0    4.2BSD     4096 16384    75     # (Cyl.    0 - 812*)
820   b:     1G        *      swap
821   c:      *        *    unused
822   e: 204800        *    4.2BSD
823   f:     5g        *    4.2BSD
824   g:      *        *    4.2BSD
825 .Ed
826 .Sh SEE ALSO
827 .Xr ccd 4 ,
828 .Xr disklabel 5 ,
829 .Xr disktab 5 ,
830 .Xr boot0cfg 8 ,
831 .Xr fdisk 8 ,
832 .Xr vinum 8
833 .Sh DIAGNOSTICS
834 The kernel device drivers will not allow the size of a disk partition
835 to be decreased or the offset of a partition to be changed while it is open.
836 Some device drivers create a label containing only a single large partition
837 if a disk is unlabeled; thus, the label must be written to the
838 .Dq a
839 partition of the disk while it is open.  This sometimes requires the desired
840 label to be set in two steps, the first one creating at least one other
841 partition, and the second setting the label on the new partition while shrinking
842 the
843 .Dq a
844 partition.
845 .Pp
846 On some machines the bootstrap code may not fit entirely in the area
847 allocated for it by some filesystems.
848 As a result, it may not be possible to have filesystems on some partitions
849 of a
850 .Dq bootable
851 disk.
852 When installing bootstrap code,
853 .Nm
854 checks for these cases.
855 If the installed boot code would overlap a partition of type FS_UNUSED
856 it is marked as type FS_BOOT.
857 The
858 .Xr newfs 8
859 utility will disallow creation of filesystems on FS_BOOT partitions.
860 Conversely, if a partition has a type other than FS_UNUSED or FS_BOOT,
861 .Nm
862 will not install bootstrap code that overlaps it.
863 .Sh BUGS
864 When a disk name is given without a full pathname,
865 the constructed device name uses the
866 .Dq c
867 partition.
868 .Pp
869 For the i386 architecture, the primary bootstrap sector contains
870 an embedded
871 .Em fdisk
872 table.
873 .Nm Disklabel
874 takes care to not clobber it when installing a bootstrap only
875 .Pq Fl B ,
876 or when editing an existing label
877 .Pq Fl e ,
878 but it unconditionally writes the primary bootstrap program onto
879 the disk for
880 .Fl w
881 or
882 .Fl R ,
883 thus replacing the
884 .Em fdisk
885 table by the dummy one in the bootstrap program.  This is only of
886 concern if the disk is fully dedicated, so that the
887 .Bx
888 disklabel
889 starts at absolute block 0 on the disk.
890 .Pp
891 .Nm
892 does not perform all possible error checking.  Warning *is* given if partitions
893 overlap; if an absolute offset does not match the expected offset; if the
894 .Dq c
895 partition does not start at 0 or does not cover the entire slice; if a
896 partition runs past the end of the device; and a number of other errors; but
897 no warning is given if space remains unused.