basic configuration - vincios/rpi-setup GitHub Wiki
Other all tutorials in this wiki assumes that you have first followed this paragraph.
Please make sure to follow this steps before all other tutorials!
-
The OS default user name is
raspi -
Create an
~/Appsfolder$ mkdir ~/Apps -
Create a
~/.logsfolder$ mkdir ~/.logs -
Create a
~/.bash_aliasesfile-
$ nano ~/.bash_aliases -
Paste these lines
alias ll='ls -l' alias la='ls -la'
-
Exit and save
-
$ source ~/.bashrc
-
Run raspi-config and change screen resolution to 1920x1080
-
Install dependencies
$ sudo apt update $ sudo apt install cifs-utils
-
Create mountpoints into the
/mediafolder# $ sudo mkdir /media/dnas $ sudo mkdir /media/qnas $ sudo mkdir /media/snas $ sudo mkdir /media/qnas/Download $ sudo mkdir /media/qnas/Media $ sudo mkdir /media/qnas/Vincenzo $ sudo mkdir /media/qnas/Vincenzo-Home $ sudo mkdir /media/snas/Immich-Library # Only if Immich is installed $ sudo mkdir /media/snas/Vincenzo
-
Create the credentials files, in a
~/.credentialsfolder (create if not exists) One for each network device (if they have different credentials)-
nano ~/.credentials/.qnas-<user>user=<YOUR-USER> password=<YOUR-PASSWORD> domain=WORKGROUP
-
Give access only to the user
$ chmod 600 ~/.credentials/.qnas-<user>
-
Repeat for each network share you want to login
-
-
Run
raspi-configand enable "Wait for Network at Boot" under "Boot options" -
Follow Systemd automounts
Systemd can automatically mount shares. Just like services, you have to create some special Unit files that describe how and where to mount.
There are two unit files:
-
.mountunits: define how to mount shares -
.automountunits: define mount points that are mounted on-demand, i.e. only when they are accessed
automount units are optional; but, when they exist, corresponding mount units must also exist. The former are meant to add functionalities to existing instances of the latter.
Important
Note that the name of the file must map to the actual filesystem mount target, that is mnt-winshare.(auto)mount refers to /mnt/winshare. This is also CASE SENSITIVE!
E.g. to mount in /home/user/Myfolder the file names must be home-user-Myfolder.(auto)mount.
If you want to mount the shrare //192.168.1.1/Multimedia to the mount path /media/nas/Media
-
Create the unit files
-
/etc/systemd/system/media-nas-media.mount[Unit] Description=NAS Multimedia Mount [Mount] What=//192.168.1.1/Multimedia Where=/media/nas/Media Type=cifs Options=cred=/path/to/cred-file,uid=raspi,gid=raspi [Install] WantedBy=multi-user.target -
/etc/systemd/system/media-nas-media.automount[Unit] Description=Automount NAS Multimedia Mount [Automount] Where=/media/nas/Media [Install] WantedBy=multi-user.target
-
Note
Don't forget to replace with your credential file (or remove the Option line if there is no login).
-
Reload the units
$ sudo systemctl daemon-reload
Then you can mount an unmount the share just like all other services:
$ systemctl start media-nas-media.mount
$ systemctl stop media-nas-media.mountAnd enable the mount at boot with
$ systemctl enable media-nas-media.mountOR the on-demand automount with
$ systemctl enable media-nas-media.automountImportant
From here.
-
Run
sudo nano /etc/fstaband add these lines (changes paths as done in point 2)#//192.168.1.200/Volume_1 /media/dnas/ cifs credentials=/home/raspi/.credentials/.dnascredentials,uid=raspi,gid=raspi,iocharset=utf8,file_mode=0755,dir_mode=0755,noperm,vers=1.0 0 0 //192.168.1.210/Multimedia /media/qnas/Media/ cifs credentials=/home/raspi/.credentials/.qnas-vincenzo,uid=raspi,gid=raspi,iocharset=utf8,file_mode=0755,dir_mode=0755,noperm 0 0 //192.168.1.210/Download /media/qnas/Download/ cifs credentials=/home/raspi/.credentials/.qnas-vincenzo,uid=raspi,gid=raspi,iocharset=utf8,file_mode=0755,dir_mode=0755,noperm 0 0 //192.168.1.210/homes/vincenzo /media/qnas/Vincenzo-Home/ cifs credentials=/home/raspi/.credentials/.qnas-vincenzo,uid=raspi,gid=raspi,iocharset=utf8,file_mode=0755,dir_mode=0755,noperm 0 0 //192.168.1.210/Vincenzo /media/qnas/Vincenzo/ cifs credentials=/home/raspi/.credentials/.qnas-vincenzo,uid=raspi,gid=raspi,iocharset=utf8,file_mode=0755,dir_mode=0755,noperm 0 0 //192.168.1.200/Vincenzo /media/snas/Vincenzo/ cifs credentials=/home/raspi/.credentials/.snas-vincenzo,uid=raspi,gid=raspi,iocharset=utf8,file_mode=0755,dir_mode=0755,noperm 0 0 //192.168.1.200/Immich-Library /media/snas/Immich-Library/ cifs credentials=/home/raspi/.credentials/.snas-vincenzo,uid=raspi,gid=raspi,iocharset=utf8,file_mode=0755,dir_mode=0755,noperm 0 0 -
Check if OK with
sudo mount -a
-
sudo apt-get install samba -
sudo nano /etc/samba/smb.conf -
Default Samba share of the user folder have some security restrictions. So, choose one of the following options
-
OPTION 1: edit the default configuration
- In the
[homes]section of smb.conf find the lineread only = yesand change toread only = no
- In the
-
OPTION 2: crate a new one configuration
-
Add to the bottom
[PiShare] comment = Pi Share path = /home/raspi browseable = yes writeable = yes only guest = no read only = no create mask = 0740 dierectory mask = 0750 public = yes valid users = %S
-
-
-
Choose a smb password for raspi user
$ sudo smbpasswd -a raspi
-
Restart smb
$ sudo systemctl restart smbd.service
If the network folder is not visible or is not writeable, try this solutions (one at time):
-
If windows explorer doesn't ask for password when you open the network share: open the Windows Credential Manager and, under the
Windows Credentiastab, manually add the credentias for the network address\\RASPBERRYPI. Then, restart Explorer or the computer. -
On the raspberry, try this command
sudo pdbedit -a -u raspi
Adapted from here.
-
Create a
.duckdnsfolder in your home directory -
Create a
duck.shfile with following contenttimestamp() { date +"%Y-%m-%d %H:%M:%S" } echo url="https://www.duckdns.org/update?domains=$DUCKDNS_DOMAINS&token=$DUCKDNS_TOKEN&ip=" | curl -k -o ~/.duckdns/log.log -K - echo " | Last run: $(timestamp)" >> ~/.duckdns/log.log
-
Create a
duck.conf.shfile with following contentexport DUCKDNS_DOMAINS=<YOUR_DUCKDNS_DOMAINS> export DUCKDNS_TOKEN=<YOUR_DUCKDNS_TOKEN>
Warning
Don't forget to edit the <YOUR_DUCKDNS_DOMAINS> and <YOUR_DUCKDNS_TOKEN> fields. No quotes needed.
Tip
<YOUR_DUCKDNS_DOMAINS> can be a comma separated (NO spaces) list of domains
-
Make the script executable
$ chmod 700 duck.sh duck.conf.sh
-
Test the script
$ . $HOME/.duckdns/duck.conf.sh; $HOME/.duckdns/duck.sh
Warning
Note the leading dot .
Tip
💡Check the result in the log.log file
-
Edit the cron configuration
$ crontab -e
-
Add this line to the bottom
*/5 * * * * . $HOME/.duckdns/duck.conf.sh; $HOME/.duckdns/duck.sh >/dev/null 2>&1
-
Start the cron service
$ sudo service cron start