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