Bobcares

How to extend XFS filesystem with LVM

by | Apr 2, 2023

Learn how to extend XFS filesystem with LVM. Our Server Management Support team is here to help you with your questions and concerns.

How to extend XFS filesystem with LVM

XFS is a popular file system that offers high scalability, high performance, as well as capacity. It comes in handy when a large amount of data has to be stored or used on the File system.

Furthermore, it offers several useful features like xfs_freeze, snapshot, xfs_unfreeze, and so on.

How to extend XFS filesystem with LVM

Unfortunately, a key limitation of XFS is that we can not downsize or reduce the file system.

However, in modern Linux distributions like Rocky Linux, Fedora, RHEL 8/9, AlmaLinux, and Ubuntu, XFS is still the default file system.

Today. We are going to take a look at how to extend XFS filesystem with LVM. Before we begin, we have to ensure that a new disk (/dev/sdb) has been added to the Linux system so that we can carry out the following steps on it:

  1. First, we have to check if the lvm2 package is installed. If not, run the following commands:
    • For Ubuntu & Debian System

      $ sudo apt install -y lvm2

    • For RHEL 7 & CentOS 7

      # yum install lvm2 -y

    • For RHEL 9/8, Rocky Linux & AlmaLinux

      # dnf install lvm2 -y

  2. Then, we have to create a partition with the fdisk command as seen here:

    fdisk /dev/sdb

    Then enter n to create the new partition.

  3. At this point, we have to enter p as the partition type.
  4. Then, enter 1 as the Partition number.
  5. Next, we have to enter the starting and ending sectors of our hard drive.
  6. Finally, we have to enter the size of the partition. For example, if we want a 10GB partition, we have to enter +10GB.
  7. After the above step, we have to create the LVM components as seen below:

    # pvcreate /dev/sdb1
    Physical volume "/dev/sdb1" successfully created

    ]# vgcreate vg_xfs /dev/sdb1
    Volume group “vg_xfs” successfully created

    # lvcreate -L +6G -n xfs_db vg_xfs
    Logical volume “xfs_db” created

  8. Now, we must format the LVM Partition as XFS File System with the following command:

    # mkfs.xfs /dev/vg_xfs/xfs_db

  9. Then, create a directory, xfs_test under /root. Now, we have to mount it as seen below:

    # mkdir /root/xfs_test
    # mount /dev/vg_xfs/xfs_db /root/xfs_test/
    # df -hT /root/xfs_test
    # mount | grep /dev/mapper/vg_xfs-xfs_db

    If we want to permanently mount the filesystem, our experts recommend adding the entry to /etc/fstab file.

  10. Next, we must verify that the Volume group has free space available with this command:

    # vgs vg_xfs

    Based on the output of the above command we can extend the file system with the lvextend command with “-r” option.

    Alternatively, if XFS is not based on LVM , we have to use xfs_growsfs command as seen below :

    # xfs_growfs -D

[Need assistance with a different issue? Our team is available 24/7.]

Conclusion

In summary, our Support Techs demonstrated how to extend XFS filesystem with LVM in few easy steps.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

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

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF