Linux Tutorial

Linux File/Directory Management

Linux Packaging And Compression

Vim Text Editor

Linux Text Processing

Linux Software Installation

Linux User/User Group Management

Linux Permission Management

Linux Filesystem Management

Linux Advanced Filesystem Management

Linux System Management

Linux Backup and Recovery

Linux System Service Management

Linux System Log Management

Linux Boot Management

LAMP/LNMP Environment

SELinux Management

Linux parted Command: Create Partitions

parted is a command-line tool for managing partitions on Linux systems. It supports multiple partition table formats, such as MBR (Master Boot Record) and GPT (GUID Partition Table), and provides advanced features like resizing and moving partitions without data loss. In this tutorial, we'll cover the basics of using the parted command to create, resize, and manage partitions.

  • Install parted:

On Ubuntu/Debian systems:

sudo apt-get update
sudo apt-get install parted

On Fedora/CentOS/RHEL systems:

sudo yum install parted
  • List devices and partitions:

To list all available devices and their partitions, use the parted command followed by -l (list):

sudo parted -l
  • Select a device:

To start working with a specific device, you'll need to invoke parted followed by the device name (e.g., /dev/sda):

sudo parted /dev/sda

This will enter the interactive parted prompt. Most commands from now on will be issued within this prompt.

  • Create a partition table:

Before creating partitions, you'll need a partition table. To create a GPT partition table, use the mklabel command:

(parted) mklabel gpt
  • Create a partition:

To create a partition, use the mkpart command followed by the partition type, name, start, and end points. For example, to create a 100GB partition for a Linux filesystem:

(parted) mkpart primary ext4 0% 100G
  • List partitions:

To see a list of partitions on the selected device, use the print command:

(parted) print
  • Resize a partition:

To resize a partition, first remove the partition with the rm command, and then create a new one with the desired size using the mkpart command. For example, to resize partition 1 to 200GB:

(parted) rm 1
(parted) mkpart primary ext4 0% 200G
  • Move a partition:

To move a partition, use the move command followed by the partition number, start, and end points. For example, to move partition 1 to start at 200GB and end at 400GB:

(parted) move 1 200G 400G
  • Delete a partition:

To delete a partition, use the rm command followed by the partition number:

(parted) rm 1
  • Exit parted:

To exit the interactive parted prompt, use the quit command:

(parted) quit

That's it! This tutorial covered the basics of using the parted command to manage partitions on Linux systems. For more advanced usage and complete list of options, refer to the parted man page by running man parted in your terminal.

  1. How to use parted to create partitions: parted is a powerful partitioning tool. To create partitions, run:

    sudo parted /dev/sdX
    
  2. Creating disk partitions with parted in Linux: Within parted, use the mkpart command to create a new partition:

    mkpart primary ext4 0% 50%
    
  3. Partitioning disks using the parted command in Unix-like systems: Use parted to partition disks. For example, to create a primary partition spanning the entire disk:

    sudo parted /dev/sdX mkpart primary 0% 100%
    
  4. Creating primary and logical partitions with parted: Use the mkpart command to create primary or logical partitions:

    mkpart primary ext4 0% 50%
    mkpart logical ext4 50% 100%
    
  5. Advanced options for the parted command in Linux: parted provides advanced options. For instance, aligning partitions to 1MB boundaries:

    sudo parted /dev/sdX mkpart primary ext4 1MiB 50%
    
  6. Partition alignment and sizing with parted in Linux: Consider alignment and sizing when partitioning with parted. Specify sizes, types, and alignment:

    mkpart primary ext4 1MiB 50%
    
  7. Managing disk space with parted in the terminal: parted allows managing disk space efficiently. Resize a partition:

    sudo parted /dev/sdX resizepart 1 75%