Hello from Ataf ๐Ÿ–
July 14, 2024

Everything About Turning a Laptop Into a Server

Posted on July 14, 2024  •  6 minutes  • 1176 words
Table of contents

Lately, I’ve been wanting to turn my old laptop, an Asus Vivobook to a personal home server. It’s been more than two year since I had used it seriously. After that, it was just used as a sandbox, or occassionally a device for distro-hopping. After working with virtual machines, SSH, and linux for almost a year, I finally decided it was time to put that old junk into a good use. As of writing this article, it’s been almost 3 weeks since I had transformed my laptop into a home server. I hope this guide will help anyone to turn their old laptop for such usage.

Part 1: The Hardware

The most important thing about a server is it’s hardware. If it’s not much durable, and doesn’t have the minimum power required, it could fail the entire purpose. My laptop had an Intel i3 7th Gen process upto 3.4 GHz with 4 core. As of RAM, it only had 4GB DDR4 memory. I decided as a minimal server, it would do just fine. Also, bandwidth was an important issue for me. For laptop, we generally use WiFi which doesn’t give an edge when it comes to network bandwidth. I decided that an ethernet cable should be the only way to connect my laptop to the internet, and I did. I had an old CAT3 ethernet cable, which I put to that use. As of battery, I had changed my battery once which would give around 1-1.5 hr of backup power. Since it was going to be a server, sitting idly and always being connected with a changer, I thought the battery backup would be enough during a power outage. For storage, the laptop had 1TB HDD that was just the perfect amount for my use case.

Part 2: The OS

The second most important thing regarding a laptop is the operating system. I had done a complete format of my hard disk, reset the bios, and was ready for installing a lightweight distro. I wanted to use a lightweight Linux based OS- and after trying BookwormPup and having prior experience of using Pop, Ubuntu, RHEL8, CentOS, I finally jumped to the most OG distro of all time- Debian. Why Debian? Mostly because I was depending on apt and systemd too much. And also because my other machines had either Pop or Ubuntu running. Since I don’t my server to be bloated with too much of snap, flatpak, and UI bloatware, I found Debian to be the perfect choice. I downloaded the Debian 12 XFCE ISO image, burned it to a USB, and booted my laptop. I found XFCE to be minimal and clean- though the phase didn’t last longer. There was very little system utilities present, so I started using Gnome as my desktop environment.

Part 3: The Softwares

After installing a fresh copy of the OS, I removed everything that was unnecessary- games, tools, calendar, etc. Also, I removed all other users except root. There was no reason for me not to use root, since I wanted escalated priviledge always. I installed several programs such as:

They can be easily installed by running the command:

apt install openssh-server openssh-client
apt install vsftpd
apt install net-tools
apt install transmission-cli
apt install screen tmux git rsync neofetch htop wget

Emby

Installing Emby was a bit complex. I had to go to their downloads page to download and install the .DEB file manually. After installing, I had nothing to do- Emby set itself up perfectly, even added itself to systemd to start the server when system boots up. All I had to do was to visit http://localhost:8096/ to set up the admin console.

Transmission CLI

I wanted a torrent client that was minimal and yet accessible through the terminal or some other interface. I primarily started using rtorrent, but the complex configuration and less user-friendliness made me look for alternatives. I believe it was my friend Asif Ajrof who told me about Transmission, a torrent client that had in-built web interface. I listened to him, tried Transmission, and right now, I’m seeding my torrents through it.

Part 4: Configuration

SSH

I added my SSH public key to the server’s ~/.ssh/authorized_keys file. And added both id_ed25519 and id_ed25519.pub file to the ~/.ssh directory- in case I have to access my GitHub or cloud machines. Also, I made the local IP address of my server static on the router- so that it can be hardcoded into my personal computer.

Also, because I intended to access my server as root, obviously OpenSSH wasn’t gonna let me do it. So I had to edit the config file /etc/ssh/sshd_config and add the things below:

PubkeyAuthentication yes
...
# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication yes
PermitRootLogin yes
...

FTP

Same goes for FTP. FTP wouldn’t allow you to access the file system as root. For root access, I had to open the /etc/ftpusers file and comment out the line that had “root” written on it.

# /etc/ftpusers: list of users disallowed FTP access. See ftpusers(5).
# root
daemon
bin
...

Systemd & Power Management

I wanted to run my server 24/7, and of course the power manager of the DE wasn’t gonna let me do that. For that, I had to go to my server and configure the power management utility manually. I set it up so that it never sleeps or suspends itself while being idle.

Then, to be 100% sure, I had to configure the systemd also. I created a file called /etc/systemd/sleep.conf.d/nosuspend.conf and put the following contents into it. (I copied it from a Debian forum).

[Sleep]
AllowSuspend=no
AllowHibernation=no
AllowSuspendThenHibernate=no
AllowHybridSleep=no

Backup & Restore

I also use my old laptop- which I’ve been referring as server, for backup purposes. For that, I use WinSCP for transferring file between my PC to server. WinSCP has compatibility for FTP, SFTP, SCP, WebDAV protocol. I wanted to use FileZilla as a solution, but to be honest- that piece of software has become garbage now- and I can’t even use it now as I used to before. Anyway, I’m glad that I found WinSCP for Windows.

Conclusion

As of now, I have been running my laptop-as-a-server machine for more than three weeks and found no issue. There was no file corruption or network issue. This is what my htop looks like when it’s sitting idly (seeding torrents, running daemons).

And this is what it looks like when I’m streaming movie or TV shows from it.

Although, it might look like a good idea to run scrapers, or web fuzzers from a home server- it isn’t. The network latency will do more harm that good. It would suck all of the bandwidth from your router, and will make your LAN very slow. I hope this article comes in your help- if you ever want to use your old laptop as a server.

Till then, happy hacking!