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