LXC launch: failed to create file backup.yaml: no such file or directory

I’m developing a DRBD+LXD recipe.

I’m pretty far along. I’ve got LXD 4.10 + LXC 4.0.6 running entirely contained in a btrfs filesystem on a DRBD partition. I’m containing LXD on the DRBD partition by setting the LXD_DIR environment variable. Since snap doesn’t honor the LXD_DIR variable, I am installing LXD & LXC by compiling from source.

My goal is to import a bunch of running openvz containers.

When I try to launch my imported container it fails with:

% lxc launch dnsimage dns -s r0
Creating dns
Error: Failed to create file 'r0/lxd/containers/dns/backup.yaml': open r0/lxd/containers/dns/backup.yaml: no such file or directory

I only have one storage pool:

% lxc storage list
+------+----------------+--------+-----------+---------+
| NAME |  DESCRIPTION   | DRIVER |  SOURCE   | USED BY |
+------+----------------+--------+-----------+---------+
| r0   | btrfs on drbd0 | btrfs  | /r0/pools | 1       |
+------+----------------+--------+-----------+---------+

Is this a bug or is there something wrong with my image, or is there something else that’s causing the failure?

I created the image by copying an openvz container to rootfs then:

rm -r rootfs/dev rootfs/proc
mkdir rootfs/dev rootfs/proc
cat > metadata.yaml
architecture: x86_64
creation_date: 1611437171
properties:
  description: import legacy "ns" -- Ubuntu 14.04 LTS
  os: Ubuntu
  release: trusty 14.04
END
tar czf dnsimage.tgz metadata.yaml rootfs
lxc image import dnsimage.tgz --alias dnsimage

I tried lxc monitor and reproduce the issue. The log doesn’t seem very informative:

location: none
metadata:
  context: {}
  level: dbug
  message: 'New event listener: 32af35c9-7aa5-45b4-a0cc-e1e58f52661d'
timestamp: "2021-01-23T21:12:39.04315908-08:00"
type: logging


location: none
metadata:
  context:
    ip: '@'
    method: GET
    protocol: unix
    url: /1.0
    username: root
  level: dbug
  message: Handling
timestamp: "2021-01-23T21:12:41.680504745-08:00"
type: logging


location: none
metadata:
  context:
    ip: '@'
    method: GET
    protocol: unix
    url: /1.0/storage-pools/r0
    username: root
  level: dbug
  message: Handling
timestamp: "2021-01-23T21:12:41.682214214-08:00"
type: logging


location: none
metadata:
  context:
    ip: '@'
    method: GET
    protocol: unix
    url: /1.0/images/aliases/dnsimage
    username: root
  level: dbug
  message: Handling
timestamp: "2021-01-23T21:12:41.683683961-08:00"
type: logging


location: none
metadata:
  context:
    ip: '@'
    method: GET
    protocol: unix
    url: /1.0/images/52091c9062c30d1c1df697e2d7e72ac22a3873565616eeee85850bfeb9119a05
    username: root
  level: dbug
  message: Handling
timestamp: "2021-01-23T21:12:41.684541946-08:00"
type: logging


location: none
metadata:
  context: {}
  level: dbug
  message: 'New event listener: a35c4830-eb3b-4c26-ad16-17ac0b47f885'
timestamp: "2021-01-23T21:12:41.685708462-08:00"
type: logging


location: none
metadata:
  context:
    ip: '@'
    method: GET
    protocol: unix
    url: /1.0/events
    username: root
  level: dbug
  message: Handling
timestamp: "2021-01-23T21:12:41.685571021-08:00"
type: logging


location: none
metadata:
  context: {}
  level: dbug
  message: Responding to instance create
timestamp: "2021-01-23T21:12:41.686510646-08:00"
type: logging


location: none
metadata:
  context:
    ip: '@'
    method: POST
    protocol: unix
    url: /1.0/instances
    username: root
  level: dbug
  message: Handling
timestamp: "2021-01-23T21:12:41.686506026-08:00"
type: logging


location: none
metadata:
  class: task
  created_at: "2021-01-23T21:12:41.68736699-08:00"
  description: Creating instance
  err: ""
  id: c7c9fda1-6ad2-475b-b1b1-ac35daba370a
  location: none
  may_cancel: false
  metadata: null
  resources:
    containers:
    - /1.0/containers/dns
    instances:
    - /1.0/instances/dns
  status: Running
  status_code: 103
  updated_at: "2021-01-23T21:12:41.68736699-08:00"
timestamp: "2021-01-23T21:12:41.701826946-08:00"
type: operation


location: none
metadata:
  context: {}
  level: dbug
  message: 'New task Operation: c7c9fda1-6ad2-475b-b1b1-ac35daba370a'
timestamp: "2021-01-23T21:12:41.701170682-08:00"
type: logging


location: none
metadata:
  context: {}
  level: dbug
  message: 'Started task operation: c7c9fda1-6ad2-475b-b1b1-ac35daba370a'
