Partitioning is the process of dividing storage drives into distinct sections for better data management. In Linux, there are commands to view Partition information, as well as commands to deal with Partition management.
A command used to expand the size of an existing partition
Partition information
lsblk
Displays a structured view of block devices, such as HDD, SSD, partitions, and mounts.
Example
lsblk -f will provide a table with detailed information about the name of a device, its partitions, the filesystem type, the UUID of each partition, and the mountpoint of that partition.
While lsblk provides an overview of devices and mount points in the system, blkid provides specific details about block devices, including their UUIDs, fs-types, and partition labels:
Example
sudo blkid /dev/nvme0n1p1 will provide information about the nvme0n1p1 partition of the nvme0n1 drive (which can be found using lsblk). The output will look something like the following:
The File System Table, also known as the fstab, is used to defines and configure how filesystems, partitions, and network drives are mounted at boot time or upon access.
Partition management
fdisk/gdisk
These commands are used to create, delete, and edit MBR and GPT partitions respectively.
Example
To create a new MBR partition on a specific device, such as /dev/sda we might do the following:
sudo fdisk /dev/sda
This leads to an interactive prompt with detailed information and steps on how to manage the partition.
Note
gdisk functions in a very similar way.
parted
Parted can also be used to select a disk, create a partition, print partition tables, resize, and remove. It functions with CLI arguments:
Example
Supposing you want to create a 20GB partition in the /dev/sdb disk, you might run the following:
parted is particularly useful when managing large disks and GPT paritions, since it allows non-destructive resizing.
growpart
Although parted is able to resize disks, growpart is a more specialized tool used for extending partitions, particularly useful in cloud environments and VMs.
Important
growpart does not create or delete partitions: all it does is extend an existing partition to fill available space
Example
To extend partition n from sdX to fill empty space until end of disk or beginning of next partition: