LoginSignup
1
2

More than 3 years have passed since last update.

LXDコンテナ内でSamba(CIFS)とNFSの両方をマウントする

Posted at

背景

LXDのコンテナ内からネットワーク上のフォルダをSamba(CIFS)でマウントする際は以下のようにする。

lxc config set TEST raw.apparmor 'mount fstype=cifs,'
lxc config set TEST security.privileged true

同様にLXDのコンテナ内からNFSでマウントする際は以下。

lxc config set TEST raw.apparmor 'mount fstype=nfs,'
lxc config set TEST security.privileged true

ここまでの情報はたくさん見つかるのだが、1つのLXDコンテナ内でSambaとNFSの両方とも使おうとしたときにどうすればよいのか情報が見つからなかった。

方法

結論としては、下記のようにraw.apparmorを設定する。

lxc config set TEST raw.apparmor "mount fstype=nfs, mount fstype=cifs,"
lxc config set TEST security.privileged true

※ 試行錯誤した結果なので冗長かもしれない

Ubuntu 18.04のコンテナイメージで両方ともマウントする例。

(ホスト)
lxc launch ubuntu:b TEST
lxc config set TEST security.privileged true
lxc config set TEST raw.apparmor "mount fstype=nfs, mount fstype=cifs,"
lxc restart TEST

lxc exec TEST bash
(コンテナ内)
apt update

# NFS
apt install nfs-util nfs-common
mkdir /mnt/nfs
mount -t nfs -o vers=3 192.168.10.***:/mnt/share /mnt/nfs

# Samba
apt install cifs-utils
mkdir /mnt/cifs
mount -t cifs -o uid=1000,gid=1000,vers=3.0,username=***,password=*******,rw //192.168.10.***/share /mnt/cifs

もちろん、コンテナ起動時に自動的にマウントするには/etc/fstabを編集すればOK。

参考

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2