Importing lxc v1 container to lxd and starting

I have a server running lxc v1
I have a container on that server called “git”
I’ve tarred that up as follows:
cd /var/lib/lxc/ ; tar -czf git.tgz git
So, git.tgz has contents like
# tar -tvzf git.tgz
drwxrwx— root/root 0 2021-08-30 08:58 git/
dr-xr-xr-x root/root 0 2021-08-30 08:58 git/rootfs/
lrwxrwxrwx root/root 0 2019-11-27 11:21 git/rootfs/bin → usr/bin
etc.

I then created a metadata.yaml file with contents
creation_date: 1630706053
properties:
architecture: “x86_64”
description: “Git”
os: “centos”
release: “centos”

and tarred that up with
tar zcf metadata.tar.gz metadata.yaml

I then imported all of that with
lxc image import metadata.tar.gz git.tgz --alias git-test

The output of that was
Image imported with fingerprint: 8e1d85f72b0c788cc50f4f57ea1f573467d6733c524986f12b1353997a2e0784

My understanding is that I next need to launch that image, so I did
lxc launch git-test

which gave me the output
Creating the instance
Instance name is: unified-mackerel
Starting unified-mackerel
Error: Failed to run: /snap/lxd/current/bin/lxd forkstart unified-mackerel /var/snap/lxd/common/lxd/containers /var/snap/lxd/common/lxd/logs/unified-mackerel/lxc.conf:
Try lxc info --show-log local:unified-mackerel for more info

Then running
lxc info --show-log local:unified-mackerel

gives
Name: unified-mackerel
Location: none
Remote: unix://
Architecture: x86_64
Created: 2021/09/04 08:16 UTC
Status: Stopped
Type: container
Profiles: default

Log:

lxc unified-mackerel 20210904081625.793 WARN     conf - conf.c:lxc_map_ids:3389 - newuidmap binary is missing
lxc unified-mackerel 20210904081625.793 WARN     conf - conf.c:lxc_map_ids:3395 - newgidmap binary is missing
lxc unified-mackerel 20210904081625.795 WARN     conf - conf.c:lxc_map_ids:3389 - newuidmap binary is missing
lxc unified-mackerel 20210904081625.795 WARN     conf - conf.c:lxc_map_ids:3395 - newgidmap binary is missing
lxc unified-mackerel 20210904081625.796 WARN     cgfsng - cgroups/cgfsng.c:fchowmodat:1296 - No such file or directory - Failed to fchownat(43, memory.oom.group, 1000000000, 0, AT_EMPTY_PATH | AT_SYMLINK_NOFOLLOW )
lxc unified-mackerel 20210904081626.559 ERROR    start - start.c:start:2142 - No such file or directory - Failed to exec "/sbin/init"
lxc unified-mackerel 20210904081626.560 ERROR    sync - sync.c:sync_wait:36 - An error occurred in another process (expected sequence number 7)
lxc unified-mackerel 20210904081626.690 WARN     network - network.c:lxc_delete_network_priv:3624 - Failed to rename interface with index 0 from "eth0" to its initial name "mac76ccdef5"
lxc unified-mackerel 20210904081626.692 ERROR    lxccontainer - lxccontainer.c:wait_on_daemonized_start:869 - Received container state "ABORTING" instead of "RUNNING"
lxc unified-mackerel 20210904081626.692 ERROR    start - start.c:__lxc_start:2053 - Failed to spawn container "unified-mackerel"
lxc unified-mackerel 20210904081626.693 WARN     start - start.c:lxc_abort:1051 - No such process - Failed to send SIGKILL via pidfd 44 for process 2090568
lxc unified-mackerel 20210904081631.309 WARN     conf - conf.c:lxc_map_ids:3389 - newuidmap binary is missing
lxc unified-mackerel 20210904081631.310 WARN     conf - conf.c:lxc_map_ids:3395 - newgidmap binary is missing
lxc 20210904081631.362 ERROR    af_unix - af_unix.c:lxc_abstract_unix_recv_fds_iov:220 - Connection reset by peer - Failed to receive response
lxc 20210904081631.362 ERROR    commands - commands.c:lxc_cmd_rsp_recv_fds:129 - Failed to receive file descriptors

