Bobcares

Increase LXD Storage Pool Size Based on Storage Backend

by | Oct 7, 2024

Learn how to increase LXD Storage Pool Size based on the Storage Backend. Our LXC/LXD Support team is here to help you with your questions and concerns.

How to Increase LXD Storage Pool Size Based on Storage Backend

How to Increase LXD Storage Pool Size Based on Storage BackendIncreasing the size of an LXD storage pool as our workloads grow is an inevitable part of managing scalable infrastructure.

In fact, the process depends on the type of storage backend we are using, such as ZFS, Btrfs, LVM, or a simple directory backend (`dir`). Each storage backend has its unique method for resizing.

Today, we will take a look at how to expand the storage pool for each of these backends.

An Overview:

Benefits of Expanding LXD Storage Pools

  • Expanding LXD storage pools ensures containers have enough space to operate smoothly, avoiding crashes or downtime.
  • Lack of storage can degrade performance. Expanding storage pools helps prevent slowdowns by providing sufficient resources for logging, caching, and data writing.
  • Sufficient storage prevents service interruptions and ensures stable container environments, reducing the risk of application crashes.
  • Expanding pools supports seamless scaling of containerized applications as workload demands grow.
  • Adequate storage allows for better allocation of resources across containers, reducing bottlenecks.

Prerequisites for Increasing Storage Pool Size

  • Expanding storage requires root or elevated permissions. Use `sudo` to execute required commands.
  • Take backups before making changes to avoid data loss, and verify their integrity by restoring in a staging environment.
  • Ensure sufficient free disk space is available using tools like `df -h`.
  • Confirm the storage backend supports resizing and identify the specific method needed for expansion.
  • Prepare for potential downtime by scheduling the process during maintenance windows and notifying stakeholders.

1. Increasing the Size of a ZFS Storage Pool

If our LXD storage pool uses the ZFS backend, we can increase its size either by expanding the partition or by adding additional storage. The steps vary depending on how our pool was created.

Case 1: Pool Based on a Disk Partition

If our ZFS storage pool is backed by a disk partition or a block device, follow these steps to expand it:

  1. Use tools like `fdisk` or `parted` to expand the partition where the ZFS pool resides:

    sudo fdisk /dev/sdX

    Then, follow the instructions to resize the partition.

  2. Once the partition is resized, tell ZFS to use the new space:

    sudo zpool set autoexpand=on
    sudo zpool online -e /dev/sdX

    This allows ZFS to automatically expand to use the additional available space.

Case 2: Pool Based on a ZFS Dataset

If our ZFS pool is created using a dataset (e.g., a file used as a source), we can resize the backing file:

  1. Resize the Backing file:

    truncate -s +10G /path/to/zfs_backing_file.img

  2. Then, expand the ZFS Pool:

    zpool online -e /path/to/zfs_backing_file.img

    This method increases the size of the ZFS dataset used by the pool.

2. Increasing the Size of a Btrfs Storage Pool

The Btrfs backend can be resized either by adding more devices to the pool or by expanding the existing partition.

Case 1: Adding a Device to a Btrfs Pool

  1. Add a new device:

    sudo btrfs device add /dev/sdX /path/to/btrfs/mount

  2. After adding a new device, balance the filesystem to distribute the data evenly across devices:

    sudo btrfs balance start /path/to/btrfs/mount

Case 2: Growing the Partition

If our Btrfs pool is based on a partition:

  1. Use `fdisk` or `parted` to grow the partition.
  2. Resize the Btrfs Filesystem:

    sudo btrfs filesystem resize max /path/to/btrfs/mount

    This will use the newly allocated space to expand the Btrfs filesystem.

 

3. Increasing the Size of an LVM Storage Pool

If our LXD storage pool is backed by LVM, you can expand the pool by resizing the logical volume.

  1. First, extend the volume group if necessary and resize the logical volume:

    sudo lvextend -L +10G /dev/volume_group/logical_volume

  2. Resize the LVM Filesystem:
    • For ext4 Filesystem:

      sudo resize2fs /dev/volume_group/logical_volume

    • For xfs Filesystem:

      sudo xfs_growfs /dev/volume_group/logical_volume

4. Increasing the Size of a Dir Storage Backend

The dir storage backend is simply a directory on the filesystem. Increasing its size depends on expanding the underlying partition or adding additional storage.

  1. If the storage pool resides on a partition, extend the partition using tools like `fdisk` or `parted`. Resize the partition or filesystem to accommodate the larger directory.
  2. Alternatively, mount additional storage (like an external disk) to the directory where the storage pool resides.

Potential Risks and How to Mitigate Them

  • Always back up data before resizing. Verify backups to ensure they work in case a restore is needed.
  • Plan resizing during maintenance windows to minimize disruption, and communicate with stakeholders in advance.
  • Use reliable tools (`fdisk` or `parted`) carefully and verify partition changes to avoid corruption.
  • Run `fsck` before and after resizing to check for errors, ensuring a smooth process.
  • Monitor system load during resizing to prevent performance degradation, and pause resizing if needed.
  • Gracefully stop non-critical containers before resizing to avoid freezing and to ensure they restart smoothly.
  • If you run into an error that says “This storage pool is in use” head to this link for a quick solution.

 

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

Conclusion

Increasing the size of an LXD storage pool depends heavily on the storage backend in use. For ZFS the process involves either resizing partitions or expanding datasets. Btrfs allows adding new devices or growing existing partitions, while LVM needs logical volumes extended. Finally, the dir backend requires expanding the underlying filesystem or adding additional storage.

In brief, our Support Experts demonstrated how to increase LXD Storage Pool Size based on the Storage Backend.

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