LXC-to-LXDしたいのだがの続き
LXCで動いているコンテナを別サーバのLXDに移行したいのだが、lxc-to-lxdはLXCとLXDが同じサーバで動いている必要があるみたい。
やりたいのはLXCを動かしてるPCを(LXCをやめて)別な用途で使うことなので、これではちょっと使えない。
なので今度は、lxd-p2c(実環境からコンテナへのマイグレーション)をLXCコンテナ内で使えばLXD環境に移せるのでは?と思った。
lxc-to-lxdは、Ubuntu18.04のlxd-toolsパッケージに入っていたんだが、lxd-p2cが無かったんで結局goを使ってビルドする必要があった。なのでUbuntu18.04なLXDコンテナにgoを入れてビルドした。
# apt install golang-go
# go version
go version go1.10.1 linux/amd64
# go get -v -x github.com/lxc/lxd/lxd-p2c
# cd go/bin
# scp ./lxd-p2c otherPC.local:
LXCのコンテナ内へlxd-p2cを転送して実行してみた。
$ ./lxd-p2c
Description:
Physical to container migration tool
(略)
動くようなので、rootアカウントで実行
# ~ubuntu/lxd-p2c
Failed to mark / private: Permission denied
# ls -l ~ubuntu/lxd-p2c
-rwxr-xr-x 1 ubuntu ubuntu 13620760 9月 29 12:29 /home/ubuntu/lxd-p2c
ユーザー環境だと動くのにrootだと動かないとは初めての経験!?
エラーメッセージでググるがこれといった情報にヒットしないのでお手上げ。コンテナは実環境じゃないからとしか言えないか。
というわけで、素直にLXCでコンテナのイメージを作成してLXDでそのイメージをインポートするしかなさそう。無駄な時間を費やしたな、とほほ・・・。
追記)
そういえばLXC1.0だとイメージなんてないじゃん。LXC on LXDしてみるか。以前失敗した記憶があるんだが。
やってみたが、やはりCannot mknod: Operation not permittedでLXCコンテナが作られない(T_T)。
ググッてヒントを見つけた。どうやらこれが原因みたいだ。
> On 2015-07-01 17:22, Janjaap Bos wrote:
>>
>> You cannot create devices from the container. You need to create them
>> beforehand outside rootfs and bind mount them in the container config.
コンテナから作れないから外で作ってバインドマウントしろとある。めんどくさ。
なんて思っていたら以前privilegedっていうオプションあったなと思いだした。
これだった。security.privileged trueでやってみたらLXCコンテナ作れた。
しかし案の定動かずorz。
root@cond:~# lxc-ls -f
NAME STATE IPV4 IPV6 AUTOSTART
----------------------------------------
lxconlxd STOPPED - - NO
root@cond:~# lxc-start -n lxconlxd
lxc-start: cgfs.c: cgfs_init: 2335 cgroupfs failed to detect cgroup metadata
lxc-start: start.c: lxc_spawn: 903 failed initializing cgroup support
lxc-start: start.c: __lxc_start: 1149 failed to spawn 'lxconlxd'
lxc-start: lxc_start.c: main: 341 The container failed to start.
lxc-start: lxc_start.c: main: 345 Additional information can be obtained by setting the --logfile and --logpriority options.
エラーメッセージでググったらcgroupfs-mountパッケージを入れたら動いたというのでやってみたがobsoleteだった。
root@cond:~# apt-get install cgroupfs-mount
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package cgroupfs-mount is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'cgroupfs-mount' has no installation candidate
LXCで動いているコンテナを別サーバのLXDに移行したいのだが、lxc-to-lxdはLXCとLXDが同じサーバで動いている必要があるみたい。
やりたいのはLXCを動かしてるPCを(LXCをやめて)別な用途で使うことなので、これではちょっと使えない。
なので今度は、lxd-p2c(実環境からコンテナへのマイグレーション)をLXCコンテナ内で使えばLXD環境に移せるのでは?と思った。
lxc-to-lxdは、Ubuntu18.04のlxd-toolsパッケージに入っていたんだが、lxd-p2cが無かったんで結局goを使ってビルドする必要があった。なのでUbuntu18.04なLXDコンテナにgoを入れてビルドした。
# apt install golang-go
# go version
go version go1.10.1 linux/amd64
# go get -v -x github.com/lxc/lxd/lxd-p2c
# cd go/bin
# scp ./lxd-p2c otherPC.local:
LXCのコンテナ内へlxd-p2cを転送して実行してみた。
$ ./lxd-p2c
Description:
Physical to container migration tool
(略)
動くようなので、rootアカウントで実行
# ~ubuntu/lxd-p2c
Failed to mark / private: Permission denied
# ls -l ~ubuntu/lxd-p2c
-rwxr-xr-x 1 ubuntu ubuntu 13620760 9月 29 12:29 /home/ubuntu/lxd-p2c
ユーザー環境だと動くのにrootだと動かないとは初めての経験!?
エラーメッセージでググるがこれといった情報にヒットしないのでお手上げ。コンテナは実環境じゃないからとしか言えないか。
というわけで、素直にLXCでコンテナのイメージを作成してLXDでそのイメージをインポートするしかなさそう。無駄な時間を費やしたな、とほほ・・・。
追記)
そういえばLXC1.0だとイメージなんてないじゃん。LXC on LXDしてみるか。以前失敗した記憶があるんだが。
やってみたが、やはりCannot mknod: Operation not permittedでLXCコンテナが作られない(T_T)。
ググッてヒントを見つけた。どうやらこれが原因みたいだ。
> On 2015-07-01 17:22, Janjaap Bos wrote:
>>
>> You cannot create devices from the container. You need to create them
>> beforehand outside rootfs and bind mount them in the container config.
コンテナから作れないから外で作ってバインドマウントしろとある。めんどくさ。
なんて思っていたら以前privilegedっていうオプションあったなと思いだした。
これだった。security.privileged trueでやってみたらLXCコンテナ作れた。
しかし案の定動かずorz。
root@cond:~# lxc-ls -f
NAME STATE IPV4 IPV6 AUTOSTART
----------------------------------------
lxconlxd STOPPED - - NO
root@cond:~# lxc-start -n lxconlxd
lxc-start: cgfs.c: cgfs_init: 2335 cgroupfs failed to detect cgroup metadata
lxc-start: start.c: lxc_spawn: 903 failed initializing cgroup support
lxc-start: start.c: __lxc_start: 1149 failed to spawn 'lxconlxd'
lxc-start: lxc_start.c: main: 341 The container failed to start.
lxc-start: lxc_start.c: main: 345 Additional information can be obtained by setting the --logfile and --logpriority options.
エラーメッセージでググったらcgroupfs-mountパッケージを入れたら動いたというのでやってみたがobsoleteだった。
root@cond:~# apt-get install cgroupfs-mount
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package cgroupfs-mount is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'cgroupfs-mount' has no installation candidate