Because I upgraded my personal notebook computer, I replaced a 2.5-inch 1T mechanical hard disk. I think idle is idle, so IT is better to make a NAS for fun, which can store some personal files and movie movies and share them with everyone at home. Next, let’s follow my steps and see how to achieve it

1. Prepare

  • Raspberry PI (click the official system, please see Baidu for detailed tutorial)
  • Idle hard disk (can be 2.5-inch or 3.5-inch, but the premise is that the hard disk case has been purchased and can support USB connection)
  • The router

2. Bind the MAC address of the router

As we all know, when you connect the raspberry PI to the router at home, the ROUTER’s DHCP service will assign you an IP address. However, the IP address will be changed automatically when the lease term expires. In order to achieve permanent change, just bind the MAC address and you can never change the IP address.

  • Go to background Page
  • Find the DHCP service from the function Settings. Here are the basic router operations are to find the corresponding DHCP service options
  • If you don’t know the MAC address of your raspberry PI, don’t worry. Here is how to find the MAC address


  • Go to Terminal Management, look at the Raspberry PI terminal, you can see the corresponding MAC address

3. Configure the file sharing service ‘Samba’

  • SSH Login address SSH pi@IP
  • The installationsambaservice

    sudo apt-get install samba -y

  • The editorsambaThe configuration file

    sudo vim /etc/samba/smb.conf

  • Add the following at the end of the file, [share] comment = Do not arbitrarily modify the database file path = /home/ PI /share_files public = no writable = yes
  • restartsambaservice

    sudo service smbd restart

  • Create a shared folder in your home directory (topiUser identity creation)

    mkdir -p ~/share_files

  • Configure the login user, because the Samba service requires a physical user to correspond to the virtual user sudo pdbedit -a -u PI

4. Configure the automatic mounting of hard disks to the shared directory

  • Connect your hard drive to the raspberry PI and view the partition you want to hang onUUID, the partition we want to mount is/dev/sda2

    sudo blkid

The one circled above is the UUID. Note it down

  • The editor/etc/fstabAdd the following to the last line, the UUID below is the one you found above

    PARTUUID=UUID /home/pi/share_files NTFS umask=000, uid= PI, gid= PI 00

5. Solve the problem that raspberry PI does not support writing to NTFS file system

After you have done the above work, you have theoretically built a NAS disk. However, the problem is that once you have connected to the disk, you cannot write to the file system because the raspberry PI kernel does not support writing to the NTFS file system. We need to install a small patch:

  • Sudo apt-get install ntfs-3G-y sudo apt-get install ntFs-3G-y
  • Update kernel module Sudo Modprobe Fuse
  • Sudo reboot Restart the system

6. Enjoy

  • For example, I have clicked remember password, so I am not required to fill in the user name and password. The first connection will prompt you to enter the user name and password, so the user name you need to fill in ispiThe password is the one you set just now

  • The Ndroid phone connects to the SMB service, downloads an ES file browser from the app store and enters the user name and password.
  • Windows connects to the SMB service,win+rCall out the window and type in the window\ \ share IP address, enter the user name and password.

—————–

I am good xu, the world’s top 500 foreign companies Linux development engineer, specializing in the production of Linux dry goods. Welcome to pay attention to my public number “liang Xu Linux”, reply “1024” to obtain the latest and most complete technical information, reply “into the group” into the master such as cloud technology exchange group.