0
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 3 years have passed since last update.

Raspberry Pi 4 Model BでexfatのディスクをSMBでネットワーク共有する

Posted at

はじめに

現在リリースされているRaspberry Pi OSはexfatのカーネルモジュールが標準ではいっているようですが、何故か有効化されていません。
ここではOS標準のexfatの有効化とRaspberry Pi 4のUSB3.0と高速なネットワークアダプタを利用して、Windows、Linux、AndroidでexfatのディスクをSMBで共有する方法を試してみました。
またUSBの差し替えを便利にするためにautofsも使用します。(設定に応じてディスクを自動的にマウントしてくれます)

exfatの有効化

最新版のOSイメージを使用する(2021/02以降のものを使用する)
Raspberry Pi OS Lite
https://www.raspberrypi.org/software/operating-systems/

インストール作成後bootドライブにsshファイルを作成する(導入直後にsshが使用できるようになります)

永続化手順

$echo exfat | sudo tee -a /etc/modules
$sudo reboot

SMBの設定

ここではユーザをpiに設定していますが、適宜ユーザを変更するようにして下さい。

$sudo apt update
$sudo apt install samba
$sudo apt install autofs
$sudo mkdir /usb
$sudo nano /etc/auto.master.d/usb.autofs

usb.autofsの編集

/usb /etc/auto.usb
$sudo nano /etc/auto.usb

auto.usbの編集
ボリュームラベルがshare1のディスクをhdd1に
ボリュームラベルがshare2のディスクをhdd2に
マウントします。

hdd1 -fstype=exfat,rw,uid=pi,gid=pi :LABEL=share1
hdd2 -fstype=exfat,rw,uid=pi,gid=pi :LABEL=share2

autofs の有効化

$systemctl enable autofs --now
$sudo reboot
$sudo nano /etc/samba/smb.conf

smb.confの編集
ネットワーク共有名[pi01]

[pi01]
   comment = Welcome to pi Server
   path = /usb/hdd1
   browseable = yes
   wriable = yes
   guest ok = no
   force create mode = 0666
   force directory mode = 0777
   read only = no
   create mask =0777
   directory mask = 0777

[pi02]
   comment = Welcome to pi Server
   path = /usb/hdd2
   browseable = yes
   wriable = yes
   guest ok = no
   force create mode = 0666
   force directory mode = 0777
   read only = no
   create mask =0777
   directory mask = 0777
# 共有のパスワードを設定します。
$sudo smbpasswd -a pi

$sudo systemctl restart smbd.service

これで設定は完了です。
ボリュームラベルがshare1のディスクを接続するとpi01
ボリュームラベルがshare2のディスクを接続するとpi02
に共有されます。
HDDであれば100MByte/sぐらいでファイル転送が可能なため、
簡易ファイルサーバとしては十分なスペックだと思います。

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