timestamp: "2021-01-23T21:12:41.701501594-08:00"
type: logging


location: none
metadata:
  class: task
  created_at: "2021-01-23T21:12:41.68736699-08:00"
  description: Creating instance
  err: ""
  id: c7c9fda1-6ad2-475b-b1b1-ac35daba370a
  location: none
  may_cancel: false
  metadata: null
  resources:
    containers:
    - /1.0/containers/dns
    instances:
    - /1.0/instances/dns
  status: Pending
  status_code: 105
  updated_at: "2021-01-23T21:12:41.68736699-08:00"
timestamp: "2021-01-23T21:12:41.701494024-08:00"
type: operation


location: none
metadata:
  context:
    ip: '@'
    method: GET
    protocol: unix
    url: /1.0/operations/c7c9fda1-6ad2-475b-b1b1-ac35daba370a
    username: root
  level: dbug
  message: Handling
timestamp: "2021-01-23T21:12:41.716430071-08:00"
type: logging


location: none
metadata:
  context:
    ephemeral: "false"
    instance: dns
    instanceType: container
    project: default
  level: info
  message: Creating container
timestamp: "2021-01-23T21:12:41.71608802-08:00"
type: logging


location: none
metadata:
  context:
    driver: btrfs
    instance: dns
    pool: r0
    project: default
  level: dbug
  message: FillInstanceConfig started
timestamp: "2021-01-23T21:12:41.717883919-08:00"
type: logging


location: none
metadata:
  context:
    driver: btrfs
    instance: dns
    pool: r0
    project: default
  level: dbug
  message: FillInstanceConfig finished
timestamp: "2021-01-23T21:12:41.717889649-08:00"
type: logging


location: none
metadata:
  context:
    ephemeral: "false"
    instance: dns
    instanceType: container
    project: default
  level: info
  message: Created container
timestamp: "2021-01-23T21:12:41.779882481-08:00"
type: logging


location: none
metadata:
  action: instance-created
  source: /1.0/instances/dns
timestamp: "2021-01-23T21:12:41.779894761-08:00"
type: lifecycle


location: none
metadata:
  context:
    driver: btrfs
    instance: dns
    pool: r0
    project: default
  level: dbug
  message: CreateInstanceFromImage started
timestamp: "2021-01-23T21:12:41.794432127-08:00"
type: logging


location: none
metadata:
  context:
    driver: btrfs
    fingerprint: 52091c9062c30d1c1df697e2d7e72ac22a3873565616eeee85850bfeb9119a05
    pool: r0
  level: dbug
  message: EnsureImage started
timestamp: "2021-01-23T21:12:41.795354842-08:00"
type: logging


location: none
metadata:
  context:
    driver: btrfs
    fingerprint: 52091c9062c30d1c1df697e2d7e72ac22a3873565616eeee85850bfeb9119a05
    pool: r0
  level: dbug
  message: Checking image volume size
timestamp: "2021-01-23T21:12:41.796512788-08:00"
type: logging


location: none
metadata:
  context:
    driver: btrfs
    fingerprint: 52091c9062c30d1c1df697e2d7e72ac22a3873565616eeee85850bfeb9119a05
    pool: r0
    size: ""
  level: dbug
  message: Setting image volume size
timestamp: "2021-01-23T21:12:41.796518768-08:00"
type: logging


location: none
metadata:
  context:
    driver: btrfs
    fingerprint: 52091c9062c30d1c1df697e2d7e72ac22a3873565616eeee85850bfeb9119a05
    pool: r0
  level: dbug
  message: EnsureImage finished
timestamp: "2021-01-23T21:12:41.798038386-08:00"
type: logging


location: none
metadata:
  context:
    driver: btrfs
    instance: dns
    pool: r0
    project: default
  level: dbug
  message: Checking volume size
timestamp: "2021-01-23T21:12:41.799001001-08:00"
type: logging


location: none
metadata:
  context:
    driver: btrfs
    instance: dns
    pool: r0
    project: default
    size: ""
  level: dbug
  message: Set new volume size
timestamp: "2021-01-23T21:12:41.799007591-08:00"
type: logging


location: none
metadata:
  context:
    driver: btrfs
    instance: dns
    pool: r0
    project: default
  level: dbug
  message: CreateInstanceFromImage finished
timestamp: "2021-01-23T21:12:41.997236891-08:00"
type: logging


location: none
metadata:
  context:
    driver: btrfs
    instance: dns
    pool: r0
    project: default
  level: dbug
  message: UpdateInstanceBackupFile started
timestamp: "2021-01-23T21:12:41.997264041-08:00"
type: logging


location: none
metadata:
  context:
    driver: btrfs
    instance: dns
    pool: r0
    project: default
  level: dbug
  message: UpdateInstanceBackupFile finished
timestamp: "2021-01-23T21:12:41.999608623-08:00"
type: logging


location: none
metadata:
  context:
    created: 2021-01-23 21:12:41.704000517 -0800 PST
    ephemeral: "false"
    instance: dns
    instanceType: container
    project: default
    used: 1969-12-31 16:00:00 -0800 PST
  level: info
  message: Deleting container
