[SOLVED] docker on btrfs using much space in /var/lib/docker/btrfs
Linux - ContainersThis forum is for the discussion of all topics relating to Linux containers. Docker, LXC, LXD, runC, containerd, CoreOS, Kubernetes, Mesos, rkt, and all other Linux container platforms are welcome.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
docker on btrfs using much space in /var/lib/docker/btrfs
Hi,
I have successfully converted my server system to the file system' btrfs' since 2 weeks.
Everything is going well and I am very happy with the possibilities of' btrfs'.
There's one thing, though, that puzzles me.
Docker seems to use a lot of memory under' /var/lib/docker/btrfs/subvolumes', a multiple of the size of the docker containers and a multiple of what it needed on my' ext4' file system.
' du -sh /var/lib...' shows me 21GB, my backup shows me 21GB, but if I make a backup of my server offline with Clonezilla, it is only 2.3 GB in total. That's the way it should be.
Is this just wrong?
I read through the following pages, but I didn't really get any smarter.
One of Btrfs's biggest advantages over most file system types is that it uses copy on write (COW) extensively. Docker takes advantage of COW to manage storage efficiently. The "du" command adds up the space allocated to files, but doesn't consider that some of the space may be shared between files. Space measurement on Btrfs is not straightforward and you can't take all numbers from tools such as "du" and "df" at face value. It doesn't sound like you're running out of space yet.
Btrfs is different from traditional filesystems. It is not just a layer that translates filenames into offsets on a block device, it is more of a layer that combines a traditional filesystem with LVM and RAID. And like LVM, it has the concept of allocating space on the underlying device, but not actually using it for files.
A traditional filesystem is divided into files and free space. It is easy to calculate how much space is used or free:
|--------files--------| |
|------------------------drive partition-------------------------------|
Btrfs combines LVM, RAID and a filesystem. The drive is divided into subvolumes, each dynamically sized and replicated:
|--files--| |--files--| |files| | |
|----@raid1----|------@raid1-------|-----@home-----|metadata| |
|------------------------drive partition-------------------------------|
The diagram shows the partition being divided into two subvolumes and metadata. One of the subvolumes is duplicated (RAID1),
so there are two copies of every file on the device. Now we not only have the concept of how much space is free at the filesystem layer,
but also how much space is free at the block layer (drive partition) below it. Space is also taken up by metadata.
When considering free space in Btrfs, we have to clarify which free space we are talking about - the block layer, or the file layer?
At the block layer, data is allocated in 1GB chunks, so the values are quite coarse, and might not bear any relation to the amount of space
that the user can actually use. At the file layer, it is impossible to report the amount of free space because the amount of space depends
on how it is used. In the above example, a file stored on the replicated subvolume @raid1 will take up twice as much space as the same file
stored on the @home subvolume. Snapshots only store copies of files that have been subsequently modified. There is no longer a 1-1 mapping
between a file as the user sees it, and a file as stored on the drive.
You can check the free space at the block layer with
btrfs filesystem show / and the free space at the subvolume layer with
btrfs filesystem df /
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.