Advance

How To Resize Active Root Partition On CentOS

How To Resize Active Root Partition On CentOS

During the CentOS installation, you partition and allocate disk space. Since the ”home partition” is always created when you install a Linux distro, clearly you will have a home directory that is also possible to be created on a separate partition. The /home directory is where your personal data such as downloaded files, settings, and system customizations are stored. However, if you do not create a separate /home partition, your /home directory will be located on your root partition. After a while, you may realize that your home partition is fully occupied and you need to resize it. In this situation, you will need to shrink your Root Partition to allocate more free space to the Home Partition. Join us with this article to learn How To Resize Active Root Partition On CentOS. Choose your considered plan on Eldernode to purchase your own CentOS VPS.

Tutorial Resize Active Root Partition On CentOS

The size of your root partition will vary depending on what you install or plan to install. However, a root partition between 2GB and 8GB could be fine. Note that a partition that you create for the root directory is different from the ”root” user account who is the administrator of the system. The root file system is represented by a forward slash (/). It is at the top of the directory tree and contains Linux and everything that you install with Linux. This is roughly equivalent to your “C:” drive under DOS or Windows. In the following, you will learn more about partitioning and the way you can resize the active root portion on CentOS.

Recommended Article: How To Resize Active Root Partition On CentOS

Prerequisites to resize active root Partition on CentOS

To increase or decrease the size of the partition you should consider some basic requirements. The desired partition must not be mounted. To resize the root LVM partition, you should boot into rescue mode and it is not possible to unmount the root partition so online.

If you resize the primary partition (non-lvm), it can be dangerous. So, do not forget to backup your content you attempt to change the size of the partition. But if you have LVM configured on your system, you do not need to worry about file system resizing, as LVM allows you to resize the file system whenever you need it.

Resize Active Root Partition On CentOS

When you install a Linux distribution on your computer, you may create three partitions. Root, Home, and Swap. Let’s go through the steps of this section to review the required steps of resizing root partition. First, you need to back up important data before performing this operation. Although the presented solution is safe, you must retain your data in the case of a failure such as a power outage or a system restart during operation.

Step 1:

Use the following command to back up the content of /home:

mkdir /temp
cp -a /home /temp/

Step 2:

Once the backup process is finished successfully, unmount the /home directory by running the command below:

umount -fl /home

Step 3:

Since you need to note the size of the home LVM volume, you can run the lvs command to display the attributes of the LVM volumes:

lvs

Note: You may view the line ”Couldn’t create temporary archive name” in the output of the above command. It is due to the root partition being full. Clear some space in the root to solve it.

Step 4:

Now, you can remove the home LVM volume. So, type:

lvremove /dev/cl/home

Step 5:

Based on your output in step 3, you will be able to extend the root LVM. Put the displayed amount of the home centos directory in the command below. To resize the root LVM volume, run:

lvextend -L+**G /dev/cl/root

Step 6:

Now, you can resize the root partition by running the following command:

xfs_growfs /dev/mapper/cl-root

Step 7:

Then, use the command below to copy the /home contents back into the /home directory:

cp -a /temp/home /

Step 8:

At this point, you need to remove the temporary location. So, type:

rm -rf /temp

Step 9:

Next, you should remove the entry from /etc/fstab. So open your favorite text editor and open /etc/fstab and remove the line for /dev/mapper/cl-home.

Step 10:

In the final step, use the command below to sync systemd up with the changes:

dracut --regenerate-all --force

Conclusion

In this article, you learned How To Resize Active Root Partition On CentOS. You are recommended to unmount live partitions to resize them, otherwise, you will face the risk of losing data. This solution is not limited to the root partition, and you can resize any partition available in the system. Also, you can refer to partition CentOS with SSD and NVMe storage. In case of receiving an unexpected error, let us and your friends know on Eldernode Community to help you solve it.

View More Posts
Tom Veitch
Eldernode Writer
We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave a Reply

Your email address will not be published. Required fields are marked *

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way

+8595670151

7 days a week, 24 hours a day