]>
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 | |
135e0389 KZ |
28 | is a script-oriented tool for partitioning any block device. It |
29 | runs in interactive mode if executed on terminal (stdin refers to a terminal). | |
fd6b7a7f | 30 | |
d5206b96 | 31 | Since version 2.26 |
5dbff4c0 | 32 | .B sfdisk |
5aac7429 KZ |
33 | supports MBR (DOS), GPT, SUN and SGI disk labels, but no longer provides any |
34 | functionality for CHS (Cylinder-Head-Sector) addressing. CHS has | |
35 | never been important for Linux, and this addressing concept does not make any | |
36 | sense for new devices. | |
689d83de | 37 | .sp |
b69719b6 | 38 | .B sfdisk |
86800f5d KZ |
39 | (since version 2.26) |
40 | .B aligns the start and end of partitions | |
41 | to block-device I/O limits when relative sizes are specified, when the default | |
eb024893 | 42 | values are used or when multiplicative suffixes (e.g., MiB) are used for sizes. |
86800f5d KZ |
43 | It is possible that partition size will be optimized (reduced or enlarged) due |
44 | to alignment if the start offset is specified exactly in sectors and partition | |
45 | size relative or by multiplicative suffixes. | |
46 | ||
47 | The recommended way is not to specify start offsets at all and specify | |
48 | partition size in MiB, GiB (or so). In this case sfdisk align all partitions | |
49 | to block-device I/O limits (or when I/O limits are too small then to megabyte | |
50 | boundary to keep disk layout portable). If this default behaviour is unwanted | |
208b2ef0 KZ |
51 | (usually for very small partitions) then specify offsets and sizes in |
52 | sectors. In this case sfdisk entirely follows specified numbers without any | |
53 | optimization. | |
689d83de | 54 | .sp |
a8a4887b | 55 | .B sfdisk |
689d83de BS |
56 | does not create the standard system partitions for SGI and SUN disk labels like |
57 | .BR fdisk (8) | |
58 | does. | |
a8a4887b KZ |
59 | It is necessary to explicitly create all partitions including whole-disk system |
60 | partitions. | |
61 | ||
aefa920a KZ |
62 | .B sfdisk |
63 | uses BLKRRPART (reread partition table) ioctl to make sure that the device is | |
1c4c6024 | 64 | not used by system or another tools (see also \-\-no-reread). It's possible that |
aefa920a KZ |
65 | this feature or another sfdisk activity races with \fBudevd\fR. The recommended way |
66 | how to avoid possible collisions is to use exclusive flock for the whole-disk | |
67 | device to serialize device access. The exclusive lock will cause udevd to skip | |
68 | the event handling on the device. For example: | |
69 | .RS | |
70 | .sp | |
71 | .nf | |
72 | .B "flock /dev/sdc sfdisk /dev/sdc" | |
73 | .fi | |
74 | .sp | |
75 | .RE | |
76 | Note, this semantic is not currently supported by udevd for MD and DM devices. | |
ac762ed7 KZ |
77 | .PP |
78 | The sfdisk prompt is only a hint for users and a displayed partition number does | |
79 | not mean that the same partition table entry will be created (if -N not | |
80 | specified), especially for tables with gaps. | |
aefa920a | 81 | |
5aac7429 KZ |
82 | .SH COMMANDS |
83 | The commands are mutually exclusive. | |
fd6b7a7f | 84 | .TP |
f49ccec2 | 85 | .RB [ \-N " \fIpartition-number\fR] " \fIdevice\fR |
689d83de | 86 | The default \fBsfdisk\fR command is to read the specification for the desired |
5aac7429 | 87 | partitioning of \fIdevice\fR from standard input, and then create a partition |
689d83de BS |
88 | table according to the specification. See below for the description of the |
89 | input format. If standard input is a terminal, then \fBsfdisk\fR starts an | |
90 | interactive session. | |
91 | .sp | |
92 | If the option \fB\-N\fR is specified, then the changes are applied to | |
7f576918 | 93 | the partition addressed by \fIpartition-number\fR. The unspecified fields |
d754d554 KZ |
94 | of the partition are not modified. |
95 | .sp | |
7f576918 BS |
96 | Note that it's possible to address an unused partition with \fB\-N\fR. |
97 | For example, an MBR always contains 4 partitions, but the number of used | |
98 | partitions may be smaller. In this case \fBsfdisk\fR follows the default | |
99 | values from the partition table and does not use built-in defaults for the | |
c805c369 | 100 | unused partition given with \fB\-N\fR. See also \fB\-\-append\fR. |
fd6b7a7f | 101 | .TP |
8175ed3d KZ |
102 | .BR \-A , " \-\-activate \fIdevice " [ \fIpartition-number...] |
103 | Switch on the bootable flag for the specified partitions and switch off the | |
1c4c6024 | 104 | bootable flag on all unspecified partitions. The special placeholder '\-' |
8175ed3d KZ |
105 | may be used instead of the partition numbers to switch off the bootable flag |
106 | on all partitions. | |
107 | ||
49032ef7 KZ |
108 | The activation command is supported for MBR and PMBR only. If GPT label is detected |
109 | than sfdisk prints warning and automatically enter PMBR. | |
110 | ||
8175ed3d KZ |
111 | If no \fIpartition-number\fR is specified, then list the partitions with an |
112 | enabled flag. | |
9a79aa6e | 113 | .TP |
c805c369 BS |
114 | .BR "\-\-delete \fIdevice " [ \fIpartition-number ...] |
115 | Delete all or the specified partitions. | |
aab9be66 | 116 | .TP |
9a79aa6e | 117 | .BR \-d , " \-\-dump " \fIdevice\fR |
7f576918 | 118 | Dump the partitions of a device in a format that is usable as input to \fBsfdisk\fR. |
689d83de | 119 | See the section \fBBACKING UP THE PARTITION TABLE\fR. |
9a79aa6e | 120 | .TP |
b06c1ca6 | 121 | .BR \-g , " \-\-show\-geometry " [ \fIdevice ...] |
349ac672 KZ |
122 | List the geometry of all or the specified devices. For backward |
123 | compatibility the deprecated option \fB\-\-show\-pt\-geometry\fR have the same | |
124 | meaning as this one. | |
7f576918 | 125 | .TP |
a592b4b5 | 126 | .BR \-J , " \-\-json " \fIdevice\fR |
7f576918 BS |
127 | Dump the partitions of a device in JSON format. Note that \fBsfdisk\fR is |
128 | not able to use JSON as input format. | |
9a79aa6e | 129 | .TP |
689d83de BS |
130 | .BR \-l , " \-\-list " [ \fIdevice ...] |
131 | List the partitions of all or the specified devices. This command can be used | |
9a79aa6e KZ |
132 | together with \fB\-\-verify\fR. |
133 | .TP | |
8abdb912 KZ |
134 | .BR \-F , " \-\-list-free " [ \fIdevice ...] |
135 | List the free unpartitioned areas on all or the specified devices. | |
136 | .TP | |
c805c369 BS |
137 | .BR "\-\-part\-attrs \fIdevice partition-number " [ \fIattributes ] |
138 | Change the GPT partition attribute bits. If \fIattributes\fR is not specified, | |
5839a4ea KZ |
139 | then print the current partition settings. |
140 | .sp | |
141 | The \fIattributes\fR argument is a | |
689d83de | 142 | comma- or space-delimited list of bits. The currently supported attribute |
d1b7bfe5 | 143 | bits are: RequiredPartition, NoBlockIOProtocol, LegacyBIOSBootable |
689d83de | 144 | and GUID-specific bits in the range from 48 to 63. For example, the string |
d1b7bfe5 | 145 | "RequiredPartition,50,51" sets three bits. |
bc9e8547 | 146 | .TP |
c805c369 | 147 | .BR "\-\-part\-label \fIdevice partition-number " [ \fIlabel ] |
80840c16 | 148 | Change the GPT partition name (label). If \fIlabel\fR is not specified, |
689d83de | 149 | then print the current partition label. |
e36fb07a | 150 | .TP |
c805c369 | 151 | .BR "\-\-part\-type \fIdevice partition-number " [ \fItype ] |
689d83de | 152 | Change the partition type. If \fItype\fR is not specified, then print the |
5839a4ea KZ |
153 | current partition type. |
154 | .sp | |
155 | The \fItype\fR argument is hexadecimal for MBR, | |
156 | GUID for GPT, type alias (e.g. "linux") or type shortcut (e.g. 'L'). | |
157 | For backward compatibility the options \fB\-c\fR and | |
c805c369 | 158 | \fB\-\-id\fR have the same meaning as this one. |
e36fb07a | 159 | .TP |
c805c369 | 160 | .BR "\-\-part\-uuid \fIdevice partition-number " [ \fIuuid ] |
689d83de BS |
161 | Change the GPT partition UUID. If \fIuuid\fR is not specified, |
162 | then print the current partition UUID. | |
e36fb07a | 163 | .TP |
65e27d54 KZ |
164 | .BR "\-\-disk\-id \fIdevice " [ \fIid ] |
165 | Change the disk identifier. If \fIid\fR is not specified, | |
166 | then print the current identifier. The identifier is UUID for GPT | |
167 | or unsigned integer for MBR. | |
168 | .TP | |
9a17d946 | 169 | .BR \-r , " \-\-reorder " \fIdevice |
c805c369 | 170 | Renumber the partitions, ordering them by their start offset. |
9a17d946 | 171 | .TP |
b06c1ca6 | 172 | .BR \-s , " \-\-show\-size " [ \fIdevice ...] |
b0ff9a76 CM |
173 | List the sizes of all or the specified devices in units of 1024 byte size. |
174 | This command is DEPRECATED in favour of | |
dbeb1d73 | 175 | .BR blockdev (8). |
9a79aa6e | 176 | .TP |
b06c1ca6 | 177 | .BR \-T , " \-\-list\-types" |
689d83de | 178 | Print all supported types for the current disk label or the label specified by |
9a79aa6e | 179 | \fB\-\-label\fR. |
3a5bdedf | 180 | .TP |
3f43f5d0 | 181 | .BR \-V , " \-\-verify " [ \fIdevice ...] |
689d83de | 182 | Test whether the partition table and partitions seem correct. |
ee5a1602 KZ |
183 | .TP |
184 | .BR "\-\-relocate \fIoper " \fIdevice | |
185 | Relocate partition table header. This command is currently supported for GPT header only. | |
186 | The argument \fIoper\fP can be: | |
187 | .RS | |
188 | .TP | |
189 | .B gpt-bak-std | |
190 | Move GPT backup header to the standard location at the end of the device. | |
191 | .TP | |
192 | .B gpt-bak-mini | |
193 | Move GPT backup header behind the last partition. Note that UEFI | |
194 | standard requires the backup header at the end of the device and partitioning | |
195 | tools can automatically relocate the header to follow the standard. | |
196 | .RE | |
5aac7429 | 197 | .SH OPTIONS |
fd6b7a7f | 198 | .TP |
703ab082 | 199 | .BR \-a , " \-\-append" |
689d83de | 200 | Don't create a new partition table, but only append the specified partitions. |
ac762ed7 KZ |
201 | .sp |
202 | Note that unused partition maybe be re-used in this case although it is not the | |
203 | last partition in the partition table. See also \fB\-N\fR to specify entry in | |
204 | the partition table. | |
fd6b7a7f | 205 | .TP |
5aac7429 | 206 | .BR \-b , " \-\-backup" |
689d83de BS |
207 | Back up the current partition table sectors before starting the partitioning. |
208 | The default backup file name is ~/sfdisk-<device>-<offset>.bak; to use another | |
7f576918 | 209 | name see option \fB\-O\fR, \fB\-\-backup\-file\fR. |
f74478a6 | 210 | .TP |
7e3b3f47 | 211 | .BR \-\-color [ =\fIwhen ] |
da25898b KZ |
212 | Colorize the output. The optional argument \fIwhen\fP |
213 | can be \fBauto\fR, \fBnever\fR or \fBalways\fR. If the \fIwhen\fR argument is omitted, | |
7f576918 BS |
214 | it defaults to \fBauto\fR. The colors can be disabled; for the current built-in default |
215 | see the \fB\-\-help\fR output. See also the \fBCOLORS\fR section. | |
da25898b | 216 | .TP |
5aac7429 KZ |
217 | .BR \-f , " \-\-force" |
218 | Disable all consistency checking. | |
f74478a6 | 219 | .TP |
0bb7e904 | 220 | .B \-\-Linux |
80840c16 | 221 | Deprecated and ignored option. Partitioning that is compatible with |
7f576918 | 222 | Linux (and other modern operating systems) is the default. |
80840c16 BS |
223 | .TP |
224 | .BR \-n , " \-\-no\-act" | |
225 | Do everything except writing to the device. | |
226 | .TP | |
227 | .B \-\-no\-reread | |
228 | Do not check through the re-read-partition-table ioctl whether the device is in use. | |
229 | .TP | |
d4a90151 KZ |
230 | .B \-\-no\-tell\-kernel |
231 | Don't tell the kernel about partition changes. This option is recommended together | |
232 | with \fB\-\-no\-reread\fR to modify a partition on used disk. The modified partition | |
eb024893 | 233 | should not be used (e.g., mounted). |
d4a90151 | 234 | .TP |
c805c369 | 235 | .BR \-O , " \-\-backup\-file " \fIpath |
80840c16 BS |
236 | Override the default backup file name. Note that the device name and offset |
237 | are always appended to the file name. | |
f42205d8 | 238 | .TP |
7e3b3f47 | 239 | .BR \-\-move-data [ =\fIpath ] |
c805c369 BS |
240 | Move data after partition relocation, for example when moving the beginning |
241 | of a partition to another place on the disk. The size of the partition has | |
242 | to remain the same, the new and old location may overlap. This option requires | |
243 | option \fB\-N\fR in order to be processed on one specific partition only. | |
f42205d8 | 244 | |
69f30c31 KZ |
245 | The optional \fIpath\fR specifies log file name. The log file contains information |
246 | about all read/write operations on the partition data. The word "@default" as | |
247 | a \fIpath\fR forces sfdisk to use ~/sfdisk-<devname>.move for the log. The log is | |
248 | optional since v2.35. | |
f42205d8 | 249 | |
c805c369 | 250 | Note that this operation is risky and not atomic. \fBDon't forget to backup your data!\fR |
f42205d8 | 251 | |
7942ba8a KZ |
252 | See also \fB\-\-move\-use\-fsync\fR. |
253 | ||
c805c369 | 254 | In the example below, the first command creates a 100MiB free area before |
eb024893 | 255 | the first partition and moves the data it contains (e.g., a filesystem), |
c805c369 BS |
256 | the next command creates a new partition from the free space (at offset 2048), |
257 | and the last command reorders partitions to match disk order | |
258 | (the original sdc1 will become sdc2). | |
f42205d8 KZ |
259 | .RS |
260 | .sp | |
1c4c6024 | 261 | .B "echo '+100M,' | sfdisk \-\-move-data /dev/sdc \-N 1" |
f42205d8 | 262 | .br |
1c4c6024 | 263 | .B "echo '2048,' | sfdisk /dev/sdc \-\-append |
f42205d8 | 264 | .br |
1c4c6024 | 265 | .B sfdisk /dev/sdc \-\-reorder |
f42205d8 KZ |
266 | .sp |
267 | .RE | |
268 | ||
7942ba8a | 269 | .TP |
2fb684f0 | 270 | .B \-\-move\-use\-fsync |
366e1639 | 271 | Use fsync system call after each write when move data to a new location by |
7942ba8a | 272 | \fB\-\-move\-data\fR. |
80840c16 | 273 | .TP |
689d83de | 274 | .BR \-o , " \-\-output " \fIlist |
01f9286c KZ |
275 | Specify which output columns to print. Use |
276 | .B \-\-help | |
277 | to get a list of all supported columns. | |
689d83de | 278 | .sp |
01f9286c | 279 | The default list of columns may be extended if \fIlist\fP is |
1c4c6024 | 280 | specified in the format \fI+list\fP (e.g., \fB\-o +UUID\fP). |
01f9286c | 281 | .TP |
5aac7429 KZ |
282 | .BR \-q , " \-\-quiet" |
283 | Suppress extra info messages. | |
f74478a6 | 284 | .TP |
689d83de | 285 | .BR \-u , " \-\-unit S" |
b0ff9a76 | 286 | Deprecated option. Only the sector unit is supported. This option is not |
1c4c6024 | 287 | supported when using the \-\-show-size command. |
f74478a6 | 288 | .TP |
689d83de | 289 | .BR \-X , " \-\-label " \fItype |
eb024893 | 290 | Specify the disk label type (e.g., \fBdos\fR, \fBgpt\fR, ...). If this option |
689d83de | 291 | is not given, then \fBsfdisk\fR defaults to the existing label, but if there |
35ca5118 KZ |
292 | is no label on the device yet, then the type defaults to \fBdos\fR. The default |
293 | or the current label may be overwritten by the "label: <name>" script header | |
294 | line. The option \fB\-\-label\fR does not force \fBsfdisk\fR to create empty | |
295 | disk label (see the \fBEMPTY DISK LABEL\fR section below). | |
01f9286c | 296 | .TP |
b06c1ca6 | 297 | .BR \-Y , " \-\-label\-nested " \fItype |
689d83de BS |
298 | Force editing of a nested disk label. The primary disk label has to exist already. |
299 | This option allows to edit for example a hybrid/protective MBR on devices with GPT. | |
15b5e942 KZ |
300 | |
301 | .TP | |
1c4c6024 | 302 | .BR \-w , " \-\-wipe "\fIwhen |
589b6931 BS |
303 | Wipe filesystem, RAID and partition-table signatures from the device, in order |
304 | to avoid possible collisions. The argument \fIwhen\fR can be \fBauto\fR, | |
305 | \fBnever\fR or \fBalways\fR. When this option is not given, the default is | |
bb881527 KZ |
306 | \fBauto\fR, in which case signatures are wiped only when in interactive mode; |
307 | except the old partition-table signatures which are always wiped before create | |
308 | a new partition-table if the argument \fIwhen\fR is not \fBnever\fR. In all | |
309 | cases detected signatures are reported by warning messages before a new | |
310 | partition table is created. See also | |
15b5e942 KZ |
311 | .BR wipefs (8) |
312 | command. | |
313 | ||
3d6db3fd | 314 | .TP |
1c4c6024 | 315 | .BR \-W , " \-\-wipe-partitions "\fIwhen |
3d6db3fd KZ |
316 | Wipe filesystem, RAID and partition-table signatures from a newly created |
317 | partitions, in order to avoid possible collisions. The argument \fIwhen\fR can | |
318 | be \fBauto\fR, \fBnever\fR or \fBalways\fR. When this option is not given, the | |
319 | default is \fBauto\fR, in which case signatures are wiped only when in | |
320 | interactive mode and after confirmation by user. In all cases detected | |
321 | signatures are reported by warning messages after a new partition is created. | |
322 | See also | |
323 | .BR wipefs (8) | |
324 | command. | |
325 | ||
689d83de BS |
326 | .TP |
327 | .BR \-v , " \-\-version" | |
328 | Display version information and exit. | |
e1422de3 | 329 | .TP |
5aac7429 KZ |
330 | .BR \-h , " \-\-help" |
331 | Display help text and exit. | |
fd6b7a7f | 332 | |
5a829806 | 333 | .SH INPUT FORMATS |
9a79aa6e KZ |
334 | .B sfdisk |
335 | supports two input formats and generic header lines. | |
336 | ||
337 | .B Header lines | |
338 | .RS | |
689d83de BS |
339 | The optional header lines specify generic information that apply to the partition |
340 | table. The header-line format is: | |
341 | .RS | |
342 | .sp | |
9a79aa6e | 343 | .B "<name>: <value>" |
689d83de BS |
344 | .sp |
345 | .RE | |
9a79aa6e KZ |
346 | The currently recognized headers are: |
347 | .RS | |
348 | .TP | |
349 | .B unit | |
689d83de | 350 | Specify the partitioning unit. The only supported unit is \fBsectors\fR. |
9a79aa6e KZ |
351 | .TP |
352 | .B label | |
689d83de | 353 | Specify the partition table type. For example \fBdos\fR or \fBgpt\fR. |
9a79aa6e KZ |
354 | .TP |
355 | .B label-id | |
689d83de BS |
356 | Specify the partition table identifier. It should be a hexadecimal number |
357 | (with a 0x prefix) for MBR and a UUID for GPT. | |
aef79c1f KZ |
358 | .TP |
359 | .B first-lba | |
360 | Specify the first usable sector for GPT partitions. | |
361 | .TP | |
362 | .B last-lba | |
363 | Specify the last usable sector for GPT partitions. | |
364 | .TP | |
365 | .B table-length | |
366 | Specify the maximal number of GPT partitions. | |
e4386c8c KZ |
367 | .TP |
368 | .B grain | |
369 | Specify minimal size in bytes used to calculate partitions alignment. The | |
370 | default is 1MiB and it's strongly recommended to use the default. Do not | |
371 | modify this variable if you're not sure. | |
e56ca068 KZ |
372 | .TP |
373 | .B sector-size | |
374 | Specify sector size. This header is informative only and it is not used when | |
375 | sfdisk creates a new partition table, in this case the real device specific | |
376 | value is always used and sector size from the dump is ignored. | |
9a79aa6e KZ |
377 | .RE |
378 | .sp | |
689d83de | 379 | Note that it is only possible to use header lines before the first partition |
9a79aa6e KZ |
380 | is specified in the input. |
381 | .RE | |
382 | ||
689d83de BS |
383 | .B Unnamed-fields format |
384 | .RS | |
9a79aa6e | 385 | .RS |
689d83de BS |
386 | .sp |
387 | .I start size type bootable | |
388 | .sp | |
389 | .RE | |
9a79aa6e | 390 | where each line fills one partition descriptor. |
689d83de | 391 | .sp |
11aa2aa2 IW |
392 | Fields are separated by whitespace, comma or semicolon possibly |
393 | followed by whitespace; initial and trailing whitespace is ignored. | |
394 | Numbers can be octal, decimal or hexadecimal; decimal is the default. | |
1c4c6024 BIG |
395 | When a field is absent, empty or specified as '\-' a default value is |
396 | used. But when the \fB\-N\fR option (change a single partition) is | |
11aa2aa2 | 397 | given, the default for each field is its previous value. |
689d83de | 398 | .sp |
9a79aa6e KZ |
399 | The default value of |
400 | .I start | |
689d83de | 401 | is the first non-assigned sector aligned according to device I/O limits. |
c805c369 | 402 | The default start offset for the first partition is 1 MiB. The offset may |
80840c16 | 403 | be followed by the multiplicative suffixes (KiB, MiB, GiB, TiB, PiB, |
ce9f568c | 404 | EiB, ZiB and YiB) then the number is interpreted as offset in bytes. |
689d83de | 405 | .sp |
9a79aa6e KZ |
406 | The default value of |
407 | .I size | |
eb024893 | 408 | indicates "as much as possible"; i.e., until the next partition or |
11aa2aa2 IW |
409 | end-of-device. A numerical argument is by default interpreted as a |
410 | number of sectors, however if the size is followed by one of the | |
411 | multiplicative suffixes (KiB, MiB, GiB, TiB, PiB, EiB, ZiB and YiB) | |
412 | then the number is interpreted as the size of the partition in bytes | |
413 | and it is then aligned according to the device I/O limits. A '+' can | |
414 | be used instead of a number to enlarge the partition as much as | |
415 | possible. Note '+' is equivalent to the default behaviour for a new | |
416 | partition; existing partitions will be resized as required. | |
689d83de BS |
417 | .sp |
418 | The partition | |
9a79aa6e | 419 | .I type |
4d755765 | 420 | is given in hex for MBR (DOS) where 0x prefix is optional; a GUID string for |
5839a4ea KZ |
421 | GPT; a shortcut or an alias. It's recommended to use two letters for MBR hex codes to |
422 | avoid collision between deprecated shortcut 'E' and '0E' MBR hex code. For backward | |
4d755765 KZ |
423 | compatibility sfdisk tries to interpret |
424 | .I type | |
5839a4ea KZ |
425 | as a shortcut as a first possibility in partitioning scripts although on another places (e.g. |
426 | \fB\-\-part-type command)\fR it tries shortcuts as the last possibility. | |
427 | ||
428 | Since v2.36 libfdisk supports partition type aliases as extension to shortcuts. The alias is a | |
429 | simple human readable word (e.g. "linux"). | |
430 | ||
431 | Supported shortcuts and aliases: | |
9a79aa6e KZ |
432 | .RS |
433 | .TP | |
5839a4ea | 434 | .B L - alias 'linux' |
9a79aa6e KZ |
435 | Linux; means 83 for MBR and 0FC63DAF-8483-4772-8E79-3D69D8477DE4 for GPT. |
436 | .TP | |
5839a4ea | 437 | .B S - alias 'swap' |
9a79aa6e KZ |
438 | swap area; means 82 for MBR and 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F for GPT |
439 | .TP | |
5839a4ea KZ |
440 | .B Ex - alias 'extended' |
441 | MBR extended partition; means 05 for MBR. The original shortcut 'E' is deprecated due to collision with | |
442 | 0x0E MBR partition type. | |
9a79aa6e | 443 | .TP |
5839a4ea | 444 | .B H - alias 'home' |
9a79aa6e KZ |
445 | home partition; means 933AC7E1-2EB4-4F13-B844-0E14E2AEF915 for GPT |
446 | .TP | |
5839a4ea | 447 | .B U - alias 'uefi' |
300e24a8 | 448 | EFI System partition, means EF for MBR and C12A7328-F81F-11D2-BA4B-00A0C93EC93B for GPT |
6ebc3785 | 449 | .TP |
5839a4ea | 450 | .B R - alias 'raid' |
7e95fd82 | 451 | Linux RAID; means FD for MBR and A19D880F-05FC-4D3B-A006-743F0F84911E for GPT |
6ebc3785 | 452 | .TP |
5839a4ea | 453 | .B V - alias 'lvm' |
7e95fd82 | 454 | LVM; means 8E for MBR and E6D6D379-F507-44C2-A23C-238F2A3DF928 for GPT |
9a79aa6e | 455 | .RE |
11aa2aa2 IW |
456 | .PP |
457 | The default | |
458 | .I type | |
459 | value is | |
5839a4ea KZ |
460 | .I linux |
461 | .sp | |
462 | The shortcut 'X' for Linux extended partition (85) is deprecated in favour of 'Ex'. | |
9a79aa6e | 463 | |
689d83de | 464 | .I bootable |
11aa2aa2 IW |
465 | is specified as [\fB*\fR|\fB-\fR], with as default not-bootable. The |
466 | value of this field is irrelevant for Linux - when Linux runs it has | |
c7a3455c | 467 | been booted already - but it might play a role for certain boot |
11aa2aa2 | 468 | loaders and for other operating systems. |
9a79aa6e KZ |
469 | .RE |
470 | ||
689d83de | 471 | .B Named-fields format |
9a79aa6e | 472 | .RS |
d35df4db | 473 | This format is more readable, robust, extensible and allows to specify additional |
eb024893 | 474 | information (e.g., a UUID). It is recommended to use this format to keep your scripts |
9a79aa6e | 475 | more readable. |
689d83de BS |
476 | .RS |
477 | .sp | |
478 | .RI [ "device \fB:" ] " name" [\fB= value "], ..." | |
479 | .sp | |
480 | .RE | |
481 | The | |
9a79aa6e | 482 | .I device |
c805c369 | 483 | field is optional. \fBsfdisk\fR extracts the partition number from the |
689d83de | 484 | device name. It allows to specify the partitions in random order. |
97325257 | 485 | This functionality is mostly used by \fB\-\-dump\fR. |
689d83de | 486 | Don't use it if you are not sure. |
9a79aa6e KZ |
487 | |
488 | The | |
489 | .I value | |
eb024893 | 490 | can be between quotation marks (e.g., name="This is partition name"). |
689d83de | 491 | The currently supported fields are: |
9a79aa6e KZ |
492 | .RS |
493 | .TP | |
689d83de BS |
494 | .BI start= number |
495 | The first non-assigned sector aligned according to device I/O limits. The default | |
ce9f568c KZ |
496 | start offset for the first partition is 1 MiB. The offset may be followed by |
497 | the multiplicative suffixes (KiB, MiB, GiB, TiB, PiB, EiB, ZiB and YiB) then | |
498 | the number is interpreted as offset in bytes. | |
9a79aa6e | 499 | .TP |
689d83de BS |
500 | .BI size= number |
501 | Specify the partition size in sectors. The number may be followed by the multiplicative | |
9a79aa6e KZ |
502 | suffixes (KiB, MiB, GiB, TiB, PiB, EiB, ZiB and YiB), then it's interpreted as size |
503 | in bytes and the size is aligned according to device I/O limits. | |
504 | .TP | |
689d83de BS |
505 | .B bootable |
506 | Mark the partition as bootable. | |
9a79aa6e | 507 | .TP |
689d83de BS |
508 | .BI attrs= string |
509 | Partition attributes, usually GPT partition attribute bits. See | |
b06c1ca6 | 510 | \fB\-\-part\-attrs\fR for more details about the GPT-bits string format. |
9a79aa6e | 511 | .TP |
689d83de | 512 | .BI uuid= string |
9a79aa6e KZ |
513 | GPT partition UUID. |
514 | .TP | |
689d83de | 515 | .BI name= string |
9a79aa6e KZ |
516 | GPT partition name. |
517 | .TP | |
689d83de | 518 | .BI type= code |
08474fde KZ |
519 | A hexadecimal number (without 0x) for an MBR partition, a GUID for a GPT partition, |
520 | or a shortcut as for unnamed-fields format. | |
689d83de | 521 | For backward compatibility the \fBId=\fR field has the same meaning. |
9a79aa6e KZ |
522 | .RE |
523 | .RE | |
524 | ||
5a829806 | 525 | .SH EMPTY DISK LABEL |
35ca5118 KZ |
526 | .B sfdisk |
527 | does not create partition table without partitions by default. The lines with | |
528 | partitions are expected in the script by default. The empty partition table has | |
529 | to be explicitly requested by "label: <name>" script header line without any | |
530 | partitions lines. For example: | |
531 | .RS | |
532 | .sp | |
533 | .B "echo 'label: gpt' | sfdisk /dev/sdb" | |
534 | .sp | |
535 | .RE | |
536 | creates empty GPT partition table. Note that the \fB\-\-append\fR disables this feature. | |
537 | ||
5a829806 | 538 | .SH BACKING UP THE PARTITION TABLE |
689d83de | 539 | It is recommended to save the layout of your devices. |
9a79aa6e KZ |
540 | .B sfdisk |
541 | supports two ways. | |
689d83de BS |
542 | .sp |
543 | Use the \fB\-\-dump\fR option to save a description of the device layout | |
544 | to a text file. The dump format is suitable for later \fBsfdisk\fR input. | |
545 | For example: | |
9a79aa6e KZ |
546 | .RS |
547 | .sp | |
1c4c6024 | 548 | .B "sfdisk \-\-dump /dev/sda > sda.dump" |
9a79aa6e KZ |
549 | .sp |
550 | .RE | |
689d83de | 551 | This can later be restored by: |
9a79aa6e KZ |
552 | .RS |
553 | .sp | |
554 | .B "sfdisk /dev/sda < sda.dump" | |
555 | .RE | |
556 | ||
689d83de BS |
557 | If you want to do a full (binary) backup of all sectors where the |
558 | partition table is stored, | |
559 | then use the \fB\-\-backup\fR option. It writes the sectors to | |
560 | ~/sfdisk-<device>-<offset>.bak files. The default name of the backup file can | |
561 | be changed with the \fB\-\-backup\-file\fR option. The backup files | |
562 | contain only raw data from the \fIdevice\fR. | |
563 | Note that the same concept of backup files is used by | |
564 | .BR wipefs (8). | |
565 | For example: | |
9a79aa6e KZ |
566 | .RS |
567 | .sp | |
1c4c6024 | 568 | .B "sfdisk \-\-backup /dev/sda" |
9a79aa6e KZ |
569 | .sp |
570 | .RE | |
689d83de | 571 | The GPT header can later be restored by: |
9a79aa6e KZ |
572 | .RS |
573 | .sp | |
c805c369 BS |
574 | .nf |
575 | .B "dd if=~/sfdisk-sda-0x00000200.bak of=/dev/sda \e" | |
576 | .B " seek=$((0x00000200)) bs=1 conv=notrunc" | |
577 | .fi | |
9a79aa6e KZ |
578 | .sp |
579 | .RE | |
689d83de BS |
580 | Note that \fBsfdisk\fR since version 2.26 no longer provides the \fB\-I\fR option to |
581 | restore sectors. | |
5593132a | 582 | .BR dd (1) |
9a79aa6e KZ |
583 | provides all necessary functionality. |
584 | ||
da25898b KZ |
585 | .SH COLORS |
586 | Implicit coloring can be disabled by an empty file \fI/etc/terminal-colors.d/sfdisk.disable\fR. | |
587 | ||
588 | See | |
589 | .BR terminal-colors.d (5) | |
590 | for more details about colorization configuration. The logical color names | |
591 | supported by | |
592 | .B sfdisk | |
593 | are: | |
594 | .TP | |
595 | .B header | |
596 | The header of the output tables. | |
597 | .TP | |
598 | .B warn | |
599 | The warning messages. | |
600 | .TP | |
601 | .B welcome | |
602 | The welcome message. | |
603 | ||
68e422ec | 604 | .SH ENVIRONMENT |
47dd6918 KZ |
605 | .IP SFDISK_DEBUG=all |
606 | enables sfdisk debug output. | |
68e422ec KZ |
607 | .IP LIBFDISK_DEBUG=all |
608 | enables libfdisk debug output. | |
609 | .IP LIBBLKID_DEBUG=all | |
610 | enables libblkid debug output. | |
611 | .IP LIBSMARTCOLS_DEBUG=all | |
612 | enables libsmartcols debug output. | |
613 | ||
67e63c12 MK |
614 | .SH NOTES |
615 | Since version 2.26 \fBsfdisk\fR no longer provides the \fB\-R\fR or | |
616 | \fB\-\-re\-read\fR option to force the kernel to reread the partition table. | |
617 | Use \fBblockdev \-\-rereadpt\fR instead. | |
618 | .PP | |
619 | Since version 2.26 \fBsfdisk\fR does not provide the \fB\-\-DOS\fR, \fB\-\-IBM\fR, \fB\-\-DOS\-extended\fR, | |
620 | \fB\-\-unhide\fR, \fB\-\-show\-extended\fR, \fB\-\-cylinders\fR, \fB\-\-heads\fR, \fB\-\-sectors\fR, | |
621 | \fB\-\-inside\-outer\fR, \fB\-\-not\-inside\-outer\fR options. | |
622 | ||
ade04bb8 MK |
623 | .SH AUTHORS |
624 | Karel Zak <kzak@redhat.com> | |
625 | .PP | |
626 | The current sfdisk implementation is based on the original sfdisk | |
627 | from Andries E. Brouwer. | |
628 | ||
5a829806 | 629 | .SH SEE ALSO |
612721db | 630 | .BR fdisk (8), |
5aac7429 | 631 | .BR cfdisk (8), |
c64061c9 VD |
632 | .BR parted (8), |
633 | .BR partprobe (8), | |
5593132a | 634 | .BR partx (8) |
689d83de | 635 | |
86d62711 | 636 | .SH AVAILABILITY |
601d12fb | 637 | The sfdisk command is part of the util-linux package and is available from |
d673b74e | 638 | https://www.kernel.org/pub/linux/utils/util-linux/. |