Mon Apr 25 22:23:48 2011 UTC ()
Use Nx.


(wiz)
diff -r1.70 -r1.71 src/sbin/fdisk/fdisk.8

cvs diff -r1.70 -r1.71 src/sbin/fdisk/fdisk.8 (switch to unified diff)

--- src/sbin/fdisk/fdisk.8 2010/04/07 09:40:58 1.70
+++ src/sbin/fdisk/fdisk.8 2011/04/25 22:23:47 1.71
@@ -1,658 +1,659 @@ @@ -1,658 +1,659 @@
1.\" $NetBSD: fdisk.8,v 1.70 2010/04/07 09:40:58 wiz Exp $ 1.\" $NetBSD: fdisk.8,v 1.71 2011/04/25 22:23:47 wiz Exp $
2.\" 2.\"
3.Dd April 6, 2010 3.Dd April 6, 2010
4.Dt FDISK 8 4.Dt FDISK 8
5.Os 5.Os
6.Sh NAME 6.Sh NAME
7.Nm fdisk 7.Nm fdisk
8.Nd MS-DOS partition maintenance program 8.Nd MS-DOS partition maintenance program
9.Sh SYNOPSIS 9.Sh SYNOPSIS
10.Nm 10.Nm
11.Op Fl aBFfiSuv 11.Op Fl aBFfiSuv
12.Bk -words 12.Bk -words
13.Oo 13.Oo
14.Fl 0 | 1 | 2 | 3 | E Ar number 14.Fl 0 | 1 | 2 | 3 | E Ar number
15.Op Fl s Ar id/start/size Ns Bq Ar /bootmenu 15.Op Fl s Ar id/start/size Ns Bq Ar /bootmenu
16.Oc 16.Oc
17.Ek 17.Ek
18.Bk -words 18.Bk -words
19.Op Fl r Ar file | Fl w Ar file 19.Op Fl r Ar file | Fl w Ar file
20.Ek 20.Ek
21.Bk -words 21.Bk -words
22.Op Fl A Ar ptn_alignment Ns Bq Ar /ptn_0_offset 22.Op Fl A Ar ptn_alignment Ns Bq Ar /ptn_0_offset
23.Ek 23.Ek
24.Bk -words 24.Bk -words
25.Op Fl b Ar cylinders/heads/sectors 25.Op Fl b Ar cylinders/heads/sectors
26.Ek 26.Ek
27.Bk -words 27.Bk -words
28.Op Fl c Ar bootcode 28.Op Fl c Ar bootcode
29.Ek 29.Ek
30.Bk -words 30.Bk -words
31.Op Fl T Ar disktype 31.Op Fl T Ar disktype
32.Ek 32.Ek
33.Bk -words 33.Bk -words
34.Op Fl t Ar disktab 34.Op Fl t Ar disktab
35.Ek 35.Ek
36.Bk -words 36.Bk -words
37.Op Ar device 37.Op Ar device
38.Ek 38.Ek
39.Nm 39.Nm
40.Fl l 40.Fl l
41.Sh DESCRIPTION 41.Sh DESCRIPTION
42The 42The
43.Nm 43.Nm
44program is used to display or update the 44program is used to display or update the
45.Em "master boot record" 45.Em "master boot record"
46or 46or
47.Em MBR 47.Em MBR
48in the first sector (sector 0) 48in the first sector (sector 0)
49of a disk that uses the MBR style of partitioning. 49of a disk that uses the MBR style of partitioning.
50The following 50The following
51.Nx 51.Nx
52ports use this style of disk partitioning: 52ports use this style of disk partitioning:
53amd64, arc, bebox, cobalt, hpcarm, hpcmips, hpcsh, i386, macppc, 53amd64, arc, bebox, cobalt, hpcarm, hpcmips, hpcsh, i386, macppc,
54mvmeppc, netwinder, ofppc, and prep. 54mvmeppc, netwinder, ofppc, and prep.
55.Pp 55.Pp
56The MBR contains bootable code, a partition table, 56The MBR contains bootable code, a partition table,
57an indication of which partition is 57an indication of which partition is
58.Sq active , 58.Sq active ,
59and (optionally, depending on the boot code) a menu 59and (optionally, depending on the boot code) a menu
60for selecting a partition to be booted. 60for selecting a partition to be booted.
61There can be at most 4 partitions defined in sector 0, 61There can be at most 4 partitions defined in sector 0,
62one of which can be an extended 62one of which can be an extended
63partition which can be split into any number of sub-partitions. 63partition which can be split into any number of sub-partitions.
64.Pp 64.Pp
65The boot code in the MBR is usually invoked by the BIOS or firmware, 65The boot code in the MBR is usually invoked by the BIOS or firmware,
66and the MBR passes control to the next stage boot code 66and the MBR passes control to the next stage boot code
67stored in the first sector of the partition to be booted 67stored in the first sector of the partition to be booted
68(the 68(the
69.Em "partition boot record" 69.Em "partition boot record"
70or 70or
71.Em PBR ) . 71.Em PBR ) .
72.Pp 72.Pp
73After booting, 73After booting,
74.Nx 74.Nx
75does not use the partitioning done by 75does not use the partitioning done by
76.Nm , 76.Nm ,
77instead it uses a 77instead it uses a
78.Nx 78.Nx
79disklabel saved in sector 1 of the 79disklabel saved in sector 1 of the
80.Nx 80.Nx
81partition. 81partition.
82See 82See
83.Xr mbrlabel 8 83.Xr mbrlabel 8
84for a way of using information from the MBR 84for a way of using information from the MBR
85to construct a 85to construct a
86.Nx 86.Nx
87disklabel. 87disklabel.
88.Pp 88.Pp
89The standard MBR boot code will only boot the 89The standard MBR boot code will only boot the
90.Sq active 90.Sq active
91partition. 91partition.
92However, 92However,
93.Nx 93.Nx
94contains additional boot programs which allow the user to 94contains additional boot programs which allow the user to
95interactively select which of the partitions to boot. 95interactively select which of the partitions to boot.
96The 96The
97.Sq mbr_ext 97.Sq mbr_ext
98code will also boot 98code will also boot
99.Nx 99.Nx
100from an extended partition but will not work on old systems that do not 100from an extended partition but will not work on old systems that do not
101support LBA reads, the 101support LBA reads, the
102.Sq mbr_com0 102.Sq mbr_com0
103and 103and
104.Sq mbr_com0_9600 104.Sq mbr_com0_9600
105will read and write from a serial port. 105will read and write from a serial port.
106At the start the 106At the start the
107.Nm 107.Nm
108program will determine whether the disk sector 0 is valid as a boot sector. 108program will determine whether the disk sector 0 is valid as a boot sector.
109(This is determined by checking the magic number.) 109(This is determined by checking the magic number.)
110If not, 110If not,
111.Nm 111.Nm
112will initialise the boot code as well as the partition table. 112will initialise the boot code as well as the partition table.
113During this, all four partitions will be marked empty. 113During this, all four partitions will be marked empty.
114.Pp 114.Pp
115The flags 115The flags
116.Fl a , 116.Fl a ,
117.Fl i 117.Fl i
118or 118or
119.Fl u 119.Fl u
120are used to indicate that the partition data is to be updated. 120are used to indicate that the partition data is to be updated.
121The 121The
122.Nm 122.Nm
123program will enter an interactive conversational mode. 123program will enter an interactive conversational mode.
124This mode is designed not to change any data unless you explicitly tell it to; 124This mode is designed not to change any data unless you explicitly tell it to;
125.Nm 125.Nm
126selects defaults for its questions to guarantee that behaviour. 126selects defaults for its questions to guarantee that behaviour.
127.Pp 127.Pp
128If partition data is going to be updated and the disk carries GUID Partition 128If partition data is going to be updated and the disk carries GUID Partition
129Tables, 129Tables,
130.Nm 130.Nm
131will remove both primary and backup GPT headers from the disk. 131will remove both primary and backup GPT headers from the disk.
132See 132See
133.Xr gpt 8 133.Xr gpt 8
134for information on how to manipulate GUID Partition Tables. 134for information on how to manipulate GUID Partition Tables.
135.Pp 135.Pp
136.Nm 136.Nm
137will calculate the correct 137will calculate the correct
138.Em cylinder , 138.Em cylinder ,
139.Em head , 139.Em head ,
140and 140and
141.Em sector 141.Em sector
142values for any partition you edit. 142values for any partition you edit.
143If you specify 143If you specify
144.Fl v 144.Fl v
145you will be asked whether you want to specify them yourself. 145you will be asked whether you want to specify them yourself.
146.Pp 146.Pp
147Finally, when all the data for the first sector has been accumulated, 147Finally, when all the data for the first sector has been accumulated,
148.Nm 148.Nm
149will ask if you really want to write the new partition table. 149will ask if you really want to write the new partition table.
150Only if you reply affirmatively to this question will 150Only if you reply affirmatively to this question will
151.Nm 151.Nm
152write anything to the disk. 152write anything to the disk.
153.Pp 153.Pp
154Available options: 154Available options:
155.Pp 155.Pp
156.Bl -tag -width Ds 156.Bl -tag -width Ds
157.It Fl 0 157.It Fl 0
158Specify partition slot 0 to be printed or updated. 158Specify partition slot 0 to be printed or updated.
159.It Fl 1 159.It Fl 1
160Specify partition slot 1 to be printed or updated. 160Specify partition slot 1 to be printed or updated.
161.It Fl 2 161.It Fl 2
162Specify partition slot 2 to be printed or updated. 162Specify partition slot 2 to be printed or updated.
163.It Fl 3 163.It Fl 3
164Specify partition slot 3 to be printed or updated. 164Specify partition slot 3 to be printed or updated.
165.It Fl A Ar ptn_alignment Ns Bq Ar /ptn_0_offset 165.It Fl A Ar ptn_alignment Ns Bq Ar /ptn_0_offset
166Specify the alignment for all partitions and optionally the offset for the 166Specify the alignment for all partitions and optionally the offset for the
167first partition of the disk and of extended partitions. 167first partition of the disk and of extended partitions.
168If 168If
169.Ar ptn_alignment 169.Ar ptn_alignment
170is specified and 170is specified and
171.Ar ptn_0_offset 171.Ar ptn_0_offset
172is not specified, then the offset is set to the alignment. 172is not specified, then the offset is set to the alignment.
173If 173If
174.Fl A 174.Fl A
175isn't specified, then the alignment of the first partition is inspected. 175isn't specified, then the alignment of the first partition is inspected.
176If it ends on a 2048 sector boundary, then the alignment is set to 2048, 176If it ends on a 2048 sector boundary, then the alignment is set to 2048,
177if the start is a power of 2 less than, or equal to 2048 then the offset 177if the start is a power of 2 less than, or equal to 2048 then the offset
178is set to the start sector. 178is set to the start sector.
179If the first partition isn't defined then the alignment and offset for disks 179If the first partition isn't defined then the alignment and offset for disks
180larger than 128GB is set to 2048 (1MB). 180larger than 128GB is set to 2048 (1MB).
181In all other cases the alignment default to a cylinder 181In all other cases the alignment default to a cylinder
182and the offset to a track (both using the BIOS geometry). 182and the offset to a track (both using the BIOS geometry).
183The 1MB alignment is the same as that used by recent windows versions. 183The 1MB alignment is the same as that used by recent windows versions.
184.It Fl a 184.It Fl a
185Change the active partition. 185Change the active partition.
186In interactive mode this question will be asked after the partitions 186In interactive mode this question will be asked after the partitions
187have been processed. 187have been processed.
188.It Fl B 188.It Fl B
189On an i386 or amd64 system, interactively update the boot selector settings. 189On an i386 or amd64 system, interactively update the boot selector settings.
190(The boot selector permits the user to interactively select the boot 190(The boot selector permits the user to interactively select the boot
191partition, and thus which operating system is run, at system boot time; see 191partition, and thus which operating system is run, at system boot time; see
192.Xr mbr 8 192.Xr mbr 8
193for more information.) 193for more information.)
194.It Fl b Ar cylinders/heads/sectors 194.It Fl b Ar cylinders/heads/sectors
195Specify the BIOS geometry parameters for 195Specify the BIOS geometry parameters for
196.Ar cylinders , 196.Ar cylinders ,
197.Ar heads , 197.Ar heads ,
198and 198and
199.Ar sectors . 199.Ar sectors .
200It is used only in conjunction with the 200It is used only in conjunction with the
201.Fl u 201.Fl u
202flag. 202flag.
203If not specified the BIOS geometry will be obtained using sysctl (i386 and 203If not specified the BIOS geometry will be obtained using sysctl (i386 and
204amd64) or by solving the simultaenous equations from the existing partition 204amd64) or by solving the simultaenous equations from the existing partition
205information. 205information.
206If that fails then either the geometry from the disklabel or 63 sectors and 206If that fails then either the geometry from the disklabel or 63 sectors and
20716 heads is used. 20716 heads is used.
208.It Fl c Ar bootcode 208.It Fl c Ar bootcode
209Specify the filename that 209Specify the filename that
210.Nm 210.Nm
211should read the bootcode from. 211should read the bootcode from.
212If the name of a directory is specified, then 212If the name of a directory is specified, then
213.Nm 213.Nm
214will look for files with the default names in that directory. 214will look for files with the default names in that directory.
215The default is to read from 215The default is to read from
216.Pa /usr/mdec/mbr , 216.Pa /usr/mdec/mbr ,
217.Pa /usr/mdec/mbr_bootsel 217.Pa /usr/mdec/mbr_bootsel
218or 218or
219.Pa /usr/mdec/mbr_ext 219.Pa /usr/mdec/mbr_ext
220depending on whether 220depending on whether
221.Ar bootmenu 221.Ar bootmenu
222was specified for any partitions 222was specified for any partitions
223on an i386 machine, and leave the bootcode empty for other 223on an i386 machine, and leave the bootcode empty for other
224machines. 224machines.
225.It Fl E Ar number 225.It Fl E Ar number
226Specify extended partition 226Specify extended partition
227.Ar number 227.Ar number
228to be printed or updated. 228to be printed or updated.
229If the specified extended partition doesn't exist on updating partition data 229If the specified extended partition doesn't exist on updating partition data
230an additional extended partition will be created. 230an additional extended partition will be created.
231.It Fl F 231.It Fl F
232Indicate that 232Indicate that
233.Ar device 233.Ar device
234is a regular file. 234is a regular file.
235Unless the geometry of 235Unless the geometry of
236.Ar device 236.Ar device
237is told to 237is told to
238.Nm 238.Nm
239by 239by
240.Fl T Ar disktype , 240.Fl T Ar disktype ,
241.Nm 241.Nm
242will count the 512-byte sectors in 242will count the 512-byte sectors in
243.Ar device 243.Ar device
244and produce a fake geometry. 244and produce a fake geometry.
245If 245If
246.Ar device 246.Ar device
247is a regular file, 247is a regular file,
248.Fl F 248.Fl F
249will be used implicitly. 249will be used implicitly.
250.It Fl f 250.It Fl f
251Run 251Run
252.Nm 252.Nm
253in a non-interactive mode. 253in a non-interactive mode.
254In this mode, you can only change the disk parameters by using the 254In this mode, you can only change the disk parameters by using the
255.Fl b 255.Fl b
256flag. 256flag.
257This is provided only so scripts or other programs may use 257This is provided only so scripts or other programs may use
258.Nm 258.Nm
259as part of an automatic installation process. 259as part of an automatic installation process.
260.Pp 260.Pp
261Using the 261Using the
262.Fl f 262.Fl f
263flag with 263flag with
264.Fl u 264.Fl u
265makes it impossible to specify the starting and ending 265makes it impossible to specify the starting and ending
266.Ar cylinder , 266.Ar cylinder ,
267.Ar head , 267.Ar head ,
268and 268and
269.Ar sector 269.Ar sector
270fields 270fields
271.Pq only Ar start No and Ar size No can be specified by Fl s No option . 271.Pq only Ar start No and Ar size No can be specified by Fl s No option .
272They will be automatically computed using the BIOS geometry. 272They will be automatically computed using the BIOS geometry.
273.It Fl i 273.It Fl i
274Explicitly request initialisation of the master boot code 274Explicitly request initialisation of the master boot code
275(similar to what 275(similar to what
276.Ic fdisk /mbr 276.Ic fdisk /mbr
277does under 277does under
278.Tn MS-DOS ) , 278.Tn MS-DOS ) ,
279even if the magic number in the first sector is ok. 279even if the magic number in the first sector is ok.
280The partition table is left alone by this (but see above). 280The partition table is left alone by this (but see above).
281.It Fl l 281.It Fl l
282Lists known 282Lists known
283.Em sysid 283.Em sysid
284values and exit. 284values and exit.
285.It Fl r Ar file 285.It Fl r Ar file
286Read the boot record from file 286Read the boot record from file
287.Ar file 287.Ar file
288instead of the specified disk. 288instead of the specified disk.
289The geometry information used is still that of the disk volume. 289The geometry information used is still that of the disk volume.
290Any changes are written back to the file. 290Any changes are written back to the file.
291.It Fl S 291.It Fl S
292When used with no other flags print a series of 292When used with no other flags print a series of
293.Pa /bin/sh 293.Pa /bin/sh
294commands for setting variables to the partition information. 294commands for setting variables to the partition information.
295This could be used by installation scripts. 295This could be used by installation scripts.
296.It Fl s Ar id/start/size Ns Bq Ar /bootmenu 296.It Fl s Ar id/start/size Ns Bq Ar /bootmenu
297Specify the partition 297Specify the partition
298.Ar id , 298.Ar id ,
299.Ar start , 299.Ar start ,
300.Ar size , 300.Ar size ,
301and optionally 301and optionally
302.Ar bootmenu . 302.Ar bootmenu .
303This flag requires the use of a partition selection flag 303This flag requires the use of a partition selection flag
304.Pq Fl 0 , 1 , 2 , 3 , No or Fl E Ar number . 304.Pq Fl 0 , 1 , 2 , 3 , No or Fl E Ar number .
305.It Fl T Ar disktype 305.It Fl T Ar disktype
306Use the disklabel 306Use the disklabel
307.Ar disktype 307.Ar disktype
308instead of the disklabel on 308instead of the disklabel on
309.Ar device . 309.Ar device .
310.It Fl t Ar disktab 310.It Fl t Ar disktab
311Read 311Read
312.Ar disktype 312.Ar disktype
313from the named 313from the named
314.Xr disktab 5 314.Xr disktab 5
315file instead of from 315file instead of from
316.Pa /etc/disktab . 316.Pa /etc/disktab .
317.It Fl u 317.It Fl u
318Update partition data, including 318Update partition data, including
319.Em id , start , No and Em size . 319.Em id , start , No and Em size .
320Unless 320Unless
321.Fl f 321.Fl f
322option 322option
323.Pq non-interactive mode 323.Pq non-interactive mode
324is specified, 324is specified,
325.Nm 325.Nm
326will display the partitions and interactively ask which one you want to edit. 326will display the partitions and interactively ask which one you want to edit.
327.Nm 327.Nm
328will step through each field showing the old value and asking for a new one. 328will step through each field showing the old value and asking for a new one.
329The 329The
330.Em start 330.Em start
331and 331and
332.Em size 332.Em size
333can be specified in blocks (NN), 333can be specified in blocks (NN),
334cylinders (NNc or NNcyl), 334cylinders (NNc or NNcyl),
335megabytes (NNm or NNMB), 335megabytes (NNm or NNMB),
336or gigabytes (NNg or NNGB), values in megabytes and gigabytes 336or gigabytes (NNg or NNGB), values in megabytes and gigabytes
337will be rounded to the nearest cylinder boundary. 337will be rounded to the nearest cylinder boundary.
338The 338The
339.Em size 339.Em size
340may be specified as 340may be specified as
341.Em $ 341.Em $
342in which case the partition will extend to the end of the available free space. 342in which case the partition will extend to the end of the available free space.
343.Pp 343.Pp
344In a non-interactive mode 344In a non-interactive mode
345.Pq specified by Fl f No option , 345.Pq specified by Fl f No option ,
346partition data should be specified by 346partition data should be specified by
347.Fl s 347.Fl s
348option. 348option.
349A partition selection option 349A partition selection option
350.Pq Fl 0 , 1 , 2 , 3 , No or Fl E Ar number 350.Pq Fl 0 , 1 , 2 , 3 , No or Fl E Ar number
351should also be specified to select a partition slot to be updated. 351should also be specified to select a partition slot to be updated.
352.Pp 352.Pp
353.Nm 353.Nm
354will not allow you to create partitions which overlap. 354will not allow you to create partitions which overlap.
355If 355If
356.Fl u 356.Fl u
357and 357and
358.Fl s 358.Fl s
359are specified in a non-interactive mode 359are specified in a non-interactive mode
360then the details of the specified partition will be changed. 360then the details of the specified partition will be changed.
361Any other partitions which overlap the requested part of the disk will be 361Any other partitions which overlap the requested part of the disk will be
362silently deleted. 362silently deleted.
363.Pp 363.Pp
364If 364If
365.Em bootmenu 365.Em bootmenu
366is specified for any partition 366is specified for any partition
367.Nm 367.Nm
368will determine whether the installed boot code supports the bootselect code, 368will determine whether the installed boot code supports the bootselect code,
369if it doesn't you will be asked whether you want to install the required 369if it doesn't you will be asked whether you want to install the required
370boot code. 370boot code.
371To remove a 371To remove a
372.Em bootmenu 372.Em bootmenu
373label, simply press 373label, simply press
374.Aq space 374.Aq space
375followed by 375followed by
376.Aq return . 376.Aq return .
377.It Fl v 377.It Fl v
378Be more verbose, specifying 378Be more verbose, specifying
379.Fl v 379.Fl v
380more than once may increase the amount of output. 380more than once may increase the amount of output.
381.Pp 381.Pp
382Using 382Using
383.Fl v 383.Fl v
384with 384with
385.Fl u 385.Fl u
386allows the user to change more parameters than normally permitted. 386allows the user to change more parameters than normally permitted.
387.It Fl w Ar file 387.It Fl w Ar file
388Write the modified partition table to file 388Write the modified partition table to file
389.Ar file 389.Ar file
390instead of the disk. 390instead of the disk.
391.El 391.El
392.Pp 392.Pp
393When called with no arguments, it prints the partition table. 393When called with no arguments, it prints the partition table.
394An example follows: 394An example follows:
395.Bd -literal 395.Bd -literal
396 Disk: /dev/rwd0d 396 Disk: /dev/rwd0d
397 NetBSD disklabel disk geometry: 397 NetBSD disklabel disk geometry:
398 cylinders: 16383, heads: 16, sectors/track: 63 (1008 sectors/cylinder) 398 cylinders: 16383, heads: 16, sectors/track: 63 (1008 sectors/cylinder)
399 total sectors: 40032696 399 total sectors: 40032696
400 400
401 BIOS disk geometry: 401 BIOS disk geometry:
402 cylinders: 1023, heads: 255, sectors/track: 63 (16065 sectors/cylinder) 402 cylinders: 1023, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
403 total sectors: 40032696 403 total sectors: 40032696
404 404
405 Partition table: 405 Partition table:
406 0: NetBSD (sysid 169) 406 0: NetBSD (sysid 169)
407 bootmenu: net 1.5. 407 bootmenu: net 1.5.
408 start 4209030, size 8289540 (4048 MB, Cyls 262-778), Active 408 start 4209030, size 8289540 (4048 MB, Cyls 262-778), Active
409 1: Primary DOS with 32 bit FAT (sysid 11) 409 1: Primary DOS with 32 bit FAT (sysid 11)
410 bootmenu: win98 410 bootmenu: win98
411 start 63, size 4208967 (2055 MB, Cyls 0-262) 411 start 63, size 4208967 (2055 MB, Cyls 0-262)
412 2: NetBSD (sysid 169) 412 2: NetBSD (sysid 169)
413 bootmenu: current 413 bootmenu: current
414 start 32515560, size 7517136 (3670 MB, Cyls 2024-2491/234/40) 414 start 32515560, size 7517136 (3670 MB, Cyls 2024-2491/234/40)
415 3: Ext. partition - LBA (sysid 15) 415 3: Ext. partition - LBA (sysid 15)
416 start 12498570, size 20016990 (9774 MB, Cyls 778-2024) 416 start 12498570, size 20016990 (9774 MB, Cyls 778-2024)
417 Extended partition table: 417 Extended partition table:
418 E0: NetBSD (sysid 169) 418 E0: NetBSD (sysid 169)
419 bootmenu: test 419 bootmenu: test
420 start 12498633, size 12305727 (6009 MB, Cyls 778-1544) 420 start 12498633, size 12305727 (6009 MB, Cyls 778-1544)
421 E1: Primary DOS with 32 bit FAT (sysid 11) 421 E1: Primary DOS with 32 bit FAT (sysid 11)
422 start 24804423, size 4096512 (2000 MB, Cyls 1544-1799) 422 start 24804423, size 4096512 (2000 MB, Cyls 1544-1799)
423 E2: Primary DOS with 32 bit FAT (sysid 11) 423 E2: Primary DOS with 32 bit FAT (sysid 11)
424 start 28900998, size 3614562 (1765 MB, Cyls 1799-2024) 424 start 28900998, size 3614562 (1765 MB, Cyls 1799-2024)
425 Bootselector enabled, infinite timeout. 425 Bootselector enabled, infinite timeout.
426 First active partition: 0 426 First active partition: 0
427.Ed 427.Ed
428.Pp 428.Pp
429This example disk is divided into four partitions, the last of which is 429This example disk is divided into four partitions, the last of which is
430an extended partition. 430an extended partition.
431The sub-partitions of the extended partition are also shown. 431The sub-partitions of the extended partition are also shown.
432In this case there is no free space in either the disk or in the extended 432In this case there is no free space in either the disk or in the extended
433partition. 433partition.
434.Pp 434.Pp
435The various fields in each partition entry are: 435The various fields in each partition entry are:
436.br 436.br
437.in +4 437.in +4
438.Em ptn_number : id_name 438.Em ptn_number : id_name
439(sysid 439(sysid
440.Em id_number ) 440.Em id_number )
441.br 441.br
442.in +4 442.in +4
443bootmenu: 443bootmenu:
444.Em bootmenu 444.Em bootmenu
445.br 445.br
446start 446start
447.Em start , 447.Em start ,
448size 448size
449.Em size ( MB 449.Em size ( MB
450MB, Cyls 450MB, Cyls
451.Em first Ns No - Ns Em next ) 451.Em first Ns No - Ns Em next )
452.Op , Active 452.Op , Active
453.in -4 453.in -4
454.in -4 454.in -4
455.Bl -tag -width "bootmenu" 455.Bl -tag -width "bootmenu"
456.It Em ptn_number 456.It Em ptn_number
457is the number of the partition. 457is the number of the partition.
458.It Em id_name 458.It Em id_name
459is the name of the filesystem type or operating system that uses this partition. 459is the name of the filesystem type or operating system that uses this partition.
460.It Em id_number 460.It Em id_number
461is the number that identifies the partition type. 461is the number that identifies the partition type.
462169 decimal is used for 462169 decimal is used for
463.Nx 463.Nx
464partitions, 464partitions,
46515 decimal to create an extended partition 46515 decimal to create an extended partition
466and 0 to mark a partition as unused. 466and 0 to mark a partition as unused.
467Use 467Use
468.Nm 468.Nm
469.Fl l 469.Fl l
470to list the known partition types. 470to list the known partition types.
471.It Em bootmenu 471.It Em bootmenu
472is the menu prompt output by the interactive boot code for this partition. 472is the menu prompt output by the interactive boot code for this partition.
473This line is omitted if the prompt is not defined. 473This line is omitted if the prompt is not defined.
474.It Em start , Em size 474.It Em start , Em size
475are the start address and size of the partition in sectors. 475are the start address and size of the partition in sectors.
476.It Em MB 476.It Em MB
477is the size of the partition in megabytes. 477is the size of the partition in megabytes.
478.It Em first , Em next 478.It Em first , Em next
479are the bounds of this partition displayed as cylinder/head/sector. 479are the bounds of this partition displayed as cylinder/head/sector.
480If the partition starts (or ends) on a cylinder boundary the head and 480If the partition starts (or ends) on a cylinder boundary the head and
481sector values are omitted. 481sector values are omitted.
482If 482If
483.Fl v 483.Fl v
484is not specified the start of extended partitions and the first partition 484is not specified the start of extended partitions and the first partition
485on the disk are rounded down to include the mandatory red tape in the 485on the disk are rounded down to include the mandatory red tape in the
486preceding track. 486preceding track.
487.It Active 487.It Active
488is output if this is the active partition. 488is output if this is the active partition.
489.El 489.El
490.Pp 490.Pp
491If the 491If the
492.Fl v 492.Fl v
493flag is specified, the beginning and end of each partition are also 493flag is specified, the beginning and end of each partition are also
494displayed as follows: 494displayed as follows:
495.in +4 495.in +4
496beg: cylinder 496beg: cylinder
497.Em cylinder , 497.Em cylinder ,
498head 498head
499.Em head , 499.Em head ,
500sector 500sector
501.Em sector 501.Em sector
502.br 502.br
503end: cylinder 503end: cylinder
504.Em cylinder , 504.Em cylinder ,
505head 505head
506.Em head , 506.Em head ,
507sector 507sector
508.Em sector 508.Em sector
509.in -4 509.in -4
510.Bl -tag -width "bootmenu" 510.Bl -tag -width "bootmenu"
511.It Em "cylinder" , Em "head" , Em "sector" 511.It Em "cylinder" , Em "head" , Em "sector"
512are the beginning or ending address of a partition. 512are the beginning or ending address of a partition.
513.Pp 513.Pp
514.Em "Note:" 514.Em "Note:"
515these numbers are read from the bootblock, so are the values calculated 515these numbers are read from the bootblock, so are the values calculated
516by a previous run of 516by a previous run of
517.Nm . 517.Nm .
518.El 518.El
519.Pp 519.Pp
520.Nm 520.Nm
521attempts to check whether each partition is bootable, 521attempts to check whether each partition is bootable,
522by checking the magic number and some other characteristics 522by checking the magic number and some other characteristics
523of the first sector of each partition (the PBR). 523of the first sector of each partition (the PBR).
524If the partition does not appear to be bootable, 524If the partition does not appear to be bootable,
525.Nm 525.Nm
526will print a line containing 526will print a line containing
527.Dq "PBR is not bootable" 527.Dq "PBR is not bootable"
528followed by an error message. 528followed by an error message.
529If the partition is bootable, and if the 529If the partition is bootable, and if the
530.Fl v 530.Fl v
531flag is specified, 531flag is specified,
532.Nm 532.Nm
533will print 533will print
534.Dq "PBR appears to be bootable" . 534.Dq "PBR appears to be bootable" .
535If the 535If the
536.Fl v 536.Fl v
537flag is specified more than once, 537flag is specified more than once,
538.Nm 538.Nm
539will print the heading 539will print the heading
540.Dq "Information from PBR:" 540.Dq "Information from PBR:"
541followed by one or more lines of information gleaned from the PBR; 541followed by one or more lines of information gleaned from the PBR;
542this additional information may be incorrect or misleading, 542this additional information may be incorrect or misleading,
543because different operating systems use different PBR formats. 543because different operating systems use different PBR formats.
544Note that, even if no errors are reported, an attempt to boot 544Note that, even if no errors are reported, an attempt to boot
545from the partition might fail. 545from the partition might fail.
546.Nx 546.Nx
547partitions may be made bootable using 547partitions may be made bootable using
548.Xr installboot 8 . 548.Xr installboot 8 .
549.Sh NOTES 549.Sh NOTES
550This program is only available (and useful) on systems with PC-platform-style 550This program is only available (and useful) on systems with PC-platform-style
551MBR partitioning. 551MBR partitioning.
552.Pp 552.Pp
553Traditionally the partition boundaries should be on cylinder boundaries 553Traditionally the partition boundaries should be on cylinder boundaries
554using the BIOS geometry, with the exception of the first partition, 554using the BIOS geometry, with the exception of the first partition,
555which traditionally begins in the second track of the first cylinder 555which traditionally begins in the second track of the first cylinder
556(cylinder 0, head 1, sector 1). 556(cylinder 0, head 1, sector 1).
557Although the BIOS geometry is typically different from the geometry 557Although the BIOS geometry is typically different from the geometry
558reported by the drive, neither will match the actual physical geometry 558reported by the drive, neither will match the actual physical geometry
559for modern disks (the actual geometry will vary across the disk). 559for modern disks (the actual geometry will vary across the disk).
560Keeping the partition boundaries on cylinder boundaries makes partitioning 560Keeping the partition boundaries on cylinder boundaries makes partitioning
561a driver easier as only relatively small numbers need be entered. 561a driver easier as only relatively small numbers need be entered.
562.Pp 562.Pp
563The automatic calculation of the starting cylinder and 563The automatic calculation of the starting cylinder and
564other parameters uses 564other parameters uses
565a set of figures that represent what the BIOS thinks is the 565a set of figures that represent what the BIOS thinks is the
566geometry of the drive. 566geometry of the drive.
567The default values should be correct for the system on which 567The default values should be correct for the system on which
568.Nm 568.Nm
569is run; however, if you move the disk to a different system, the 569is run; however, if you move the disk to a different system, the
570BIOS of that system might use a different geometry translation. 570BIOS of that system might use a different geometry translation.
571.Pp 571.Pp
572If you run the equivalent of 572If you run the equivalent of
573.Nm 573.Nm
574on a different operating system then the 574on a different operating system then the
575.Ar bootmenu 575.Ar bootmenu
576strings associated with extended partitions may be lost. 576strings associated with extended partitions may be lost.
577.Pp 577.Pp
578Editing an existing partition is risky, and may cause you to 578Editing an existing partition is risky, and may cause you to
579lose all the data in that partition. 579lose all the data in that partition.
580.Pp 580.Pp
581You should run this program interactively once or twice to see how it works. 581You should run this program interactively once or twice to see how it works.
582This is completely safe as long as you answer the last question in the negative. 582This is completely safe as long as you answer the last question in the negative.
583You can also specify 583You can also specify
584.Fl w Ar file 584.Fl w Ar file
585to write the output to a file and later specify 585to write the output to a file and later specify
586.Fl r Ar file 586.Fl r Ar file
587to read back the updated information. 587to read back the updated information.
588This can be done without having write access to the disk volume. 588This can be done without having write access to the disk volume.
589.Sh FILES 589.Sh FILES
590.Bl -tag -width /usr/mdec/mbrxxxxxxxx -compact 590.Bl -tag -width /usr/mdec/mbrxxxxxxxx -compact
591.It Pa /usr/mdec/mbr 591.It Pa /usr/mdec/mbr
592Default location of i386 bootcode 592Default location of i386 bootcode
593.It Pa /usr/mdec/mbr_bootsel 593.It Pa /usr/mdec/mbr_bootsel
594Default location of i386 bootselect code 594Default location of i386 bootselect code
595.It Pa /usr/mdec/mbr_ext 595.It Pa /usr/mdec/mbr_ext
596Default location of i386 bootselect for extended partitions 596Default location of i386 bootselect for extended partitions
597.El 597.El
598.Sh EXAMPLES 598.Sh EXAMPLES
599Update MBR partition data of 599Update MBR partition data of
600.Pa /dev/rwd0d 600.Pa /dev/rwd0d
601in interactive mode: 601in interactive mode:
602.Pp 602.Pp
603.Dl Ic fdisk -u /dev/rwd0d 603.Dl Ic fdisk -u /dev/rwd0d
604.Pp 604.Pp
605Change active MBR partition of 605Change active MBR partition of
606.Pa /dev/rwd0d 606.Pa /dev/rwd0d
607in interactive mode: 607in interactive mode:
608.Pp 608.Pp
609.Dl Ic fdisk -a /dev/rwd0d 609.Dl Ic fdisk -a /dev/rwd0d
610.Pp 610.Pp
611Install MBR bootcode 611Install MBR bootcode
612.Pa /usr/mdec/mbr_bootsel 612.Pa /usr/mdec/mbr_bootsel
613into 613into
614.Pa /dev/rwd0d : 614.Pa /dev/rwd0d :
615.Pp 615.Pp
616.Dl Ic fdisk -c /usr/mdec/mbr_bootsel /dev/rwd0d 616.Dl Ic fdisk -c /usr/mdec/mbr_bootsel /dev/rwd0d
617.Pp 617.Pp
618Set MBR partition data for slot 0 of 618Set MBR partition data for slot 0 of
619.Pa /dev/rwd0d 619.Pa /dev/rwd0d
620specifying values without prompt: 620specifying values without prompt:
621.Pp 621.Pp
622.Dl Ic fdisk -f -u -0 -s 169/63/2097089 /dev/rwd0d 622.Dl Ic fdisk -f -u -0 -s 169/63/2097089 /dev/rwd0d
623.Pp 623.Pp
624Make partition slot 0 of 624Make partition slot 0 of
625.Pa /dev/rwd0d 625.Pa /dev/rwd0d
626active without prompt: 626active without prompt:
627.Pp 627.Pp
628.Dl Ic fdisk -f -a -0 /dev/rwd0d 628.Dl Ic fdisk -f -a -0 /dev/rwd0d
629.Pp 629.Pp
630Initialize and create MBR partition data using bootcode 630Initialize and create MBR partition data using bootcode
631.Pa destdir/usr/mdec/mbr 631.Pa destdir/usr/mdec/mbr
632without prompt against 1GB disk image file 632without prompt against 1GB disk image file
633.Pa diskimg : 633.Pa diskimg :
634.Pp 634.Pp
635.Dl Ic fdisk -f -i -b 130/255/63 -c destdir/usr/mdec/mbr -F diskimg 635.Dl Ic fdisk -f -i -b 130/255/63 -c destdir/usr/mdec/mbr -F diskimg
636.Pp 636.Pp
637Create MBR partition data for slot 0 which has an active NetBSD partition 637Create MBR partition data for slot 0 which has an active
638using whole disk without prompt against 1GB disk image file 638.Nx
 639partition using whole disk without prompt against 1GB disk image file
639.Pa diskimg : 640.Pa diskimg :
640.Pp 641.Pp
641.Dl Ic fdisk -f -a -u -0 -s 169/63/2097089 -F diskimg 642.Dl Ic fdisk -f -a -u -0 -s 169/63/2097089 -F diskimg
642.Sh SEE ALSO 643.Sh SEE ALSO
643.Xr disktab 5 , 644.Xr disktab 5 ,
644.Xr boot 8 , 645.Xr boot 8 ,
645.Xr disklabel 8 , 646.Xr disklabel 8 ,
646.Xr gpt 8 , 647.Xr gpt 8 ,
647.Xr installboot 8 , 648.Xr installboot 8 ,
648.Xr mbr 8 , 649.Xr mbr 8 ,
649.Xr mbrlabel 8 650.Xr mbrlabel 8
650.Sh BUGS 651.Sh BUGS
651The word 652The word
652.Sq partition 653.Sq partition
653is used to mean both an MBR partition and a 654is used to mean both an MBR partition and a
654.Nx 655.Nx
655partition, sometimes in the same sentence. 656partition, sometimes in the same sentence.
656.Pp 657.Pp
657There are subtleties that the program detects that are not explained in 658There are subtleties that the program detects that are not explained in
658this manual page. 659this manual page.