]>
Commit | Line | Data |
---|---|---|
295b3979 | 1 | //po4a: entry man manual |
c6a568fc MB |
2 | //// |
3 | sfdisk.8 -- man page for sfdisk | |
4 | Copyright (C) 2014 Karel Zak <kzak@redhat.com> | |
5 | ||
6 | Permission is granted to make and distribute verbatim copies of this | |
7 | manual provided the copyright notice and this permission notice are | |
8 | preserved on all copies. | |
9 | ||
10 | Permission is granted to copy and distribute modified versions of this | |
11 | manual under the conditions for verbatim copying, provided that the | |
12 | entire resulting derived work is distributed under the terms of a | |
13 | permission notice identical to this one. | |
14 | //// | |
15 | = sfdisk(8) | |
16 | :doctype: manpage | |
17 | :man manual: System Administration | |
18 | :man source: util-linux {release-version} | |
19 | :page-layout: base | |
20 | :command: sfdisk | |
299604dd MB |
21 | :plus: + |
22 | :asterisk: * | |
c6a568fc MB |
23 | |
24 | == NAME | |
25 | ||
26 | sfdisk - display or manipulate a disk partition table | |
27 | ||
28 | == SYNOPSIS | |
29 | ||
4d297435 | 30 | *sfdisk* [options] _device_ [*-N* _partition-number_] |
c6a568fc | 31 | |
89456be7 | 32 | *sfdisk* [options] _command_ |
c6a568fc MB |
33 | |
34 | == DESCRIPTION | |
35 | ||
36 | *sfdisk* is a script-oriented tool for partitioning any block device. It runs in interactive mode if executed on a terminal (stdin refers to a terminal). | |
37 | ||
38 | Since version 2.26 *sfdisk* supports MBR (DOS), GPT, SUN and SGI disk labels, but no longer provides any functionality for CHS (Cylinder-Head-Sector) addressing. CHS has never been important for Linux, and this addressing concept does not make any sense for new devices. | |
39 | ||
40 | *sfdisk* protects the first disk sector when create a new disk label. The option *--wipe always* disables this protection. Note that *fdisk*(8) and *cfdisk*(8) completely erase this area by default. | |
41 | ||
42 | *sfdisk* (since version 2.26) *aligns the start and end of partitions* to block-device I/O limits when relative sizes are specified, when the default values are used or when multiplicative suffixes (e.g., MiB) are used for sizes. It is possible that partition size will be optimized (reduced or enlarged) due to alignment if the start offset is specified exactly in sectors and partition size relative or by multiplicative suffixes. | |
43 | ||
44 | The recommended way is not to specify start offsets at all and specify partition size in MiB, GiB (or so). In this case *sfdisk* aligns all partitions to block-device I/O limits (or when I/O limits are too small then to megabyte boundary to keep disk layout portable). If this default behaviour is unwanted (usually for very small partitions) then specify offsets and sizes in sectors. In this case *sfdisk* entirely follows specified numbers without any optimization. | |
45 | ||
46 | *sfdisk* does not create the standard system partitions for SGI and SUN disk labels like *fdisk*(8) does. It is necessary to explicitly create all partitions including whole-disk system partitions. | |
47 | ||
bd67ca44 | 48 | *sfdisk* uses *BLKRRPART* (reread partition table) ioctl to make sure that the device is not used by system or other tools (see also *--no-reread*). It's possible that this feature or another *sfdisk* activity races with *systemd-udevd*(8). The recommended way how to avoid possible collisions is to use *--lock* option. The exclusive lock will cause *systemd-udevd* to skip the event handling on the device. |
c6a568fc MB |
49 | |
50 | The *sfdisk* prompt is only a hint for users and a displayed partition number does not mean that the same partition table entry will be created (if *-N* not specified), especially for tables with gaps. | |
51 | ||
52 | == COMMANDS | |
53 | ||
54 | The commands are mutually exclusive. | |
55 | ||
56 | [*-N* _partition-number_] __device__:: | |
299604dd MB |
57 | The default *sfdisk* command is to read the specification for the desired partitioning of _device_ from standard input, and then create a partition table according to the specification. See below for the description of the input format. If standard input is a terminal, then *sfdisk* starts an interactive session. |
58 | + | |
59 | If the option *-N* is specified, then the changes are applied to the partition addressed by _partition-number_. The unspecified fields of the partition are not modified. | |
60 | + | |
61 | Note that it's possible to address an unused partition with *-N*. For example, an MBR always contains 4 partitions, but the number of used partitions may be smaller. In this case *sfdisk* follows the default values from the partition table and does not use built-in defaults for the unused partition given with *-N*. See also *--append*. | |
c6a568fc MB |
62 | |
63 | *-A*, *--activate* __device__ [__partition-number__...]:: | |
299604dd MB |
64 | Switch on the bootable flag for the specified partitions and switch off the bootable flag on all unspecified partitions. The special placeholder '-' may be used instead of the partition numbers to switch off the bootable flag on all partitions. |
65 | + | |
66 | The activation command is supported for MBR and PMBR only. If a GPT label is detected, then *sfdisk* prints warning and automatically enters PMBR. | |
67 | + | |
68 | If no _partition-number_ is specified, then list the partitions with an enabled flag. | |
c6a568fc | 69 | |
c4762c43 KZ |
70 | *--backup-pt-sectors* _device_:: |
71 | Back up the current partition table sectors in binary format and exit. See the *BACKING UP THE PARTITION TABLE* section. | |
72 | ||
c6a568fc | 73 | *--delete* _device_ [__partition-number__...]:: |
299604dd | 74 | Delete all or the specified partitions. |
c6a568fc MB |
75 | |
76 | *-d*, *--dump* _device_:: | |
c83a52f0 | 77 | Dump the partitions of a device in a format that is usable as input to *sfdisk*. See the *BACKING UP THE PARTITION TABLE* section. |
c6a568fc MB |
78 | |
79 | *-g*, *--show-geometry* [__device__...]:: | |
299604dd | 80 | List the geometry of all or the specified devices. For backward compatibility the deprecated option *--show-pt-geometry* have the same meaning as this one. |
c6a568fc MB |
81 | |
82 | *-J*, *--json* _device_:: | |
299604dd | 83 | Dump the partitions of a device in JSON format. Note that *sfdisk* is not able to use JSON as input format. |
c6a568fc MB |
84 | |
85 | *-l*, *--list* [__device__...]:: | |
299604dd | 86 | List the partitions of all or the specified devices. This command can be used together with *--verify*. |
c6a568fc MB |
87 | |
88 | *-F*, *--list-free* [__device__...]:: | |
299604dd | 89 | List the free unpartitioned areas on all or the specified devices. |
c6a568fc MB |
90 | |
91 | *--part-attrs* _device partition-number_ [__attributes__]:: | |
299604dd MB |
92 | Change the GPT partition attribute bits. If _attributes_ is not specified, then print the current partition settings. The _attributes_ argument is a comma- or space-delimited list of bits numbers or bit names. For example, the string "RequiredPartition,50,51" sets three bits. The currently supported attribute bits are: |
93 | + | |
94 | *Bit 0 (RequiredPartition)*;; | |
95 | If this bit is set, the partition is required for the platform to function. The creator of the partition indicates that deletion or modification of the contents can result in loss of platform features or failure for the platform to boot or operate. The system cannot function normally if this partition is removed, and it should be considered part of the hardware of the system. | |
96 | *Bit 1 (NoBlockIOProtocol)*;; | |
97 | EFI firmware should ignore the content of the partition and not try to read from it. | |
98 | *Bit 2 (LegacyBIOSBootable)*;; | |
99 | The partition may be bootable by legacy BIOS firmware. | |
100 | *Bits 3-47*;; | |
101 | Undefined and must be zero. Reserved for expansion by future versions of the UEFI specification. | |
102 | *Bits 48-63*;; | |
103 | Reserved for GUID specific use. The use of these bits will vary depending on the partition type. For example Microsoft uses bit 60 to indicate read-only, 61 for shadow copy of another partition, 62 for hidden partitions and 63 to disable automount. | |
c6a568fc MB |
104 | |
105 | *--part-label* _device partition-number_ [__label__]:: | |
299604dd | 106 | Change the GPT partition name (label). If _label_ is not specified, then print the current partition label. |
c6a568fc MB |
107 | |
108 | *--part-type* _device partition-number_ [__type__]:: | |
299604dd MB |
109 | Change the partition type. If _type_ is not specified, then print the current partition type. |
110 | + | |
111 | The _type_ argument is hexadecimal for MBR, GUID for GPT, type alias (e.g. "linux") or type shortcut (e.g. 'L'). For backward compatibility the options *-c* and *--id* have the same meaning as this one. | |
c6a568fc MB |
112 | |
113 | *--part-uuid* _device partition-number_ [__uuid__]:: | |
299604dd | 114 | Change the GPT partition UUID. If _uuid_ is not specified, then print the current partition UUID. |
c6a568fc MB |
115 | |
116 | *--disk-id* _device_ [__id__]:: | |
299604dd | 117 | Change the disk identifier. If _id_ is not specified, then print the current identifier. The identifier is UUID for GPT or unsigned integer for MBR. |
c6a568fc MB |
118 | |
119 | *-r*, *--reorder* _device_:: | |
299604dd | 120 | Renumber the partitions, ordering them by their start offset. |
c6a568fc MB |
121 | |
122 | *-s*, *--show-size* [__device__...]:: | |
299604dd | 123 | List the sizes of all or the specified devices in units of 1024 byte size. This command is DEPRECATED in favour of *blockdev*(8). |
c6a568fc MB |
124 | |
125 | *-T*, *--list-types*:: | |
299604dd | 126 | Print all supported types for the current disk label or the label specified by *--label*. |
c6a568fc MB |
127 | |
128 | *-V*, *--verify* [__device__...]:: | |
299604dd | 129 | Test whether the partition table and partitions seem correct. |
c6a568fc MB |
130 | |
131 | *--relocate* _oper_ _device_:: | |
299604dd MB |
132 | Relocate partition table header. This command is currently supported for GPT header only. The argument _oper_ can be: |
133 | + | |
134 | *gpt-bak-std*;; | |
135 | Move GPT backup header to the standard location at the end of the device. | |
136 | *gpt-bak-mini*;; | |
137 | Move GPT backup header behind the last partition. Note that UEFI standard requires the backup header at the end of the device and partitioning tools can automatically relocate the header to follow the standard. | |
c6a568fc MB |
138 | |
139 | == OPTIONS | |
140 | ||
141 | *-a*, *--append*:: | |
299604dd MB |
142 | Don't create a new partition table, but only append the specified partitions. |
143 | + | |
144 | Note that unused partition maybe be re-used in this case although it is not the last partition in the partition table. See also *-N* to specify entry in the partition table. | |
c6a568fc MB |
145 | |
146 | *-b*, *--backup*:: | |
03fdf118 | 147 | Back up the current partition table sectors before starting the partitioning. The default backup file name is _~/sfdisk-<device>-<offset>.bak_; to use another name see option *-O*, *--backup-file*. See section *BACKING UP THE PARTITION TABLE* for more details. |
c6a568fc MB |
148 | |
149 | *--color*[**=**__when__]:: | |
299604dd | 150 | Colorize the output. The optional argument _when_ can be *auto*, *never* or *always*. If the _when_ argument is omitted, it defaults to *auto*. The colors can be disabled; for the current built-in default see the *--help* output. See also the *COLORS* section. |
c6a568fc MB |
151 | |
152 | *-f*, *--force*:: | |
299604dd | 153 | Disable all consistency checking. |
c6a568fc MB |
154 | |
155 | *--Linux*:: | |
299604dd | 156 | Deprecated and ignored option. Partitioning that is compatible with Linux (and other modern operating systems) is the default. |
c6a568fc MB |
157 | |
158 | *--lock*[=_mode_]:: | |
bd67ca44 | 159 | Use exclusive BSD lock for device or file it operates. The optional argument _mode_ can be *yes*, *no* (or 1 and 0) or *nonblock*. If the _mode_ argument is omitted, it defaults to *yes*. This option overwrites environment variable *$LOCK_BLOCK_DEVICE*. The default is not to use any lock at all, but it's recommended to avoid collisions with *systemd-udevd*(8) or other tools. |
c6a568fc MB |
160 | |
161 | *-n*, *--no-act*:: | |
299604dd | 162 | Do everything except writing to the device. |
c6a568fc MB |
163 | |
164 | *--no-reread*:: | |
299604dd | 165 | Do not check through the re-read-partition-table ioctl whether the device is in use. |
c6a568fc MB |
166 | |
167 | *--no-tell-kernel*:: | |
299604dd | 168 | Don't tell the kernel about partition changes. This option is recommended together with *--no-reread* to modify a partition on used disk. The modified partition should not be used (e.g., mounted). |
c6a568fc MB |
169 | |
170 | *-O*, *--backup-file* _path_:: | |
299604dd | 171 | Override the default backup file name. Note that the device name and offset are always appended to the file name. |
c6a568fc MB |
172 | |
173 | *--move-data*[**=**__path__]:: | |
299604dd MB |
174 | Move data after partition relocation, for example when moving the beginning of a partition to another place on the disk. The size of the partition has to remain the same, the new and old location may overlap. This option requires option *-N* in order to be processed on one specific partition only. |
175 | + | |
e6743239 | 176 | The optional _path_ specifies log file name. The log file contains information about all read/write operations on the partition data. The word "@default" as a _path_ forces *sfdisk* to use _~/sfdisk-<devname>.move_ for the log. The log is optional since v2.35. |
299604dd MB |
177 | + |
178 | Note that this operation is risky and not atomic. *Don't forget to backup your data!* | |
179 | + | |
180 | See also *--move-use-fsync*. | |
181 | + | |
182 | In the example below, the first command creates a 100MiB free area before the first partition and moves the data it contains (e.g., a filesystem), the next command creates a new partition from the free space (at offset 2048), and the last command reorders partitions to match disk order (the original sdc1 will become sdc2). | |
183 | + | |
897e5450 KZ |
184 | ____ |
185 | *echo '+100M,' | sfdisk --move-data /dev/sdc -N 1* | |
186 | ||
187 | *echo '2048,' | sfdisk /dev/sdc --append* | |
188 | ||
189 | *sfdisk /dev/sdc --reorder* | |
190 | ____ | |
c6a568fc MB |
191 | |
192 | *--move-use-fsync*:: | |
299604dd | 193 | Use the *fsync*(2) system call after each write when moving data to a new location by *--move-data*. |
c6a568fc MB |
194 | |
195 | *-o*, *--output* _list_:: | |
299604dd MB |
196 | Specify which output columns to print. Use *--help* to get a list of all supported columns. |
197 | + | |
198 | The default list of columns may be extended if _list_ is specified in the format _{plus}list_ (e.g., *-o +UUID*). | |
199 | //TRANSLATORS: Keep {plus} untranslated. | |
c6a568fc MB |
200 | |
201 | *-q*, *--quiet*:: | |
299604dd | 202 | Suppress extra info messages. |
c6a568fc MB |
203 | |
204 | *-u*, *--unit S*:: | |
299604dd | 205 | Deprecated option. Only the sector unit is supported. This option is not supported when using the *--show-size* command. |
c6a568fc MB |
206 | |
207 | *-X*, *--label* _type_:: | |
299604dd | 208 | Specify the disk label type (e.g., *dos*, *gpt*, ...). If this option is not given, then *sfdisk* defaults to the existing label, but if there is no label on the device yet, then the type defaults to *dos*. The default or the current label may be overwritten by the "label: <name>" script header line. The option *--label* does not force *sfdisk* to create empty disk label (see the *EMPTY DISK LABEL* section below). |
c6a568fc MB |
209 | |
210 | *-Y*, *--label-nested* _type_:: | |
299604dd | 211 | Force editing of a nested disk label. The primary disk label has to exist already. This option allows editing for example a hybrid/protective MBR on devices with GPT. |
c6a568fc MB |
212 | |
213 | *-w*, *--wipe* _when_:: | |
299604dd | 214 | Wipe filesystem, RAID and partition-table signatures from the device, in order to avoid possible collisions. The argument _when_ can be *auto*, *never* or *always*. When this option is not given, the default is *auto*, in which case signatures are wiped only when in interactive mode; except the old partition-table signatures which are always wiped before create a new partition-table if the argument _when_ is not *never*. The *auto* mode also does not wipe the first sector (boot sector), it is necessary to use the *always* mode to wipe this area. In all cases detected signatures are reported by warning messages before a new partition table is created. See also the *wipefs*(8) command. |
c6a568fc MB |
215 | |
216 | *-W*, *--wipe-partitions* _when_:: | |
bd67ca44 | 217 | Wipe filesystem, RAID and partition-table signatures from a newly created partition, in order to avoid possible collisions. The argument _when_ can be *auto*, *never* or *always*. When this option is not given, the default is *auto*, in which case signatures are wiped only when in interactive mode and after confirmation by user. In all cases detected signatures are reported by warning messages after a new partition is created. See also *wipefs*(8) command. |
c6a568fc MB |
218 | |
219 | *-v*, *--version*:: | |
299604dd | 220 | Display version information and exit. |
c6a568fc MB |
221 | |
222 | *-h*, *--help*:: | |
299604dd | 223 | Display help text and exit. |
c6a568fc MB |
224 | |
225 | == INPUT FORMATS | |
226 | ||
227 | *sfdisk* supports two input formats and generic header lines. | |
228 | ||
229 | === Header lines | |
230 | ||
231 | The optional header lines specify generic information that apply to the partition table. The header-line format is: | |
232 | ||
233 | *<name>: <value>* | |
234 | ||
235 | The currently recognized headers are: | |
236 | ||
237 | *unit*:: | |
299604dd | 238 | Specify the partitioning unit. The only supported unit is *sectors*. |
c6a568fc | 239 | *label*:: |
299604dd | 240 | Specify the partition table type. For example *dos* or *gpt*. |
c6a568fc | 241 | *label-id*:: |
299604dd | 242 | Specify the partition table identifier. It should be a hexadecimal number (with a 0x prefix) for MBR and a UUID for GPT. |
c6a568fc | 243 | *first-lba*:: |
b3d80e63 | 244 | Specify the first usable sector for GPT partitions. This header is ignored if the script and device sector size differ. In this case *sfdisk* uses label specific default. |
c6a568fc | 245 | *last-lba*:: |
b3d80e63 | 246 | Specify the last usable sector for GPT partitions. This header is ignored if the script and device sector size differ. In this case *sfdisk* uses label specific default. |
c6a568fc | 247 | *table-length*:: |
299604dd | 248 | Specify the maximal number of GPT partitions. |
c6a568fc | 249 | *grain*:: |
299604dd | 250 | Specify minimal size in bytes used to calculate partitions alignment. The default is 1MiB and it's strongly recommended to use the default. Do not modify this variable if you're not sure. |
c6a568fc | 251 | *sector-size*:: |
b3d80e63 | 252 | Specify sector size. *sfdisk* always uses device sector size. Since version 2.39 *sfdisk* recalculates sizes from dump if the script and device sector size differ. |
c6a568fc MB |
253 | |
254 | Note that it is only possible to use header lines before the first partition is specified in the input. | |
255 | ||
256 | === Unnamed-fields format | |
257 | ||
258 | ____ | |
259 | _start size type bootable_ | |
260 | ____ | |
261 | ||
262 | where each line fills one partition descriptor. | |
263 | ||
534679d0 | 264 | Fields are separated by whitespace, comma (recommended) or semicolon possibly followed by whitespace; initial and trailing whitespace is ignored. Numbers can be octal, decimal or hexadecimal; decimal is the default. When a field is absent, empty or specified as '-' a default value is used. But when the *-N* option (change a single partition) is given, the default for each field is its previous value. |
c6a568fc | 265 | |
bd67ca44 | 266 | The default value of _start_ is the first non-assigned sector aligned according to device I/O limits. The default start offset for the first partition is 1 MiB. If the offset is followed by the multiplicative suffixes (KiB, MiB, GiB, TiB, PiB, EiB, ZiB and YiB), then the number is interpreted as offset in bytes. Since v2.38 when the *-N* option (change a single partition) is given, a '{plus}' can be used to enlarge partition by move start of the partition if there is a free space before the partition. |
c6a568fc | 267 | |
299604dd MB |
268 | //TRANSLATORS: Keep {plus} untranslated. |
269 | The default value of _size_ indicates "as much as possible"; i.e., until the next partition or end-of-device. A numerical argument is by default interpreted as a number of sectors, however if the size is followed by one of the multiplicative suffixes (KiB, MiB, GiB, TiB, PiB, EiB, ZiB and YiB) then the number is interpreted as the size of the partition in bytes and it is then aligned according to the device I/O limits. A '{plus}' can be used instead of a number to enlarge the partition as much as possible. Note '{plus}' is equivalent to the default behaviour for a new partition; existing partitions will be resized as required. | |
c6a568fc MB |
270 | |
271 | The partition _type_ is given in hex for MBR (DOS) where 0x prefix is optional; a GUID string for GPT; a shortcut or an alias. It's recommended to use two letters for MBR hex codes to avoid collision between deprecated shortcut 'E' and '0E' MBR hex code. For backward compatibility *sfdisk* tries to interpret _type_ as a shortcut as a first possibility in partitioning scripts although on other places (e.g. *--part-type* command) it tries shortcuts as the last possibility. | |
272 | ||
273 | Since v2.36 libfdisk supports partition type aliases as extension to shortcuts. The alias is a simple human readable word (e.g. "linux"). | |
274 | ||
275 | Since v2.37 libfdisk supports partition type names on input, ignoring the case of the characters and all non-alphanumeric and non-digit characters in the name (e.g. "Linux /usr x86" is the same as "linux usr-x86"). | |
276 | ||
277 | Supported shortcuts and aliases: | |
278 | ||
279 | *L - alias 'linux'*:: | |
299604dd | 280 | Linux; means 83 for MBR and 0FC63DAF-8483-4772-8E79-3D69D8477DE4 for GPT. |
c6a568fc MB |
281 | |
282 | *S - alias 'swap'*:: | |
299604dd | 283 | swap area; means 82 for MBR and 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F for GPT |
c6a568fc MB |
284 | |
285 | *Ex - alias 'extended'*:: | |
299604dd | 286 | MBR extended partition; means 05 for MBR. The original shortcut 'E' is deprecated due to collision with 0x0E MBR partition type. |
c6a568fc MB |
287 | |
288 | *H - alias 'home'*:: | |
299604dd | 289 | home partition; means 933AC7E1-2EB4-4F13-B844-0E14E2AEF915 for GPT |
c6a568fc MB |
290 | |
291 | *U - alias 'uefi'*:: | |
299604dd | 292 | EFI System partition, means EF for MBR and C12A7328-F81F-11D2-BA4B-00A0C93EC93B for GPT |
c6a568fc MB |
293 | |
294 | *R - alias 'raid'*:: | |
299604dd | 295 | Linux RAID; means FD for MBR and A19D880F-05FC-4D3B-A006-743F0F84911E for GPT |
c6a568fc MB |
296 | |
297 | *V - alias 'lvm'*:: | |
299604dd | 298 | LVM; means 8E for MBR and E6D6D379-F507-44C2-A23C-238F2A3DF928 for GPT |
c6a568fc MB |
299 | |
300 | The default _type_ value is _linux_. | |
301 | ||
302 | The shortcut 'X' for Linux extended partition (85) is deprecated in favour of 'Ex'. | |
303 | ||
299604dd MB |
304 | // TRANSLATORS: Keep {asterisk} untranslated. |
305 | _bootable_ is specified as [*{asterisk}*|*-*], with as default not-bootable. The value of this field is irrelevant for Linux - when Linux runs it has been booted already - but it might play a role for certain boot loaders and for other operating systems. | |
c6a568fc MB |
306 | |
307 | === Named-fields format | |
308 | ||
309 | This format is more readable, robust, extensible and allows specifying additional information (e.g., a UUID). It is recommended to use this format to keep your scripts more readable. | |
310 | ||
311 | ____ | |
312 | [_device_ *:*] _name_[**=**__value__], ... | |
313 | ____ | |
314 | ||
315 | The _device_ field is optional. *sfdisk* extracts the partition number from the device name. It allows specifying the partitions in random order. This functionality is mostly used by *--dump*. Don't use it if you are not sure. | |
316 | ||
534679d0 KZ |
317 | The _value_ can be between quotation marks (e.g., name="This is partition name"). The fields *start=* and *size=* support '{plus}' and '-' in the same way as *Unnamed-fields format*. |
318 | ||
319 | The currently supported fields are: | |
c6a568fc MB |
320 | |
321 | **start=**__number__:: | |
bd67ca44 | 322 | The first non-assigned sector aligned according to device I/O limits. The default start offset for the first partition is 1 MiB. If the offset is followed by the multiplicative suffixes (KiB, MiB, GiB, TiB, PiB, EiB, ZiB and YiB), then the number is interpreted as offset in bytes. |
c6a568fc MB |
323 | |
324 | **size=**__number__:: | |
299604dd | 325 | Specify the partition size in sectors. The number may be followed by the multiplicative suffixes (KiB, MiB, GiB, TiB, PiB, EiB, ZiB and YiB), then it's interpreted as size in bytes and the size is aligned according to device I/O limits. |
c6a568fc MB |
326 | |
327 | *bootable*:: | |
299604dd | 328 | Mark the partition as bootable. |
c6a568fc MB |
329 | |
330 | **attrs=**__string__:: | |
299604dd | 331 | Partition attributes, usually GPT partition attribute bits. See *--part-attrs* for more details about the GPT-bits string format. |
c6a568fc MB |
332 | |
333 | **uuid=**__string__:: | |
299604dd | 334 | GPT partition UUID. |
c6a568fc MB |
335 | |
336 | **name=**__string__:: | |
299604dd | 337 | GPT partition name. |
c6a568fc MB |
338 | |
339 | **type=**__code__:: | |
299604dd | 340 | A hexadecimal number (without 0x) for an MBR partition, a GUID for a GPT partition, a shortcut as for unnamed-fields format or a type name (e.g. type="Linux /usr (x86)"). See above the section about the unnamed-fields format for more details. For backward compatibility the *Id=* field has the same meaning. |
c6a568fc MB |
341 | |
342 | == EMPTY DISK LABEL | |
343 | ||
344 | *sfdisk* does not create partition table without partitions by default. The lines with partitions are expected in the script by default. The empty partition table has to be explicitly requested by "label: <name>" script header line without any partitions lines. For example: | |
345 | ||
346 | ____ | |
347 | *echo 'label: gpt' | sfdisk /dev/sdb* | |
348 | ____ | |
349 | ||
350 | creates empty GPT partition table. Note that the *--append* disables this feature. | |
351 | ||
352 | == BACKING UP THE PARTITION TABLE | |
353 | ||
354 | It is recommended to save the layout of your devices. *sfdisk* supports two ways. | |
355 | ||
c4762c43 | 356 | === Dump in sfdisk compatible format |
c6a568fc | 357 | |
c4762c43 KZ |
358 | Use the *--dump* command to save a description of the device layout to a text file. |
359 | The dump format is suitable for later *sfdisk* input. For example: | |
c6a568fc MB |
360 | ____ |
361 | *sfdisk --dump /dev/sda > sda.dump* | |
362 | ____ | |
363 | ||
364 | This can later be restored by: | |
c6a568fc MB |
365 | ____ |
366 | *sfdisk /dev/sda < sda.dump* | |
367 | ____ | |
368 | ||
fe834846 | 369 | Note that *sfdisk* completely restores partition types and partition UUIDs. This could potentially become problematic if you duplicate the same layout to different disks, as it may result in duplicate UUIDs within your system. |
60c81b32 | 370 | |
c4762c43 KZ |
371 | === Full binary backup |
372 | ||
373 | If you want to do a full binary backup of all sectors where the partition table is stored, then use the *--backup-pt-sectors* command. It writes the sectors to _~/sfdisk-<device>-<offset>.bak_ files. The default name of the backup file can be changed with the *--backup-file* option. The backup files contain only raw data from the _device_. For example: | |
c6a568fc MB |
374 | |
375 | ____ | |
c4762c43 | 376 | *sfdisk --backup-pt-sectors /dev/sda* |
c6a568fc MB |
377 | ____ |
378 | ||
379 | The GPT header can later be restored by: | |
380 | ||
381 | ____ | |
c4762c43 KZ |
382 | *dd if=~/sfdisk-sda-0x00000200.bak of=/dev/sda seek=$\((0x00000200)) bs=1 conv=notrunc* |
383 | ____ | |
384 | ||
385 | ||
344b0cd4 | 386 | It's also possible to use the *--backup* option to create the same backup immediately after startup for other *sfdisk* commands. For example, backup partition table before deleting all partitions from partition table: |
c4762c43 KZ |
387 | ____ |
388 | *sfdisk --backup --delete /dev/sda* | |
c6a568fc MB |
389 | ____ |
390 | ||
c4762c43 | 391 | |
03fdf118 KZ |
392 | The same concept of backup files is used by *wipefs*(8). |
393 | ||
c6a568fc MB |
394 | Note that *sfdisk* since version 2.26 no longer provides the *-I* option to restore sectors. *dd*(1) provides all necessary functionality. |
395 | ||
6c62faf1 | 396 | include::man-common/colors.adoc[] |
c6a568fc | 397 | |
6c62faf1 | 398 | The logical color names supported by *sfdisk* are: |
c6a568fc MB |
399 | |
400 | *header*:: | |
299604dd | 401 | The header of the output tables. |
c6a568fc | 402 | *warn*:: |
299604dd | 403 | The warning messages. |
c6a568fc | 404 | *welcome*:: |
299604dd | 405 | The welcome message. |
c6a568fc MB |
406 | |
407 | == ENVIRONMENT | |
408 | ||
e6743239 | 409 | *SFDISK_DEBUG*=all:: |
299604dd | 410 | enables *sfdisk* debug output. |
e6743239 | 411 | *LIBFDISK_DEBUG*=all:: |
299604dd | 412 | enables libfdisk debug output. |
e6743239 | 413 | *LIBBLKID_DEBUG*=all:: |
299604dd | 414 | enables libblkid debug output. |
e6743239 | 415 | *LIBSMARTCOLS_DEBUG*=all:: |
299604dd | 416 | enables libsmartcols debug output. |
e6743239 | 417 | *LOCK_BLOCK_DEVICE*=<mode>:: |
299604dd | 418 | use exclusive BSD lock. The mode is "1" or "0". See *--lock* for more details. |
c6a568fc MB |
419 | |
420 | == NOTES | |
421 | ||
422 | Since version 2.26 *sfdisk* no longer provides the *-R* or *--re-read* option to force the kernel to reread the partition table. Use *blockdev --rereadpt* instead. | |
423 | ||
424 | Since version 2.26 *sfdisk* does not provide the *--DOS*, *--IBM*, *--DOS-extended*, *--unhide*, *--show-extended*, *--cylinders*, *--heads*, *--sectors*, *--inside-outer*, *--not-inside-outer* options. | |
425 | ||
534679d0 KZ |
426 | == EXAMPLES |
427 | ||
428 | *sfdisk --list --label-nested=mbr /dev/sda*:: | |
429 | Print protective MBR on device with GPT disk label. | |
430 | ||
c417ce68 | 431 | *echo -e ',10M,L\n,10M,L\n,+,\n' | sfdisk /dev/sdc*:: |
534679d0 KZ |
432 | Create three Linux partitions, with the default start, the size of the first two partitions is 10MiB, and the last partition fills all available space on the device. |
433 | ||
434 | *echo -e 'size=10M, type=L\n size=10M, type=L\n size=+\n' | sfdisk /dev/sdc*:: | |
435 | The same as the previous example, but in named-fields format. | |
436 | ||
437 | *echo -e 'type=swap' | sfdisk -N 3 /dev/sdc*:: | |
344b0cd4 | 438 | Set type of the 3rd partition to 'swap'. |
534679d0 KZ |
439 | |
440 | *sfdisk --part-type /dev/sdc 3 swap*:: | |
441 | The same as the previous example, but without script use. | |
442 | ||
443 | *sfdisk --delete /dev/sdc 2*:: | |
444 | Delete 2nd partition. | |
445 | ||
897e5450 | 446 | *echo "\+,+" | sfdisk -N 3 --move-data /dev/sdc*:: |
534679d0 KZ |
447 | Enlarge 3rd partition in both directions, move start to use free space before the partition and enlarge the size to use all free space after to the partition, and move partition data too. |
448 | ||
c6a568fc MB |
449 | == AUTHORS |
450 | ||
451 | mailto:kzak@redhat.com[Karel Zak] | |
452 | ||
453 | The current *sfdisk* implementation is based on the original *sfdisk* from Andries E. Brouwer. | |
454 | ||
455 | == SEE ALSO | |
456 | ||
457 | *fdisk*(8), | |
458 | *cfdisk*(8), | |
459 | *parted*(8), | |
460 | *partprobe*(8), | |
461 | *partx*(8) | |
462 | ||
625e9c61 | 463 | include::man-common/bugreports.adoc[] |
c6a568fc | 464 | |
625e9c61 | 465 | include::man-common/footer.adoc[] |
c6a568fc MB |
466 | |
467 | ifdef::translation[] | |
625e9c61 | 468 | include::man-common/translation.adoc[] |
c6a568fc | 469 | endif::[] |