2.4.6 mkpart

Command: mkpart [part-type name fs-type] 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:

  • btrfs
  • ext2, ext3, ext4
  • fat16, fat32
  • hfs, hfs+, hfsx
  • hp-ufs
  • jfs
  • linux-swap, linux-swap(new,old,v0,v1)
  • nilfs2
  • ntfs
  • reiserfs
  • sun-ufs
  • ufs
  • xfs

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 partitions2. 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



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://lwn.net/Articles/428584/ and its many comments.