1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

RaspberryPiとWindowsPC/スマホをSambaでファイルを共有する

Last updated at Posted at 2023-05-13

ハードディスクのマウント設定はここ

sambaのインストール

RaspberryPiにSambaをインストールする

$ apt install samba

Sambaの設定ファイルを編集する(元に戻せるようにバックアップを作成しておく)

$ sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_bk
$ sudo nano /etc/samba/smb.conf

# 設定ファイルに以下を追加
[pi]
path= /mnt/hdd
read only = No
guest ok=Yes
force user = pi

[pi] :共通フォルダ名
path: HDDのマウント位置
guest ok: ゲストユーザのアクセスを許可する
force user:強制的にpiというユーザでアクセスする


Samba起動状態を確認し、再起動します

image.png

Active: active(running)になっていたら動いている状態になります.
以下のコマンドで再起動する

 $ sudo systemctl restart smbd

WindowsPCからアクセスする

ネットワークドライブの割り当て

image.png

以下のようにフォルダにアクセスできれば、成功です。
image.png

スマホの場合は、以下のようになっていればOK

image.png

ユーザパスワードでログインさせる

※上記の設定だとセキュリティがスカスカなので、sambaにアクセスするユーザを登録します。

# samba設定ファイルを変数して、guest ok = Noにする
$ sudo nano /etc/samba/smb.conf
guest ok=No
# ユーザを登録する(Linuxに存在するユーザでないとエラーになるので注意)
pi@raspberrypi:~ $ sudo pdbedit -a pi
new password:
retype new password:
# Sambaを再起動する
sudo systemctl restart smbd

スマホとの共有は以下がお勧めです。

1
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?