Raspberry Pi x Lego – Home server

Why Lego?

In grade 1, my homeroom teacher happened to be the school’s primary computer teacher. The entire computer lab was Mac based, PowerPC’s everywhere. Then there was this special computer, a computer that had a Lego case (and ran Windows). He would passionately tell us how he built it and showed us how everything worked inside. Yeah, nobody had a single clue what he was talking about because you know, we were in grade 1. But hey it’s a computer with a Lego case, how cool! Ever since then I wanted one myself. As far as I remember, this marked the day I became a computer nerd 😛

Why a home server?

It is now common for one user to have multiple devices and we expect our data to be present on all of them. A common solution is to just make a copy for each device. For example, music. Want music on your tablet? Make a copy. Want music on your phone? Make a copy. Every single time I make a change to my song library, I have to manually copy it over to each device. Wouldn’t it be nice to have all your media just stored in one place and point all your devices to just “get it” from that location? This is where the home server comes in.

The computer

Raspberry Pi Model B

This is our “computer”. The famous “computer for 35 bucks”, the first generation Raspberry Pi. I bought it three years ago for experimenting around the GPIO pins in hopes of automating my room one day. That never happened as I lived in dorms so renovating my room is out of the question. I moved out since and rented a place. However, it clearly says in my contract no modifications of any kind shall be made to the room. Oh well 😛

Performance wise we are looking at something equivalent to an average computer in 1998-ish.

Haven’t touched this thing for three years, hopefully the humidity in Hong Kong hasn’t killed it.

It’s alive!

Testing if it is still working, excuse the poor presentation. Flashed the latest Raspbian OS “Jessie” on to the SD card and plugged it into a router. All the lights indicate its ok!

Setting it up server side

SSH enabled right out of the box!

Yeah, I am a Windows user… so we don’t have native SSH. PuTTY to the rescue!

Let’s configure our Raspberry Pi for server use with “sudo raspi-config”

We will be running the server “headless” (without a screen) so we can reduce the memory allocated to the GPU (Graphics Processing Unit) to the minimum.

The Raspberry Pi has 256MB of RAM, this will give us 16MB for the GPU and 240MB for the system itself.

We will be using the USB drive as our storage, let’s have it automatically mount on boot.

Install and configure UFW (Uncomplicated FireWall) for Samba file sharing.

Allow TCP 135,139,445 and UDP 138,139 from all the devices that you plan to share with.

Install, add Samba users and configure our Samba shares to point to our USB drive

Reboot the server! PuTTY calmly reminds us that the server has disconnected us

Accessing the shares in Windows is as easy as Pi

Click “Map network drive”

Enter you server details: \\<server_hostname>\<your _samba_folder>
Select a drive letter
Check reconnect at sign-in

All done! It’s just like an external drive!

Now that the functionality is there, let’s work on the case

Procuring the Legos

We will need a plan of course. Our official unit of measurement here is “Lego bumps”

Lego, you are truly evil, charging people by the bucket, a round bucket.

Talk about fitting a square peg in a round hole

The build

Remember to pad the bottom of the Raspberry Pi with some foam. Rubbing the bottom of a bare printed circuit board with Lego bumps isn’t exactly great.

Other than that, just build around the ports and build up from there!


Heat dissipation is inspired by Microsoft Surface Pro’s “Perimeter Venting”

I’ve decided to go with a similar design for the roof. This keeps most of the dust on the roof while allowing hot air to flow out from the top

Completed form. IKEA cup and Galaxy S4 for size reference.

Installing it with the rest of my network equipment


Completely scientific performance benchmark: You can stream six Girl’s Generation music videos in full high definition 1080P at the same time.

Alright, in all seriousness, here are the numbers:

Sequential reading from server: 33Mbps or ~4 megabytes per second

Sequential writing to the server: 25Mbps or ~3 megabytes per second

I’ve decided to only measure sequential performance because this is a media server, so most of the time, this is responsible for serving up big chunky files.

Performance analysis

The Surface Ethernet Adapter is rated at 100Mbps
The Raspberry Pi Ethernet Adapter is rated at 100Mbps
The Netgear router connecting the two is rated at 100Mbps

So why are we getting 33Mbps read, 25Mbps write? Clearly there is a bottleneck somewhere… let’s look at how the Raspberry Pi is doing

Woah 100% CPU usage, well at least we know our poor Raspberry Pi is trying its best. Clearly we are bounded by the processor, not surprising considering it has the processing power roughly equivalent to a computer in 1998. Let’s look at the breakdown.

Samba (our file share) is only using around 15% not too bad.

The NTFS-3G driver is the culprit here, using 65% of our puny processor. Accessing drives that are formatted as NTFS has always been a bit meh and inefficient on anything other than Windows. Technically I should already be glad that in Linux I can at least read and write to it. I am talking about you Mac OSX (older versions can only read from NTFS).

Seeing how NTFS is the problem, I decided to reformat the drives into something a little more Linux friendly, like ext4.

Result? 8MB/sec read and write or ~64Mbps. We are still processor bound as Samba is now able to “share faster” so its processor usage went up as processor usage for accessing the USB drive filesystem drops.

I could consider overclocking; however, this is a server and it will be running 24/7 so I want to maximize stability and reliability. Therefore overclocking is disregarded.


Didn’t you just say you will disregard that as an option? Yeah, but in the name of science and curiosity let’s briefly this option a little bit 😛

Before someone yells at me for using presets. Yes, I’ve also tried manually tweaking the parameters individually by editing the /boot/config.txt. After all my overclocking experience comes from the PC world 😉 This screenshot is strictly here for your visual pleasure.

900Mhz is as high as I can go without significant issues…

… and by without significant issues I mean:

It boots

The processor is running at 75C (it is rated for 85C so 7x is a “little” uncomfortably high)

The USB/Ethernet chip is now not finger friendly (it is rated for 70C and not finger friendly means 50C+)

Yeah, let’s just put it back into normal mode at 700Mhz

For what it’s worth, this 30% overclock gives us a 20% performance boost all across the board. So if your application requires such performance, I recommend getting some RAM heatsinks for the processor and controller.


For anyone interested in doing the same thing, there’s good news. This is the first generation Raspberry Pi, bought three years ago. The Raspberry Pi has moved on since then and the current one is the Raspberry Pi 3. It is still priced the same, so it’s still “a computer for 35 bucks”. For the processor, mine has a single-core clocked at 700Mhz, the current one is a quad-core clocked at 1.2Ghz. Needless to say, massive performance gains to be had for the same price!

Humming along at 700Mhz, so far it has reliably operated for a month and still ticking (I’ve only shut it down once as I was building a Lego case for it)

Leave a Reply

Your email address will not be published.