Skip to content

This project is to assist in the creation of a Raspberry Pi based NAS

Notifications You must be signed in to change notification settings

alecmedina-code/PiNAS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 

Repository files navigation

Pi NAS

This was a project for school during my time at the University of Houston
This project is to create a Raspberry Pi NAS (Network-Attatched-Storage)

Hardware Required

*Can be bought together via Raspberry Pi Kit

^May need to buy a micro SD card reader if you do not have an adapter or one built into your computer

Software Required

*Only needed for windows users

Information Required

Find your router's IP address and write this down. We will refer to this as "router's IP" for now on as it may differ among networks.


Setup

The following steps will be performed to complete this project. If you are using Windows your steps will be different for SSH-ing into your Raspberry Pi and should be done using Putty.

  • Connect micro SD card to your computer.

  • Open Raspberry Pi Imager. rpi_imager

  • Choose Raspberry Pi Os (32-bit) as the operating system. rpi_os

  • Choose your micro SD card as the storage device. rpi_storage

  • Click "WRITE".

  • Open new terminal at the boot drive (mounted micro SD after write). newterminal

  • Type the following command in the terminal and press enter. This creates an SSH directory in the boot drive and enables SSH-ing for the Raspberry Pi. terminal

  • Insert your micro SD card into your Raspberry Pi and connect your Pi (highlighted in green below) to power and to your router via ethernet. hardware

  • Type the following command in a new terminal and press enter. This will create an SSH session with the Raspberry Pi. ssh

  • If asked "Are you sure you want to continue connecting (yes/no)?" type "yes" and press enter.

  • When prompted for pi@raspberrypi.local's password type "raspberry" and press enter.

NOTE: We have now SSH'd into the Raspberry Pi.

  • Type the following command in the terminal and press enter. This will open a file where we can set our static IP address for Raspberry Pi. dhcpcd

  • Delete the lines between "# Example static IP configuration:" and "# It is possible to fall back to a static IP if DHCP fails:" and replace it with the following shown below. Here you should replace '192.168.1.254' with your router's IP and also replace the first three octets of '192.168.1.105/24' with the first three octets of your router's IP. staticip

  • After these changes have been made press control+O then enter to write to the file, then control+X to exit from the file.

  • Type the following command in the terminal and press enter. This will reboot the Raspberry Pi with the new network setup. reboot

  • Type the following command in the terminal and press enter. This will SSH into the Raspberry Pi again using the new static IP address. Here, you should use the static IP you set in the previous step. sshnewip

  • If asked "Are you sure you want to continue connecting (yes/no)?" type "yes" and press enter.

  • When prompted for pi@192.168.1.105's password type "raspberry" and press enter.

  • Type the following command in the terminal and press enter. This will list all storage devices connected to the raspberry pi (including RAM so do not be alarmed if the list is lengthy). fdisk

  • If you scroll through you should see a disk named /dev/sda. This means 'storage device a'. If this is not your storage device's name, look for something similar. I know that my external SSD is 250 GB, as we can see this is close to the storage capacity of /dev/sda. This is another way to verify you are using the correct storage device. Near the bottom we see /dev/sda1, this is a partition on the drive. You may have more. We need to delete any partitions before continuing. sda

  • Type the following commands in the terminal. This will delete the partitions on /dev/sda. If your drive is named something different you should use that name. If you have multiple partitions you should do the the last two lines for each partition. No terminal screen shots are provided as I do not want to erase the data off my drive.

pi@raspberrypi:~ $ sudo fdisk /dev/sda
Command (m for help): d
Partition number (1,2, default 2): 1
  • Type the following commands in the terminal. This will create a new partition on /dev/sda. Note when presented with the second, third and fourth lines, just press enter, the terminal will use the defaults.
Command (m for help): n
Partition number (1-128. default 1):
First sector (34-976773134. default 65535):
Last sector. +/-sectors or +/-size{K,M,F,T,P} (65535*976773134. default 976766):

Created a new partition 1 of type 'Linux filesystem' and of size 232.9 GiB.

Command (m for help): w
  • Type the following command in the terminal and press enter. This will format the drive partition we just created to ext4, a common linux file system type.
sudo mkfs -t ext4 /dev/sda1
  • Type the following commands in the terminal and press enter. This will mount the drive partition to a directory named volume.
sudo mkdir /volume
sudo mount /dev/sda1 /volume/
  • Type the following commands in the terminal and press enter. This will give everyone read/write access to the directory the drive partition is mounted to.
cd volume/
sudo chmod 777 -R .
  • Type the following command in the terminal and press enter. This will open a file where we can automate the mounting of our drive partition to our volume directory. fstab

  • Add the new code shown on the forth line below. This will set the partition /dev/sda1 to be automatically mounted to the directory /volume with ext4 format on boot. fstabfinal

  • After these changes have been made press control+O then enter to write to the file, then control+X to exit from the file.

  • Type the following commands in the terminal and press enter. This will update all package links for the Raspberry Pi and install samba dependicies. Samba is a software package that implements SMB (Server Message Block) protocol to allow us to connect to the drive from any device.

sudo apt-get update
sudo apt-get install samba
  • Type the following command in the terminal and press enter. This will open a file where we can set up our directory for SMB protocol and a few more settings. opensmb

  • Add the new code shown on the bottom four lines. This will setup the directory to be viewed as PiNAS on the network, with the path to the /volume directory and with writeable access to individuals with an account on the Raspberry Pi. smb

  • After these changes have been made press control+O then enter to write to the file, then control+X to exit from the file.

  • Type the following command in the terminal and press enter. This will restrart the samba server to accept the new settings we have created for our PiNAS.

sudo systemctl restart smbd
  • Type the following command in the terminal and press enter. This will let you create a new user and password for our user pi on the Samba SMB server. When prompted to enter a password, enter your desired password. You may want to eventually change your password for the Raspberry Pi itself, this is a different step. This step only setups a user on the Samba SMB server.
sudo smbpasswd -a pi
New SMB password: 
Retype new SMB passowrd: 
Added user pi. 
  • We have no completed the setup of our Raspberry Pi NAS. To connect to the PiNAS click on your desktop and then press cmd+k. This will open an application that allows us to connect to the PiNAS via SMB. Enter the following into the search bar. If your IP address was different, enter that IP. connect

  • When the next window appears, click on PiNAS and press OK. volume

  • If everything was successful you should now see thew PiNAS mounted under Locations. finder

About

This project is to assist in the creation of a Raspberry Pi based NAS

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages