
{{ $('Map tags to IDs').item.json.title }}
How to Use parted for Disk Management
The parted
command-line utility in Linux is used for managing disk partitions. It offers features for creating, resizing, and deleting partitions, all in a user-friendly interface. This tutorial will guide you through the basics of using parted
for disk management tasks.
1. Installing parted
Most Linux distributions come with parted
pre-installed. To check if it’s installed, run:
parted --version
If it’s not installed, you can install it using your package manager:
- For Ubuntu:
sudo apt update sudo apt install parted
- For CentOS:
sudo yum install parted
2. Starting parted
To use parted
, you need to specify the disk you want to manage:
sudo parted /dev/sdX
Replace sdX
with the actual device name (e.g., /dev/sda
).
3. Viewing Current Partitions
Once inside the parted prompt, you can view the current partition table by typing:
print
This command displays the partition layout, including size and filesystem type.
4. Creating a New Partition
To create a new partition, first, you need to specify the start and end points:
mkpart primary ext4 1MiB 100MiB
This example creates a primary partition of type ext4, starting at 1MiB and ending at 100MiB. Adjust the sizes as needed for your disk layout.
5. Resizing a Partition
To resize an existing partition, use the resizepart
command. For example, to resize the first partition:
resizepart 1 200MiB
This command resizes partition 1 to end at 200MiB.
6. Deleting a Partition
If you need to delete a partition, use the rm
command:
rm 1
This command removes partition 1. Be cautious, as this action cannot be undone.
7. Saving Changes
After making changes, exit parted to save the changes:
quit
Alternatively, you can run the command parted -s /dev/sdX mkpart primary ext4 1MiB 100MiB
directly from the terminal to perform actions without entering the interactive mode.
8. Conclusion
By following this tutorial, you have learned how to use the parted
command for disk management in Linux. Mastering disk partitioning is vital for effective system management and data organization. Continue exploring advanced features and options within parted
to enhance your disk management skills!