Need help?

Our experts have had an average response time of 11.7 minutes in August 2021 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

LXC LVM – How to add storage space

by | Jun 30, 2019

LXC aka “Linux containers” make virtual server creation easy.

However, often LXC containers quickly fill the root file system to 100% and get into app errors. And, adding additional disk space using LXC LVM method come to rescue here. But, any bad step while adding disk can corrupt the live data.

That’s why, we frequently receive requests to add storage via LXC LVM method as part of our Server Management Services.

Today, we’ll see how our Dedicated Engineers make use of LVM method to add disk space in LXC.


Why LXC LVM method ?

Logical Volume Management or LVM allows much flexibility in LXC disk space management. It allows to simply expand the host’s root file system.

Typically, we suggest customers to maintain one logical volume per container and mount each of those as sub directories of /var/lib/lxc. Moreover, we then rename each of these volume with unique details. Again, this helps to separate the disk of the LXC container from the main server.

Let’s now check on how our Support Engineers added storage to LXC container for one of our customers.

The customer was running LXC containers inside Amazon EC2 instances.


Preparing LXC for disk addition

Usually, we make sure to backup the LXC instance prior to disk addition. This would work as a fall back option in case of any failures in the process.

The options included AMI backup or Volume snapshot of LXC instance. In general, Volume Snapshot will not work for this instance as the customer was using LVM in all his EC2 instances.

The only option was to create an AMI image of EC2 instance for backup of EC2 instance. Therefore, we went ahead with the AMI backup before proceeding the disk extension.

Again, the AMI backup task involves shutting down the instance first. This would avoid any possible anomalies during the backup process.


How we add disk space using LXC LVM method

After backup from the admin panel, we connect to the hardware node server as root user. Here the customer wanted to add 100GB to the LXC instance.

We begin by issuing the command lsblk that lists information about all available block devices on the server. Here, the output show up as :

[[email protected] centos]# lsblk
xvdc 202:32 0 80G 0 disk
└─xvdc1 202:33 0 80G 0 part
└─VG_LXC-LV_LXC 253:0 0 170G 0 lvm /lxc
xvda 202:0 0 10G 0 disk
└─xvda1 202:1 0 10G 0 part /
xvdf 202:80 0 100G 0 disk
└─xvdf1 202:81 0 100G 0 part
xvdb 202:16 0 100G 0 disk
└─xvdb1 202:17 0 100G 0 part
└─VG_LXC-LV_LXC 253:0 0 170G 0 lvm /lxc

Adding additional 100GB volume to the existing LXC involves the following steps.


1. Create a new physical volume

At first, we create a new physical volume by executing the command:

pvcreate /dev/xvdf1
Physical volume "/dev/xvdf1" successfully created

Further, we use the pvdisplay command to see that the new physical volume shows up correctly.


2. Add a volume group

Now, we need to add the newly created physical volume to the Volume Group. For example, to add /dev/xvdf1 to volume group VG_LXC, we use :

vgextend VG_LXC /dev/xvdf1

Then to confirm the status of the volume group, we execute:


3. Extend the disk

It’s time now to extend the disk. For this, our Dedicated Engineers execute the command as :

lvextend -L +100G /dev/VG_LXC/LV_LXC

This extends the disk by 100 GB.
Here also, we use lvdisplay command to see the attributes of a logical volume including size, read/write status, etc.

4. Mount

We, then mount the extended volume group and expand the size of the mounted filesystem by using the following steps.

resize2fs /dev/VG_LXC/LV_LXC

Here, for the resize2fs program to work on a mounted file system, the kernel should support on-line resizing.

Finally, we confirm that the newly added disk shows up fine using the command:

df -h

The output clearly shows free 100G on the /dev/mapper/VG_LXC-LV_LXC partition.

[Trouble adding disk to LXC using LVM ? We can fix it for you.]



In short, the need for extending disk space often arises in LXC instances. Today, we saw how our Support Engineers use the LXC LVM method to add disk space and fix related errors.


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.


var google_conversion_label = "owonCMyG5nEQ0aD71QM";


Submit a Comment

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

Privacy Preference Center


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]


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


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

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie


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.