Bug 1327596

Summary: systemd creates btrfs <container>/var/lib/machines snapshot inside the container
Product: [Fedora] Fedora Reporter: Paul Alesius <Paul>
Component: systemdAssignee: systemd-maint
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: unspecified    
Version: 23CC: johannbg, lnykryn, msekleta, muadda, Paul, s, systemd-maint, zbyszek
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-04-15 13:29:56 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Paul Alesius 2016-04-15 13:04:37 UTC
Description of problem:
I have a btrfs disk mounted to /var/lib/machines on the host (no subvol, just the root of the btrfs), and something creates additional snapshots inside /var/lib/machines

Version-Release number of selected component (if applicable):
systemd.x86_64                           222-14.fc23               @@commandline
kernel 4.5

How reproducible:
always

Steps to Reproduce:
1. mount btrfs to /var/lib/machines
2. create a subvolume,let's say "testcontainer", so you have /var/lib/machines/testcontainer
3. After some time, I don't know when or what's causing it, but issuing:
    "btrfs subvolume list -a /var/lib/machines"
  results in:
    ID 279 gen 5904 top level 5 path testcontainer
    ID 285 gen 5904 top level 277 path <FS_TREE>/testcontainer/var/lib/machines


Additional info:
Note the additional subvolume that exists inside the container, the snapshot is of /var/lib/machines/testcontainer/var/lib/machines

Comment 1 Michal Sekletar 2016-04-15 13:08:33 UTC
I think it is systemd-tmpfiles which creates sub-volume inside the container once you boot it.

Comment 2 Paul Alesius 2016-04-15 13:21:43 UTC
You're right, I think this fixed it:

  cp /usr/lib/tmpfiles.d/systemd-nspawn.conf /var/lib/machines/etc/tmpfiles.d/
  vim /var/lib/machines/etc/tmpfiles.d/systemd-nspawn.conf

And comment out the line "v /var/lib/machines 0700 - - -"

The "v" according to "man tmpfiles.d", makes it create a snapshot.

It still shouldn't be the default behavior to create snapshots, since it creates a btrfs subvolume mess with stuff you don't want.

Comment 3 Paul Alesius 2016-04-15 13:29:47 UTC
Creating the directory /var/lib/machines inside the container, seems to also fix it, since tmpfiles.d will see that the directory exists and not invoke a btrfs subvolume/snapshot create to create it.