The cart is empty

Managing disk space is a critical aspect of operating system management, especially in a Linux environment. The ability to efficiently resize a disk partition can be useful in many situations, such as expanding data capacity, improving system performance, or simply better organizing disk space. In this article, we'll discuss how to resize a disk partition in Linux using command-line tools and graphical user interfaces.

Preparation

Before making any changes, it's essential to back up important data. Despite the reliability of tools, unexpected situations may arise that could lead to data loss.

Using the fdisk Tool for Partition Resizing

  1. Identify the Partition: First, identify the disk partition you want to resize. This can be done using the lsblk or fdisk -l command, which displays a list of all available disks and partitions.

  2. Unmount the Partition: Before resizing the partition, it must be safely unmounted using the umount /dev/sdXN command, where sdXN is the partition identifier.

  3. Modify the Partition: By running fdisk /dev/sdX, you open the menu for managing partitions on the disk. Using the "d" option, delete the existing partition, and using the "n" option, create a new partition with the desired larger size. It's important that the new partition starts at the same sector as the original partition to avoid data loss.

  4. Save Changes and Reload the Partition Table: After making changes in fdisk, save the changes and request the kernel to reload the partition table using the partprobe command or by restarting the system.

Expanding the File System

After successfully resizing the partition, it's necessary to expand the file system to utilize the newly acquired space. For ext4 file systems, you can use the resize2fs /dev/sdXN command, where sdXN is the identifier of the resized partition.

Graphical User Interface (GUI)

For users who prefer a graphical interface, tools like GParted can be used. GParted is a graphical application that allows easy and intuitive resizing of disk partitions. Simply select the partition, click on the "Resize/Move" option, and set the new partition size. Upon confirming the changes, GParted automatically performs all necessary adjustments to the partition and file system.

 

Resizing a disk partition in Linux can be done in several ways, whether using command-line tools or graphical user interfaces. It's always important to proceed with caution and ensure that all data is safely backed up. With proper care and attention, the process of expanding disk space can be smooth and fast.