parted: mkpart
2.4.5 mkpart
------------
-- Command: mkpart [PART-TYPE FS-TYPE NAME] START END
Creates a new partition, _without_ creating a new file system on
that partition. This is useful for creating partitions for file
systems (or LVM, etc.) that Parted doesn't support. You may
specify a file system type, to set the appropriate partition code
in the partition table for the new partition. FS-TYPE is required
for data partitions (i.e., non-extended partitions). START and END
are the offset from the beginning of the disk, that is, the
"distance" from the start of the disk.
PART-TYPE is one of 'primary', 'extended' or 'logical', and may be
specified only with 'msdos' or 'dvh' partition tables. A NAME must
be specified for a 'gpt' partition table. Neither PART-TYPE nor
NAME may be used with a 'sun' partition table.
FS-TYPE must be one of these supported file systems:
* ext2
* fat16, fat32
* hfs, hfs+, hfsx
* linux-swap
* NTFS
* reiserfs
* ufs
* btrfs
For example, the following creates a logical partition that will
contain an ext2 file system. The partition will start at the
beginning of the disk, and end 692.1 megabytes into the disk.
(parted) mkpart logical 0.0 692.1
Now, we will show how to partition a low-end flash device
("low-end", as of 2011/2012). For such devices, you should use
4MiB-aligned partitions(1). This command creates a tiny
place-holder partition at the beginning, and then uses all
remaining space to create the partition you'll actually use:
$ parted -s /dev/sdX -- mklabel msdos \
mkpart primary fat32 64s 4MiB \
mkpart primary fat32 4MiB -1s
Note the use of '--', to prevent the following '-1s' last-sector
indicator from being interpreted as an invalid command-line option.
The above creates two empty partitions. The first is unaligned and
tiny, with length less than 4MiB. The second partition starts
precisely at the 4MiB mark and extends to the end of the device.
The next step is typically to create a file system in the second
partition:
$ mkfs.vfat /dev/sdX2
---------- Footnotes ----------
(1) Cheap flash drives will be with us for a long time to come, and,
for them, 1MiB alignment is not enough. Use at least 4MiB-aligned
partitions. For details, see Arnd Bergman's article,
<http://http://lwn.net/Articles/428584/> and its many comments.