How to turn your old Macbook (or any old laptop) into a home server

Thijs De Bruin
5 min readJan 7, 2024

--

Introduction

I’ve been interested in setting up a home server for a while now. After I upgraded my Mac I was left with an old Macbook pro (late 2015, Dual core i5). Nothing fancy, but enough for me to start experimenting. In this post I will go through all the steps I took to turn my old Macbook pro (2015) into a basic home server with Ubuntu Server 22.04, although I’m sure this tutorial will apply to most old laptops.

Wiping the Macbook

First things first. Cleaning the Macbook. Erasing all content of my Macbook, doing a factory reset, turned out to be a little bit more involved on this older Macbook pro model. Following instructions on an apple support page, I did the following. First I signed out of iCloud and iMessage (don’t think this is needed but for completeness you can do it as well). After this step came the actual factory reset part.

First you need to open Disk Utility. While rebooting, press and hold Command (⌘) en R. Then, at the bottom of the option pannel, select Disk Utility. Locate the Macintosh HD or Macintosh volume group, and click Erase as demonstrated in the picture below.

Installing Ubuntu server

To install Ubuntu Server we need 3 things: the Ubuntu Server ISO file, a USB flash drive, and Balena Etcher.

First, download the ISO file from the official Ubuntu website. When the download is complete, we need to use Balena Etcher to burn the ISO file onto a USB stick and create a bootable USB drive from which we can install Ubuntu Server. This process is extremely easy. Simply select the iso file, select the USB drive, and click flash. That’s it!

Now we’re ready to install Ubuntu Server on our machine. If you are still in the Disk Utility, click restart and hold down the Option key to enter the Startup Manager. Select the USB drive (usually labeled as EFI Boot).

From this point, you can simply follow the install instructions from the Ubuntu Server menu. You can navigate through the options using the arrow and enter keys. If you require some assistance during the installation process or want to know more about the options I can refer you to the official installation documentation.

Connecting to your server

If you followed the installation instructions and everything went well, the server should be up and running! You can now connect to the server from any pc on your local network with OpenSSH Server. First we need to make sure that OpenSSH Server is installed on the server. You can check this with the command:

sudo systemctl status ssh

If this does not return anything or results in an error, install openssh-server

sudo apt update
sudo apt install openssh-server

If you have firewall enabled on your Ubuntu server, you need to allow SSH connections by executing the command

sudo ufw allow ssh

After this is done, you should now be able to connect. To do so we need to find the ip of the machine in your local network. Type ‘ip a’ in the terminal of the server and look for the IPv4 adress (something like 192.168.0.0). Then, in the terminal of your other machine write

ssh {username}@{IPv4_adress}

You should now be prompted for a password, and you have to accept that the connection is safe when connecting for the first time by typing yes. And that’s it, you are now connected to your own server!

Tips and tricks

How to stop the server from sleeping

I found that the server would sleep when I closed the lid. Not very helpful if you want your server to be always online. To make sure that the server never sleeps, you use the terminal to edit the configuration file (feel free to change vim to nano if you prefer)

sudo vim /etc/systemd/logind.conf

In this file, change the lines ’#HandleLidSwitch’ and ’HandleLidSwitchExternalPower’ from suspend to ignore. In addition, set the line LidSwitchIgnoreInhibited=no. Afterwards, restart the server using the `reboot` command.

Next, disable the suspend daemon with the following commands

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
sudo systemctl status sleep.target suspend.target hibernate.target hybrid-sleep.target

You should see something like

How to turn the screen off

If, like me, you want to interact with the server through an ssh connection, and not through the server terminal itself, you can turn off the screen to save some power. Here I have to credit Maximilian Böhm for describing an excellent solution.

First we create a new service

sudo vim /etc/systemd/system/enable-console-blanking.service

paste the following into the file

[Unit]
Description=Enable virtual console blanking

[Service]
Type=oneshot
Environment=TERM=linux
StandardOutput=tty
TTYPath=/dev/console
ExecStart=/usr/bin/setterm -blank 1

[Install]
WantedBy=multi-user.target

After rebooting the server, enable the new service by running

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

After a restart the screen should go blank after a minute and power consumption should drop. Hit any key to wake the screen up again.

And we are done! You should now have your own home server which you can use to do a variety of things. Including hosting VMs, running scripts, hosting a media server, hosting a smart home solution etc etc. Good luck!

--

--