Macbook Pro Homelab

Macbook Pro Homelab

Computer Science
August 22, 2023
Ronny Coste
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.
notion image
After my visit to the apple store I learned a few things:
  1. They do not take the battery out even thought it could be dangerous.
  1. 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.
  1. 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.
  1. 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.
  1. 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.
notion image
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:
  1. Setup SSH.
  1. Setup VNC.
  1. Installed NEXTCLOUD .
  1. Installed UmbrelOS
  1. Setup the laptop to continue working with the lid close.

Why I setup these services and what do they do?

  1. SSH
    1. 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.
  1. VNC
    1. 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.
    1. 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:
      1. Open a terminal window.
      1. Insert this command sudo nano /etc/apache2/ports.conf
      1. Once the file open look for the line that says Listen 80
      1. Change the 80 to 8080. That would look like this Listen 8080
      1. Save by pressing Control + O
      1. Then quit by pressing Control + X
      1. After that open this other file # nano /etc/apache2/sites-enabled/000-default.conf
      1. Change the line that says <Virtualhost *80> change it to <Virtualhost *8080>
      1. Save by pressing Control + O
      1. Then quit by pressing Control + X
      1. Restart Apache using this command, NEXTCLOUD is based on Apache systemctl restart apache2
      1. now check if it works by going to http://localhost.local:8080 or http://server.ip:8080
      Adding external drives to nextcloud:
      1. Open terminal window
      1. Create a mounting folder that is easy to remember with the following command mkdir /mnt/disk2
      1. check for your drives with the command lsblk
      1. Identify your drives. This needs to be done by storage side, and usually external drives are identified with sda, sdb, sdc, etc.
      1. Format the drive.
        1. sudo fdisk /dev/sdb With this command you enter in fdisk mode | manager.
        2. d D is for deleting the partition.
        3. n N is for creating a new partition.
        4. w W is to save all the changes.
        5. mkfs -t ext4 /dev/sdb1 This command will turn the drives file system into ext4 which plays nicely with linux in comparison with others.
      1. Mount the drive to the mounting folder that we created earlier using the command sudo mount /dev/sda1 /mnt/disk2
      1. On nextcloud enable the add-on to use external storage support. It will add for your nextcloud admin password.
      1. Go to the tab for external storage support and add your new drive. as shown below
        1. notion image
      1. Now it should be working but because you do not have permission to the folder yet.
      1. To give permission to download and upload to this external drives we use these two commands.
        1. sudo chown -R www-data:www-data /mnt/disk2
        2. sudo chmod -R 0750 /mnt/disk2
        3. 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
  1. UmbrelOS
    1. 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.
      notion image
  1. Continue Working with closed lid
    1. 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:
How to install external drives to Nextcloud:
Installing Linux as dual book on Macbooks:
Cristophe article about running the Macbook without a battery and the throttles workaround:
X-Code releases in case you have a Macbook that does not support the latest and greatest:
Program to tell the CPU that the temps are normal:
sysclUpdated Feb 23, 2024