]>
Commit | Line | Data |
---|---|---|
5aac7429 KZ |
1 | .\" sfdisk.8 -- man page for sfdisk |
2 | .\" Copyright (C) 2014 Karel Zak <kzak@redhat.com> | |
fd6b7a7f | 3 | .\" |
5aac7429 KZ |
4 | .\" Permission is granted to make and distribute verbatim copies of this |
5 | .\" manual provided the copyright notice and this permission notice are | |
6 | .\" preserved on all copies. | |
7 | .\" | |
8 | .\" Permission is granted to copy and distribute modified versions of this | |
9 | .\" manual under the conditions for verbatim copying, provided that the | |
10 | .\" entire resulting derived work is distributed under the terms of a | |
11 | .\" permission notice identical to this one. | |
12 | .\" | |
7f576918 | 13 | .TH SFDISK 8 "June 2015" "util-linux" "System Administration" |
fd6b7a7f | 14 | .SH NAME |
5aac7429 | 15 | sfdisk \- display or manipulate a disk partition table |
fd6b7a7f | 16 | .SH SYNOPSIS |
b61dfcf5 | 17 | .B sfdisk |
f49ccec2 BS |
18 | [options] |
19 | .I device | |
20 | .RB [ \-N | |
21 | .IR partition-number ] | |
5aac7429 KZ |
22 | .sp |
23 | .B sfdisk | |
f49ccec2 BS |
24 | [options] |
25 | .I command | |
fd6b7a7f KZ |
26 | .SH DESCRIPTION |
27 | .B sfdisk | |
689d83de | 28 | is a script-oriented tool for partitioning any block device. |
fd6b7a7f | 29 | |
d5206b96 | 30 | Since version 2.26 |
5dbff4c0 | 31 | .B sfdisk |
5aac7429 KZ |
32 | supports MBR (DOS), GPT, SUN and SGI disk labels, but no longer provides any |
33 | functionality for CHS (Cylinder-Head-Sector) addressing. CHS has | |
34 | never been important for Linux, and this addressing concept does not make any | |
35 | sense for new devices. | |
689d83de | 36 | .sp |
b69719b6 | 37 | .B sfdisk |
7f576918 | 38 | (since version 2.26) aligns the start and end of partitions to |
689d83de BS |
39 | block-device I/O limits when relative sizes are specified, or when the |
40 | default values are used. | |
41 | .sp | |
a8a4887b | 42 | .B sfdisk |
689d83de BS |
43 | does not create the standard system partitions for SGI and SUN disk labels like |
44 | .BR fdisk (8) | |
45 | does. | |
a8a4887b KZ |
46 | It is necessary to explicitly create all partitions including whole-disk system |
47 | partitions. | |
48 | ||
5aac7429 KZ |
49 | .SH COMMANDS |
50 | The commands are mutually exclusive. | |
fd6b7a7f | 51 | .TP |
f49ccec2 | 52 | .RB [ \-N " \fIpartition-number\fR] " \fIdevice\fR |
689d83de | 53 | The default \fBsfdisk\fR command is to read the specification for the desired |
5aac7429 | 54 | partitioning of \fIdevice\fR from standard input, and then create a partition |
689d83de BS |
55 | table according to the specification. See below for the description of the |
56 | input format. If standard input is a terminal, then \fBsfdisk\fR starts an | |
57 | interactive session. | |
58 | .sp | |
59 | If the option \fB\-N\fR is specified, then the changes are applied to | |
7f576918 | 60 | the partition addressed by \fIpartition-number\fR. The unspecified fields |
d754d554 KZ |
61 | of the partition are not modified. |
62 | .sp | |
7f576918 BS |
63 | Note that it's possible to address an unused partition with \fB\-N\fR. |
64 | For example, an MBR always contains 4 partitions, but the number of used | |
65 | partitions may be smaller. In this case \fBsfdisk\fR follows the default | |
66 | values from the partition table and does not use built-in defaults for the | |
67 | unused partition given with \fB\-N\fR. See also \fB\---append\fR. | |
fd6b7a7f | 68 | .TP |
703ab082 | 69 | .BR \-A , " \-\-activate \fIdevice\fR [" \fIpartition-number\fR...] |
689d83de BS |
70 | Switch on the bootable flag. If no \fIpartition-number\fR is specified, |
71 | then all partitions with an enabled flag are listed. | |
9a79aa6e | 72 | .TP |
9a79aa6e | 73 | .BR \-d , " \-\-dump " \fIdevice\fR |
7f576918 | 74 | Dump the partitions of a device in a format that is usable as input to \fBsfdisk\fR. |
689d83de | 75 | See the section \fBBACKING UP THE PARTITION TABLE\fR. |
9a79aa6e | 76 | .TP |
b06c1ca6 | 77 | .BR \-g , " \-\-show\-geometry " [ \fIdevice ...] |
689d83de | 78 | List the geometry of all or the specified devices. |
7f576918 | 79 | .TP |
a592b4b5 | 80 | .BR \-J , " \-\-json " \fIdevice\fR |
7f576918 BS |
81 | Dump the partitions of a device in JSON format. Note that \fBsfdisk\fR is |
82 | not able to use JSON as input format. | |
9a79aa6e | 83 | .TP |
689d83de BS |
84 | .BR \-l , " \-\-list " [ \fIdevice ...] |
85 | List the partitions of all or the specified devices. This command can be used | |
9a79aa6e KZ |
86 | together with \fB\-\-verify\fR. |
87 | .TP | |
b06c1ca6 | 88 | .BR \-\-part\-attrs " \fIdevice partno [" \fIattrs ] |
689d83de BS |
89 | Change the GPT partition attribute bits. If \fIattrs\fR is not specified, |
90 | then print the current partition settings. The \fIattrs\fR argument is a | |
91 | comma- or space-delimited list of bits. The currently supported attribute | |
92 | bits are: RequiredPartiton, NoBlockIOProtocol, LegacyBIOSBootable | |
93 | and GUID-specific bits in the range from 48 to 63. For example, the string | |
bc9e8547 KZ |
94 | "RequiredPartiton,50,51" sets three bits. |
95 | .TP | |
b06c1ca6 | 96 | .BR \-\-part\-label " \fIdevice partno [" \fIlabel ] |
80840c16 | 97 | Change the GPT partition name (label). If \fIlabel\fR is not specified, |
689d83de | 98 | then print the current partition label. |
e36fb07a | 99 | .TP |
b06c1ca6 | 100 | .BR \-\-part\-type " \fIdevice partno [" \fItype ] |
689d83de BS |
101 | Change the partition type. If \fItype\fR is not specified, then print the |
102 | current partition type. The \fItype\fR argument is hexadecimal for MBR, | |
103 | or a GUID for GPT. For backward compatibility the options \fB\-c\fR and | |
104 | \fB\-\-id\fR have the same meaning. | |
e36fb07a | 105 | .TP |
b06c1ca6 | 106 | .BR \-\-part\-uuid " \fIdevice partno [" \fIuuid ] |
689d83de BS |
107 | Change the GPT partition UUID. If \fIuuid\fR is not specified, |
108 | then print the current partition UUID. | |
e36fb07a | 109 | .TP |
b06c1ca6 | 110 | .BR \-s , " \-\-show\-size " [ \fIdevice ...] |
689d83de | 111 | List the sizes of all or the specified devices. |
9a79aa6e | 112 | .TP |
b06c1ca6 | 113 | .BR \-T , " \-\-list\-types" |
689d83de | 114 | Print all supported types for the current disk label or the label specified by |
9a79aa6e | 115 | \fB\-\-label\fR. |
3a5bdedf | 116 | .TP |
3f43f5d0 | 117 | .BR \-V , " \-\-verify " [ \fIdevice ...] |
689d83de | 118 | Test whether the partition table and partitions seem correct. |
5aac7429 KZ |
119 | |
120 | .SH OPTIONS | |
fd6b7a7f | 121 | .TP |
703ab082 | 122 | .BR \-a , " \-\-append" |
689d83de | 123 | Don't create a new partition table, but only append the specified partitions. |
fd6b7a7f | 124 | .TP |
5aac7429 | 125 | .BR \-b , " \-\-backup" |
689d83de BS |
126 | Back up the current partition table sectors before starting the partitioning. |
127 | The default backup file name is ~/sfdisk-<device>-<offset>.bak; to use another | |
7f576918 | 128 | name see option \fB\-O\fR, \fB\-\-backup\-file\fR. |
f74478a6 | 129 | .TP |
7f576918 | 130 | .BR \-\-color [ \fI=when ] |
da25898b KZ |
131 | Colorize the output. The optional argument \fIwhen\fP |
132 | can be \fBauto\fR, \fBnever\fR or \fBalways\fR. If the \fIwhen\fR argument is omitted, | |
7f576918 BS |
133 | it defaults to \fBauto\fR. The colors can be disabled; for the current built-in default |
134 | see the \fB\-\-help\fR output. See also the \fBCOLORS\fR section. | |
da25898b | 135 | .TP |
5aac7429 KZ |
136 | .BR \-f , " \-\-force" |
137 | Disable all consistency checking. | |
f74478a6 | 138 | .TP |
80840c16 BS |
139 | .BR \-\-Linux |
140 | Deprecated and ignored option. Partitioning that is compatible with | |
7f576918 | 141 | Linux (and other modern operating systems) is the default. |
80840c16 BS |
142 | .TP |
143 | .BR \-n , " \-\-no\-act" | |
144 | Do everything except writing to the device. | |
145 | .TP | |
146 | .B \-\-no\-reread | |
147 | Do not check through the re-read-partition-table ioctl whether the device is in use. | |
148 | .TP | |
149 | .BR \-O , " \-\-backup\-file " \fIpath\fR | |
150 | Override the default backup file name. Note that the device name and offset | |
151 | are always appended to the file name. | |
152 | .TP | |
689d83de | 153 | .BR \-o , " \-\-output " \fIlist |
01f9286c KZ |
154 | Specify which output columns to print. Use |
155 | .B \-\-help | |
156 | to get a list of all supported columns. | |
689d83de | 157 | .sp |
01f9286c KZ |
158 | The default list of columns may be extended if \fIlist\fP is |
159 | specified in the format \fI+list\fP (e.g. \fB-o +UUID\fP). | |
160 | .TP | |
5aac7429 KZ |
161 | .BR \-q , " \-\-quiet" |
162 | Suppress extra info messages. | |
f74478a6 | 163 | .TP |
689d83de BS |
164 | .BR \-u , " \-\-unit S" |
165 | Deprecated option. Only the sector unit is supported. | |
f74478a6 | 166 | .TP |
689d83de BS |
167 | .BR \-X , " \-\-label " \fItype |
168 | Specify the disk label type (e.g. \fBdos\fR, \fBgpt\fR, ...). If this option | |
169 | is not given, then \fBsfdisk\fR defaults to the existing label, but if there | |
170 | is no label on the device yet, then the type defaults to \fBdos\fR. | |
01f9286c | 171 | .TP |
b06c1ca6 | 172 | .BR \-Y , " \-\-label\-nested " \fItype |
689d83de BS |
173 | Force editing of a nested disk label. The primary disk label has to exist already. |
174 | This option allows to edit for example a hybrid/protective MBR on devices with GPT. | |
175 | .TP | |
176 | .BR \-v , " \-\-version" | |
177 | Display version information and exit. | |
e1422de3 | 178 | .TP |
5aac7429 KZ |
179 | .BR \-h , " \-\-help" |
180 | Display help text and exit. | |
fd6b7a7f | 181 | |
9a79aa6e KZ |
182 | .SH "INPUT FORMATS" |
183 | .B sfdisk | |
184 | supports two input formats and generic header lines. | |
185 | ||
186 | .B Header lines | |
187 | .RS | |
689d83de BS |
188 | The optional header lines specify generic information that apply to the partition |
189 | table. The header-line format is: | |
190 | .RS | |
191 | .sp | |
9a79aa6e | 192 | .B "<name>: <value>" |
689d83de BS |
193 | .sp |
194 | .RE | |
9a79aa6e KZ |
195 | The currently recognized headers are: |
196 | .RS | |
197 | .TP | |
198 | .B unit | |
689d83de | 199 | Specify the partitioning unit. The only supported unit is \fBsectors\fR. |
9a79aa6e KZ |
200 | .TP |
201 | .B label | |
689d83de | 202 | Specify the partition table type. For example \fBdos\fR or \fBgpt\fR. |
9a79aa6e KZ |
203 | .TP |
204 | .B label-id | |
689d83de BS |
205 | Specify the partition table identifier. It should be a hexadecimal number |
206 | (with a 0x prefix) for MBR and a UUID for GPT. | |
9a79aa6e KZ |
207 | .RE |
208 | .sp | |
689d83de | 209 | Note that it is only possible to use header lines before the first partition |
9a79aa6e KZ |
210 | is specified in the input. |
211 | .RE | |
212 | ||
689d83de BS |
213 | .B Unnamed-fields format |
214 | .RS | |
9a79aa6e | 215 | .RS |
689d83de BS |
216 | .sp |
217 | .I start size type bootable | |
218 | .sp | |
219 | .RE | |
9a79aa6e | 220 | where each line fills one partition descriptor. |
689d83de | 221 | .sp |
80840c16 | 222 | Fields are separated by whitespace, or by comma or semicolon possibly followed by |
9a79aa6e | 223 | whitespace; initial and trailing whitespace is ignored. Numbers can be octal, |
689d83de BS |
224 | decimal or hexadecimal; decimal is the default. When a field is absent or empty, |
225 | a default value is used. But when the \fB-N\fR option (change a single partition) | |
226 | is given, the default for each field is its previous value. | |
227 | .sp | |
9a79aa6e KZ |
228 | The default value of |
229 | .I start | |
689d83de | 230 | is the first non-assigned sector aligned according to device I/O limits. |
ce9f568c | 231 | The default start offset for the first partition is 1 MiB. The offset may |
80840c16 | 232 | be followed by the multiplicative suffixes (KiB, MiB, GiB, TiB, PiB, |
ce9f568c | 233 | EiB, ZiB and YiB) then the number is interpreted as offset in bytes. |
689d83de | 234 | .sp |
9a79aa6e KZ |
235 | The default value of |
236 | .I size | |
689d83de | 237 | is as much as possible (until the next partition or end-of-device). A '+' can be |
9a79aa6e KZ |
238 | used instead of a number for size, which also means as much as possible. The |
239 | size may be followed by the multiplicative suffixes (KiB, MiB, GiB, TiB, PiB, | |
240 | EiB, ZiB and YiB), then the number is interpreted as size of the partition in | |
241 | bytes and then the size is aligned according to the device I/O limits. | |
242 | The default is to interpret the number as number of sectors. | |
689d83de BS |
243 | .sp |
244 | The partition | |
9a79aa6e | 245 | .I type |
689d83de BS |
246 | is given in hex for MBR (DOS), without the 0x prefix, a GUID string for GPT, or |
247 | a shortcut: | |
9a79aa6e KZ |
248 | .RS |
249 | .TP | |
689d83de | 250 | .B L |
9a79aa6e KZ |
251 | Linux; means 83 for MBR and 0FC63DAF-8483-4772-8E79-3D69D8477DE4 for GPT. |
252 | .TP | |
689d83de | 253 | .B S |
9a79aa6e KZ |
254 | swap area; means 82 for MBR and 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F for GPT |
255 | .TP | |
256 | .B E | |
257 | extended partition; means 5 for MBR | |
258 | .TP | |
259 | .B H | |
260 | home partition; means 933AC7E1-2EB4-4F13-B844-0E14E2AEF915 for GPT | |
261 | .TP | |
262 | .B X | |
263 | linux extended partition; means 85 for MBR. | |
264 | .RE | |
265 | ||
689d83de BS |
266 | .I bootable |
267 | is specified as [\fB*\fR|\fB-\fR], with as default not-bootable. (The value of | |
268 | this field is irrelevant for Linux - when Linux runs it has been booted already - | |
269 | but might play a role for certain boot loaders and for other operating systems.) | |
9a79aa6e KZ |
270 | .RE |
271 | ||
689d83de | 272 | .B Named-fields format |
9a79aa6e | 273 | .RS |
689d83de | 274 | This format is more readable, robust, extendible and allows to specify additional |
80840c16 | 275 | information (e.g. a UUID). It is recommended to use this format to keep your scripts |
9a79aa6e | 276 | more readable. |
689d83de BS |
277 | .RS |
278 | .sp | |
279 | .RI [ "device \fB:" ] " name" [\fB= value "], ..." | |
280 | .sp | |
281 | .RE | |
282 | The | |
9a79aa6e | 283 | .I device |
689d83de BS |
284 | field is optional. \fBsfdisk\fRextracts the partition number from the |
285 | device name. It allows to specify the partitions in random order. | |
97325257 | 286 | This functionality is mostly used by \fB\-\-dump\fR. |
689d83de | 287 | Don't use it if you are not sure. |
9a79aa6e KZ |
288 | |
289 | The | |
290 | .I value | |
689d83de BS |
291 | can be between quotation marks (e.g. name="This is partition name"). |
292 | The currently supported fields are: | |
9a79aa6e KZ |
293 | .RS |
294 | .TP | |
689d83de BS |
295 | .BI start= number |
296 | The first non-assigned sector aligned according to device I/O limits. The default | |
ce9f568c KZ |
297 | start offset for the first partition is 1 MiB. The offset may be followed by |
298 | the multiplicative suffixes (KiB, MiB, GiB, TiB, PiB, EiB, ZiB and YiB) then | |
299 | the number is interpreted as offset in bytes. | |
9a79aa6e | 300 | .TP |
689d83de BS |
301 | .BI size= number |
302 | Specify the partition size in sectors. The number may be followed by the multiplicative | |
9a79aa6e KZ |
303 | suffixes (KiB, MiB, GiB, TiB, PiB, EiB, ZiB and YiB), then it's interpreted as size |
304 | in bytes and the size is aligned according to device I/O limits. | |
305 | .TP | |
689d83de BS |
306 | .B bootable |
307 | Mark the partition as bootable. | |
9a79aa6e | 308 | .TP |
689d83de BS |
309 | .BI attrs= string |
310 | Partition attributes, usually GPT partition attribute bits. See | |
b06c1ca6 | 311 | \fB\-\-part\-attrs\fR for more details about the GPT-bits string format. |
9a79aa6e | 312 | .TP |
689d83de | 313 | .BI uuid= string |
9a79aa6e KZ |
314 | GPT partition UUID. |
315 | .TP | |
689d83de | 316 | .BI name= string |
9a79aa6e KZ |
317 | GPT partition name. |
318 | .TP | |
689d83de BS |
319 | .BI type= code |
320 | A hexadecimal number (without 0x) for an MBR partition, or a GUID for a GPT partition. | |
321 | For backward compatibility the \fBId=\fR field has the same meaning. | |
9a79aa6e KZ |
322 | .RE |
323 | .RE | |
324 | ||
689d83de BS |
325 | .SH "BACKING UP THE PARTITION TABLE" |
326 | It is recommended to save the layout of your devices. | |
9a79aa6e KZ |
327 | .B sfdisk |
328 | supports two ways. | |
689d83de BS |
329 | .sp |
330 | Use the \fB\-\-dump\fR option to save a description of the device layout | |
331 | to a text file. The dump format is suitable for later \fBsfdisk\fR input. | |
332 | For example: | |
9a79aa6e KZ |
333 | .RS |
334 | .sp | |
335 | .B "sfdisk --dump /dev/sda > sda.dump" | |
336 | .sp | |
337 | .RE | |
689d83de | 338 | This can later be restored by: |
9a79aa6e KZ |
339 | .RS |
340 | .sp | |
341 | .B "sfdisk /dev/sda < sda.dump" | |
342 | .RE | |
343 | ||
689d83de BS |
344 | If you want to do a full (binary) backup of all sectors where the |
345 | partition table is stored, | |
346 | then use the \fB\-\-backup\fR option. It writes the sectors to | |
347 | ~/sfdisk-<device>-<offset>.bak files. The default name of the backup file can | |
348 | be changed with the \fB\-\-backup\-file\fR option. The backup files | |
349 | contain only raw data from the \fIdevice\fR. | |
350 | Note that the same concept of backup files is used by | |
351 | .BR wipefs (8). | |
352 | For example: | |
9a79aa6e KZ |
353 | .RS |
354 | .sp | |
355 | .B "sfdisk --backup /dev/sda" | |
356 | .sp | |
357 | .RE | |
689d83de | 358 | The GPT header can later be restored by: |
9a79aa6e KZ |
359 | .RS |
360 | .sp | |
4bb82a45 | 361 | .B dd if=~/sfdisk-sda-0x00000200.bak of=/dev/sda seek=$((0x00000200)) bs=1 conv=notrunc |
9a79aa6e KZ |
362 | .sp |
363 | .RE | |
689d83de BS |
364 | Note that \fBsfdisk\fR since version 2.26 no longer provides the \fB\-I\fR option to |
365 | restore sectors. | |
9a79aa6e KZ |
366 | .B dd (1) |
367 | provides all necessary functionality. | |
368 | ||
da25898b KZ |
369 | .SH COLORS |
370 | Implicit coloring can be disabled by an empty file \fI/etc/terminal-colors.d/sfdisk.disable\fR. | |
371 | ||
372 | See | |
373 | .BR terminal-colors.d (5) | |
374 | for more details about colorization configuration. The logical color names | |
375 | supported by | |
376 | .B sfdisk | |
377 | are: | |
378 | .TP | |
379 | .B header | |
380 | The header of the output tables. | |
381 | .TP | |
382 | .B warn | |
383 | The warning messages. | |
384 | .TP | |
385 | .B welcome | |
386 | The welcome message. | |
387 | ||
9a79aa6e | 388 | .SH NOTES |
689d83de | 389 | Since version 2.26 \fBsfdisk\fR no longer provides the \fB\-R\fR or |
b06c1ca6 | 390 | \fB\-\-re\-read\fR option to force the kernel to reread the partition table. |
689d83de | 391 | Use \fBblockdev \-\-rereadpt\fR instead. |
9a79aa6e | 392 | .PP |
b06c1ca6 WP |
393 | Since version 2.26 \fBsfdisk\fR does not provide the \fB\-\-DOS\fR, \fB\-\-IBM\fR, \fB\-\-DOS\-extended\fR, |
394 | \fB\-\-unhide\fR, \fB\-\-show\-extended\fR, \fB\-\-cylinders\fR, \fB\-\-heads\fR, \fB\-\-sectors\fR, | |
395 | \fB\-\-inside\-outer\fR, \fB\-\-not\-inside\-outer\fR options. | |
9a79aa6e | 396 | |
68e422ec | 397 | .SH ENVIRONMENT |
47dd6918 KZ |
398 | .IP SFDISK_DEBUG=all |
399 | enables sfdisk debug output. | |
68e422ec KZ |
400 | .IP LIBFDISK_DEBUG=all |
401 | enables libfdisk debug output. | |
402 | .IP LIBBLKID_DEBUG=all | |
403 | enables libblkid debug output. | |
404 | .IP LIBSMARTCOLS_DEBUG=all | |
405 | enables libsmartcols debug output. | |
406 | ||
612721db | 407 | .SH "SEE ALSO" |
612721db | 408 | .BR fdisk (8), |
5aac7429 | 409 | .BR cfdisk (8), |
c64061c9 VD |
410 | .BR parted (8), |
411 | .BR partprobe (8), | |
5aac7429 | 412 | .BR partx(8) |
689d83de | 413 | |
5aac7429 KZ |
414 | .SH AUTHOR |
415 | Karel Zak <kzak@redhat.com> | |
416 | .PP | |
417 | The current sfdisk implementation is based on the original sfdisk | |
418 | from Andries E. Brouwer. | |
419 | ||
86d62711 | 420 | .SH AVAILABILITY |
601d12fb KZ |
421 | The sfdisk command is part of the util-linux package and is available from |
422 | ftp://ftp.kernel.org/pub/linux/utils/util-linux/. |