Server Setup

Extending CentOS 7 File System after Resizing the Volume on Azure or AWS

by ,


We have by far the largest RPM repository with dynamic stable NGINX modules and VMODs for Varnish 4.1 and 6.0 LTS. If you want to install nginx, Varnish and lots of useful modules for them, this is your one stop repository to get all performance related software.
You have to maintain an active subscription in order to be able to use the repository!

Sometimes you are running out of space on your system and need to increase disk size. Both AWS and Azure provide visual interface to do this task. However, you also need to adjust your Linux filesystem to account for those changes. Here is how you do it for CentOS 7 system

Step 1. Expand the modified partition using growpart

First, install the cloud-utils-growpart script:

yum install cloud-utils-growpart

Next, use it to grow the logical partition to extend to all the available space:

growpart /dev/sda 1

Step 2. Resize filesystem

Both AWS and Azure use XFS for filesystem. You might have already tried:

resize2fs /dev/sda1 will issue:

And received this dreaded message because resize2fs does not account for XFS:

resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/sda1
Couldn't find valid filesystem superblock. 

You should do something different instead. First mount the root partition once again at /mnt:

mount /dev/sda1 /mnt

Now you can complete the resizing with:

xfs_growfs -d /mnt
  1. CarstenH.

    This Tip saved my day!! All what I did before did not wok, because of the xfs issue – YOU know the solution! I did it on a way too small Azure -> Plesk Onyx installation and resized from only 30GB to 1023GB in seconds ! Many THX! :))

    Reply
  2. Ricardo Salvador

    You save my day! awesome job! Thank you very much. In my case, I needed to grow /dev/sda 2.
    I used the following commands:

    1) sudo yum install cloud-utils-growpart

    2) sudo growpart /dev/sda 2

    3) sudo mount /dev/sda2 /mnt

    4) sudo xfs_growfs -d /mnt

    Regards!

    Reply
  3. David Cavazos

    For some reason “yum install cloud-utils-growpart” is not working for me. I have CentOS 7 and it begins to install but then it cant find the downloads on any of the mirrors. Any ideas?

    Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.