How to Increase & Expand Your Filesystem in CentOS 8

How to Increase & Expand Your Filesystem in CentOS 8

What Do I Need?

  • A Dedicated or VPS Linux Server
  • CentOS
  • Putty

What is the Filesystem Extension?

Very early on in your career as a web server sysadmin, it’ll soon become necessary to use an awesome tool called LVM.

  1. Inputs
  1. Check the size of the filesystem by using the following command:
df -h

  1. Let’s take a look at the drives present and see how we’re going to increase them.
fdisk -l

  1. Increase Disk Size
  1. In this guide, we’re going to simulate increasing the size of the /dev/sda4 (Linux LVM) by a size of 10GB.
  1. Create Partition
  1. After increasing the size of the disk, you need to create a new partition:
fdisk /dev/sda


  1. Press ‘N’ to a new partition.
  2. Next press ‘P’ to indicate the type. We’ll select ‘Primary’.
  3. When asked to indicate a partition number, by default it’s the following with the number ‘3’.
  4. Next, the starting and ending sectors are indicated. Ensure you check that they match the values specified by a hyphen. In this example, we’ll use all of the unallocated space:

  1. Change the default type to Linux LVM. To do this, use the ‘T’ command, indicate the type of partition we want to change and number, and enter its code in the 8e hexadecimal system:

  1. Next press ‘P’:

  1. Now you’ve created /dev/sda3 partition. It remains only to save the changes with the ‘W’ command. After that the fdisk will automatically close:

  1. Extend LVM
  1. To use the created volume in LVM, initialize it with the pvcreate common:
pvcreate /dev/sda3

  1. Check the name of the volume group to which you want to add the partition. Let’s use vgdisplay for this. The default is cl:

  1. Add the new partition to this group:
vgextend cl /dev/sda3

  1. Using the lvdisplay let’s look at the name and path to the logical one that needs to be expanded, by default, this is root and /dev/cl/root:
lvdisplay

  1. Next, expand it. In order to facilitate this, lvextend will specify the path to the logical volume and the -l +100%FREE parameter, which indicates that we want to use all of the free space:
lvextend -l +100%FREE /dev/cl/root

  1. The last step left is to expand the filesystem. If you’re using xfs using the following command:
xfs_growfs /dev/mapper/cl-root
  1. If you’re using ext4, use the following command:
resize2fs -p /dev/mapper/cl-root

  1. Check the results and ensure that they match what you’re expecting:
df -h

Next Steps

Before starting on expanding and extending your filesystem, I recommend first getting a pen and pad and working out where you want the majority of your space allocated. It’s best to do this on a fresh server implementation before you start building up various sites and applications in-situ. It’s always a good idea to keep some hard disk space free just in case your client’s webspace expansion needs outstrip your own automated systems. To this end, plan ahead and implement before your web server layout with the following considerations in mind:

  • Will the bulk of your users be e-commerce or business users?
  • If so, prepare for large databases and lots of content.
  • Will the bulk of your users be script-runners and app developers?
  • If so, prepare again for large databases and lots of processor and memory cycles.

Conclusion

Always look out for those pesky log files and temporary caches getting a little too big. So get used to purging useless dumps periodically. To that end, try out some of the following commands when things start to get a little hectic:

        cd /var/tmp
        rm -r *

** Huge thanks to Paul Joyce for correcting a typo on one of the commands!

  • Do you need the best VPS? Read about our different offers.

How To Set up a VSFTPD Server on a CentOS 7 VPS or Dedicated Server

Brief Description FTP is usually insecure exposing clear-text passwords, userna
2 min read
Avi Ilinsky
Avi Ilinsky
Hosting Expert

How To Set up a VSFTPD Server on an Ubuntu 16.04 VPS or Dedicated Server

Brief Description FTP data is usually insecure since information (usernames, pa
2 min read
Eliran Ouzan
Eliran Ouzan
Web Designer & Hosting Expert

How to use phpMyAdmin to develop a website (without MySQL experience)

Brief description A web developer who is not well versed into coding websites f
2 min read
Idan Cohen
Idan Cohen
Marketing Expert

How to Install MySQL on a Windows Web Server Running Apache

This tutorial will show you how to install the MySQL database on a Windows serve
3 min read
Michael Levanduski
Michael Levanduski
Expert Hosting Writer & Tester
HostAdvice.com provides professional web hosting reviews fully independent of any other entity. Our reviews are unbiased, honest, and apply the same evaluation standards to all those reviewed. While monetary compensation is received from a few of the companies listed on this site, compensation of services and products have no influence on the direction or conclusions of our reviews. Nor does the compensation influence our rankings for certain host companies. This compensation covers account purchasing costs, testing costs and royalties paid to reviewers.
Click to go to the top of the page
Go To Top