parted Commands Cheat Sheet

• Updated June 7, 2019


Linux users have used fdisk for as long as can be remembered to partition their hard disks. However, as large hard disks have become more and more prevalent, fdisk can no longer be used because it has a 2 TB partition limit. Luckily, parted has been around for a long time and can be used to label and partition any modern sized hard disk.

This post will be an ever growing list of parted commands to quickly get you started using it.

Disclaimer

Unlike fdisk, every parted command executes in real time. This introduces much more room for human error that could cause data loss. I am not, nor is anyone else, responsible for any potential data loss when using parted.

parted /dev/sdb print
parted /dev/sdb unit s print
parted /dev/sdb print free
parted /dev/sdb unit s print free

Create Partitions

Create a Primary Partition Using All Disk Space

First, if needed, create a partition table label:

parted /dev/sdb mklabel gpt

Second, create the primary partition:

parted /dev/sdb mkpart primary 0 100%

After running the above command you will more than likely see the following warning message:

Warning: The resulting partition is not properly aligned for best performance.

To dig into why this occurs, and a possible solution, I suggest you read through how to align partitions for best performance using parted.

However, as suggested in the comments in that blog post, a quicker way to ensure parted aligns the partition properly is to ensure the START and END parameters in the parted command use percentages instead of exact values.

parted /dev/sdb mkpart primary 0% 100%

References

If you found this post useful, you can help support this site and get something for yourself by signing up for any of the services listed below through the provided links.

The following links are part of affiliate programs, and I will receive a referral payment from any of the services you sign-up for.

  • Get Faster Shipping: Perhaps you're about to order some stuff on Amazon but want to get more value out of the money you would normally pay for shipping. Sign-up for a free, 30-day trial of Amazon Prime to get free two-day shipping, access to thousands of movies and TV shows, and more.
  • Start Investing Now: Are you looking to start investing some of your disposable saved income? Get started by opening an account with Webull, where upon sign-up and opening a brokerage account with an initial deposit of at least $100 you will receive 1 stock valued (subject to change based on normal market movement) between $8 and $1600.

Thanks for reading and take care.