Monday, June 1, 2020

How to setup File Server with Raspberry Pi


We are gonna kick off with preparing fresh copy of Raspberry PI OS Lite on empty SD card with Raspberry Pi Imager software. When is all done SD card has to be removed and inserted back into card reader so Windows can see newly created partition. In my case i'm using Notepadd++ to create empty file called "SSH" without file extension and we are gonna save it to boot partition of our SD card.

Because SSH is enabled with placing empty file called SSH in root partition of SD card, we do not need to connect Monitor, Keyboard and  Mouse to our Raspberry Pi. We are gonna be using SSH connection from another computer or even from another Raspberry Pi. From Windows computer we can use PuTTY software and from Linux computer we can to simply from terminal window.

Before we power on our Raspberry Pi, we need to insert SD card into Raspberry Pi,  connect LAN cable to network Router, connect USB hard drive and we are ready to power up Raspberry Pi.

Next step is to find out IP address of our future File Server. Because we didn't connect monitor to our File Server, the best way to find it is to login into Router and from there read IP address of our File Server.

I'm using Linux terminal for connection to server, but once you are connected commands are the same from Linux or Windows.

To connect from Windows, we need to open the PuTTY software, enter IP address of our File Server and click on Open button.


In the next Window we need to enter valid username and password. Default username for Raspberry Pi OS is "pi" and password "raspberry".


For Linux computer we need to just open terminal and enter command:


sudo ssh pi@IP_Address

and when asked enter valid password and we are connected. Now we are ready to make necessary changes to our File Server system and install necessary software.

So let's get started, first we are gonna open raspi config software by typing:

    sudo raspi-config


First option is to change password for "pi" user, so here we can set desired password. Next under Network Options we are gonna change default hostname to our needs, i personally like to change it to "FileServer".


After changing Hostname, raspi-config software is gonna ask to reboot our new File Server.

In next step we have to login an update our Raspberry Pi OS on our FileServer, so to do that we are gonna enter next two command:

sudo apt update
sudo apt upgrade

Create folder for mounting our USB drive:

sudo mkdir -m 1777 /media/USB_Drive

Edit "fstab" file and add mount point for our USB Drive:

sudo nano /etc/fstab

Add at end of file next line for ntfs formated hard drive:

/dev/sda1    /media/USB_Drive    ntfs    defaults    0    1

Save changes and mount partition with next command:

sudo mount -a

Install samba server:

sudo apt install samba samba-common-bin

Edit samba config and add our share at end of file:

sudo nano /etc/samba/smb.conf

[Network share]
  comment = Network shared folder
       path = /media/USB_Drive
       browseable = yes
       writable = yes
       only guest = no
       create mask = 0777
       directory mask = 0777
       public = yes
       guest ok = yes

Add pi user to samba and set password:

sudo smbpasswd -a pi

Restart samba service:

sudo service smbd restart

And with restarting samba service we are ready to open File Manager and browse our FileServer.


So from now on our server is ready to go, even if you turn off Raspberry Pi, everything is starting automatically with booting Raspberry Pi OS.

Thanks for visiting!
Till the next time.

No comments:

Post a Comment

Programing AT89C2051 using SDCC compiler on Debian Linux

My Homemade AT89C2051 Development Board First and foremost we need to install a compiler and we need a programmer to load the code into the ...