Skip to main content
Engineering LibreTexts

04-A.7.1: Disk Setup Process - parted

  • Page ID
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    The parted Command

    GNU parted is a text-based partitioning utility (although, there is a GUI based tool as well) that works with most Linux disk labels and other disk types. This utility was designed to minimize the chance of data loss, but as always it is a good idea to back up all your files before running this program.


    parted [options] [device [command [options...]...]]

    Command Options:

    Options Option Meaning
    -l, --list Lists partition layout on all block devices.
    -m, --machine Displays machine parseable output.
    -s, --script Never prompts for user intervention.
    -a alignment-type, --align alignment-type

    Sets alignment for newly created partitions. Valid alignment types are:

    Use the minimum alignment allowed by the disk type.
    Align partitions to cylinders.
    Use minimum alignment as given by the disk topology information. This and the opt value will use layout information provided by the disk to align the Logical partition table addresses to actual physical blocks on the disks. The min value is the minimum alignment needed to align the partition properly to physical blocks, which avoids performance degradation.
    Use optimum alignment as given by the disk topology information. This aligns to a multiple of the physical block size in a way that guarantees optimal performance.

    Again, we will use /dev/sda, and assume that you want a single partition on the disk, occupying all the free space.

    1) Start parted as follows:

    pbmac@pbmac-server $ sudo parted /dev/sda

    2) Create a new GPT disklabel (aka partition table):

    (parted) mklabel gpt

    3) Set the default unit to TB:

    (parted) unit TB

    4) Create one partition occupying all the space on the drive. For a 4TB drive:

    (parted) mkpart
    Partition name?  []? primary
    File system type?  [ext2]? ext4
    Start? 0
    End? 4

    5) Check that the results are correct:

    (parted) print

    There should be one partition occupying the entire drive.

    6) Save and quit "parted":

    (parted) quit

    The partprobe Command

    If you use fdisk or parted on a running live system and alter the partition table, the kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe.

    After you alter the partition table you should see a warning:

    The partition table has been altered.
    Calling ioctl() to re-read partition table.
    Re-reading the partition table failed.: Device or resource busy

    You simply need to run the partprobe command to advise the operating system that the partition table has been altered.

    pbmac@pbmac-server $ sudo partprobe

    Adapted from:
    "InstallingANewHardDrive" by Robert Unverzagt, The Community Help Wiki is licensed under CC BY-SA 4.0
    "How to partition and format a drive on Linux" by Seth Kenlon, is licensed under CC BY-SA 4.0
    "How to partition a disk in Linux" by Daniel Oh, is licensed under CC BY-SA 4.0

    04-A.7.1: Disk Setup Process - parted is shared under a CC BY-SA 4.0 license and was authored, remixed, and/or curated by LibreTexts.

    • Was this article helpful?