💻

LXD 6.2 から Incus 6.8 への移行で発生したエラーと復旧方法
December 26, 2024February 06, 2025
#Develop#LXD

2023 年の終わりに LXD のポリシー変更によりプロジェクトが二分されることとなりました。 今年の春ごろから image のダウンロードなどもできなくなり使いづらい状態となってきたので Incus に乗り換えようと思った記録となります。

エラーを完全に治せなかったものの、コンテナの復旧はできました。

LXD の顛末についてはこちらを参照してください

Important notice for LXD users (image server)

Introduction The image server at https://images.linuxcontainers.org has been in operation since early 2014, first offering images to LXC users through the download template and then once LXD came around, it was expanded to also provide LXD container and eventually virtual-machine images. The infrastructure used to build and distribute those images has always been purposefully kept community owned and operated. That’s so that every distribution represented on the image server is on equal footing...

Linux Containers Forum

Important notice for LXD users (image server)

環境

  • Ubuntu 22.04
  • LXD 6.2
  • LVM

乗り換え手順が存在する

  • incus をインストール
  • セットアップせずに lxd-to-incus を実行する
root@dev:~# lxd-to-incus
=> Looking for source server
==> Detected: snap package
=> Looking for target server
==> Detected: systemd
=> Connecting to source server
=> Connecting to the target server
=> Checking server versions
==> Source version: 6.2
==> Target version: 6.8
=> Validating version compatibility
Error: LXD version is newer than maximum version "5.21.99"

上記のエラーが出た。 incus が fork したバージョンより新しいバージョンは未対応らしい —ignore-version-check で回避できるので試してみる。

root@dev:~# lxd-to-incus --ignore-version-check

エラーが出て incus が起動しなくなった。 lxd はすでにコンテナがなくなってしまっていた。

Source server: snap package
Target server: systemd
Source server paths: &{daemon:/var/snap/lxd/common/lxd logs:/var/snap/lxd/common/lxd/logs cache:/var/snap/lxd/common/lxd/cache}
Target server paths: &{daemon:/var/lib/incus logs:/var/log/incus cache:/var/cache/incus}
Rewrite SQL statements:
 - UPDATE storage_pools_config SET value='/var/lib/incus/storage-pools/default' WHERE value='/var/snap/lxd/common/lxd/storage-pools/default';
 - UPDATE profiles SET description='Default Incus profile' WHERE description='Default LXD profile';
 - UPDATE projects SET description='Default Incus project' WHERE description='Default LXD project';
 - DELETE FROM storage_volumes_config WHERE key='volatile.uuid';
 - DELETE FROM storage_volumes_snapshots_config WHERE key='volatile.uuid';
 - CREATE TABLE certificates (
    id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
    fingerprint TEXT NOT NULL,
    type INTEGER NOT NULL,
    name TEXT NOT NULL,
    certificate TEXT NOT NULL,
    restricted INTEGER NOT NULL DEFAULT 0,
    UNIQUE (fingerprint)
);
CREATE TABLE "certificates_projects" (
    certificate_id INTEGER NOT NULL,
    project_id INTEGER NOT NULL,
    FOREIGN KEY (certificate_id) REFERENCES certificates (id) ON DELETE CASCADE,
    FOREIGN KEY (project_id) REFERENCES "projects" (id) ON DELETE CASCADE,
    UNIQUE (certificate_id, project_id)
);
 - DELETE FROM schema WHERE version < 73;
UPDATE schema SET version=69 WHERE version=73;
 - INSERT INTO certificates (id, fingerprint, type, name, certificate, restricted) SELECT id, identifier, 1, name, json_extract(metadata, "$.cert"), 1 FROM identities WHERE type=1;
INSERT INTO certificates (id, fingerprint, type, name, certificate, restricted) SELECT id, identifier, 1, name, json_extract(metadata, "$.cert"), 0 FROM identities WHERE type=2;
INSERT INTO certificates (id, fingerprint, type, name, certificate, restricted) SELECT id, identifier, 2, name, json_extract(metadata, "$.cert"), 0 FROM identities WHERE type=3;
INSERT INTO certificates (id, fingerprint, type, name, certificate, restricted) SELECT id, identifier, 3, name, json_extract(metadata, "$.cert"), 1 FROM identities WHERE type=4;
INSERT INTO certificates (id, fingerprint, type, name, certificate, restricted) SELECT id, identifier, 3, name, json_extract(metadata, "$.cert"), 0 FROM identities WHERE type=6;
INSERT INTO certificates_projects (certificate_id, project_id) SELECT identity_id, project_id FROM identities_projects;
 - DROP TRIGGER on_auth_group_delete;