Doesn’t seem that I’m the first to get the ‘No such file or directory - Failed to exec “/sbin/init”’ error .
However, looking through how some of those were solved doesn’t seem overly relevant to my circumstances.

Anyone got any idea what I’m doing wrong?

Thanks in advance.

# cat /var/snap/lxd/common/lxd/logs/unified-mackerel/lxc.conf 
lxc.log.file = /var/snap/lxd/common/lxd/logs/unified-mackerel/lxc.log
lxc.log.level = warn
lxc.console.buffer.size = auto
lxc.console.size = auto
lxc.console.logfile = /var/snap/lxd/common/lxd/logs/unified-mackerel/console.log
lxc.mount.auto = proc:rw sys:rw cgroup:mixed
lxc.autodev = 1
lxc.pty.max = 1024
lxc.mount.entry = /dev/fuse dev/fuse none bind,create=file,optional 0 0
lxc.mount.entry = /dev/net/tun dev/net/tun none bind,create=file,optional 0 0
lxc.mount.entry = /proc/sys/fs/binfmt_misc proc/sys/fs/binfmt_misc none rbind,create=dir,optional 0 0
lxc.mount.entry = /sys/firmware/efi/efivars sys/firmware/efi/efivars none rbind,create=dir,optional 0 0
lxc.mount.entry = /sys/fs/fuse/connections sys/fs/fuse/connections none rbind,create=dir,optional 0 0
lxc.mount.entry = /sys/fs/pstore sys/fs/pstore none rbind,create=dir,optional 0 0
lxc.mount.entry = /sys/kernel/config sys/kernel/config none rbind,create=dir,optional 0 0
lxc.mount.entry = /sys/kernel/debug sys/kernel/debug none rbind,create=dir,optional 0 0
lxc.mount.entry = /sys/kernel/security sys/kernel/security none rbind,create=dir,optional 0 0
lxc.mount.entry = /sys/kernel/tracing sys/kernel/tracing none rbind,create=dir,optional 0 0
lxc.mount.entry = /dev/mqueue dev/mqueue none rbind,create=dir,optional 0 0
lxc.include = /snap/lxd/current/lxc/config//common.conf.d/
lxc.arch = linux64
lxc.hook.version = 1
lxc.hook.pre-start = /proc/2097/exe callhook /var/snap/lxd/common/lxd "default" "unified-mackerel" start
lxc.hook.stop = /snap/lxd/current/bin/lxd callhook /var/snap/lxd/common/lxd "default" "unified-mackerel" stopns
lxc.hook.post-stop = /snap/lxd/current/bin/lxd callhook /var/snap/lxd/common/lxd "default" "unified-mackerel" stop
lxc.tty.max = 0
lxc.uts.name = unified-mackerel
lxc.mount.entry = /var/snap/lxd/common/lxd/devlxd dev/lxd none bind,create=dir 0 0
lxc.apparmor.profile = lxd-unified-mackerel_</var/snap/lxd/common/lxd>//&:lxd-unified-mackerel_<var-snap-lxd-common-lxd>:
lxc.seccomp.profile = /var/snap/lxd/common/lxd/security/seccomp/unified-mackerel
lxc.idmap = u 0 1000000 1000000000
lxc.idmap = g 0 1000000 1000000000
lxc.mount.auto = shmounts:/var/snap/lxd/common/lxd/shmounts/unified-mackerel:/dev/.lxd-mounts
lxc.net.0.type = phys
lxc.net.0.name = eth0
lxc.net.0.flags = up
lxc.net.0.link = mac34897cdb
lxc.rootfs.path = dir:/var/snap/lxd/common/lxd/containers/unified-mackerel/rootfs

When using split images like you are here, the rootfs tarball must have the root filesystem directly at its root (so bin/ instead of rootfs/bin/).

2 Likes

Many thanks for the response - that’s solved my issue.

@clennon You can mark his reply to your topic as the solution so that if someone has the same error again, they know where to find the solution. Thanks.

1 Like