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