timestamp: "2021-01-23T21:12:41.999644143-08:00"
type: logging


location: none
metadata:
  context:
    driver: btrfs
    instance: dns
    pool: r0
    project: default
  level: dbug
  message: DeleteInstance started
timestamp: "2021-01-23T21:12:42.00096368-08:00"
type: logging


location: none
metadata:
  context:
    driver: btrfs
    instance: dns
    pool: r0
    project: default
    volName: dns
  level: dbug
  message: Deleting instance volume
timestamp: "2021-01-23T21:12:42.001447743-08:00"
type: logging


location: none
metadata:
  context:
    driver: btrfs
    instance: dns
    pool: r0
    project: default
  level: dbug
  message: DeleteInstance finished
timestamp: "2021-01-23T21:12:42.192211534-08:00"
type: logging


location: none
metadata:
  context:
    created: 2021-01-23 21:12:41.704000517 -0800 PST
    ephemeral: "false"
    instance: dns
    instanceType: container
    project: default
    used: 1969-12-31 16:00:00 -0800 PST
  level: info
  message: Deleted container
timestamp: "2021-01-23T21:12:42.210221978-08:00"
type: logging


location: none
metadata:
  action: instance-deleted
  source: /1.0/instances/dns
timestamp: "2021-01-23T21:12:42.210229458-08:00"
type: lifecycle


location: none
metadata:
  context: {}
  level: dbug
  message: 'Failure for task operation: c7c9fda1-6ad2-475b-b1b1-ac35daba370a: Failed
    to create file ''r0/lxd/containers/dns/backup.yaml'': open r0/lxd/containers/dns/backup.yaml:
    no such file or directory'
timestamp: "2021-01-23T21:12:42.210249038-08:00"
type: logging


location: none
metadata:
  class: task
  created_at: "2021-01-23T21:12:41.68736699-08:00"
  description: Creating instance
  err: 'Failed to create file ''r0/lxd/containers/dns/backup.yaml'': open r0/lxd/containers/dns/backup.yaml:
    no such file or directory'
  id: c7c9fda1-6ad2-475b-b1b1-ac35daba370a
  location: none
  may_cancel: false
  metadata: null
  resources:
    containers:
    - /1.0/containers/dns
    instances:
    - /1.0/instances/dns
  status: Failure
  status_code: 400
  updated_at: "2021-01-23T21:12:41.68736699-08:00"
timestamp: "2021-01-23T21:12:42.211539725-08:00"
type: operation


location: none
metadata:
  context: {}
  level: dbug
  message: 'Disconnected event listener: a35c4830-eb3b-4c26-ad16-17ac0b47f885'
timestamp: "2021-01-23T21:12:42.212753541-08:00"
type: logging


location: none
metadata:
  context: {}
  level: dbug
  message: 'Event listener finished: a35c4830-eb3b-4c26-ad16-17ac0b47f885'
timestamp: "2021-01-23T21:12:42.212666531-08:00"
type: logging

I get the same error using a standard image:

% lxc launch ubuntu:20.04 test1 -s r0
Creating test1
Error: Failed instance creation: Failed to create file 'r0/lxd/containers/test1/backup.yaml': open r0/lxd/containers/test1/backup.yaml: no such file or directory

Is there anything else I can do to debug this?

Please can you show the contents of r0/lxd/containers directory in your LXD_DIR path.

Its suspect that the error doesn’t have an absolute file path in my view, and that is derived from the LXD_DIR env var.

Also, to rule out any issues with your image, have you tried creating an instance using a standard image?

Thanks @tomp.

My LXD_DIR is set to /r0/lxd.

There is a /r0/lxd/containers which is empty.
But there is no /r0/lxd/r0/lxd/containers.

Yes, I tried a standard container (see the bottom of of my updated post)

I’m curious about the missing / at the beginning of the paths. It seems like a clue, but I’m not sure what to do about it.

I’m using systemd to start my LXD with the following .service file:

[Unit]
Description=r0 LXD - main daemon
After=network-online.target openvswitch-switch.service lxcfs.service
Requires=network-online.target lxcfs.service
Documentation=man:lxd(1)
ConditionPathExists=/r0/lxd

[Service]
EnvironmentFile=-/etc/environment
Environment=LXD_DIR=r0/lxd
ExecStartPre=/usr/lib/x86_64-linux-gnu/lxc/lxc-apparmor-load
ExecStart=/usr/local/bin/lxd --group lxd --logfile=/var/log/lxd/lxd.log
ExecStartPost=/usr/local/bin/lxd waitready --timeout=600
KillMode=process
TimeoutStartSec=600s
TimeoutStopSec=30s
Restart=on-failure
LimitNOFILE=1048576
LimitNPROC=infinity
TasksMax=infinity

FOUND IT!!! It’s the above file. That’s where the missing / is.
Thanks!

1 Like