DROP TRIGGER on_cluster_group_delete;
DROP TRIGGER on_identity_delete;
DROP TRIGGER on_identity_provider_group_delete;
DROP TRIGGER on_image_alias_delete;
DROP TRIGGER on_image_delete;
DROP TRIGGER on_instance_backup_delete;
DROP TRIGGER on_instance_delete;
DROP TRIGGER on_instance_snaphot_delete;
DROP TRIGGER on_network_acl_delete;
DROP TRIGGER on_network_delete;
DROP TRIGGER on_network_zone_delete;
DROP TRIGGER on_node_delete;
DROP TRIGGER on_operation_delete;
DROP TRIGGER on_profile_delete;
DROP TRIGGER on_project_delete;
DROP TRIGGER on_storage_bucket_delete;
DROP TRIGGER on_storage_pool_delete;
DROP TRIGGER on_storage_volume_backup_delete;
DROP TRIGGER on_storage_volume_delete;
DROP TRIGGER on_storage_volume_snapshot_delete;
DROP TRIGGER on_warning_delete;
DROP TABLE identities_projects;
DROP TABLE auth_groups_permissions;
DROP TABLE auth_groups_identity_provider_groups;
DROP TABLE identities_auth_groups;
DROP TABLE identity_provider_groups;
DROP TABLE identities;
DROP TABLE auth_groups;
Rewrite commands:
Migration started
Stopping the source server
Stopping the target server
Unmounting "/var/lib/incus/devlxd"
Unmounting "/var/lib/incus/shmounts"
Wiping the target server
Migrating the data
Moving data over
Migrating database files
Writing the database patch
Cleaning up target paths
Cleaning up path "/var/lib/incus/backups"
Cleaning up path "/var/lib/incus/images"
Cleaning up path "/var/lib/incus/devices"
Cleaning up path "/var/lib/incus/devlxd"
Cleaning up path "/var/lib/incus/security"
Cleaning up path "/var/lib/incus/shmounts"
Rewrite symlinks:
 - "/var/lib/incus/storage-pools/lxdpool/containers/blog" to "/var/lib/incus/containers/blog"
 - "/var/lib/incus/storage-pools/lxdpool/containers/develop" to "/var/lib/incus/containers/develop"
 - "/var/lib/incus/storage-pools/default/containers/imacoco" to "/var/lib/incus/containers/imacoco"
 - "/var/lib/incus/storage-pools/default/containers/pokemon-note" to "/var/lib/incus/containers/pokemon-note"
 - "/var/lib/incus/storage-pools/default/containers/python" to "/var/lib/incus/containers/python"
 - "/var/lib/incus/storage-pools/default/containers/redash" to "/var/lib/incus/containers/redash"
 - "/var/lib/incus/storage-pools/lxdpool/containers/stable-diffusion" to "/var/lib/incus/containers/stable-diffusion"
 - "/var/lib/incus/storage-pools/default/containers/test" to "/var/lib/incus/containers/test"
 - "/var/lib/incus/storage-pools/default/containers/wpsandbox" to "/var/lib/incus/containers/wpsandbox"
Rewrite symlinks:
Rewrite symlinks:
Rewrite symlinks:
Starting the target server
ERROR: Failed to run: systemctl start incus.service incus.socket: exit status 1 (Job for incus.service failed because the control process exited with error code.
See "systemctl status incus.service" and "journalctl -xeu incus.service" for details.)

データベースに不整合が出てしまい起動できなかった。

incus は lxd からフォークしているためフォーク後に追加された DB の変更に対応できていないためと思われる。

私はついぞ治すことはできなかった。

削除

直せなかったので、incus を再インストールした。

ストレージプールは無傷で残っているので、incus のリカバリー機能でインポートした。

