Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
Disk partitioning is a fundamental task when setting up or managing storage on a Linux system. It involves dividing a disk into one or more regions, each of which can be managed separately. This article will guide you through the process of creating and managing disk partitions in Linux using various command-line tools.
Before diving into the commands, it's essential to understand the basics of disk partitioning. A disk partition is a logical division of a hard disk drive (HDD) or solid-state drive (SSD). Each partition can be formatted with a filesystem and used to store data independently.
Several tools are available for disk partitioning in Linux, including:
fdisk
: A command-line utility for creating and manipulating partition tables.parted
: A more advanced command-line utility that supports both MBR and GPT partition tables.gparted
: A graphical frontend to parted
.fdisk
List available disks:
sudo fdisk -l
This command lists all available disks and their current partitions.
Select the disk to partition:
sudo fdisk /dev/sda
Replace /dev/sda
with the appropriate disk identifier.
Create a new partition:
n
to create a new partition.Write changes to disk:
w
to write the changes and exit fdisk
.Format the new partition:
sudo mkfs.ext4 /dev/sda1
Replace /dev/sda1
with the new partition identifier.
parted
Start parted
with the desired disk:
sudo parted /dev/sda
Create a new partition table (optional):
(parted) mklabel gpt
Replace gpt
with msdos
for an MBR partition table if needed.
Create a new partition:
(parted) mkpart primary ext4 1MiB 100%
This command creates a primary partition with the ext4 filesystem, spanning from 1MiB to the end of the disk.
Exit parted
:
(parted) quit
Format the new partition:
sudo mkfs.ext4 /dev/sda1
Replace /dev/sda1
with the new partition identifier.
gparted
Install gparted
(if not already installed):
sudo apt-get install gparted
Launch gparted
:
sudo gparted
Use the graphical interface to create, resize, move, and delete partitions as needed.
Disk partitioning in Linux is a critical skill for system administrators and users who need to manage storage effectively. Whether you prefer command-line tools like fdisk
and parted
or graphical tools like gparted
, Linux offers robust utilities to handle all your partitioning needs.