Convalesco

Current revision: 0.11

Last update: 2026-02-27 10:34:56 +0000 UTC

An eye for an eye will only make the whole world blind.

M. Ghandi


MiniDLNA Server on Raspberry Pi Model B

Date: 03/11/2024, 22:46

Category: technology

Revision: 1



Table of Contents

Introduction

The Raspberry Pi Model B can serve as dedicated video streaming device. It’s small, silent, and doesn’t consume much power. Given the Raspberry Pi’s limited specifications, it is not suited tasks for heavy-duty tasks, but it’s perfect for services such as miniDLNA. MiniDLNA is a lightweight DLNA universal plug and play (UPnP) media server that can stream media files to video clients.

Hardware Specs and Cost

The Raspberry Pi Model B (Rev 2) runs on BCM2835 SoC featuring a 700 MHz, ARM11 dual core CPU (ARMv6 architecture) and 512 MB of RAM. The Pi has 2 x USB 2.0 ports and 100Mbps ethernet. However the actual data transfer speed is closer to 160 Mbps (~22 MB/s).

The project will require a raspberry Pi case, EU RPi power cable, ethernet 10/100 cable, 512GB USB v2 drive to store data and an 8GB SD card for the operating system and the applications that are going to be installed.

In Greece, putting the required hardware together costs around 65€. The most likely target group for this post however, are techies with spare parts lying around. Otherwise you might want to look for a modern alternative.

Hardware Limitations

Using iperf3 to measure bandwidth shows a maximum data transfer speed of approximately 80 Mbps. Sustained speeds typically range from 40 to 60 Mbps for unencrypted connections.

Encryption significantly reduces data transfer speeds, with the Raspberry Pi’s CPU acting as a bottleneck for encryption and decryption processes. The optimal way to upload media to the Pi is via FTP. If you need to use SSL, it’s better to terminate the SSL connection elsewhere. Transferring 100MB of data through SSH took 81 seconds, while the same data transferred through FTP took around 22 seconds reaching an average speed of 40Mbps.

Streaming 1080p content typically requires between 7 and 14 Mbps of bandwidth, depending on factors such as the codec, bitrate, number of audio streams, etc. I have tested 720p and 1080p content and it worked without problems. In theory we should be able to stream 4k content as well, as it requires 25 to 35 Mbps, but I haven’t tested it. I have not tested media transcoding on this device but I would advice against it.

System setup

DietPi and FreeBSD are, IMO, the operating system of choice for Pi projects. In this case, I went with DietPi. Follow the installation instructions.

The lsblk command lists available storage devices, while mkfs.ext4 formats the selected partition to the ext4 filesystem. That can be done using the cfdisk command. To format and mount the USB disk:

$ lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda           8:0    1 461.3G  0 disk
└─sda1        8:1    1 461.2G  0 part /mnt/data
mmcblk0     179:0    0   7.4G  0 disk
├─mmcblk0p1 179:1    0   128M  0 part /boot
└─mmcblk0p2 179:2    0   7.3G  0 part /

$ sudo mkfs.ext4 /dev/sda1
[...]

Now you should be able to mount the disk to the /mnt/data directory and create the media directories:

$ sudo mount /dev/sda1 /mnt/data
$ sudo mkdir /mnt/data/{sports,family}
$ sudo chown dietpi:dietpi /mnt/data/{sports,family}

The dietpi-drive_manager command can be used to configure the system to mount the USB drive automatically during startup.

Configure vsFTPd

The vsFTPd server allows secure file transfers over FTP. The settings provided ensure that users can only access specific directories and disable unnecessary features for a lightweight, secure setup. The FTP protocol supports SSL, but it’s disabled in this setup to maximize data transfer speeds. Assuming vsFTPd has been installed, the configuration is set in file /etc/vsftpd.conf:

userlist_deny=YES
local_root=/mnt/data
listen=YES
listen_ipv6=NO
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=002
anon_upload_enable=NO
anon_mkdir_write_enable=NO
dirmessage_enable=YES
use_localtime=YES
connect_from_port_20=YES
chown_uploads=NO
xferlog_enable=NO
xferlog_file=/var/log/vsftpd.log
xferlog_std_format=YES
idle_session_timeout=60
data_connection_timeout=30
async_abor_enable=NO
ascii_upload_enable=NO
ascii_download_enable=NO
ftpd_banner=DietPi FTP
chroot_local_user=NO
chroot_list_enable=NO
ls_recurse_enable=YES
secure_chroot_dir=/run/vsftpd/empty
pam_service_name=vsftpd
# rsa_cert_file=/etc/ssl/private/vsftpd.pem

The important part is the local_root configuration here. This setup will make sure the dietpi user can upload files only under the /mnd/data directory. SSL is disabled of course.

Configure miniDLNA

The miniDLNA configuration is set on /etc/minidlna.conf:

media_dir=V,/mnt/data/family
media_dir=V,/mnt/data/sports
db_dir=/mnt/dietpi_userdata/.MiniDLNA_Cache
log_level=warn
network_interface=eth0
port=8200
friendly_name=DietPi MiniDLNA
serial=12345678
model_number=1
inotify=yes
album_art_names=Cover.jpg/cover.jpg/AlbumArtSmall.jpg/albumartsmall.jpg/AlbumArt.jpg/albumart.jpg/Album.jpg/album.jpg/Folder.jpg/folder.jpg/Thumb.jpg/thumb.jpg

Once the configuration is properly set and the service starts, the media files will be available to DLNA/UPnP clients. MiniDLNA can stream music and images as well.

Conclusion

The Raspberry Pi Model B breathes new life as a capable media server, offering a cost-effective way to share files and media with loved ones. With a few simple steps, it transforms from an outdated device to a valuable tool for your digital needs.