root@dev:/var/lib/incus/storage-pools/default# incus admin recover
このサーバーは、次のストレージプールを持っています:
他のストレージプールを回復しますか? (yes/no) [default=no]: yes
Name of the storage pool: lxdpool
Name of the storage backend (dir, lvm, lvmcluster): lvm
ストレージプールのソース (適用できるブロックデバイス、ボリュームグループ、データセット、パス...) /dev/mapper/vg-lxdpool
追加のストレージプール設定プロパティー(KEY=VALUE, 完了時は空文字列): lvm.thinpool_name=lxdpool
追加のストレージプール設定プロパティー(KEY=VALUE, 完了時は空文字列): lvm.vg_name=vg
追加のストレージプール設定プロパティー(KEY=VALUE, 完了時は空文字列):
他のストレージプールを回復しますか? (yes/no) [default=no]:
リカバリープロセスは次のストレージプールをスキャンします:
- 新規: "lxdpool" (バックエンド="lvm", ソース="/dev/mapper/vg-lxdpool")
失われたボリュームのスキャンを続行しますか? (yes/no) [default=yes]:
未知のボリュームをスキャンしています...
次の未知のストレージプールが見つかりました:
- Storage pool "lxdpool" of type "lvm"
次の未知のボリュームが見つかりました:
- Container "blog"(プール "lxdpool" 上, プロジェクト "default" 内, スナップショット 0 個を含む)
- Container "develop"(プール "lxdpool" 上, プロジェクト "default" 内, スナップショット 0 個を含む)
- Container "stable-diffusion"(プール "lxdpool" 上, プロジェクト "default" 内, スナップショット 0 個を含む)
現在、次のものが不足しています:
- Network "lxdbr0" in project "default"
不足しているエントリーを作成してから ENTER を押してください:
次の未知のストレージプールが見つかりました:
- Storage pool "lxdpool" of type "lvm"
次の未知のボリュームが見つかりました:
- Container "blog"(プール "lxdpool" 上, プロジェクト "default" 内, スナップショット 0 個を含む)
- Container "develop"(プール "lxdpool" 上, プロジェクト "default" 内, スナップショット 0 個を含む)
- Container "stable-diffusion"(プール "lxdpool" 上, プロジェクト "default" 内, スナップショット 0 個を含む)
現在、次のものが不足しています:
- Network "lxdbr0" in project "default"
不足しているエントリーを作成してから ENTER を押してください:
次の未知のストレージプールが見つかりました:
- Storage pool "lxdpool" of type "lvm"
次の未知のボリュームが見つかりました:
- Container "blog"(プール "lxdpool" 上, プロジェクト "default" 内, スナップショット 0 個を含む)
- Container "develop"(プール "lxdpool" 上, プロジェクト "default" 内, スナップショット 0 個を含む)
- Container "stable-diffusion"(プール "lxdpool" 上, プロジェクト "default" 内, スナップショット 0 個を含む)
それらを回復しますか? (yes/no) [default=no]: yes
リカバリーを開始します...
root@dev:/var/lib/incus/storage-pools/default# incus list
+------------------+---------+------+------+-----------+-----------+
|    NAME    | STATE | IPV4 | IPV6 |  TYPE  | SNAPSHOTS |
+------------------+---------+------+------+-----------+-----------+
| blog       | STOPPED |   |   | CONTAINER | 0     |
+------------------+---------+------+------+-----------+-----------+
| develop     | STOPPED |   |   | CONTAINER | 0     |
+------------------+---------+------+------+-----------+-----------+
| stable-diffusion | STOPPED |   |   | CONTAINER | 0     |
+------------------+---------+------+------+-----------+-----------+

まとめ

incus にアップグレードする場合は LXD のバージョンに注意する。

LXD5.21.99 まではlxd-to-incusを利用する。

それ以上の場合にはコンテナをバックアップしインポートするほうが安全と思われる。

データベースが壊れた場合で、コンテナを利用していたストレージが無傷であればリカバリーを試すことで復旧できる(場合がある)

参考

おしまい



ChatGPTにサイトロゴを作ってもらいOGPLinkに追加した
February 16, 2024February 03, 2025

サイトのロゴを作ろうと思い立ったがどうデザインしていいかわからなかった。 いい感じに作って欲しいが適切に伝えられる気もしなかったので chatgpt に丸投げしてみた。 環境 GPT4 出来上がったもの サイト情報を伝える プロンプト 回答 もう少しシンプルなものにしてほしかったので依頼してみる 回答 調子に乗ってサイト名を入れてもら…

Continue reading...
sakakinox

Written by sakakinox
Server enginier

Copyright © sakakinox.net 2021-2025.