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


Linux is unique compared to other operating systems in that you’re expected to have at least basic knowledge of the OS’ command line. You can do pretty much everything from the command line, and oftentimes, it might be even easier than juggling through the GUI.

Among the things you can do with the command line, there’s resizing partitions. Here’s a breakdown on how to get that done.

Preparation

Proper preparation is key

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

Captura de pantalla 2026-02-28 132620 Credit: Arol Wright / How-To Geek

Once backups are secured, administrators must assess the current disk layout using command-line utilities. The lsblk command provides a clear hierarchical view of all attached block devices and their respective partitions, allowing you to identify the specific drive and partition designations, such as /dev/sda1 or /dev/nvme0n1p2. Additionally, commands like df -h and fdisk -l offer crucial information about file system usage, sector sizes, and the exact starting and ending boundaries of existing partitions.

To successfully expand a partition, there must be unallocated space available on the physical drive immediately contiguous to the partition you intend to enlarge. If the unallocated space is located at the beginning of the drive or separated by another active partition, standard expansion methods will not work without moving data, which is a significantly more complex and risky procedure. Furthermore, administrators need to determine the file system type 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 online resizing for expanding ext4 and XFS file systems while they are actively mounted and in use, shrinking operations or structural changes to the partition table itself may require unmounting the drive or booting from a live USB environment to ensure exclusive access to the storage device.

Expanding a standard (non-LVM) partition

For most users

Expanding a standard, non-LVM partition involves a strict two-step process: modifying the partition table to recognize the larger physical space, and subsequently instructing the file system to expand into that newly allocated boundary.

The first phase requires altering the partition boundary 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 recreation process, it is absolutely critical that the new partition begins at the exact same starting sector as the original; failing to match the starting sector will result in immediate data loss and a destroyed file system.

Captura de pantalla 2026-02-28 133358 Credit: Arol Wright / How-To Geek

Using fdisk is relatively straightforward:

  • 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 (e.g., 1). This only deletes the partition entry in the partition table, not the data.
  • Type n to create a new partition. Use the same start sector as noted earlier and accept the default end sector to use all available space.
  • Type w to write the changes to the disk and exit.
  • You may need to reboot the system for the kernel to recognize the partition table changes: sudo reboot.

The ending sector is then extended to encompass the adjacent unallocated space. Alternatively, the growpart utility offers a safer, more streamlined approach by automatically rewriting the partition table to extend the specified partition into available contiguous space without requiring manual dsudeletion and recreation of sector boundaries.

Once the underlying partition table has been updated to reflect the increased size, the operating system must be notified of the hardware change. Running the partprobe command forces the kernel to re-read the partition tables, ensuring it recognizes the new dimensions of the block device without requiring a system reboot. The second phase addresses the file system itself, which is still unaware of the additional space and retains its original sizing limits. For standard ext2, ext3, or ext4 file systems, the resize2fs command is executed against the target partition block device. This utility scales the file system structures to fill the entirety of the newly expanded partition. If the partition utilizes the XFS file system, the xfs_growfs command is used instead, which requires the partition to be mounted and takes the mount point directory as its argument rather than the device path.

Expanding with LVM

You can also do this with your server

The Logical Volume Manager offers a highly flexible abstraction layer over physical storage, making the expansion process significantly more dynamic than dealing with standard partitions.

LVM architecture is built on three primary components: Physical Volumes which map to actual storage devices, Volume Groups which pool the storage of one or more Physical Volumes, and Logical Volumes which are the final usable partitions carved from the Volume Group. To expand an LVM setup, an administrator first needs available raw storage. This can be achieved by adding an entirely new hard drive to the system or utilizing unallocated space on an existing drive.

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

Once the Physical Volume is initialized, the next step is to expand the capacity of the overarching Volume Group. The vgextend command is utilized 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. With the Volume Group successfully expanded, the administrator can now allocate this fresh space to a specific Logical Volume.

