canonical / lxd

Powerful system container and virtual machine manager
https://canonical.com/lxd
GNU Affero General Public License v3.0
4.38k stars 931 forks source link

How to free up space after using snapshots? #9127

Closed ma3252788 closed 3 years ago

ma3252788 commented 3 years ago

Required information

Issue description

At some point in the past, I took a snapshot of a container, and recently when I was organizing the container, I noticed that the space inside the container was not freed up after the files were deleted, and I think this is because I took a snapshot before. How do I properly free up my hard drive space? Just delete all the previous snapshots?

Steps to reproduce

  1. lxc snapshot part1 snapname
  2. lxc exec part1 bash
  3. delele some files, however, the free space does not decrease after running the df -h command

Information to attach

Log:

lxc part1 20210817010616.705 WARN conf - conf.c:lxc_setup_devpts:1616 - Invalid argument - Failed to unmount old devpts instance


 - [ ] Container configuration (`lxc config show NAME --expanded`)

architecture: x86_64 config: image.architecture: x86_64 image.description: Ubuntu 16.04 LTS server (20181207) image.os: ubuntu image.release: xenial security.privileged: "true" volatile.base_image: ed24e99183897c62fad305b6f2257c33c1cb457f6d59a970b421046e8f94481f volatile.eth1.hwaddr: 00:16:3e:3a:0f:98 volatile.eth1.name: eth0 volatile.idmap.base: "0" volatile.idmap.next: '[]' volatile.last_state.idmap: '[]' volatile.last_state.power: RUNNING devices: eth1: nictype: bridged parent: br1 type: nic gpu: type: gpu nvidia-uvm: path: /dev/nvidia-uvm type: unix-char root: path: / pool: lxd-zfs type: disk share: path: /home/ubuntu/bigdisk source: /home/mcj/bigdisk type: disk ephemeral: false profiles:

stgraber commented 3 years ago

Closing as this is a support question and not really an issue (nothing actionable for us). In general those are better handled at https://discuss.linuxcontainers.org

But yes, you're correct, a snapshot is always free at the time it's taken but becomes costly overtime as the state diverges. If you create an instance with 2GB of data, you make a snapshot and then proceed to delete that 2GB of data. The size will still be 2GB as the snapshot is preventing it from getting actually released.