Troubleshooters.Com® and Linux Library Present:

Parted Cheat-Sheet



Partitioning is complicated, with lots to remember, so it's nice to have a graphical partitioning tool like gparted. But sometimes there's no X server, or there's not enough memory to run X, so you must go command line. When that happens, parted is a good choice.

If you're used to gparted, it's important to understand that parted does only limited things. It does not format partitions, nor does it make partition "labels" like those shown by the blkid program. Formatting of partitions is performed by programs like mkfs.ext4 or mkswap. Partition labels are created using the -L option to the formatting programs.

While we're on the subject of labels, consider the very unfortunate choice of "mklabel" as a parted command. The "mklabel" command makes a partition table on a hard disk, it doesn't put a text label on a partition. There is a synonym command called mktable, but for whatever reason most examples on the web use mklabel as the command.

Running Parted

First, I always start parted like this:

parted <devicename>

In the preceding, <devicename> would be something like /dev/sda or /dev/sdb or /dev/hda, but would never be something like /dev/sda1. <devicename> is always a disk, not a partition.

Once you run the parted <devicename> command, you're in Parted's interactive environment. You can run Parted's help command to see all possible Parted commands, and you can run help <command> to get help for an individual command. In general, you can run the command, and you will be queried for its arguments.

A couple vital points. Your first internal command should be the unit command, like this:

(parted) unit MiB

Setting units to MiB makes it much easier to align all your partitions optimally, because optimal alignment occurs on MiB boundaries.

Whenever you want to see what's going on, use the print Parted command:

(parted) print                             
Model: VBOX HARDDISK (ide)
Disk /dev/hda: 8192MiB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start    End      Size     Type     File system  Flags
 1      1.00MiB  7001MiB  7000MiB  primary
 2      7001MiB  8191MiB  1190MiB  primary

The preceding shows you the size of the disk and every partition, in the selected units, which I already set to MiB to conform with optimal alignment.

The other universally helpful Parted command is help, which gives you a list of commands, or if followed by the name of one of those commands, gives you info on that command. This is how you figure out what arguments to use for a command, and what types and units to use in the command syntax.

Parted Cheat-Sheet

Command Meaning
unit Sets the kind of unit. I always use MiB. I always make this my first command.
print Show the disk and partition information, complete with sizes in your selected unit.
help Lists available commands. If followed by a command, gives help on that command's syntax and choices.
mklabel Makes a partition table on the disk. If you use Linux, the type should always be either "msdos" or "gpt".
mkpart Make Partition. You'll be asked primary or secondary, format type, start and end (in your chosen units). Always make sure your unit setting is "MiB". Always make your first partition starts at 1, and if your last one is intended to fill the rest of the disk, make its end be -1, which means end of disk. You can't put in a size directly: You must do the math and put in start and end.
rm <#> Delete partition number <#>, which can be found using the print command. Obviously, use caution.
set <number> <flag> <state> This is how you set flags of partitions. To make partition 1 bootable, perform the following command:

(parted) set 1 boot on
align-check This queries you whether you want optimal or minimal alignment, and I always say optimal. Then it asks you for the partition number, (which can be found using the print command), and when you put in the partition number, it reports it as being either aligned or not. Aligned partitions are a good thing for top notch disk performance.
quit Exit the Parted program.

Cheat-Sheet of Related Commands

Formatting and making partition label strings are done by other commands.

Command Meaning
lsblk -o +label,fstype,uuid Command to see all relevant info on all partitions, without being root.
mkfs.ext4 -L <mystring> /dev/<partition> Create an ext4 filesystem, with label <mystring>, on partition /dev/<partition>, where <partition> is something like sda1 or sda2 or sdb1 or hda2 but not sda or hdb.
mkswap -L <mystring> /dev/<partition> Create a swap filesystem, with label <mystring>, on partition /dev/<partition>, where <partition> is something like sda1 or sda2 or sdb1 or hda2 but not sda or hdb.


When you can't run X, you must run a command line interface partitioning utility, and that requires more preparation. This document's intent is that, once in Parted, you can do what you need to do for most tasks.

Most GUI partitioners do a lot more than partition. They include format utilities. They do the math so you can specify partitions by size instead of start and end. Parted performs only partitioning duties, so you need to use Linux commands like mkfs.ext4 and mkswap to do actual formatting, perhaps with the -L <labeltext> option to give the partition a text label.

Here's a little story to end this document. A few days ago I installed Plop Linux on a Virtual Machine with 110MB of RAM. By 2015 standards that's quite a shoehorn.

Installing Plop Linux a couple days ago, first couple tries used a GUI install so I could use gparted. Every single step of the install went incredibly slowly, as Linux spent most of its time rearranging memory. It finally got so slow I couldn't finish. Then I installed solely in CLI, used parted instead of gparted. The install was lively: just a few minutes. When I rebooted, the 110MB was enough to run the new installation in a fairly lively manner, in Fluxbox, if I kept opened windows to a low number.

GUI partitioning is a lot more intuitive and requires a lot less memorization, but sometimes a GUI partitioner is something you just can't afford.

[ Training | Troubleshooters.Com | Email Steve Litt ]