A home server evolution: the stone age
If money wasn't a factor, I would splash some cash on a nice NAS and that would probably be the end of my home server journey.
But what if I could get started with what I already have laying around? Anything would be an improvement over copying files to a USB key and carrying it around.
My objective is simple: share files on the network and play videos on the TV.
I have a Raspberry Pi Model B available. It's the first generation of Raspberry Pi, released in 2012, and featuring 512 MB of RAM and a 700 MHz CPU. That's not powerful enough to run popular media player software like Kodi or Plex. At a bare minimum, Plex recommends 1.2 GHz to play a video with no transcoding.
However, my TV happens to be a smart TV and is DLNA certified. This means the TV follows certain standards, including Universal Plug and Play (UPnP). So the Raspberry Pi can serve files on the network, and some DLNA software can be installed on top of it to serve the shared media files.
This setup works surprisingly well: it allows to play on the TV any video stored on the Pi. It's even possible to play 4K videos without buffering, something I wasn't expecting. General file sharing on the network works well too.
Added bonus: the TV can also play music and display photos. If navigation was a little more intuitive and snappier, I may actually enjoy using these features from time to time.
The main downside is the speed of transfer: it takes close to 3 minutes to copy 1 GB to the device (average speed of 6 MB/s). The Raspberry Pi has USB 2.0 ports so I had low expectations.
- Raspberry Pi
- SD card (8 GB, for the OS)
- USB key (16 GB, for storage)
- ethernet cable (to connect the Pi to the router)
I have tried to use a spare external hard drive but the Pi couldn't supply it with enough power, so I'm sticking to the USB stick.
Format the USB key
List information about block devices and identify the disk name (assumed to be "sda" in the next few snippets):
Create a GPT partition table:
sudo parted /dev/sda --script -- mklabel gpt
Create an EXT4 partition that takes up the whole space:
sudo parted /dev/sda --script -- mkpart primary ext4 0% 100%
Format the partition to ext4:
sudo mkfs.ext4 -F /dev/sda1
Set up the home server
I have chosen Samba (implementing the SMB protocol) to not restrict network access to a certain OS (NFS being used for Linux, and AFS for Mac).
Create the share directory with read, write, and execute permissions:
sudo mkdir -m 777 /media/key/share
Mount the drive to this new directory:
sudo mount -t auto /dev/sda1 /media/key
sudo apt-get install samba samba-common-bin
Backup the default config:
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.default
Edit the config:
sudo nano /etc/samba/smb.conf
Add the share configuration at the bottom of the file:
[home]comment = Homepath = "/media/key/share"writeable = yesguest ok = yescreate mask = 0777 directorymask = 0777force user = pi
Allow the "pi" user to connect to shares:
sudo smbpasswd -a pi
sudo systemctl restart smbd
Edit fstab configuration so that the drive mounts whenever the Pi reboots:
sudo nano /etc/fstab /dev/sda1 /media/key auto noatime 0 0
Access the share on a Mac:
Finder > Go > Connect to server > smb://192.168.0.XX/share
Use the Pi's IP address and login with the "pi" user and the Samba password.
Automatically mount the drive on a Mac:
System Preferences > Users & Groups > Login Items > Add an item to the Login Items list
Set up DLNA
sudo apt-get install minidlna
Edit the miniDLNA config:
sudo nano /etc/minidlna.conf
Specify the source directory:
Set the display name:
sudo service minidlna start
Whenever changing the config, restart miniDLNA for the change to take effect:
sudo service minidlna restart
It works! But the limited size of the USB key and the slow speed of transfer are major limitations. I have some ideas about how to upgrade the setup and bring it from the stone age to the contemporary times. Using a secondhand workstation seems like a smart option, but an easier upgrade could consist in getting a more recent Raspberry Pi and an SSD. A project for another day!