The lvextend 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 within the lvextend command. This integrated flag automatically detects the underlying file system, whether it is ext4 or XFS, and seamlessly executes the appropriate file system resizing utility in tandem with the volume expansion. This eliminates the need to run separate commands like resize2fs or xfs_growfs manually.


Command lines can be intimidating, and especially so when you’re dealing with something as complicated as partitioning. Hopefully, though, this makes it a tad easier.



Source link

Leave a Reply

Subscribe to Our Newsletter

Get our latest articles delivered straight to your inbox. No spam, we promise.

Recent Reviews


Do you ever walk past a person on the streets exhibiting mental health issues and wonder what happened to their family? I have a brother—or at least, I used to. I worry about where he is and hope he is safe. He hasn’t taken my call since 2014.

James and his brother as young children playing together before his brother became sick. James is on the right and his brother is on the left.

James and his brother as young children playing together before his brother became sick. James is on the right and his brother is on the left.

When I was 13, I had a very bad day. I was in the back of the car, and what I remember most was the world-crushing sound violently panging off every surface: he was pounding his fists into the steering wheel, and I worried it would break apart. He was screaming at me and my mother, and I remember the web of saliva and tears hanging over his mouth. His eyes were red, and I knew this day would change everything between us. My brother was sick.

Nearly 20 years later, I still have trouble thinking about him. By the time we realized he was mentally ill, he was no longer a minor. The police brought him to a facility for the standard 72-hour hold, where he was diagnosed with paranoid delusional schizophrenia. Concluding he was not a danger to himself or others, they released him.

There was only one problem: at 18, my brother told the facility he was not related to us and that we were imposters. When they let him out, he refused to come home.

My parents sought help and even arranged for medication, but he didn’t take it. Before long, he disappeared.

My brother’s decline and disappearance had nothing to do with the common narratives about drug use or criminal behavior. He was sick. By the time my family discovered his condition, he was already 18 and legally independent from our custody.

The last time he let me visit, I asked about his bed. I remember seeing his dirty mattress on the floor beside broken glass and garbage. I also asked about the laptop my parents had gifted him just a year earlier. He needed the money, he said—and he had maxed out my parents’ credit card.

In secret from my parents, I gave him all the cash I had saved. I just wanted him to be alright.

My parents and I tried texting and calling him; there was no response except the occasional text every few weeks. But weeks turned into months.

Before long, I was graduating from high school. I begged him to come. When I looked in the bleachers, he was nowhere to be seen. I couldn’t help but wonder what I had done wrong.

The last time I heard from him was over the phone in 2014. I tried to tell him about our parents and how much we all missed him. I asked him to be my brother again, but he cut me off, saying he was never my brother. After a pause, he admitted we could be friends. Making the toughest call of my life, I told him he was my brother—and if he ever remembers that, I’ll be there, ready for him to come back.

I’m now 32 years old. I often wonder how different our lives would have been if he had been diagnosed as a minor and received appropriate care. The laws in place do not help families in my situation.

My brother has no social media, and we suspect he traded his phone several years ago. My family has hired private investigators over the years, who have also worked with local police to try to track him down.

One private investigator’s report indicated an artist befriended my brother many years ago. When my mother tried contacting the artist, they said whatever happened between them was best left in the past and declined to respond. My mom had wanted to wish my brother a happy 30th birthday.

My brother grew up in a safe, middle-class home with two parents. He had no history of drug use or criminal record. He loved collecting vintage basketball cards, eating mint chocolate chip ice cream, and listening to Motown music. To my parents, there was no smoking gun indicating he needed help before it was too late.

The next time you think about a person screaming outside on the street, picture their families. We need policies and services that allow families to locate and support their loved ones living with mental illness, and stronger protections to ensure that individuals leaving facilities can transition into stable care. Current laws, including age-based consent rules, the limits of 72-hour holds, and the lack of step-down or supported housing options, leave too many families without resources when a serious diagnosis occurs.

Governments and lawmakers need to do better for people like my brother. As someone who thinks about him every day, I can tell you the burden is too heavy to carry alone.

James Finney-Conlon is a concerned brother and mental health advocate. He can be reached at [email protected].



Source link