Jetserver – The Lazy Admin Blog
Home  /  CentOS  /  CentOS 7: Resize xfs Partition

CentOS 7: Resize xfs Partition

Daniel Alum September 03, 2017 Leave a Comment

So, we got a CentOS 7 Machine with 20GB (XFS Filesystem), We want to increase the disk to 120GB. The machine is actually a VM inside XenServer (HVM).

Fdisk output before the upgrade –

As you can see there is on HD (/dev/xvda) with two partitions on it –

The main “/” root partition with 18 GB

Another swap partition with 1 GB

So far, so good :), let’s continue with the resize –

Increasing the disk size from XenServer:

 

 

*Increasing disk聽has the potential to cause a lot of damage. It鈥檚 very important to make a backup of your server, if you are using a virtual machine, make sure to take a snapshot before starting the process.

So, we turned off the server, resized the disk. Now, let’s take a look at fdisk outpt

The /dev/xvda is now 120 GB as we want to, but we still need to resize the partition. Since our swap partition (/xvda2) comes right after xvda1, we can’t resize xvda1 unless we remove / move xvda2. In that case, since it’s only a swap partition we choose to remove it, resize and then re-create it.

Let’s start the process 馃檪

fdisk /dev/xvda

Delete the 2 partitions (xvda1 + xvda2) we have by typing “d”:

After we deleted them, we need to create them again with the increased size.

Since, we want the swap partition with聽 2GB size, so we have to limit the block size of our primary root partition.

You can calculate block to GB in this site:

http://www.unitconversion.org/data-storage/blocks-to-gigabytes-conversion.html

120 GB is聽251658240 blocks.

2聽GB (to our swap partition) is聽4194304 blocks.

We will give 118 GB to our primary root partition and 2GB to swap partition

We will calculate:

251658240 – 4194304 =聽247463936

The last sector of our primary too partition will be 247463936 (118GB)

Now create another partition to swap with the rest of the blocks:

Change the partition system id of our swap:

We’ve finished with fdisk for now, type “w” in the fdisk prompt to save changes & exit. You should receive an error saying “Re-reading the partition table failed with error 16” –

The error is normal – you need to reboot the server for the system to follow all the changes. Before we reboot the server, as we don’t have (yet) a swap partition, let’s first remark it in fstat as the system might fail to boot.

Edit fstab and remark the swap partiton –

vi /etc/fstab

Save & reboot.

After server goes back from reboot, your swap partition won’t mount because of UUID changes. We will fix this below. First, increase the disk size with the following command:

xfs_growfs -d /

Our primary root partition now reflects the right size:

We have to create our swap now, run the following command:

Copy the uuid that the mksawp command has generated. Edit the /etc/fstab file – remove our previous remark and paste the new uuid.

vi /etc/fstab

That’s it!

Previous Article
Next Article

About Author

Daniel Alum

Leave a Reply

Cancel reply

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

Search Our Blog

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Filter by Categories
Apache
CentOS
CloudLinux
cPanel
ESXI
iSCSI
JetBackup
Litespeed
MySQL
NGINX
Reduxio
SSL
Uncategorized
VMware
Wordpress
XEN

Tags

apache aspx backup CentOS cloudlinux cPanel CXS freetds google htaccess iscsi JetBackup Libmodsecurity litespeed modsec modsecurity mssql MySQL netapp nginx odbc php php.ini phpselector VMFS WHM xenserver

Popular Posts

  • Allow a cPanel server to run a VHOST from multiple IP addresses April 3, 2018
  • How To Install & Configure a Galera Cluster with MySQL on Centos 7 February 6, 2018
  • Libmodsecurity installation April 14, 2016
  • JetBackup Cheat Sheet :: Automatically Acknowledge Alerts November 15, 2018

Recent Posts

  • Building your own private cloud April 20, 2021
  • Dealing with aggressive bot scanners September 14, 2020
  • Litespeed Geo Location Redirect September 14, 2020
  • JetBackup :: Restore on steroids ! August 21, 2020

Recent Comments

  • Khan on Allow a cPanel server to run a VHOST from multiple IP addresses
  • Khan on Allow a cPanel server to run a VHOST from multiple IP addresses
  • Oleg Drabkin on Allow a cPanel server to run a VHOST from multiple IP addresses
  • Khan on Allow a cPanel server to run a VHOST from multiple IP addresses
  • Daniel on How To Install & Configure a Galera Cluster with MySQL on Centos 7
讗讞住讜谉 讗转专讬诐 | JetApps