Change the kernel dev_t, representing a pointer to a specinfo structure,
[dragonfly.git] / sbin / i386 / fdisk / fdisk.8
CommitLineData
984263bc 1.\" $FreeBSD: src/sbin/i386/fdisk/fdisk.8,v 1.17.2.11 2002/04/25 16:25:12 trhodes Exp $
b13267a5 2.\" $DragonFly: src/sbin/i386/fdisk/fdisk.8,v 1.10 2006/09/10 01:26:28 dillon Exp $
984263bc
MD
3.\"
4.Dd October 4, 1996
5.Dt FDISK 8
6.Os
7.Sh NAME
8.Nm fdisk
9.Nd PC slice table maintenance program
10.Sh SYNOPSIS
11.Nm
b13267a5 12.Op Fl BCIaistu
984263bc 13.Op Fl b Ar bootcode
28e1b113 14.Op Fl p Ar diskimage
984263bc
MD
15.Op Fl 1234
16.Op Ar disk
984263bc
MD
17.Nm
18.Fl f Ar configfile
19.Op Fl itv
20.Op Ar disk
21.Sh PROLOGUE
22In order for the BIOS to boot the kernel,
23certain conventions must be adhered to.
24Sector 0 of the disk must contain boot code,
25a slice table,
26and a magic number.
27BIOS slices can be used to break the disk up into several pieces.
28The BIOS brings in sector 0 and verifies the magic number. The sector
290 boot code then searches the slice table to determine which
30slice is marked
31.Em active .
32This boot code then brings in the bootstrap from the
33.Em active
34slice and, if marked bootable, runs it.
35Under DOS,
36you can have one or more slices with one
37.Em active .
38The DOS
39.Nm
40program can be used to divide space on the disk into slices and set one
41.Em active .
42.Sh DESCRIPTION
43The
9bb2a92d 44.Dx
984263bc
MD
45program,
46.Nm ,
47serves a similar purpose to the DOS program. The first form is used to
48display slice information or to interactively edit the slice
49table. The second is used to write a slice table using a
50.Ar configfile
51and is designed to be used by other scripts/programs.
52.Pp
53Options are:
76b2e665 54.Bl -tag -width indent
984263bc
MD
55.It Fl a
56Change the active slice only. Ignored if
57.Fl f
58is given.
59.It Fl b Ar bootcode
60Get the boot code from the file
61.Ar bootcode .
62Default is
63.Pa /boot/mbr .
28e1b113
MD
64.It Fl p Ar diskimage
65The disk image is specified as a normal file instead of as a device,
66which is useful when building emulated disks for vmware, bochs, etc.
984263bc
MD
67.It Fl B
68Reinitialize the boot code contained in sector 0 of the disk. Ignored
69if
70.Fl f
71is given.
b13267a5
MD
72.It Fl C
73Normally if the CHS fields for a partition are set to all 1's if they
74would otherwise wrap. This typically causes BIOSes to properly detect
75that the disk should be put in Large mode. If this option is specified
76the CHS fields will be set to wrapped values instead. This option may
77be needed on very old PCs.
984263bc
MD
78.It Fl f Ar configfile
79Set slice values using the file
80.Ar configfile .
81The
82.Ar configfile
83always modifies existing slices, unless
84.Fl i
85is also given, in which case all existing slices are deleted (marked
86as "unused") before the
87.Ar configfile
88is read. The
89.Ar configfile
90can be "-", in which case
91.Ar stdin
92is read. See
93.Sx CONFIGURATION FILE ,
94below, for file syntax.
95.Pp
96.Em WARNING :
97when
98.Fl f
99is used, you are not asked if you really want to write the slices
100table (as you are in the interactive mode). Use with caution!
101.It Fl i
102Initialize sector 0 of the disk. This implies
103.Fl u ,
104unless
105.Fl f
106is given.
107.It Fl I
108Initialize the contents of sector 0
109for one
9bb2a92d 110.Dx
984263bc
MD
111slice covering the entire disk.
112.It Fl s
e6d78ffd
CP
113Print a summary of all slices on the disk and exit.
114All other options will be ignored.
984263bc
MD
115.It Fl t
116Test mode; do not write slice values. Generally used with the
117.Fl f
118option to see what would be written to the slice table. Implies
119.Fl v .
120.It Fl u
121Is used for updating (editing) sector 0 of the disk. Ignored if
122.Fl f
123is given.
124.It Fl v
125Be verbose. When
126.Fl f
127is used,
128.Nm
129prints out the slice table that is written to the disk.
130.It Fl 1234
131Operate on a single fdisk entry only. Ignored if
132.Fl f
133is given.
134.El
135.Pp
136The final disk name can be provided as a
137.Sq bare
138disk name only, e.g.\&
139.Ql da0 ,
140or as a fully qualified device node under
141.Pa /dev .
142If omitted, the disks
143.Ql ad0
144and
145.Ql da0
146are searched in that order, until one is found to respond.
147.Pp
148When called without options,
149.Nm
150prints the sector 0 slice table.
151An example follows:
152.Bd -literal
153 ******* Working on device /dev/ad0 *******
154 parameters extracted from in-core disklabel are:
155 cylinders=769 heads=15 sectors/track=33 (495 blks/cyl)
156
157 parameters to be used for BIOS calculations are:
158 cylinders=769 heads=15 sectors/track=33 (495 blks/cyl)
159
160 Warning: BIOS sector numbering starts with sector 1
161 Information from DOS bootblock is:
162 The data for partition 1 is:
aa0ab232 163 sysid 165,(DragonFly/FreeBSD/NetBSD/386BSD)
984263bc
MD
164 start 495, size 380160 (185 Meg), flag 0
165 beg: cyl 1/ sector 1/ head 0;
166 end: cyl 768/ sector 33/ head 14
167 The data for partition 2 is:
168 sysid 164,(unknown)
169 start 378180, size 2475 (1 Meg), flag 0
170 beg: cyl 764/ sector 1/ head 0;
171 end: cyl 768/ sector 33/ head 14
172 The data for partition 3 is:
173 <UNUSED>
174 The data for partition 4 is:
175 sysid 99,(ISC UNIX, other System V/386, GNU HURD or Mach)
176 start 380656, size 224234 (109 Meg), flag 80
177 beg: cyl 769/ sector 2/ head 0;
178 end: cyl 197/ sector 33/ head 14
179.Ed
180.Pp
181The disk is divided into three slices that happen to fill the disk.
182The second slice overlaps the end of the first.
183(Used for debugging purposes.)
184.Bl -tag -width "cyl, sector and head"
185.It Em "sysid"
186is used to label the slice.
9bb2a92d 187.Dx
984263bc
MD
188reserves the
189magic number 165 decimal (A5 in hex).
190.It Em start No and Em size
191fields provide the start address
192and size of a slice in sectors.
193.It Em "flag 80"
194specifies that this is the active slice.
195.It Em cyl , sector No and Em head
196fields are used to specify the beginning and end addresses of the slice.
197.It Em Note :
198these numbers are calculated using BIOS's understanding of the disk geometry
199and saved in the bootblock.
200.El
201.Pp
202The
203.Fl i
204and
205.Fl u
206flags are used to indicate that the slice data is to be updated.
207Unless the
208.Fl f
209option is also given,
210.Nm
211will enter a conversational mode.
212In this mode, no changes will be written to disk unless you explicitly tell
213.Nm
214to.
215.Pp
216.Nm Fdisk
217will display each slice and ask whether you want to edit it.
218If you say yes,
219.Nm
220will step through each field, show you the old value,
221and ask you for a new one.
222When you are done with the slice,
223.Nm
224will display it and ask you whether it is correct.
225.Nm Fdisk
226will then proceed to the next entry.
227.Pp
228Getting the
229.Em cyl , sector ,
230and
231.Em head
232fields correct is tricky, so by default,
233they will be calculated for you;
234you can specify them if you choose to though.
235.Pp
236After all the slices are processed,
237you are given the option to change the
238.Em active
239slice.
240Finally, when all the new data for sector 0 has been accumulated,
241you are asked to confirm whether you really want to rewrite it.
242.Pp
243The difference between the
244.Fl u
245and
246.Fl i
247flags is that
248the
249.Fl u
250flag just edits (updates) the fields as they appear on the disk,
251while the
252.Fl i
253flag is used to "initialize" sector 0;
254it will set up the last BIOS slice to use the whole disk for
9bb2a92d 255.Dx
984263bc
MD
256and make it active.
257.Sh NOTES
258The automatic calculation of starting cylinder etc. uses
259a set of figures that represent what the BIOS thinks the
260geometry of the drive is.
261These figures are taken from the in-core disklabel by default,
262but
263.Nm
264initially gives you an opportunity to change them.
265This allows you to create a bootblock that can work with drives
266that use geometry translation under the BIOS.
267.Pp
268If you hand craft your disk layout,
269please make sure that the
9bb2a92d 270.Dx
984263bc
MD
271slice starts on a cylinder boundary.
272A number of decisions made later may assume this.
273(This might not be necessary later.)
274.Pp
275Editing an existing slice will most likely result in the loss of
276all data in that slice.
277.Pp
278You should run
279.Nm
280interactively once or twice to see how it works.
281This is completely safe as long as you answer the last question
282in the negative. There are subtleties that
283.Nm
284detects that are not fully explained in this manual page.
285.Sh CONFIGURATION FILE
286When the
287.Fl f
288option is given, a disk's slice table can be written using values
289from a
290.Ar configfile .
291The syntax of this file is very simple;
292each line is either a comment or a specification, as follows:
293.Bl -tag -width Ds
294.It Xo
295.Ic #
296.Ar comment ...
297.Xc
298Lines beginning with a "#" are comments and are ignored.
299.It Xo
300.Ic g
301.Ar spec1
302.Ar spec2
303.Ar spec3
304.Xc
305Set the BIOS geometry used in slice calculations. There must be
306three values specified, with a letter preceding each number:
307.Bl -tag -width Ds
308.Sm off
309.It Cm c Ar num
310.Sm on
311Set the number of cylinders to
312.Ar num .
313.Sm off
314.It Cm h Ar num
315.Sm on
316Set the number of heads to
317.Ar num .
318.Sm off
319.It Cm s Ar num
320.Sm on
321Set the number of sectors/track to
322.Ar num .
323.El
324.Pp
325These specs can occur in any order, as the leading letter determines
326which value is which; however, all three must be specified.
327.Pp
328This line must occur before any lines that specify slice
329information.
330.Pp
331It is an error if the following is not true:
332.Bd -literal -offset indent
aa0d550a
SW
3331 \(<= number of cylinders
3341 \(<= number of heads \(<= 256
3351 \(<= number of sectors/track < 64
984263bc
MD
336.Ed
337.Pp
338The number of cylinders should be less than or equal to 1024, but this
339is not enforced, although a warning will be printed. Note that bootable
9bb2a92d 340.Dx
984263bc
MD
341slices (the "/" filesystem) must lie completely within the
342first 1024 cylinders; if this is not true, booting may fail.
343Non-bootable slices do not have this restriction.
344.Pp
345Example (all of these are equivalent), for a disk with 1019 cylinders,
34639 heads, and 63 sectors:
347.Bd -literal -offset indent
348g c1019 h39 s63
349g h39 c1019 s63
350g s63 h39 c1019
351.Ed
352.It Xo
353.Ic p
354.Ar slice
355.Ar type
356.Ar start
357.Ar length
358.Xc
359Set the slice given by
360.Ar slice
361(1-4) to type
362.Ar type ,
363starting at sector
364.Ar start
365for
366.Ar length
367sectors.
368.Pp
369Only those slices explicitly mentioned by these lines are modified;
370any slice not referenced by a "p" line will not be modified.
371However, if an invalid slice table is present, or the
372.Fl i
373option is specified, all existing slice entries will be cleared
374(marked as unused), and these "p" lines will have to be used to
375explicitly set slice information. If multiple slices need to be
376set, multiple "p" lines must be specified; one for each slice.
377.Pp
378These slice lines must occur after any geometry specification lines,
379if one is present.
380.Pp
381The
382.Ar type
383is 165 for
9bb2a92d 384.Dx
984263bc
MD
385slices. Specifying a slice type of zero is
386the same as clearing the slice and marking it as unused; however,
387dummy values (such as "0") must still be specified for
388.Ar start
389and
390.Ar length .
391.Pp
392Note: the start offset will be rounded upwards to a head boundary if
393necessary, and the end offset will be rounded downwards to a cylinder
394boundary if necessary.
395.Pp
396Example: to clear slice 4 and mark it as unused:
397.Bd -literal -offset indent
398p 4 0 0 0
399.Ed
400.Pp
401Example: to set slice 1 to a
9bb2a92d 402.Dx
984263bc
MD
403slice, starting at sector 1
404for 2503871 sectors (note: these numbers will be rounded upwards and
405downwards to correspond to head and cylinder boundaries):
406.Pp
407.Bd -literal -offset indent
408p 1 165 1 2503871
409.Ed
410.Pp
411.It Xo
412.Ic a
413.Ar slice
414.Xc
415Make
416.Ar slice
417the active slice. Can occur anywhere in the config file, but only
418one must be present.
78753989
CP
419If no
420.Cm a
421line is present, all slices of the disk are made inactive.
984263bc
MD
422.Pp
423Example: to make slice 1 the active slice:
424.Bd -literal -offset indent
425a 1
426.Ed
427.El
428.Sh FILES
429.Bl -tag -width /boot/mbr -compact
430.It Pa /boot/mbr
431The default boot code
432.El
433.Sh SEE ALSO
434.Xr boot0cfg 8 ,
435.Xr disklabel 8 ,
436.Xr newfs 8
437.Sh BUGS
438The default boot code will not necessarily handle all slice types
439correctly, in particular those introduced since MS-DOS 6.x.
440.Pp
441The entire program should be made more user-friendly.
442.Pp
443Most users new to
9bb2a92d 444.Dx
984263bc
MD
445do not understand the difference between
446.Ar slice
447and
448.Ar partition
449causing difficulty to adjust.
450.Pp
451You cannot use this command to completely dedicate a disk to
9bb2a92d 452.Dx .
984263bc
MD
453The
454.Xr disklabel 8
455command must be used for this.