User Tools

Site Tools


doc:appunti:hardware:raspberrypi_nas

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
doc:appunti:hardware:raspberrypi_nas [2021/03/10 15:40] niccolodoc:appunti:hardware:raspberrypi_nas [2021/04/02 13:47] (current) – [Home Mediacenter and NAS with the Raspberry Pi] niccolo
Line 1: Line 1:
 ====== Home Mediacenter and NAS with the Raspberry Pi ====== ====== 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:+This is my recipe to build a **[[wp>Home_theater_PC|mediacenter]]** and **[[wp>Network-attached_storage|NAS]]** box using the **[[wp>Raspberry_Pi|Raspberry Pi]]**. This is the list of hardware components:
  
-  * Raspberry Pi 4. +  * **Raspberry Pi 4** Model B with 4 Gb RAM
-  * Seagate IronWolf 3.5 inch Hard disk, 4 Tb+  * 4 Tb **hard disk** Seagate IronWolf 3.5 inches
-  * Suptronics.com X835 exapnsion board to connect SATA drives.+  * **Suptronics.com X835** USB to SATA adapter, to connect the hard disk. 
 +  * Ugreen **USB audio** adapter. 
 +  * **Gamepad** USB wireless (SNES-like) used as remote control.
  
 +{{.:raspberrypi:rpi-nas-mediacenter.png?640|Raspberry Pi NAS and mediacenter}}
 +
 +{{.:raspberrypi:wifi-forbidden.png?90 |WiFi Warning}}
 +**WARNING** :!: It turned out that the **Raspberry Pi 4**, when it uses the **USB 3** interface, produces **radio interferences on the 2.4 GHz** band. It is **impossibile to connect to the 2.4 GHz WiFi** access point which is only 5 meters far. It was also **impossible to use a wireless keyboard and mouse**, using one USB dongle which also operates on the 2.4 GHz. To operate a **wireless gamepad** (which also uses an USB dongle on the 2.4 GHz frequencies) I had to distantiate the dongle from the Raspberry Pi using and USB **extension cable of about 0.5 meters**. Due this **severe problem**, I can suggest the RPi4 solution only if you will use the **Ethernet** interface or an access point on the **5 Ghz** band. As an alternative to the wireless gamepad or keyboard, you can use the **[[https://play.google.com/store/apps/details?id=org.leetzone.android.yatsewidgetfree|Yatse application]]** on an Android smartphone.
 +
 +{{.:raspberrypi:forbidden-mpg4.png?90 |MPEG4 Warning}}
 +**WARNING** :!: There is another potential problem with the **Raspberry Pi 4**: due the increased CPU power, the designers decided to drop the **H263** and **MPG4** codecs from the hardware. That codecs were enabled in-hardware into the older Raspberry Pi models and the license price was included into the hardware price. In older models you could also purchase additional licenses, e.g. for **MPEG2** and **VC-1**; this is no longer an option on the Raspberry Pi 4. I experience a **[[https://github.com/raspberrypi/linux/issues/4257|bug]]** with **Kodi** and **kernel 5.10**: software decoding of MPEG4 streams (e.g. the ones produced by the XviD library) were terribly jerky. I had to downgrade to **kernel 4.19** to solve the problem. Notice that the **LibreELEC 9.2** and **10.0 Beta** distributions play the same file smoothly.
 ====== Subsystems ====== ====== Subsystems ======
  
   * **[[raspberrypi_nas_x835_sata_board]]**   * **[[raspberrypi_nas_x835_sata_board]]**
   * **[[raspberrypi_nas_smart_hard_disk]]**   * **[[raspberrypi_nas_smart_hard_disk]]**
 +  * **[[raspberrypi_nas_networking]]**
   * **[[raspberrypi_nas_kodi]]**   * **[[raspberrypi_nas_kodi]]**
   * **[[raspberrypi_nas_audio]]**   * **[[raspberrypi_nas_audio]]**
-  * **[[raspberrypi_nas_networking]]** 
   * **[[raspberrypi_nas_mail]]**   * **[[raspberrypi_nas_mail]]**
 +  * **[[raspberrypi_nas_remote_control]]**
 +  * **[[raspberrypi_nas_case]]**
  
-===== Networking ===== 
- 
-Current release of **RaspiOS** (we are on Debian 10 Buster) uses **dhcpcd** to manage networking (see **[[https://www.raspberrypi.org/documentation/configuration/tcpip/|Raspberry Pi TCP/IP Networking]]**). This means that: 
- 
-  * Use **/etc/dhcpcd.conf** file to define static IP address or fallback IP address (if DHCP fails). The same file is used to e.g. disable **WiFi** (wlan0) interface. 
-  * Do not use **/etc/network/interfaces** for static or dynamic IP assignment. 
-  * WiFi ESSIDs and passwords are in **/etc/wpa_supplicant/wpa_supplicant.conf**. 
-  * Do not install **Network Manager**. 
-  * If a gaphical interface is needed, use **lxplug-network**. 
-  * If some package installs the systemd **wpa_supplicant.service**, disable it or you will have two conflicting ''wpa_supplicant'' processes running (execute the ''systemctl disable wpa_supplicant.service'' command and reboot). 
- 
-I want the **eth0** interface to have a static IP address beside the one eventually assigned by DHCP (i.e. I want an IP alias on eth0:0). This is useful when I wan connect to the host even in an unknown network. To achieve this when dhcpcd is running, it is necessary to create an **user defined hook script**. See this page for more details: **[[..:linux:sa:dhcpcd_ip_alias]]**. 
- 
-===== 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: 
- 
-<file> 
-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 
-</file> 
- 
-The content of **/etc/postfix/sender_canonical_maps** will force the **MAIL FROM** on locally generated mails: 
- 
-<file> 
-root                       pimedianas@example.org 
-root@pimedianas            pimedianas@example.org 
-root@localhost             pimedianas@example.org 
-root@localhost.localdomain pimedianas@example.org 
-</file> 
- 
-Write the proper info about **localhost** in **/etc/hosts**: 
- 
-<file> 
-127.0.1.1  localhost.localdomain   localhost 
-</file> 
- 
-Finally I had to put my **SMTP credentials** required by the relaying server into **/etc/postfix/sasl_passwd**: 
- 
-<file> 
-mail.example.org pimedianas:MyVerySecretPwd 
-</file> 
- 
-Last but not least, I redirected all the mail for root to my real email address in **/etc/aliases**: 
- 
-<file> 
-root:   niccolo@example.org 
-</file> 
- 
-Remember to compile all the files and restart the service: 
- 
-<code> 
-postmap /etc/postfix/sasl_passwd 
-postmap /etc/postfix/sender_canonical_maps 
-newaliases 
-systemctl restart postfix.service 
-</code> 
- 
-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**: 
- 
-<file> 
-[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 
-</file> 
- 
-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 Settings** => **Add-ons** => **Unknown sources**. Finally we can do **Kodi Main Manu** => **Add-ons** => **My add-ons** => **Install 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 **[[https://www.musicpd.org/|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. 
- 
-===== Transfer rate ===== 
- 
-We measured the **transfer rate** from other home NASes, just to figure out how much time is required to **transfer 500 Gb of data**. The receiving NAS is the **Raspberry Pi 4** with a **Seagate 4 Tb** IronWolf 3.5 inch hard disk connected through the **X835 USB3** interface. The network is limited to **100 Mbit** transfer rate, due to the limit of the LAN switch. 
- 
-^ NAS model          ^ Disk model  ^ Transfer rate (Mbit)  ^ 500 Gb transfer time (hours)  ^ 
-| LaCie d2 Network   | WDC WD10EFRX-68FYTN0, 1Tb, 5400 rpm         13 |  87.5 | 
-| QNAP TS-120        | Hitachi Deskstar 7K1000.B, 1Tb, 7200 rpm  |   98 |  12.7 | 
- 
-===== Web References ===== 
- 
-  * **[[https://kodi.wiki/view/PulseAudio|Kodi with PulseAudio]]** 
-  * **[[https://gist.github.com/bheisig/bf1a13a05cdb6a12ee805b00dc6d90bb|PulseAudio for Kodi, MPD and remote access on a Ubuntu host]]** 
-  * **[[https://serverfault.com/questions/275364/get-drive-power-state-without-waking-it-up/|Get drive power state without waking it up]]** 
-  * **[[https://unix.stackexchange.com/questions/366438/hard-disk-not-going-to-standby-automatically|Hard disk not going to standby automatically]]** 
-  * **[[https://serverfault.com/questions/305847/how-to-determine-disc-spindown-time|How to determine disc spindown time]]** 
  
doc/appunti/hardware/raspberrypi_nas.txt · Last modified: 2021/04/02 13:47 by niccolo