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