lxc-create wastes disk space by keeping installation debs

Bug #1037626 reported by Fajar A. Nugraha on 2012-08-16
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxc (Ubuntu)
Medium
Unassigned

Bug Description

A default ubuntu container created using "lxc-create -n ubuntu -t ubuntu" results in 386M space used on /var/lib/lxc/ubuntu/rootfs. A big part of that space is used by cached debs on /var/lib/lxc/ubuntu/rootfs/var/cache/apt/archives/ . Running "apt-get clean" inside the container's rootfs reduced space usage to 242M.

The wasted space becomes even more apparent if the backing store supports compression (e.g. zfsonlinux with gzip compression enabled). In this case the original used space (after compression) was 196M, and was reduced to 95M after the cached package files are removed, over 50% disk space saving.

Suggestion: Modify lxc-ubuntu template to run "apt-get clean" inside the container's rootfs as part of container creation process.

# lsb_release -rd
Description: Ubuntu 12.04.1 LTS
Release: 12.04

# apt-cache policy lxc
lxc:
  Installed: 0.7.5-3ubuntu62
  Candidate: 0.7.5-3ubuntu62
  Version table:
 *** 0.7.5-3ubuntu62 0
        500 http://archive.ubuntu.com/ubuntu/ precise-updates/universe amd64 Packages
        100 /var/lib/dpkg/status
     0.7.5-3ubuntu52 0
        500 http://archive.ubuntu.com/ubuntu/ precise/universe amd64 Packages

Expected result:
"lxc-create -t ubuntu" result in a container which uses disk space efficiently

Actual result:
"lxc-create -t ubuntu" result in a container which uses more disk space than it should

Related branches

Serge Hallyn (serge-hallyn) wrote :

Thanks, Fajar. Agreed this should be done.

Changed in lxc (Ubuntu):
status: New → Triaged
importance: Undecided → Medium
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package lxc - 0.8.0~rc1-4ubuntu26

---------------
lxc (0.8.0~rc1-4ubuntu26) quantal; urgency=low

  * 0100-template-cleanup-cache: clean up template cache if interrupted
    during build. (LP: #1037331)
  * 0101-template-empty-apt-cache: do an apt-cache clean after creating
    a new cache. (LP: #1037626)
  * 0102-lxc-start-d-check-privs: exit early (with failure) if starting a
    daemonized container with insufficient privilege. (LP: #918327)
  * 0103-make-rootfs-location-optional: allow custom location for a
    container rootfs to be specified. (LP: #1019398)
 -- Serge Hallyn <email address hidden> Fri, 17 Aug 2012 09:44:02 -0500

Changed in lxc (Ubuntu):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers