centos7-samba-1

CentOS7にsambaを入れて、NAS機能を持たせる。
まずは、sambaをインストール。CentOS7インストール時に「 ソフトウエアの選択 」から 「サーバー(GUI使用)」をクリック、そして「選択した環境のアドオン」では、「ファイルとストレージサーバー」 を選択していれば、自動的に入っているはずだが、これをチェックを兼ねて。

[root@centos7 ~]# yum install samba
読み込んだプラグイン:fastestmirror, langpacks
Loading mirror speeds from cached hostfile

---------- 中略 ----------

パッケージ samba-4.8.3-4.el7.x86_64 はインストール済みか最新バージョンです
何もしません

ちゃんとはいっているようだ。入っていなければ、ここでインストールされるはず。
次に、samba用ディレクトリを作成。 HDDの領域が一番ある/homeに作成。

[root@centos7 ~]# mkdir /home/samba
[root@centos7 ~]# chmod 777 /home/samba

次に、sambaの設定ファイルをいじる。

[root@centos7 ~]# nano /etc/samba/smb.conf

エディターは最近nanoを使いだしたが、もちろんviでもOK。
まずは、[global]セクション。

workgroupの設定(XXXX)はLAN環境に応じて設定してください。
netbios name = CENTOS7 これも自由に設定可
192.168.11.のLAN内からのみアクセスokに。
プリンタは使わないので、止めておく。
[global]
workgroup = EKBT
server string = CentOS7 smb %v
security = user
netbios name = CENTOS7
host allow = 192.168.11.

passdb backend = tdbsam
dos charset = cp932

# printing = cups
# printcap name = cups
load printers = no
disable spooles = yes
# cups options = raw

次に、[Publoc]設定を追加。

[Public]
comment = Nas Public
path = /home/samba
public = yes
writable = yes
guest ok = yes
guest only = yes

これで設定はおわり。一応設定ファイルをチェックしておく。

[root@centos7 ~]# testparm

問題なさそうだったら、続いて、samba用のユーザーを作る。ユーザーはCentOS7インストール時作っているので、それを使用。
また別にユーザーを作ってそれを使ってもいい。

[root@centos7 ~]# pdbedit -a user1

あとはSELinuxがうごいているはずなので、これを止める。
まずは動作状況を確認。

[root@centos7 ~]# getenforce
Enforcing

動いているようだ。
一応動作を止めて、警告のみにする。

[root@centos7 ~]# setenforce 0
[root@centos7 ~]# getenforce
Permissive

LAN内のみのNAS運用の場合は、完全に止めてもいいと思われる。
そのためには、SELinuxの設定ファイルをいじる。

[root@centos7 ~]# nano /etc/sysconfig/selinux

SELINUX=disabledと入力しSELinuxを止める。

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing – SELinux security policy is enforced.
# permissive – SELinux prints warnings instead of enforcing.
# disabled – No SELinux policy is loaded.
#SELINUX=enforcing
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
# targeted – Targeted processes are protected,
# minimum – Modification of targeted policy. Only selected processes are pr$
# mls – Multi Level Security protection.
SELINUXTYPE=targeted

これでsambaの動作の下準備は終了。sambaを起動する。

[root@centos7 ~]# systemctl start smb
[root@centos7 ~]# systemctl start nmb

sambaは起動ステップが二つあるので両方とも起動する。
さらに、NAS起動時に自動で起動するよう設定。

[root@centos7 ~]# systemctl enable smb
[root@centos7 ~]# systemctl enable nmb

これで、LAN内から見えるようになっているはずなので、LAN内のWindowsマシンに移動して、ネットワークを見てみる。