Online resizing of an LXC container on LVM volume

Written by - 0 comments

Published on - Listed in Linux LVM


In the past I already tried to dynamically resize a running LXC on a Debian Wheezy machine with LXC 0.8. Although the logical volume and its file system could be increased, the LXC itself, running on this LV, did not see the new disk size. Only after a reboot of the LXC in question, the new disk size was seen.

That has changed now and it works. On an Ubuntu 14.04 with LXC 1.0.3 I successfully increased an LXC's rootfs while running.

The disk size was first 20G, which could be seen in the LXC itself:

root@lxc1:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/lxc/lxc1   20G  8.2G   11G  44% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
none            3.2G   80K  3.2G   1% /run
none            5.0M     0  5.0M   0% /run/lock
none             16G     0   16G   0% /run/shm
none            100M     0  100M   0% /run/user

On the physical host I increased/extended the logical volume of this LXC with additional 100GB:

root@physical-host:~# lvextend -L +100G /dev/lxc/lxc1
  Extending logical volume lxc1 to 120.00 GiB
  Logical volume lxc1 successfully resized

... and then adjusted the file system size to the new LV size:

root@physical-host:~# resize2fs /dev/lxc/lxc1
resize2fs 1.42.9 (4-Feb-2014)
Filesystem at /dev/lxc/lxc1 is mounted on /var/lib/lxc1/rootfs; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 8
The filesystem on /dev/lxc/lxc1 is now 31457280 blocks long.

In the LXC, I ran df again:

root@lxc1:~# df -h
Filesystem     Size  Used Avail Use% Mounted on
/dev/lxc/lxc1  118G  8.2G  105G   8% /
none           4.0K     0  4.0K   0% /sys/fs/cgroup
none           3.2G   84K  3.2G   1% /run
none           5.0M     0  5.0M   0% /run/lock
none            16G     0   16G   0% /run/shm
none           100M     0  100M   0% /run/user

Fun :-).


Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.

RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Observability   Office   OpenSearch   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder