Linux parted command
The Linux parted command is a useful tool for managing disk partitions on a Linux system. It allows users to create, delete, resize, and modify partitions with ease. By using parted, you can effectively manage your disk space allocation and optimize the performance of your system. This command provides a flexible and powerful way to work with partitions, making it a valuable tool for system administrators and advanced users. With its versatile features and options, the Linux parted command is a handy utility for handling disk partitioning tasks efficiently.
parted Syntax:
Options:
Option | Description |
---|---|
-h, —help | Displays a help message and exits |
-l, —list | Lists partition layout on all devices |
-s, —script | Never prompts for user intervention |
-a, —align | Set alignment for new partitions |
-v, —version | Displays version information and exits |
Parameters:
Parameter | Description |
---|---|
device | Specifies the device to be partitioned |
command | Specifies the action to be taken on the device |
parameters | Additional parameters for the specified command |
parted Usage:
Create a new partition
Create a new primary partition with ext4 filesystem from the beginning to the end of the disk.
Resize a partition
Resize the first partition on /dev/sdb to use only the first 50% of the disk.
Check partition alignment
Check if the first partition on /dev/sdb is aligned properly with minimal alignment.
Set partition flag
Set the boot flag on the first partition on /dev/sdb.
How do I use parted in Linux?
To use the parted command in Linux, execute the following command:
How do I list partitions with parted?
To list partitions using parted, run the following command:
How do I create a new partition with parted?
To create a new partition using parted, follow this example:
How can I resize a partition with parted?
To resize a partition with parted, use the following command format:
How do I format a partition using parted?
To format a partition using parted, you can use the mkfs command. Here’s an example for formatting a partition as ext4:
How can I align partitions in parted?
To align partitions in parted for optimal performance, consider using the “align-check optimal” command. Here’s how you can do it:
How do I label a partition using parted?
To label a partition with a specific name using parted, you can use the “name” command. Here’s an example:
Applications of the parted command
- Managing disk partitions
- Creating, resizing, moving, and deleting disk partitions
- Setting partition labels and flags
- Viewing partition information
- Checking and fixing disk partition issues