You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

意外重启后LXD容器处于ERROR状态无法启动/删除的恢复求助

恢复LXD容器:解决ZFS池无法导入的问题

Hey there, let's work through this issue where your LXD containers got stuck in ERROR state after an unexpected system reset. The core problem here is that LXD can't access its underlying ZFS pool, so we'll focus on fixing that first to get your containers back up.

Step 1: Check and import the ZFS pool

First, let's confirm the current state of your ZFS pools:

zpool list

If the lxd pool doesn't show up in the output, list all pools that are available for import:

zpool import

If you see the lxd pool listed here, try importing it directly:

zpool import lxd

If you get an error about the pool being busy or already mounted, unmount the LXD storage directory first (if it's mounted):

umount /var/lib/lxd

Then retry the import command.

Step 2: Locate and import the pool from raw storage device

If zpool import doesn't detect the lxd pool, we need to check your disk partitions for ZFS metadata. Run this command against your storage partition (replace /dev/sdXn with your actual device path, e.g., /dev/sda2):

zdb -l /dev/sdXn

If this command returns metadata for the lxd pool, import it by specifying the device path:

zpool import -d /dev/sdXn lxd

Step 3: Restore LXD container state after pool import

Once the ZFS pool is successfully imported, restart the LXD service to refresh its connection to the pool:

service lxd restart  # Ubuntu 16.04 uses this legacy command; systemctl restart lxd works too

Now try starting one of your containers to test:

lxc start cups-lxc

If the container still fails to start, check its logs for specific error details:

lxc info cups-lxc --show-log

Common issues here might be corrupted container configs or minor ZFS dataset inconsistencies. If logs point to config problems, you can try restoring from a backup (if you have one) or manually editing the config file located at /var/lib/lxd/containers/cups-lxc/config.

Step 4: Recover data if the pool is corrupted

If the ZFS pool is irreparably damaged, you can still rescue your container data:

  1. List any existing ZFS snapshots for your containers:
    zfs list -t snapshot
    
  2. If you have a snapshot, roll back to it to restore the container's state:
    zfs rollback lxd/containers/cups-lxc@<snapshot-name>
    
  3. If no snapshots exist, mount the container's ZFS dataset to a temporary directory to extract data:
    zfs mount lxd/containers/cups-lxc /tmp/cups-recover
    cp -r /tmp/cups-recover/* /path/to/your/backup/folder
    zfs unmount /tmp/cups-recover
    
    You can then create a new container and copy the recovered data into it.

内容的提问来源于stack exchange,提问作者nacho

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 08:39:59