クライアントとゲストマシンでファイルを共有するときのメモ
設定
下記コマンドでファイル共有ができる。
lxc config device add <instance_name> <device_name> <device_type> <device_option_key>=<device_option_value> <device_option_key>=<device_option_value> ...
例
lxc config device add my_instance disk-storage-device disk source=/home/user/share path=/home/user/share
ただしこのままでは、下記のようにゲスト側のオーナーとグループがnobody:nogroupとなってしまう
$ ls -l
total 4
drwxrwxr-x 2 nobody nogroup 4096 Apr 14 06:25 share
そこでraw.idmapを設定してホストとゲストのユーザーとグループのIDを紐付けることで解決する。
ゲスト
$ id
uid=1002(user) gid=1002(user) groups=1002(user)
ホストで設定して、ゲストを再起動する
$ id
uid=1001(user) gid=1001(user) groups=1001(user),100(users)
$ lxc config set my_instance raw.idmap 'both 1001 1002'
$ lxc restart my_instance
共有の解除方法
$ lxc config device remove my_instance share_disk