Parted: Difference between revisions
(Update zh-hans page link.) |
(→Partition schemes: link to bug reports about parted not supporting +size or similar) |
||
(73 intermediate revisions by 25 users not shown) | |||
Line 3: | Line 3: | ||
[[Category:Commands]] | [[Category:Commands]] | ||
[[Category:GNU]] | [[Category:GNU]] | ||
[[ja: | [[de:GParted]] | ||
[[ru: | [[es:Parted]] | ||
[[ja:Parted]] | |||
[[ru:Parted]] | |||
[[tr:Parted]] | |||
[[zh-hans:Parted]] | [[zh-hans:Parted]] | ||
{{Related articles start}} | {{Related articles start}} | ||
Line 16: | Line 19: | ||
== Installation == | == Installation == | ||
[[Install]] the {{Pkg|parted}} | [[Install]] one of the following packages: | ||
* {{Pkg|parted}} – command-line only. | |||
* {{Pkg|gparted}} – a graphical front-end for ''parted''. | |||
{{Note|1=The {{Pkg|xorg-xhost}} optional dependency is needed for running GParted under [[Wayland]]. [http://gparted-forum.surf4.info/viewtopic.php?id=17682]}} | |||
== Usage == | == Usage == | ||
Line 22: | Line 30: | ||
Parted has two modes: command line and interactive. Parted should always be started with: | Parted has two modes: command line and interactive. Parted should always be started with: | ||
# parted device | # parted ''device'' | ||
where {{ic|''device''}} is | where {{ic|''device''}} is [[block device]] name like {{ic|/dev/sda}}, {{ic|/dev/nvme0n1}}, {{ic|/dev/mmcblk0}}, etc. If you omit the {{ic|''device''}} argument, ''parted'' will attempt to guess which device you want. | ||
=== Command line mode === | === Command line mode === | ||
Line 68: | Line 76: | ||
=== Create new partition table === | === Create new partition table === | ||
{{Warning|If you create a new partition table on a disk with data on it, it will erase all the data on the disk. Make sure this is what you want to do.}} | |||
{{Tip| | |||
* Check that your NVMe drives and Advanced Format hard disk drives are using the [[Advanced Format|optimal logical sector size]] before partitioning. | |||
* Consider performing [[SSD memory cell clearing]] before partitioning an SSD. | |||
}} | |||
You need to (re)create the partition table of a device when it has never been partitioned before, or when you want to change the type of its partition table. Recreating the partition table of a device is also useful when the partition scheme needs to be restructured from scratch. | You need to (re)create the partition table of a device when it has never been partitioned before, or when you want to change the type of its partition table. Recreating the partition table of a device is also useful when the partition scheme needs to be restructured from scratch. | ||
Line 85: | Line 100: | ||
=== Partition schemes === | === Partition schemes === | ||
{{ | {{Expansion|Replace all percentages with explicit MiB aligned sizes to prevent [[Advanced Format#Partition alignment|alignment issues]]. Also warn about the issues.|Talk:Installation guide#Remove parted}} | ||
You can decide the number and size of the partitions the devices should be split into, and which directories will be used to mount the partitions in the installed system (also known as ''mount points''). See [[Partitioning#Partition scheme]] for the required partitions. | You can decide the number and size of the partitions the devices should be split into, and which directories will be used to mount the partitions in the installed system (also known as ''mount points''). See [[Partitioning#Partition scheme]] for the required partitions. | ||
Line 91: | Line 106: | ||
The following command will be used to create partitions: | The following command will be used to create partitions: | ||
(parted) mkpart ''part-type'' ''fs-type'' ''start'' ''end'' | (parted) mkpart ''part-type-or-part-label'' ''fs-type'' ''start'' ''end'' | ||
* {{ic|''part-type''}} is one of {{ic|primary}}, {{ic|extended}} or {{ic|logical}}, | * {{ic|''part-type-or-part-label''}} is interpreted differently based on the partition table: | ||
* {{ic|''fs-type''}} is an identifier chosen among those listed by entering {{ic|help mkpart}} as the closest match to the file system that you will use. The ''mkpart'' command does not actually create the file system: the {{ic|''fs-type''}} parameter will simply be used by ''parted'' to set | ** MBR: the parameter is interpreted as {{ic|''part-type''}}, which can be one of {{ic|primary}}, {{ic|extended}} or {{ic|logical}}. | ||
** GPT: the parameter is interpreted as {{ic|''part-label''}}, which sets the [[PARTLABEL]] attribute of the partition. To avoid setting a partition label, pass an empty quoted string ({{ic|""}}). {{Note|Many tutorials on the web use commands which start with {{ic|mkpart primary}} even for GPT. They are wrong, this would set "primary" as the partition label.}} | |||
* {{ic|''start''}} is the beginning of the partition from the start of the device. It consists of a number followed by a [ | * {{ic|''fs-type''}} is an identifier chosen among those listed by entering {{ic|help mkpart}} as the closest match to the file system that you will use. The ''mkpart'' command does not actually create the file system: the {{ic|''fs-type''}} parameter will simply be used by ''parted'' to set [[Wikipedia:GUID Partition Table#Partition type GUIDs|partition type GUID]] for GPT partitions or [[Wikipedia:Partition type|partition type ID]] for MBR partitions. {{Tip|''parted'' maps types named after Linux native file systems to the same "Linux filesystem" partition type (GUID {{ic|0FC63DAF-8483-4772-8E79-3D69D8477DE4}} or ID {{ic|0x83}}), so it is perfectly safe to e.g. use {{ic|ext2}} for an ''ext4''-formatted partition.}} | ||
* {{ic|''start''}} is the beginning of the partition from the start of the device. It consists of a number followed by a [https://www.gnu.org/software/parted/manual/parted.html#unit unit], for example {{ic|1MiB}} means start at 1 MiB. | |||
* {{ic|''end''}} is the end of the partition from the start of the device (''not'' from the {{ic|''start''}} value). It has the same syntax as {{ic|''start''}}, for example {{ic|100%}} means end at the end of the device (use all the remaining space). | * {{ic|''end''}} is the end of the partition from the start of the device (''not'' from the {{ic|''start''}} value). It has the same syntax as {{ic|''start''}}, for example {{ic|100%}} means end at the end of the device (use all the remaining space). | ||
{{ | {{Tip| | ||
* On a disk with a MBR partition table leave at least 33 512-byte sectors (16.5 KiB) of free unpartitioned space at the end of the disk to allow [[gdisk#Convert between MBR and GPT|converting between MBR and GPT]]. | |||
* If you do not want to leave unused space in the device, make sure that each partition starts where the previous one ends. | |||
}} | |||
{{Note|''parted'' may issue a warning like: | {{Note|1=<nowiki/> | ||
* ''parted'' does not support specifying the start and end of a partition relative to the previous partition. See [https://debbugs.gnu.org/cgi/bugreport.cgi?bug=59176 bug #59176] and [https://debbugs.gnu.org/cgi/bugreport.cgi?bug=55841 bug #55841]. | |||
* ''parted'' may issue a warning like: | |||
Warning: The resulting partition is not properly aligned for best performance. | Warning: The resulting partition is not properly aligned for best performance. | ||
Line 113: | Line 134: | ||
* {{ic|''partition''}} is the number of the partition to be flagged (see the output of the {{ic|print}} command). | * {{ic|''partition''}} is the number of the partition to be flagged (see the output of the {{ic|print}} command). | ||
* {{ic|esp}} is an alias for {{ic|boot}} on GPT. [https://www.gnu.org/software/parted/manual/html_node/set.html] | |||
{{Expansion|Explain the {{ic|boot}}, {{ic|legacy_boot}} and {{ic|esp}} flags and their different usage on MBR and GPT.}} | {{Expansion|Explain the {{ic|boot}}, {{ic|legacy_boot}} and {{ic|esp}} flags and their different usage on MBR and GPT.}} | ||
Line 120: | Line 142: | ||
In every instance, a special bootable [[EFI system partition]] is required. | In every instance, a special bootable [[EFI system partition]] is required. | ||
If creating a new EFI | If creating a new EFI system partition, use the following commands (the recommended size is at least 1 GiB): | ||
(parted) mkpart | (parted) mkpart "EFI system partition" fat32 1MiB 1025MiB | ||
(parted) set 1 esp on | (parted) set 1 esp on | ||
The remaining partition scheme is entirely up to you. For one | The remaining partition scheme is entirely up to you. For one root partition using 100% of remaining space: | ||
(parted) mkpart | (parted) mkpart "root partition" ext4 1025MiB 100% | ||
(parted) type 2 4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709 | |||
For separate | For separate swap (4 GiB) and {{ic|/}} (all remaining space) partitions: | ||
(parted) mkpart | (parted) mkpart "swap partition" linux-swap 1025MiB 5121MiB | ||
(parted) mkpart | (parted) mkpart "root partition" ext4 5121MiB 100% | ||
(parted) type 3 4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709 | |||
And for separate {{ic|/}} ( | And for separate swap (4 GiB), {{ic|/}} (32 GiB) and {{ic|/home}} (all remaining space) partitions: | ||
(parted) mkpart | (parted) mkpart "swap partition" linux-swap 1025MiB 5121MiB | ||
(parted) | (parted) mkpart "root partition" ext4 5121MiB 37889MiB | ||
(parted) mkpart | (parted) type 3 4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709 | ||
(parted) mkpart "home partition" ext4 37889MiB 100% | |||
(parted) set 4 linux-home on | |||
==== BIOS/MBR examples ==== | ==== BIOS/MBR examples ==== | ||
Line 147: | Line 173: | ||
(parted) set 1 boot on | (parted) set 1 boot on | ||
In the following instance, a | In the following instance, a 4 GiB swap partition will be created, followed by a {{ic|/}} partition using all the remaining space: | ||
(parted) mkpart primary | (parted) mkpart primary linux-swap 1MiB 4097MiB | ||
(parted) | (parted) mkpart primary ext4 4097MiB 100% | ||
(parted) | (parted) set 2 boot on | ||
In the final example below, separate {{ic|/boot}} ( | In the final example below, separate {{ic|/boot}} (1 GiB), swap (4 GiB), {{ic|/}} (32 GiB), and {{ic|/home}} (all remaining space) partitions will be created: | ||
(parted) mkpart primary | (parted) mkpart primary ext4 1MiB 1025MiB | ||
(parted) set 1 boot on | (parted) set 1 boot on | ||
(parted) | (parted) set 1 bls_boot on | ||
(parted) mkpart primary linux-swap | (parted) mkpart primary linux-swap 1025MiB 5121MiB | ||
(parted) mkpart primary | (parted) mkpart primary ext4 5121MiB 37889MiB | ||
(parted) mkpart primary ext4 37889MiB 100% | |||
=== Resizing partitions === | === Resizing partitions === | ||
{{Warning| | {{Warning|ext2/3/4 partitions that are being resized must be unmounted and not in use. It is difficult and hazardous to try to edit the root filesystem on a running OS; use a live media/rescue system instead.}} | ||
{{Note| | {{Note| | ||
* You can only move the end of the partition with {{ic|parted}}. | * You can only move the end of the partition with {{ic|parted}}. | ||
* As of parted | * As of parted v3.2 ''resizepart'' may need the use of [[#Interactive mode]].[https://bugs.launchpad.net/ubuntu/+source/parted/+bug/1270203] | ||
* These instructions apply to partitions that have ext2, ext3 or | * These instructions apply to partitions that have ext2, ext3, ext4, or btrfs filesystems. | ||
}} | }} | ||
Line 180: | Line 208: | ||
Where {{ic|''number''}} is the number of the partition you are growing, and {{ic|''end''}} is the new end of the partition (which needs to be larger than the old end). | Where {{ic|''number''}} is the number of the partition you are growing, and {{ic|''end''}} is the new end of the partition (which needs to be larger than the old end). | ||
Then, to grow the filesystem on the partition: | Then, to grow the (ext2/3/4) filesystem on the partition (if {{ic|''size''}} is not specified, it will default to the size of the partition): | ||
# resize2fs /dev/''sdaX'' ''size'' | # resize2fs /dev/''sdaX'' ''size'' | ||
Where {{ic|'' | Or to grow a Btrfs filesystem: | ||
# btrfs filesystem resize ''size'' ''/path/to/mount/point'' | |||
Where {{ic|''/path/to/mount/point''}} stands for the mount point of the partition you are growing, and {{ic|''size''}} in the form {{ic|16G}} or {{ic|+1G}} is the new size or modification of the partition. Use {{ic|max}} to fill the remaining space on the partition. | |||
==== Shrinking partitions ==== | ==== Shrinking partitions ==== | ||
To shrink | To shrink an ext2/3/4 filesystem on the partition: | ||
# resize2fs /dev/''sdaX'' ''size'' | # resize2fs /dev/''sdaX'' ''size'' | ||
Where {{ic|'' | {{Note|In contrast to parted, {{man|8|resize2fs}} uses K, M, G and T to mean KiB, MiB, GiB and TiB. Be aware that {{Pkg|e2fsprogs}} documentation misrefers to kibibytes, mebibytes, gibibytes and tebibytes as "power-of-two kilobytes, megabytes, gigabytes, terabytes".}} | ||
To shrink a Btrfs filesystem: | |||
# btrfs filesystem resize ''size'' ''/path/to/mount/point'' | |||
Where {{ic|''/path/to/mount/point''}} stands for the mount point of the partition you are shrinking, and {{ic|''size''}} is the new size of the partition. | |||
Then shrink the partition (in parted interactive mode): | Then shrink the partition (in parted interactive mode): | ||
Line 204: | Line 242: | ||
# resizepart ''device'' ''number'' ''size'' | # resizepart ''device'' ''number'' ''size'' | ||
Where {{ic|''device''}} is the device that holds the partition, {{ic|''number''}} is the number of the partition and {{ic|''size''}} is the new size of the partition. | Where {{ic|''device''}} is the device that holds the partition, {{ic|''number''}} is the number of the partition and {{ic|''size''}} is the new size of the partition, in 512-byte sectors. | ||
== Warnings == | == Warnings == | ||
Parted will always warn you before doing something that is potentially dangerous, unless the command is one of those that is inherently dangerous ( | Parted will always warn you before doing something that is potentially dangerous, unless the command is one of those that is inherently dangerous (e.g. ''rm'', ''mklabel'' and ''mkpart''). | ||
=== Alignment === | === Alignment === | ||
{{Warning|''parted'' only aligns the partition start, but not the size. This is not enough for dm-crypt/LUKS, see [[Advanced Format#Partition alignment]].}} | |||
When creating a partition, ''parted'' might warn about improper partition alignment but does not hint about proper alignment. For example: | When creating a partition, ''parted'' might warn about improper partition alignment but does not hint about proper alignment. For example: | ||
Line 226: | Line 266: | ||
== Tips and tricks == | == Tips and tricks == | ||
=== | === Check alignment === | ||
{{Warning|''parted'' only verifies the alignment of a partition start, but not the size. This is not enough for dm-crypt/LUKS, see [[Advanced Format#Partition alignment]].}} | |||
On an already partitioned disk, you can use ''parted'' to verify the alignment of a partition on a device. For instance, to verify alignment of partition 1 on {{ic|/dev/sda}}: | On an already partitioned disk, you can use ''parted'' to verify the alignment of a partition on a device. For instance, to verify alignment of partition 1 on {{ic|/dev/sda}}: | ||
Line 245: | Line 279: | ||
* [https://www.gnu.org/software/parted/manual/ GNU parted - Parted User's Manual] | * [https://www.gnu.org/software/parted/manual/ GNU parted - Parted User's Manual] | ||
* [ | * [https://rainbow.chard.org/2013/01/30/how-to-align-partitions-for-best-performance-using-parted/ How to align partitions for best performance using parted] | ||
* [http://positon.org/resize-an-ext3-ext4-partition Resize an ext3/ext4 partition] | * [http://positon.org/resize-an-ext3-ext4-partition Resize an ext3/ext4 partition] | ||
* [http://gparted-forum.surf4.info/ Official GParted forums] | * [http://gparted-forum.surf4.info/ Official GParted forums] |
Latest revision as of 09:56, 28 March 2024
GNU Parted is a program for creating and manipulating partition tables. GParted is a GUI frontend.
Installation
Install one of the following packages:
Usage
Parted has two modes: command line and interactive. Parted should always be started with:
# parted device
where device
is block device name like /dev/sda
, /dev/nvme0n1
, /dev/mmcblk0
, etc. If you omit the device
argument, parted will attempt to guess which device you want.
Command line mode
In command line mode, this is followed by one or more commands. For example:
# parted /dev/sda mklabel gpt mkpart P1 ext3 1MiB 8MiB
--help
) can only be specified on the command line.Interactive mode
Interactive mode simplifies the partitioning process and reduces unnecessary repetition by automatically applying all partitioning commands to the specified device.
In order to start operating on a device, execute:
# parted /dev/sdx
You will notice that the command-line prompt changes from a hash (#
) to (parted)
: this also means that the new prompt is not a command to be manually entered when running the commands in the examples.
To see a list of the available commands, enter:
(parted) help
When finished, or if wishing to implement a partition table or scheme for another device, exit from parted with:
(parted) quit
After exiting, the command-line prompt will change back to #
.
If you do not give a parameter to a command, Parted will prompt you for it. For example:
(parted) mklabel New disk label type? gpt
Rounding
Since many partitioning systems have complicated constraints, Parted will usually do something slightly different to what you asked. (For example, create a partition starting at 10.352Mb, not 10.4Mb) If the calculated values differ too much, Parted will ask you for confirmation. If you know exactly what you want, or to see exactly what Parted is doing, it helps to specify partition endpoints in sectors (with the "s" suffix) and give the "unit s" command so that the partition endpoints are displayed in sectors.
As of parted-2.4, when you specify start and/or end values using IEC binary units like “MiB”, “GiB”, “TiB”, etc., parted treats those values as exact, and equivalent to the same number specified in bytes (i.e., with the “B” suffix), in that it provides no “helpful” range of sloppiness. Contrast that with a partition start request of “4GB”, which may actually resolve to some sector up to 500MB before or after that point. Thus, when creating a partition, you should prefer to specify units of bytes (“B”), sectors (“s”), or IEC binary units like “MiB”, but not “MB”, “GB”, etc.
Partitioning
Create new partition table
- Check that your NVMe drives and Advanced Format hard disk drives are using the optimal logical sector size before partitioning.
- Consider performing SSD memory cell clearing before partitioning an SSD.
You need to (re)create the partition table of a device when it has never been partitioned before, or when you want to change the type of its partition table. Recreating the partition table of a device is also useful when the partition scheme needs to be restructured from scratch.
Open each device whose partition table must be (re)created with:
# parted /dev/sdx
To then create a new GUID Partition Table, use the following command:
(parted) mklabel gpt
To create a new Master Boot Record/MS-DOS partition table instead, use:
(parted) mklabel msdos
Partition schemes
You can decide the number and size of the partitions the devices should be split into, and which directories will be used to mount the partitions in the installed system (also known as mount points). See Partitioning#Partition scheme for the required partitions.
The following command will be used to create partitions:
(parted) mkpart part-type-or-part-label fs-type start end
part-type-or-part-label
is interpreted differently based on the partition table:- MBR: the parameter is interpreted as
part-type
, which can be one ofprimary
,extended
orlogical
. - GPT: the parameter is interpreted as
part-label
, which sets the PARTLABEL attribute of the partition. To avoid setting a partition label, pass an empty quoted string (""
).Note: Many tutorials on the web use commands which start withmkpart primary
even for GPT. They are wrong, this would set "primary" as the partition label.
- MBR: the parameter is interpreted as
fs-type
is an identifier chosen among those listed by enteringhelp mkpart
as the closest match to the file system that you will use. The mkpart command does not actually create the file system: thefs-type
parameter will simply be used by parted to set partition type GUID for GPT partitions or partition type ID for MBR partitions.Tip: parted maps types named after Linux native file systems to the same "Linux filesystem" partition type (GUID0FC63DAF-8483-4772-8E79-3D69D8477DE4
or ID0x83
), so it is perfectly safe to e.g. useext2
for an ext4-formatted partition.start
is the beginning of the partition from the start of the device. It consists of a number followed by a unit, for example1MiB
means start at 1 MiB.end
is the end of the partition from the start of the device (not from thestart
value). It has the same syntax asstart
, for example100%
means end at the end of the device (use all the remaining space).
- On a disk with a MBR partition table leave at least 33 512-byte sectors (16.5 KiB) of free unpartitioned space at the end of the disk to allow converting between MBR and GPT.
- If you do not want to leave unused space in the device, make sure that each partition starts where the previous one ends.
- parted does not support specifying the start and end of a partition relative to the previous partition. See bug #59176 and bug #55841.
- parted may issue a warning like:
Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel?In this case, read Partitioning#Partition alignment and follow #Alignment to fix it.
The following command will be used to flag the partition that contains the /boot
directory as bootable:
(parted) set partition boot on
partition
is the number of the partition to be flagged (see the output of theprint
command).esp
is an alias forboot
on GPT. [2]
UEFI/GPT examples
In every instance, a special bootable EFI system partition is required.
If creating a new EFI system partition, use the following commands (the recommended size is at least 1 GiB):
(parted) mkpart "EFI system partition" fat32 1MiB 1025MiB (parted) set 1 esp on
The remaining partition scheme is entirely up to you. For one root partition using 100% of remaining space:
(parted) mkpart "root partition" ext4 1025MiB 100% (parted) type 2 4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709
For separate swap (4 GiB) and /
(all remaining space) partitions:
(parted) mkpart "swap partition" linux-swap 1025MiB 5121MiB (parted) mkpart "root partition" ext4 5121MiB 100% (parted) type 3 4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709
And for separate swap (4 GiB), /
(32 GiB) and /home
(all remaining space) partitions:
(parted) mkpart "swap partition" linux-swap 1025MiB 5121MiB (parted) mkpart "root partition" ext4 5121MiB 37889MiB (parted) type 3 4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709 (parted) mkpart "home partition" ext4 37889MiB 100% (parted) set 4 linux-home on
BIOS/MBR examples
For a minimum single primary partition using all available disk space, the following command would be used:
(parted) mkpart primary ext4 1MiB 100% (parted) set 1 boot on
In the following instance, a 4 GiB swap partition will be created, followed by a /
partition using all the remaining space:
(parted) mkpart primary linux-swap 1MiB 4097MiB (parted) mkpart primary ext4 4097MiB 100% (parted) set 2 boot on
In the final example below, separate /boot
(1 GiB), swap (4 GiB), /
(32 GiB), and /home
(all remaining space) partitions will be created:
(parted) mkpart primary ext4 1MiB 1025MiB (parted) set 1 boot on (parted) set 1 bls_boot on (parted) mkpart primary linux-swap 1025MiB 5121MiB (parted) mkpart primary ext4 5121MiB 37889MiB (parted) mkpart primary ext4 37889MiB 100%
Resizing partitions
- You can only move the end of the partition with
parted
. - As of parted v3.2 resizepart may need the use of #Interactive mode.[3]
- These instructions apply to partitions that have ext2, ext3, ext4, or btrfs filesystems.
If you are growing a partition, you have to first resize the partition and then resize the filesystem on it, while for shrinking the filesystem must be resized before the partition to avoid data loss.
Growing partitions
To grow a partition (in parted interactive mode):
(parted) resizepart number end
Where number
is the number of the partition you are growing, and end
is the new end of the partition (which needs to be larger than the old end).
Then, to grow the (ext2/3/4) filesystem on the partition (if size
is not specified, it will default to the size of the partition):
# resize2fs /dev/sdaX size
Or to grow a Btrfs filesystem:
# btrfs filesystem resize size /path/to/mount/point
Where /path/to/mount/point
stands for the mount point of the partition you are growing, and size
in the form 16G
or +1G
is the new size or modification of the partition. Use max
to fill the remaining space on the partition.
Shrinking partitions
To shrink an ext2/3/4 filesystem on the partition:
# resize2fs /dev/sdaX size
To shrink a Btrfs filesystem:
# btrfs filesystem resize size /path/to/mount/point
Where /path/to/mount/point
stands for the mount point of the partition you are shrinking, and size
is the new size of the partition.
Then shrink the partition (in parted interactive mode):
(parted) resizepart number end
Where number
is the number of the partition you are shrinking, and end
is the new end of the partition (which needs to be smaller than the old end).
When done, use the resizepart command from util-linux to tell the kernel about the new size:
# resizepart device number size
Where device
is the device that holds the partition, number
is the number of the partition and size
is the new size of the partition, in 512-byte sectors.
Warnings
Parted will always warn you before doing something that is potentially dangerous, unless the command is one of those that is inherently dangerous (e.g. rm, mklabel and mkpart).
Alignment
When creating a partition, parted might warn about improper partition alignment but does not hint about proper alignment. For example:
(parted) mkpart primary fat16 0 32M Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel?
The warning means the partition start is not aligned. Enter "Ignore" to go ahead anyway, print the partition table in sectors to see where it starts, and remove/recreate the partition with the start sector rounded up to increasing powers of 2 until the warning stops. As one example, on a flash drive with 512B sectors, Parted wanted partitions to start on sectors that were a multiple of 2048, which is 1 MiB alignment.
If you want parted to attempt to calculate the correct alignment for you, specify the start position as 0% instead of some concrete value. To make one large ext4 partition, your command would look like this:
(parted) mkpart primary ext4 0% 100%
Tips and tricks
Check alignment
On an already partitioned disk, you can use parted to verify the alignment of a partition on a device. For instance, to verify alignment of partition 1 on /dev/sda
:
# parted /dev/sda (parted) align-check optimal 1 1 aligned