NEW LOCATION

Olá Brazil Brazil NVMe-powered VPS Plans in Brazil Now Available.

Deploy Instantly
  • +357 2425 0808
  • Login
  • English

Home

Blog

How To Extend Root Partition using Home ...

How To Extend Root Partition using Home Partition space in CentOS

How To Extend Root Partition using Home Partition space in CentOS

NetShop ISP

NetShop ISP · Blog Author

May 30, 2024 · Technical Tutorials

After popular demand by existing customers using CentOS 7 servers, we have prepared this tutorial on how to resize root partition after deleting the default /home partition.

In graphical installation of CentOS 7, unless specified otherwise, the installer will create the following partitions: /centos-root , /centos-home and /swap.

This happens usually when system admins forget to customize the partitioning layout during the installation process. There is a solution though which does not require you to re-install the server.

Steps to Resize Root Partition in CentOS and Deleting Home Partition

Pre-requisites:

  • SSH Access on CentOS 7 Server with root or sudo privileged user
  • XFS Filesystem with LVM
  • Ensure you have taken all necessary backups – any disk related operations are high risk!

Step 1: Copy contents of /home directory

Regardless if you already took backup of your entire server, do another quick backup of the /home directory in a location within the server. After the completion of the resize operation, you will be able to quickly transfer back the contents to the /home directory.

root@localhost:~$ mkdir /temp && cp -a /home /temp/

Step 2: Unmount /home

The following command will unmount /home directory. This is a crucial step as without unmounting you cannot proceed to the next steps.

root@localhost:~$ umount -fl /home

Once done, execute the lvs command to display the attributes of the LVM volumes (you will need these in Step 3).

root@localhost:~$ lvs

Step 3: Remove the Home LVM Volume

Run the following command to remove the LVM volume for home.

root@localhost:~$ lvremove /dev/centos/home

Important: We used …/centos/… because of the “VG” attribute from Step 2. If yours is different please adjust your command in Step 3 accordingly.

Step 4: Resize/Extend the Root LVM Volume

From Step 2, we see (in our example) that the LSize of home volume is ~2,13T. Therefore, it is safe to extend our root LVM by 2 TB.

root@localhost:~$ lvextend -L+2T /dev/centos/root

Then run the following command to finalize the resizing of root partition:

root@localhost:~$ xfs_growfs /dev/mapper/centos-root

Step 5: Copy contents of /home back to original directory

root@localhost:~$ cp -a /temp/home /

Confirm that you see all of your directories and files in /home by executing the command ls /home/.

If you are happy with what you see, proceed and delete the temporary directory you created in Step 1 as follows:

root@localhost:~$ rm -rf /temp

Step 6: Update /etc/fstab and Sync systemd with all changes

At this point we have resized the root partition successfully but we need to ensure that the system will not look to mount the /home partition on its next boot. For this reason you need to remove the line for /dev/mapper/centos-home from file /etc/fstab. Do so using your favorite editor (nano, vi, etc).

Finally, run the following command to sync systems with all changes above.

root@localhost:~$ dracut --regenerate-all --force

You are all set! Enjoy your newly resized Root partition in CentOS!

Press Releases
79

Free VPS Trial

No Credit Card Required.

Recent Posts

Black Friday & Cyber Monday Offer – 30% Lifetime Discount on VPS Plans

Black Friday & Cyber Monday Offer – 30% Lifetime Discount on VPS Plans

02 December, 2024

How To Install Sendy on Ubuntu 22.04 Server

How To Install Sendy on Ubuntu 22.04 Server

27 November, 2024

How To Extract Certificates and Private Key from .PFX file

How To Extract Certificates and Private Key from .PFX file

19 November, 2024

NetShop ISP CEO Stefano Sordini to Moderate Key Panel on Forex AI Automation at Cyprus Fintech Summit 2024

NetShop ISP CEO Stefano Sordini to Moderate Key Panel on Forex AI Automation at Cyprus Fintech Summit 2024

15 November, 2024

Preparing for the Daylight Saving Time (DST) Change: Essential Updates for MetaTrader 4/5 Platforms

Preparing for the Daylight Saving Time (DST) Change: Essential Updates for MetaTrader 4/5 Platforms

25 October, 2024

#letushostyou

Award Winning Hosting Provider established in 2004.

120 Faneromenis Avenue, Imperial Tower, 2nd Floor, Larnaca 6031, Cyprus

Products

Bare Metal Servers

Customized Servers

Virtual / Cloud Servers

Forex VPS

Storage VPS

cPanel Web Hosting

Reseller Web Hosting

Colocation

Addons

Premium DNS

Email Hosting

Cloud Backup

DDoS Protection

Licenses

SSL Certificates

Domain Names

Premium SLAs

About Us

Data Center Locations

Looking Glass

Our Company

Contact Us

Careers in Cyprus

Become a Partner

Awards

Certifications

© 2024 S.S. NetShop Internet Services Ltd. All rights reserved.  Terms & Conditions  |  Privacy Policy
CY Reg. Number: HE 217340 | EU VAT Number: CY10217340J

Visa
Mastercard
PayPal
Bitcoin
Tether
Ethereum
Litecoin
Wise
Revolut
Wire Transfer