I have been very interested in re-using, and re-purposing as many of my electronics and possessions as much as I can so with my old laptop I decided to do just that. Turn the laptop into a server. This post will walk through my experience of setting up my homelab on my 2015 13” Macbook Pro, with some sprinkles of my experience dealing with retail store apple employees.
Laptop Specs:
- Intel Core i7 Gen Fourth
- 16Gb of Ram
- 512GB SSD; Upgradable to up to 2TB.
- Retina Display
Services Running on the laptop:
First steps in the process
Fix and clean the laptop. This past week I have been tinkering and problem solving some issues on my old Macbook pro 13” from 2015. It is a great laptop with great specs but the battery decided to expand so I took it to the apple store to get them to recycle the battery because they say they do so on their website.
After my visit to the apple store I learned a few things:
- They do not take the battery out even thought it could be dangerous.
- To recycle the battery you would either have to pay for a repair, at the time that visited the store 08/2023 it was 250 dollars because they swap the entire assembly, or you can donate / recycle the entire laptop.
- They are not knowledgable about electronics at all. Two genius bar “Experts” Connected the laptop to see if it works after I told them that it’s not a good idea, and a sales person from the store wanted to get wire cutters to cut the battery connections without checking the circuit of the battery.
- Genius bar “Experts” do not like the idea of people like me repairing their own equipment because it is dangerous yet they do things are I would consider dangerous and would not do when I repair my electronics.
- My genius bar “Expert” loved that I was really handy and was more into repairing things myself but not so enthusiastic if it was an un-authorize repair shop. Which technically I would fall under.
After I disconnected, deep clean the laptop, and took the battery to recycle / dispose at the apple store. I notice that the performance of the laptop was not the same… This is because apple throttles the CPU if no Battery is detected. The reasoning behind this is that the battery has a temperature sensor that if disconnected the CPU won’t know the temp of the battery thus it assumes it is overheating, and throttles. This issue cost half the performance of my CPU so I had to do something about that.
How to solve the throttling issue?
I personally just installed linux and that solved all my throttling issues but if you must have MacOS Cristophe found a way to do so and explained it in this post.
Note: Using the laptop without a battery and just installing linux is the best course of action as you, in this case me, will be leaving the laptop connected to an outlet indefinitely, so a battery is unnecessary.
Setting up services
After solving the throttling issues I started tackling different Quality of Life / Services aspects of this server, ie:
- Setup SSH.
- Setup VNC.
- Installed NEXTCLOUD .
- Installed UmbrelOS
- Setup the laptop to continue working with the lid close.
Why I setup these services and what do they do?
- SSH
SSH allows for a secure remote access to the computer / server as long as you are in the same network to it using the Command Line.
- VNC
VNC allows for remote access to the desktop GUI, so I will have access to my server apps, and GUI from a remote computer (iPad). Usually VNC or RDP is what it is use in softwares like Team-viewer or Any-desk. Ubuntu 22.04 has VNC setup guide built into the settings of ubuntu.
- NEXTCLOUD
- Open a terminal window.
- Insert this command
sudo nano /etc/apache2/ports.conf
- Once the file open look for the line that says
Listen 80
- Change the 80 to 8080. That would look like this
Listen 8080
- Save by pressing
Control + O
- Then quit by pressing
Control + X
- After that open this other file
# nano /etc/apache2/sites-enabled/000-default.conf
- Change the line that says
<Virtualhost *80>
change it to<Virtualhost *8080>
- Save by pressing
Control + O
- Then quit by pressing
Control + X
- Restart Apache using this command, NEXTCLOUD is based on Apache
systemctl restart apache2
- now check if it works by going to http://localhost.local:8080 or http://server.ip:8080
- Open terminal window
- Create a mounting folder that is easy to remember with the following command
mkdir /mnt/disk2
- check for your drives with the command
lsblk
- Identify your drives. This needs to be done by storage side, and usually external drives are identified with sda, sdb, sdc, etc.
- Format the drive.
sudo fdisk /dev/sdb
With this command you enter in fdisk mode | manager.d
D is for deleting the partition.n
N is for creating a new partition.w
W is to save all the changes.mkfs -t ext4 /dev/sdb1
This command will turn the drives file system into ext4 which plays nicely with linux in comparison with others.- Mount the drive to the mounting folder that we created earlier using the command
sudo mount /dev/sda1 /mnt/disk2
- On nextcloud enable the add-on to use external storage support. It will add for your nextcloud admin password.
- Go to the tab for external storage support and add your new drive. as shown below
- Now it should be working but because you do not have permission to the folder yet.
- To give permission to download and upload to this external drives we use these two commands.
sudo chown -R www-data:www-data /mnt/disk2
sudo chmod -R 0750 /mnt/disk2
NEXTCLOUD is a self-hosted cloud service. So Imagine Google Cloud or Icloud but you own it and host all the files.
The benefits of something like this is that you do not have to pay for more storage or more bandwidth and it could be more secure too because hackers might not have the incentive to hack your instance. The downside is that if you do not setup a public IP or domain for your server you might not have access to all your files, and security is as strong as you set it up.
To setup NEXTCLOUD I followed this youtube video.
Note: If you install NEXTCLOUD, and Umbrel on the same machine both services run on the same set of ports, ie: port 8081. So to solve that I reassigned the port for NEXTCLOUD to port 8080.
Changing ports on next cloud:
Adding external drives to nextcloud:
Now uploading, downloading, and everything in between should work flawlessly.
Whenever the drives are disconnected you will have to run the following command to make sure that the drives mounts to the right directory.
sudo mount /dev/sda1 /mnt/disk2
- UmbrelOS
UmbrelOS is some sort of self-hosted operating system. It was designed at first for the raspberry pi but now it works with anything that runs linux.
Umbrel is an easy way to get into self-hosting as it has a lot of applications that you might be interested in, in an easy to install package. It even has nextcloud in it!
At first I setup NEXTCLOUD on Umbrel but It has some shortcoming like setting up external drives for NEXTCLOUD it is quite annoying and time-consuming so unless you are happy with your internal storage of the host machine then I recommend just setting up NEXTCLOUD on it own.
Coming back to Umbrel here I have running a Llama.cpp instance, VPN, Pi-Hole, ChatGPT, among other things.
- Continue Working with closed lid
This is self-Explanatory. When I close the laptop the laptop does not go to sleep or shutdowns, or stops the services.
How to do this?
1. Open the terminal in Ubuntu 20.04 LTS
2. enter this command
sudo gedit /etc/systemd/logind.conf
3. Enter your password.
4. Logind.conf will open, on that file look for the line #HandleLidSwitch=suspend
5. Replace the line with the following: HandleLidSwitch=ignore
if you want to make sure your laptop keeps running after you close the lid. Don’t forget to remove the # symbol in the actions that you changed.
6. save
7. Restart using this command sudo systemctl restart systemd-logind
8. Now it should work.After about a two days of fixing, cleaning, talking to apple reps, and setting up the services I have an awesome machine that can run pretty much anything that I throw at it at a decent speed. It is quiet, it stays cool, and it is now my main server replacing my old raspberry pi 4 with 4GB of Ram.
Useful resources
First article that brought to my attention Cristophe solution:
https://hackaday.com/2023/02/17/hack-lets-intel-macbook-run-without-a-battery/
UmbrelOS:
https://community.umbrel.com
NEXTCLOUD:
https://help.nextcloud.com
How to install external drives to Nextcloud:
https://www.youtube.com/watch?v=D8eDnlGDUk4
Disable system Integrity Macbook’s:
https://www.r-studio.com/data_recovery_macintosh/System_Integrity_Protection.shtml
Installing Linux as dual book on Macbooks:
https://www.makeuseof.com/tag/install-linux-macbook-pro/
Using a Macbook with the lid closed on MacOS:
https://apple.stackexchange.com/questions/415539/can-i-use-a-macbook-as-a-server-with-the-lid-closed
Cristophe article about running the Macbook without a battery and the throttles workaround:
https://portugnole.blogspot.com/2020/05/running-macbook-without-battery-lets-go.html
X-Code releases in case you have a Macbook that does not support the latest and greatest:
https://xcodereleases.com/
Program to tell the CPU that the temps are normal:
CPUTune
syscl • Updated Aug 6, 2024