Cannot create image from container - read only snapshot

I’m new to LXD and really loving it. I’m working on a backup script that will create images of containers, export them, and scp them to a different server. My testing was working fine and then trying to publish a snapshot to an image for a particular container failed, and I can’t get past it.

I’m using Ubuntu 18.04 with btrfs. I’m basically doing the following:

$ lxc publish mycontainer/current --alias mycontainer-image

and I’m getting this:

Error: Failed to change ownership of: /var/lib/lxd/storage-pools/default/snapshots/mycontainer/current/rootfs

and /var/log/syslog shows this:

Jan 29 12:33:46 hydride lxd[1701]: Failed chown: Read-only file system
Jan 29 12:33:46 hydride lxd[1701]: t=2019-01-29T12:33:46-0500 lvl=eror msg=“Failed exporting container” created=2019-01-29T12:33:39-0500 ephemeral=false name=mycontainer/current used=1969-12-31T19:00:00-0500

This seems to be happening with any container that has a “current.ro” directory in /var/lib/lxd/storage-pools/default/snapshots/mycontainer

This has been a real show stopper, so any help would be greatly appreciated.

Thanks.
John

So I renamed the snapshot directory from ‘current.ro’ to current.ro_old’ and I’m now able to do everything I need to do. I’m new to both LXD and btrfs, so if anyone could shed a little like on the predicament I would really appreciate it.

Thanks.
John

That’s a good catch and I am trying to figure out a way to reproduce it.
Here is what I do (unsuccessfully):

lxc launch images:alpine/edge alpine
lxc exec alpine -- mkdir current.ro
lxc snapshot alpine current
lxc publish alpine/current --alias mycontainer

and it works fine for me.

Can you try to get a set of reproducible steps (ideally with alpine, otherwise with Ubuntu)?

I’ll try to establish some reproducible steps, but my testing has not been very methodical. One thing that I was trying to establish as a backup routine before my method of (1) snapshot, (2), publish snapshot to image, (3) export image, was using lxc copy initiated by a remote lxd host, pulling a copy of the most recent snapshot of each container on the production server. Because that method involved creating a snapshot (called ‘current’), it’s possible that that is where the read only problem was created.

I’m guessing that ‘current.ro’ directory would need to be in the path:

/var/lib/lxd/storage-pools/default/snapshots/mycontainer/

and it would need to set to read only (btrfs feature?). This is where my lack of knowledge of btrfs complicates things.

All of these details aside, simos, is there a best practice method to follow for backing up containers to another server? That’s really all I want.

Thanks so much.
John

I may have figured out some aspect of the cause of the problem, although I can’t exactly reproduce it. I discovered that multiple instances of the script I was testing, which uses snapshot creation and lxc copy to grab a copy from the production server, were running on the backup (remote) server. And as part of my testing I was “canceling” (or so I thought) the script. In the process of cancellation I suspect I disrupted the completion of the ‘currrent.ro’ snapshot, so the volume stayed read only, and presented the problem I was having.

In short, I suspect I could only recreate the situation if I disrupted my script again, but I’m not too excited about doing that. But thank you for helping me through this. I suspect if I let the script run I won’t have problems. A little precarious.

John