User Tools

Site Tools


doc:appunti:hardware:raspberrypi_nas

This is an old revision of the document!


Home Mediacenter and NAS with the Raspberry Pi

This is my recipe to build a mediacenter and NAS box using the Raspberry Pi. This is the list of components:

  • Raspberry Pi 4.
  • Seagate IronWolf 3.5 inch Hard disk, 4 Tb.
  • Suptronics.com X835 exapnsion board to connect SATA drives.

Subsystems

Mail system

I want a working mail system on the NAS, mainly because I want to eventually receive error messages from the various subsystems, think e.g. at the smartd daemon watching for S.M.A.R.T. hard drive errors…

In the following examples pimedianas is the hostname of my Raspberry Pi Mediacenter NAS. I istalled the postfix package and configured it as satellite system using a SMTP relay host. The relevant settings in /etc/postfix/main.cf are:

myhostname = pimedianas
mydestination = $myhostname, localhost.localdomain, localhost
relayhost = mail.example.org:587
default_transport = smtp
relay_transport = smtp
myorigin = $myhostname
# Rewrite some sender addresses.
sender_canonical_maps = hash:/etc/postfix/sender_canonical_maps
# Relay host requires SASL authentication.
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_mechanism_filter = plain, login
smtp_sasl_security_options =
smtp_tls_security_level = may

The content of /etc/postfix/sender_canonical_maps will force the MAIL FROM on locally generated mails:

root                       pimedianas@example.org
root@pimedianas            pimedianas@example.org
root@localhost             pimedianas@example.org
root@localhost.localdomain pimedianas@example.org

Write the proper info about localhost in /etc/hosts:

127.0.1.1  localhost.localdomain   localhost

Finally I had to put my SMTP credentials required by the relaying server into /etc/postfix/sasl_passwd:

mail.example.org pimedianas:MyVerySecretPwd

Last but not least, I redirected all the mail for root to my real email address in /etc/aliases:

root:   niccolo@example.org

Remember to compile all the files and restart the service:

postmap /etc/postfix/sasl_passwd
postmap /etc/postfix/sender_canonical_maps
newaliases
systemctl restart postfix.service

Now all the locally generated mails addressed to root, root@pimedianas, root@localhost or root@localhost.localdomain should have the MAIL FROM rewritten as above and forwarded to the external mailbox.

Kodi

Installed the packages:

  • kodi
  • kodi-bin - Contains the executable kodi-standalone, which is the one to execute.
  • kodi-peripheral-joystick - Necessary to add support for the gamepad.
  • kodi-eventclients-kodi-send - Contains the kodi-send tool, used to control Kodi from the command line.

We create an user called kodi which belongs to the groups: audio, video, input, pulse and pulse-access. To execute kodi as a Systemd service we created an Unit file /etc/systemd/system/kodi.service:

[Unit]
Description = Kodi Media Center

# if you don't need the MySQL DB backend, this should be sufficient
After = systemd-user-sessions.service network.target sound.target

# if you need the MySQL DB backend, use this block instead of the previous
# After = systemd-user-sessions.service network.target sound.target mysql.service
# Wants = mysql.service

[Service]
User = kodi
Group = kodi
Type = simple
ExecStart = /usr/bin/kodi-standalone
Restart = always
RestartSec = 15

[Install]
WantedBy = multi-user.target

The service must be enabled and started.

Kodi Add-ons

We don't want to depend on auto-download, audo-updates, etc. So we manually download the zip file for each app-on on the local filesystem. To allow installation in this way, it is required to enable System SettingsAdd-onsUnknown sources. Finally we can do Kodi Main ManuAdd-onsMy add-onsInstall from zip file.

Despite installing the add-on from a zip file, any required add-ons not present into the system will be automatically downloaded from the net and installed. Fortunately you can find the zip files of this additional add-ons into the $HOME/.kodi/addons/packages/ directory, so you can backup them for later use.

Music

Beside Kodi, which has its own functions to play music, I want also the functions offered by the Music Player Daemon; so I installed the Debian packages:

  • mpd - The Music Player Daemon, the underlying daemon which actually plays music.
  • ncmpc - It is a MPD client for text terminals, based on ncurses.
doc/appunti/hardware/raspberrypi_nas.1615456518.txt.gz · Last modified: 2021/03/11 09:55 by niccolo