My old laptop, is my new web server

Posted by ryansouthgate on 23 Jan 2023

I hate throwing things away, even tech that isn’t working - optimistically believing that I’ll find the time to fix it.

I stumbled across the below video a few weeks ago. If you haven’t watched it, give it a watch. Yes, it’s simplistic, it’s heavy on the advertising, but the messaging is solid:

Old tech can still have a purpose

Although, after a few years of running OMV (on an Odroid) and Raspberry Pis and lots of docker containers on them, I personally wouldn’t use Windows for server use. The (mostly) Debain-based operating systems I’ve used, have been absolutely rock solid. I’m talking hundreds of days of uptime, only rebooted when I’d updated packages on the systems.

My Old laptop

This laptop is a ZooStorm W550SU…. Yeh, I hadn’t heard of that brand either.

I picked this up about 8 years ago for less than £450. The specs were very good for the price:

  • Intel i5-4210M
  • 16GB (2x8) RAM, DDR3, 1333 MT/s
  • 1TB WD Hard Drive (5400RPM)
  • Intel Graphics controller
  • 1Gb Ethernet
  • WiFi + Bluetooth

The Zoostorm laptop open

The keyboard was livable, the trackpad was terrible.

The laptop was bought as a Dev machine. I had no intentions of gaming on it. No media consumption, just code & build.

It has served that purpose very well. It lasted nearly 6 years, before the screen died. The backlight stays on, but nothing shows. All is well when connecting to an external monitor via HDMI/VGA, but the convenience of a laptop had gone.

The laptop was starting to show it’s age, the battery wouldn’t last a long time and it started to get a little slow. A Black Friday deal came up for a Dell that could wipe the floor with it. I purchased the Dell laptop 4 years ago, and am still using it to this day. I stopped using the ZooStorm, I didn’t have the heart to throw it away, and knew there might still be some life in the old dog yet.

The battery has certainly seen better days and had started to leak on the inside of the laptop (with no external signs)…

Recently I’ve been looking to save money by moving away from services that are no longer serving their purpose, read more about moving from Ghost to Hugo here.

A Webserver

I downloaded Ubuntu Server, installed it on the Laptop (selecting Docker) and started experimenting. Ubunutu Server is a non GUI operating system, which means it runs really light, you use the command line.

It was still a little slow at first, I could hear the HDD spinning up and down when it needed a break. This seemed to be a bottle neck as it wouldn’t start running commands until the HDD had (audibly) spun up. I found a Kioxia 480GB SSD for less than £30 the other week, which was a great upgrade. Commands sent to the laptop, now run instantly and finish a lot quicker than they used to.

I have some Smart Plugs around the house, which primarily allow me to turn things on/off automatically. I flashed these with Tasmota, hooked them up to Home Assistant and they draw nice graphs, showing energy usage over time. At idle, this laptop will consume around 12 Watts. When it’s around 100% utilisation, I’ve recorded around 40W, which isn’t bad, given it’s rarely at 100% CPU for long at all.

After some experimentation, I decided that this will be an immensely capable webserver, that wont cost a lot to run. It’s an Intel i5 serving up static HTML/JS/CSS - super easy for this machine. I’ll be saving around £80/year on a Ghost Subscription, so in the first year of running, I will have saved ~£55 (given energy pricing at the time of writing).

I’ve also decided to self-host a GitHub Actions runner on the laptop too. This is CI/CD for my blog. Nice to have it all on one box and in one place.

It’s certainly overkill for now, however I plan on further utilising this server for other websites I want to create.

Saving Energy

With the recent energy crisis in the UK (and other parts of the world), there’s never been a better time to ensure that your devices are running as efficiently as possible.

I might be able to fit this into my very modest server rack in the loft. But to save space, I need to be able to close the lid. Closing the lid, puts the machine to sleep. I configured Ubuntu Server so that it no longer goes to sleep when the lid is shut. Great! The below commands do this:

# Ignore the lid switch
sudo echo "HandleLidSwitch=ignore" >> /etc/systemd/logind.conf

# If a high level inhibitor lock is taken (e.g. shutdown, reboot, sleep, idle) then respect that lock
sudo echo "LidSwitchIgnoreInhibited=no" >> /etc/systemd/logind.conf

However, the screen backlight is still on, even though the screen is broken and it’s shut. This is a waste of energy (and generates heat). I found some more config online, applied it, which keeps the screen off. Checking the power usage now showed an average idle of 8 Watts - a 4 Watt saving! The code to create/enable this using systemd is below:

sudo touch /etc/systemd/system/enable-console-blanking.service
sudo echo "" >> /etc/systemd/system/enable-console-blanking.service

# Fill out the systemd configuration
sudo cat <<EOT >> /etc/systemd/system/enable-console-blanking.service
[Unit]
Description=Enable virtual console blanking
[Service]
Type=oneshot
Environment=TERM=linux
StandardOutput=tty
TTYPath=/dev/console
# Turn off screen after 1 min
ExecStart=/usr/bin/setterm -blank 1
[Install]
WantedBy=multi-user.target
EOT

sudo chmod 664 /etc/systemd/system/enable-console-blanking.service
sudo systemctl enable enable-console-blanking.service

I’ve also turned off Wifi and Bluetooth because I’ve got this machine connected to my 16-Port Netgear Unmanaged switch. Also, turning these off might save a fraction of a Watt. I installed and used rfkill like this:

# Install rfkill
sudo apt install rfkill -y

# Lists all RF devices and their states
rfkill

# Block all devices
sudo rfkill block all

Closing

I’m really happy with the cost savings, that’s some nice beer money right there! Also, hosting your own stuff is rewarding too. I’ve learnt more things about Ubuntu Server and Linux in general. My scripting has got better, as I’ve scripted the setup of this machine from fresh.

I hope to write about the specifics of Self-hosting a blog (created with Hugo), and serving that to the internet in the future. There’s lots of consideration into security, and there’s services out there that can make this a breeze.

Thanks for reading



comments powered by Disqus