1CFDISK(8) Linux Programmer's Manual CFDISK(8)
2
3
4
6 cfdisk - Curses based disk partition table manipulator for Linux
7
9 cfdisk [-agvz] [-c cylinders] [-h heads] [-s sectors-per-track] [-P
10 opt] [device]
11
13 cfdisk is a curses based program for partitioning any hard disk drive.
14 Typical values of the device argument are:
15
16 /dev/hda [default]
17 /dev/hdb
18 /dev/sda
19 /dev/sdb
20 /dev/sdc
21 /dev/sdd
22
23 In order to write the partition table cfdisk needs something called the
24 `geometry' of the disk: the number of `heads' and the number of `sec‐
25 tors per track'. Linux does not use any geometry, so if the disk will
26 not be accessed by other operating systems, you can safely accept the
27 defaults that cfdisk chooses for you. The geometry used by cfdisk is
28 found as follows. First the partition table is examined, to see what
29 geometry was used by the previous program that changed it. If the par‐
30 tition table is empty, or contains garbage, or does not point at a con‐
31 sistent geometry, the kernel is asked for advice. If nothing works 255
32 heads and 63 sectors/track is assumed. The geometry can be overridden
33 on the command line or by use of the `g' command. When partitioning an
34 empty large modern disk, picking 255 heads and 63 sectors/track is
35 always a good idea. There is no need to set the number of cylinders,
36 since cfdisk knows the disk size.
37
38 Next, cfdisk tries to read the current partition table from the disk
39 drive. If it is unable to figure out the partition table, an error is
40 displayed and the program will exit. This might also be caused by
41 incorrect geometry information, and can be overridden on the command
42 line. Another way around this problem is with the -z option. This
43 will ignore the partition table on the disk.
44
45 The main display is composed of four sections, from top to bottom: the
46 header, the partitions, the command line and a warning line. The
47 header contains the program name and version number followed by the
48 disk drive and its geometry. The partitions section always displays
49 the current partition table. The command line is the place where com‐
50 mands and text are entered. The available commands are usually dis‐
51 played in brackets. The warning line is usually empty except when
52 there is important information to be displayed. The current partition
53 is highlighted with reverse video (or an arrow if the -a option is
54 given). All partition specific commands apply to the current parti‐
55 tion.
56
57 The format of the partition table in the partitions section is, from
58 left to right: Name, Flags, Partition Type, Filesystem Type and Size.
59 The name is the partition device name. The flags can be Boot, which
60 designates a bootable partition or NC, which stands for "Not Compatible
61 with DOS or OS/2". DOS, OS/2 and possibly other operating systems
62 require the first sector of the first partition on the disk and all
63 logical partitions to begin on the second head. This wastes the second
64 through the last sector of the first track of the first head (the first
65 sector is taken by the partition table itself). cfdisk allows you to
66 recover these "lost" sectors with the maximize command (m). Note:
67 fdisk(8) and some early versions of DOS create all partitions with the
68 number of sectors already maximized. For more information, see the
69 maximize command below. The partition type can be one of Primary or
70 Logical. For unallocated space on the drive, the partition type can
71 also be Pri/Log, or empty (if the space is unusable). The filesystem
72 type section displays the name of the filesystem used on the partition,
73 if known. If it is unknown, then Unknown and the hex value of the
74 filesystem type are displayed. A special case occurs when there are
75 sections of the disk drive that cannot be used (because all of the pri‐
76 mary partitions are used). When this is detected, the filesystem type
77 is displayed as Unusable. The size field displays the size of the par‐
78 tition in megabytes (by default). It can also display the size in sec‐
79 tors and cylinders (see the change units command below). If an aster‐
80 isk (*) appears after the size, this means that the partition is not
81 aligned on cylinder boundaries.
82
84 The DOS 6.x FORMAT command looks for some information in the first sec‐
85 tor of the data area of the partition, and treats this information as
86 more reliable than the information in the partition table. DOS FORMAT
87 expects DOS FDISK to clear the first 512 bytes of the data area of a
88 partition whenever a size change occurs. DOS FORMAT will look at this
89 extra information even if the /U flag is given -- we consider this a
90 bug in DOS FORMAT and DOS FDISK.
91
92 The bottom line is that if you use cfdisk or fdisk to change the size
93 of a DOS partition table entry, then you must also use dd to zero the
94 first 512 bytes of that partition before using DOS FORMAT to format the
95 partition. For example, if you were using cfdisk to make a DOS parti‐
96 tion table entry for /dev/hda1, then (after exiting fdisk or cfdisk and
97 rebooting Linux so that the partition table information is valid) you
98 would use the command "dd if=/dev/zero of=/dev/hda1 bs=512 count=1" to
99 zero the first 512 bytes of the partition. Note:
100
101 BE EXTREMELY CAREFUL if you use the dd command, since a small typo can
102 make all of the data on your disk useless.
103
104 For best results, you should always use an OS-specific partition table
105 program. For example, you should make DOS partitions with the DOS
106 FDISK program and Linux partitions with the Linux fdisk or Linux cfdisk
107 program.
108
109
111 cfdisk commands can be entered by pressing the desired key (pressing
112 Enter after the command is not necessary). Here is a list of the
113 available commands:
114
115 b Toggle bootable flag of the current partition. This allows you
116 to select which primary partition is bootable on the drive.
117
118 d Delete the current partition. This will convert the current
119 partition into free space and merge it with any free space imme‐
120 diately surrounding the current partition. A partition already
121 marked as free space or marked as unusable cannot be deleted.
122
123 g Change the disk geometry (cylinders, heads, or sectors-per-
124 track). WARNING: This option should only be used by people who
125 know what they are doing. A command line option is also avail‐
126 able to change the disk geometry. While at the change disk
127 geometry command line, you can choose to change cylinders (c),
128 heads (h), and sectors per track (s). The default value will be
129 printed at the prompt which you can accept by simply pressing
130 the Enter key, or you can exit without changes by pressing the
131 ESC key. If you want to change the default value, simply enter
132 the desired value and press Enter. The altered disk parameter
133 values do not take effect until you return to the main menu (by
134 pressing Enter or ESC at the change disk geometry command line).
135 If you change the geometry such that the disk appears larger,
136 the extra sectors are added at the end of the disk as free
137 space. If the disk appears smaller, the partitions that are
138 beyond the new last sector are deleted and the last partition on
139 the drive (or the free space at the end of the drive) is made to
140 end at the new last sector.
141
142 h Print the help screen.
143
144 m Maximize disk usage of the current partition. This command will
145 recover the unused space between the partition table and the
146 beginning of the partition, but at the cost of making the parti‐
147 tion incompatible with DOS, OS/2 and possibly other operating
148 systems. This option will toggle between maximal disk usage and
149 DOS, OS/2, etc. compatible disk usage. The default when creat‐
150 ing a partition is to create DOS, OS/2, etc. compatible parti‐
151 tions.
152
153 n Create new partition from free space. If the partition type is
154 Primary or Logical, a partition of that type will be created,
155 but if the partition type is Pri/Log, you will be prompted for
156 the type you want to create. Be aware that (1) there are only
157 four slots available for primary partitions and (2) since there
158 can be only one extended partition, which contains all of the
159 logical drives, all of the logical drives must be contiguous
160 (with no intervening primary partition). cfdisk next prompts
161 you for the size of the partition you want to create. The
162 default size, equal to the entire free space of the current par‐
163 tition, is displayed in megabytes. You can either press the
164 Enter key to accept the default size or enter a different size
165 at the prompt. cfdisk accepts size entries in megabytes (M)
166 [default], kilobytes (K), cylinders (C) and sectors (S) by
167 entering the number immediately followed by one of (M, K, C or
168 S). If the partition fills the free space available, the parti‐
169 tion is created and you are returned to the main command line.
170 Otherwise, the partition can be created at the beginning or the
171 end of the free space, and cfdisk will ask you to choose where
172 to place the partition. After the partition is created, cfdisk
173 automatically adjusts the other partitions' partition types if
174 all of the primary partitions are used.
175
176 p Print the partition table to the screen or to a file. There are
177 several different formats for the partition that you can choose
178 from:
179
180
181 r Raw data format (exactly what would be written to disk)
182
183 s Partition table in sector order format
184
185 t Partition table in raw format
186
187 The raw data format will print the sectors that would be written
188 to disk if a write command is selected. First, the primary par‐
189 tition table is printed, followed by the partition tables asso‐
190 ciated with each logical partition. The data is printed in hex
191 byte by byte with 16 bytes per line.
192
193 The partition table in sector order format will print the parti‐
194 tion table ordered by sector number. The fields, from left to
195 right, are the number of the partition, the partition type, the
196 first sector, the last sector, the offset from the first sector
197 of the partition to the start of the data, the length of the
198 partition, the filesystem type (with the hex value in parenthe‐
199 sis), and the flags (with the hex value in parenthesis). In
200 addition to the primary and logical partitions, free and unus‐
201 able space is printed and the extended partition is printed
202 before the first logical partition.
203
204 If a partition does not start or end on a cylinder boundary or
205 if the partition length is not divisible by the cylinder size,
206 an asterisk (*) is printed after the non-aligned sector num‐
207 ber/count. This usually indicates that a partition was created
208 by an operating system that either does not align partitions to
209 cylinder boundaries or that used different disk geometry infor‐
210 mation. If you know the disk geometry of the other operating
211 system, you could enter the geometry information with the change
212 geometry command (g).
213
214 For the first partition on the disk and for all logical parti‐
215 tions, if the offset from the beginning of the partition is not
216 equal to the number of sectors per track (i.e., the data does
217 not start on the first head), a number sign (#) is printed after
218 the offset. For the remaining partitions, if the offset is not
219 zero, a number sign will be printed after the offset. This cor‐
220 responds to the NC flag in the partitions section of the main
221 display.
222
223 The partition table in raw format will print the partition table
224 ordered by partition number. It will leave out all free and
225 unusable space. The fields, from left to right, are the number
226 of the partition, the flags (in hex), the starting head, sector
227 and cylinder, the filesystem ID (in hex), the ending head, sec‐
228 tor and cylinder, the starting sector in the partition and the
229 number of sectors in the partition. The information in this ta‐
230 ble can be directly translated to the raw data format.
231
232 The partition table entries only have 10 bits available to rep‐
233 resent the starting and ending cylinders. Thus, when the abso‐
234 lute starting (ending) sector number is on a cylinder greater
235 than 1023, the maximal values for starting (ending) head, sector
236 and cylinder are printed. This is the method used by OS/2, and
237 thus fixes the problems associated with OS/2's fdisk rewriting
238 the partition table when it is not in this format. Since Linux
239 and OS/2 use absolute sector counts, the values in the starting
240 and ending head, sector and cylinder are not used.
241
242 q Quit program. This will exit the program without writing any
243 data to disk.
244
245 t Change the filesystem type. By default, new partitions are cre‐
246 ated as Linux partitions, but since cfdisk can create partitions
247 for other operating systems, change partition type allows you to
248 enter the hex value of the filesystem you desire. A list of the
249 know filesystem types is displayed. You can type in the
250 filesystem type at the prompt or accept the default filesystem
251 type [Linux].
252
253 u Change units of the partition size display. It will rotate
254 through megabytes, sectors and cylinders.
255
256 W Write partition table to disk (must enter an upper case W).
257 Since this might destroy data on the disk, you must either con‐
258 firm or deny the write by entering `yes' or `no'. If you enter
259 `yes', cfdisk will write the partition table to disk and the
260 tell the kernel to re-read the partition table from the disk.
261 The re-reading of the partition table does not work in some
262 cases, for example for device-mapper devices. In particular
263 case you need to inform kernel about new partitions by part‐
264 probe(8), kpartx(8) or reboot the system.
265
266 Up Arrow
267
268 Down Arrow
269 Move cursor to the previous or next partition. If there are
270 more partitions than can be displayed on a screen, you can dis‐
271 play the next (previous) set of partitions by moving down (up)
272 at the last (first) partition displayed on the screen.
273
274 CTRL-L Redraws the screen. In case something goes wrong and you cannot
275 read anything, you can refresh the screen from the main command
276 line.
277
278 ? Print the help screen.
279
280 All of the commands can be entered with either upper or lower case let‐
281 ters (except for Writes). When in a sub-menu or at a prompt to enter a
282 filename, you can hit the ESC key to return to the main command line.
283
285 -a Use an arrow cursor instead of reverse video for highlighting
286 the current partition.
287
288 -g Do not use the geometry given by the disk driver, but try to
289 guess a geometry from the partition table.
290
291 -v Print the version number and copyright.
292
293 -z Start with zeroed partition table. This option is useful when
294 you want to repartition your entire disk. Note: this option
295 does not zero the partition table on the disk; rather, it simply
296 starts the program without reading the existing partition table.
297
298 -c cylinders
299
300 -h heads
301
302 -s sectors-per-track
303 Override the number of cylinders, heads and sectors per track
304 read from the BIOS. If your BIOS or adapter does not supply
305 this information or if it supplies incorrect information, use
306 these options to set the disk geometry values.
307
308 -P opt Prints the partition table in specified formats. opt can be one
309 or more of "r", "s" or "t". See the print command (above) for
310 more information on the print formats.
311
313 0: No errors; 1: Invocation error; 2: I/O error; 3: cannot get geome‐
314 try; 4: bad partition table on disk.
315
317 fdisk(8), sfdisk(8), mkfs(8), parted(8), partprobe(8), kpartx(8)
318
320 The current version does not support multiple disks.
321
323 Kevin E. Martin (martin@cs.unc.edu)
324
325
327 The cfdisk command is part of the util-linux-ng package and is avail‐
328 able from ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/.
329
330
331
332The BOGUS Linux Release 3 June 1995 CFDISK(8)