×
image-review-0
Rating: 4.6 | 75 reviews
image-review-1
Rating: 5.0/5

How to Expand a Linux Disk Partition ?

Expanding a disk partition on a Linux system can seem like a daunting task, but it is quite manageable with the right steps. This tutorial will guide you through the process of expanding a Linux disk partition using both command-line tools and graphical utilities.

Prerequisites

  • A Linux system with a disk partition that needs expanding.
  • Administrative (root) access to the system.
  • Backup of important data (recommended).

Step 1: Check Current Disk Space

Before making any changes, it's important to understand the current disk space usage. Open a terminal and run the following command:

df -h

This will display the disk space usage of all partitions in a human-readable format.

Step 2: Identify the Partition to Expand

Next, identify the partition you want to expand. You can use the lsblk command to list all block devices and their partitions:

lsblk

Take note of the partition name you want to expand (e.g., /dev/sda1).

Step 3: Unmount the Partition (if necessary)

If the partition is mounted and in use, you will need to unmount it before resizing. Use the umount command:

sudo umount /dev/sda1

Replace /dev/sda1 with your partition name.

Step 4: Resize the Partition

Using Command-Line Tools

1. Use fdisk or parted to Resize the Partition

You can use either fdisk or parted to resize the partition. Here, we'll use fdisk as an example:

sudo fdisk /dev/sda

Enter d to delete the partition, then enter the partition number (e.g., 1 for /dev/sda1). Don't worry; this will not delete the data.

Next, enter n to create a new partition. Follow the prompts to create a new partition with the desired size. Ensure the starting sector matches the original partition's starting sector.

Finally, write the changes by entering w.

2. Resize the Filesystem

After resizing the partition, you need to resize the filesystem to occupy the new space. For an ext4 filesystem, use the resize2fs command:

sudo resize2fs /dev/sda1

Replace /dev/sda1 with your partition name.

Using Graphical Tools

If you prefer a graphical interface, you can use GParted:

  1. Install GParted if it’s not already installed:
    sudo apt-get install gparted
  2. Open GParted:
    sudo gparted
  3. Select the partition you want to resize.
  4. Right-click on the partition and select "Resize/Move."
  5. Drag the slider or enter the new size to expand the partition.
  6. Click "Resize/Move" and then "Apply" to execute the changes.

Step 5: Mount the Partition

Once the partition and filesystem have been resized, you can mount the partition again:

sudo mount /dev/sda1 /mnt

Replace /dev/sda1 with your partition name and /mnt with the mount point.

Step 6: Verify the Changes

Finally, verify the changes by checking the disk space usage again:

df -h

Ensure that the partition has been resized and the filesystem occupies the new space.

Conclusion

Expanding a Linux disk partition can help you make better use of your storage space. Whether you prefer command-line tools or graphical utilities, this tutorial provides the steps needed to safely and effectively resize your partitions. Always remember to back up important data before making changes to disk partitions.

By following these steps, you should be able to expand your Linux disk partition with ease. If you encounter any issues or need further assistance, feel free to contact our support team at INNOVAHOSTING.NET.