LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Containers
User Name
Password
Linux - Containers This 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


Reply
  Search this Thread
Old 01-20-2018, 06:55 AM   #1
taumeister
Member
 
Registered: Nov 2017
Location: Germany / Bonn
Distribution: Deepin Linux, Debian
Posts: 65

Rep: Reputation: 1
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.

https://success.docker.com/article/W...age_filesystem

https://github.com/moby/moby/issues/27653

https://github.com/moby/moby/issues/3894

Last edited by taumeister; 01-25-2018 at 04:13 PM.
 
Old 01-24-2018, 09:53 PM   #2
JonnerR
LQ Newbie
 
Registered: Dec 2005
Posts: 22

Rep: Reputation: 17
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.
 
1 members found this post helpful.
Old 01-25-2018, 04:13 PM   #3
taumeister
Member
 
Registered: Nov 2017
Location: Germany / Bonn
Distribution: Deepin Linux, Debian
Posts: 65

Original Poster
Rep: Reputation: 1
Youre right! Thanks for explanation

I found a good info on Ubuntu Forum

Quote:
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 /
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Canonical and Docker Partner to Distribute Docker Releases as Snaps on Ubuntu LXer Syndicated Linux News 0 12-03-2016 09:57 PM
btrfs filesystem df /mnt/btrfs/ shows bothe data and metdata with raid1 and single. gonus Linux - Software 3 07-17-2014 02:48 PM
LXer: Rollback To A Working State With btrfs + apt-btrfs-snapshot On Ubuntu 12.10 LXer Syndicated Linux News 0 11-25-2012 10:42 AM
ext4 vs btrfs, and with btrfs do I still need to use LVM? blue_k Linux - Software 4 08-17-2012 11:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Containers

All times are GMT -5. The time now is 02:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration