Low-cost Raspberry Pi Home Server] Preliminary: Install Ubuntu Server 1 on Raspberry pi 4

[Low-cost Raspberry Pi Home Server] Prerequisite: Install Ubuntu Server on Raspberry pi 4

What is Raspberry Pi

Raspberry Pi can be used to build a home server that is very small, power efficient, and inexpensive. For those who don't know what a Raspberry Pi is, a Raspberry Pi is a small computer on a credit card sized board. This small computer costs about $70. At the time of writing, the latest version is Raspberry Pi 4, and you can choose memory configuration. Check on the links below to see what it looks like:

If it's your first time working with a Raspberry Pi, it's recommended to purchase a starter kit. If you decide to buy just the main unit, please remember to also prepare an SD card, a power cable, and a micro HDMI monitor cable.

As for memory choice, I've been using an 8GB Raspberry Pi for my personal server at home for several years now, starting with the first generation. The last upgrade was from a Raspberry Pi 2 2GB, which served me well for a few years until it couldn't handle the load anymore due to adding new websites. It started crashing every other day. So, I made the decision to upgrade to a Raspberry Pi 4 8GB version. If you're looking to save a bit more money, the 4GB variant should be sufficient for most people's needs.

Why install Ubuntu?

Newcomers to Raspberry Pi typically uses the pre-installed Raspbian OS that comes with starter kits. In most cases, Raspbian works well and can be used to set up simple servers. However, based on my experience over the years, Raspbian sometimes lags behind in terms of Linux software support. If you plan to use Raspberry Pi primarily as a server, Ubuntu Server is a more stable option with easier to find resources. In recent years, Ubuntu also has provided official support for Raspberry Pi systems. For this series where I intend to focus on server configuration, I won't be using Raspbian OS and recommend using Ubuntu Server instead.

How to install Ubuntu

Because most off-the-shelf Raspberry Pi kits come with the Raspbian operating system pre-installed, if you want to use Ubuntu, you'll need to use the Raspberry Pi Imager to write the system onto an SD card. This step must be completed on another computer, which can be either a Windows or Mac system you typically use. You'll also need an SD card reader to do this.

After opening the downloaded Raspberry Pi Imager, the screen looks like this:

After selecting the SD card in the middle, when you click on "Choose OS" on the left, you will see a menu of available operating systems. Versions may vary over time, but you should be able to find Ubuntu. It is recommended to select the LTS, 64-bit, Server version, such as the second option in the image below.

(Note: Ubuntu Server does not come with a graphical user interface, so even if you connect a monitor, it will display a command-line interface with a black background and white text. If you are not familiar with this type of interface, you can choose the regular version of Ubuntu for now. Once you are confident that all your requirements can be met through the command line, you can switch to the Server version. The 64-bit architecture is important, especially if you plan to connect external hard drives larger than 2TB.)

Select your operating system and press Write, then go get a cup of coffee and wait for Ubuntu to load.

Ubuntu - Initial Setup

Once the software is installed, you can insert the SD card into the Raspberry Pi and power it on. For the first boot, you will definitely need a monitor, so connect the prepared monitor cable to the screen. (After completing the initial setup, you can actually do without it.)

The first thing you need to know when the Raspberry Pi boots up is how to log in. If you have installed Ubuntu Server, the default username and password are ubuntu/ubuntu. Once you have logged in, the first thing you should do is change the password. You can do this by entering the following command in the command line:

$ passwd

Next, you can follow the on-screen instructions to change the password. I won't go into detail here.

In order to avoid the need for a physical monitor in the future (buying a new monitor would defeat the purpose of low-cost computing), it's essential to set up remote access. The goal for today is to configure SSH (Secure Shell), which will allow us to log into the system remotely.

Since we're setting up a home server for use, I'll assume that you have connected an Ethernet cable and have the capability to configure a static internal IP address (typically within the 192.168.x.x range) for your wired network interface based on its MAC address. The method for setting this up can vary depending on your router, so please consult your router's instructions. Here's an example from Netgear的說明 for reference.

With a static IP address, we can connect to this IP address from within the local network for remote access. If you want to set up a wireless network, you can refer to this article. However, remember to configure a static IP address for your wireless network interface based on its MAC address as well.

The MAC address and whether the network is successfully configured can be confirmed by this command:

$ ifconfig

If you are using a wired network connection, you can check the IP address and MAC address information for the "eth0" interface. Before setting a static IP, it will typically show an automatically assigned IP address. After setting a static IP and rebooting, running the same command should display the configured IP address.

For wireless network connections, you would typically look at the "wlan" interface in a similar manner to check the IP address and MAC address information.

Next we'll set up ssh. First we'll install the necessary software.

$ sudo apt update
$ sudo apt install openssh-server

In addition to the ssh server, don't forget to install and configure a firewall.

$ sudo apt install ufw
$ sudo ufw allow ssh

In theory, you should have completed the setup by now. You can verify if the SSH service is running by using the following command:

$ sudo systemctl status ssh

If successful, you will see the active (running) status.

If it's not active, turn it on manually.

$ sudo systemctl start ssh

With this setup, we should now be able to use ssh to connect from other computers.

$ ssh ubuntu@[Raspberry Pi's IP address]


Leave a ReplyCancel reply