Afraid of breaking your Linux install? Here’s how to resize partitions safely

https://www.profitableratecpm.com/f4ffsdxe?key=39b1ebce72f3758345b2155c98e6709c

Linux is unique from other operating systems in that you must have at least basic knowledge of the operating system’s command line. You can do just about everything from the command line, and often it can be even easier than juggling the GUI.

Among the things you can do with the command line is resizing partitions. Here is an explanation on how to achieve this.

Preparation

Good preparation is essential

Before making any changes to disk partitions, you need to prepare everything if you want to avoid catastrophic data loss. The absolute first step in any partition resizing operation is to create a complete and verified backup of all critical data residing on the target drive. Disk operations inherently carry a risk of file system corruption or accidental deletion. Therefore, using tools to image the drive or securely copy essential files to external storage media is non-negotiable.

Screenshot 2026-02-28 132620 Credit: Arol Wright / How-To Geek

Once backups are secure, administrators should evaluate the current disk layout using command-line utilities. THE lsblk The command provides a clear hierarchical view of all connected block devices and their respective partitions, allowing you to identify specific drive and partition designations, such as /dev/sda1 Or /dev/nvme0n1p2. Additionally, commands like df -h And fdisk -l provide crucial information about file system usage, sector sizes, and the exact start and end boundaries of existing partitions.

To successfully extend a partition, there must be unallocated space available on the physical disk immediately adjacent to the partition you wish to extend. If the unallocated space is located at the beginning of the disk or separated by another active partition, standard expansion methods will not work without moving the data, which is a much more complex and risky procedure. Additionally, administrators should determine the type of file system currently formatted on the partition, such as ext4 or XFS, as this dictates the specific tools required for the final resizing phase. While modern Linux kernels often support inline resizing for extending ext4 and XFS file systems when actively mounted and in use, shrink operations or structural changes to the partition table itself may require unmounting the drive or booting from an active USB environment to ensure exclusive access to the storage device.

Extending a standard (non-LVM) partition

For most users

Extending a standard non-LVM partition involves a strict two-step process: modifying the partition table to recognize the larger physical space, then instructing the file system to expand within this newly allocated boundary.

The first phase requires changing the partition boundaries using a tool like fdisk Or parted. A common, albeit intimidating, method using fdisk involves deleting the existing partition record and immediately recreating it. During this re-creation process, it is absolutely essential that the new partition begins at exactly the same starting sector as the original; not matching the starting sector will result in immediate data loss and a destroyed file system.

Screenshot 2026-02-28 133358 Credit: Arol Wright / How-To Geek

Using fdisk is relatively simple:

  • Run sudo fdisk /dev/sda.

  • Type p to print the partition table and note the start sector of the partition you want to resize.

  • Type d to delete the partition, then the partition number (for example, 1). This deletes only the partition entry in the partition table, not the data.

  • Type n to create a new partition. Use the same start sector as shown previously and accept the default end sector to use all available space.

  • Type w to write the changes to disk and exit.

  • You may need to reboot the system for the kernel to recognize the partition table changes: sudo reboot.

The final sector is then expanded to encompass adjacent unallocated space. Alternatively, the growpart The utility provides a safer and more streamlined approach by automatically rewriting the partition table to extend the specified partition into the available contiguous space without requiring manual deletion and re-creation of sector boundaries.

After the underlying partition table is updated to reflect the increase in size, the operating system must be informed of the hardware change. Run the partprobe The command forces the kernel to reread the partition tables, ensuring that it recognizes the new block device dimensions without requiring a system reboot. The second phase involves the file system itself, which still ignores the extra space and retains its original size limits. For standard ext2, ext3 or ext4 file systems, the resize2fs The command is executed on the target partition block device. This utility scales file system structures to fill the entire newly extended partition. If the partition uses the XFS file system, the xfs_growfs The command is used instead, which requires the partition to be mounted and takes the mount point directory as an argument rather than the device path.

Expansion with LVM

You can also do this with your server

The Logical Volume Manager provides a very flexible abstraction layer over physical storage, making the expansion process significantly more dynamic than standard partition management.

The LVM architecture is based on three main components: physical volumes which correspond to the actual storage devices, volume groups which group together the storage of one or more physical volumes, and logical volumes which are the final usable partitions carved out of the volume group. To expand an LVM configuration, an administrator first needs available raw storage. This can be achieved by adding a completely new hard drive to the system or by using unallocated space on an existing drive.

The new storage space must first be initialized as a physical volume using the pvcreate order. This step prepares the raw disk or partition by writing LVM metadata to it, signaling the LVM subsystem that the device is ready to be incorporated into an existing storage pool.

After the physical volume is initialized, the next step is to expand the capacity of the global volume group. THE vgextend The command is used to add the newly created physical volume into the desired volume group. By doing so, the total pool of available, unallocated storage blocks within that specific volume group is immediately increased. Once the volume group is successfully expanded, the administrator can now allocate this new space to a specific logical volume.

THE lvextend The command is responsible for increasing the size of the logical volume itself. A major advantage of this LVM process is the ability to use the -r Or --resizefs flag directly in the lvextend order. This built-in flag automatically detects the underlying file system, whether ext4 or XFS, and seamlessly runs the appropriate file system resizing utility in tandem with the volume extension. This eliminates the need to run separate commands like resize2fs Or xfs_growfs manually.


Command lines can be intimidating, especially when dealing with something as complicated as partitioning. Hopefully this makes things a little easier though.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button