【7回】Raspberry Pi 3 にsambaを導入!

今回は、Raspberry Pi 3 Model Bにsambaを導入します。

 

インストール

まずは、事前に全パッケージの更新と、rootアカウントのパスワードを設定(Raspbianの初期値はパスワードなし状態)しておきます。

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo rbi-update
$ sudo passed root

 

次にsamba本体をインストールします。

$ sudo apt-get install samba

 

設定(smb.conf)

設定の前に元の設定ファイルのバックアップをとっておきます。

$ sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
$ sudo /etc/samba/smb.conf

 

設定ファイルの中身を以下の様に変更しました。

#======================= Global Settings =======================

[global]
   workgroup = WORKGROUP
   client max protocol = SMB3
;   wins server = w.x.y.z
   dns proxy = no
;   interfaces = 127.0.0.0/8 eth0
;   bind interfaces only = yes
   log file = /var/log/samba/log.%m
   max log size = 1000
   syslog = 0
   panic action = /usr/share/samba/panic-action %d
   server role = standalone server
   passdb backend = tdbsam
   obey pam restrictions = yes
   unix password sync = yes
   passwd program = /usr/bin/passwd %u
   passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
   pam password change = yes
   map to guest = bad user
;   logon path = \\%N\profiles\%U
;   logon drive = H:
;   logon script = logon.cmd
; add user script = /usr/sbin/adduser --quiet --disabled-password --gecos "" %u
; add machine script  = /usr/sbin/useradd -g machines -c "%u machine account" -d /var/lib/samba -s /bin/false %u
; add group script = /usr/sbin/addgroup --force-badname %g
;   include = /home/samba/etc/smb.conf.%m
;   idmap uid = 10000-20000
;   idmap gid = 10000-20000
;   template shell = /bin/bash
;   usershare max shares = 100
   usershare allow guests = yes

#======================= Share Definitions =======================

[hdd1]
        comment = raspberrypi_nas
        path = /mnt/hdd1
        force user = pi
        read only = No
        guest ok = No

※上記にはコメント行は削除してあります。

[global]内で変更したのは5行目に1行追加しただけです。

[hdd1]以降は全て置き換えました。

 

sambaアカウントの追加

OS上のアカウントはsambaに自動的に追加されません。その為、以下のコマンドで追加する必要があります。

$ sudo smbpasswd -a pi

 

 

sambaの自動起動設定

以下のコマンドで自動起動設定ができます。

$ sudo update-rc.d samba defaults

 

 

 

参考サイト

 

コメント

タイトルとURLをコピーしました