Comprehensive manual on installing Ubuntu on VPS

Comprehensive manual on installing Ubuntu on VPS

12:41, 17.12.2021

Contenido del artículo
arrow

  • Automatic Ubuntu installation
  • Manual installation of Ubuntu with installimage
  • Manually installing Ubuntu from an ISO image 
  • Initial system setup

In this article, we will describe in detail how to install Ubuntu on a server. We will use Ubuntu 20.04 LTS distribution as an example, as it is one of the most popular and stable. Minimum hardware requirements for this OS version are as follows:

  • 2-core processor with a frequency of 1.5-2 GHz;
  • 4 GB of RAM;
  • 25 GB of storage space.

Even the most inexpensive VPS allow full deployment of the Ubuntu 20.04 LTS operating system because this build is characterized by minimal system requirements. So, first, let's consider a full Ubuntu installation with minimal user input.

Automatic Ubuntu installation

When you rent a VPS from HostZealot, you can pre-select the appropriate server OS and control panel. If you need to do it yourself, we will tell you how.

The easiest and most convenient way is to install Ubuntu automatically using preseed. This method is universal and ideal when the administrator needs to install the same distribution on multiple server machines. Preseeding is a variant of automated installation of Ubuntu, Debian and similar operating systems.

First, you need to download the system image from the official site, then go to the directory and create a script that will automatically mount and unpack the file. Let's start by installing rsync by entering a command in the console:

apt install rsync

Initialise isoextract.sh.

#!/bin/bash
 
# The name of the directory to decompress
BUILDDIR=iso
# Image name
IMAGE=lubuntu-18.04.4-desktop-amd64.iso
 
# Extract the image to the directory
rm -rf $BUILDDIR/
mkdir $BUILDDIR
echo "----- Mounting image -----"
sudo mount -o loop $IMAGE /mnt/iso
echo "----- Syncing -----"
rsync -av /mnt/iso/ $BUILDDIR
chmod -R u+w $BUILDDIR
sudo umount /mnt/iso

echo "----- Complete -----"

Now we have to make it executable:

chmod +x isoextract.sh

And launch it:

./isoextract.sh

In fact, we can do without scripts if we write all the commands manually, but this is less convenient, more energy-consuming, and not as elegant.

The beauty of using preseed is that we specify in advance the answers to all the questions that the system will give us during the installation. This saves us from having to respond manually every time - again, handy if we have a large number of servers. Preseed instructions usually include 4 parts:

  1. Owner.
  2. Parameter name.
  3. Type of parameter.
  4. Value.

Between all these parts we write one space - this is important. The installer is called d-i, and this very value will be in the first field in most instructions. We can create such instruction in three ways:

  1. By using the kernel startup parameters.
  2. By specifying an instruction file downloaded from the net.
  3. Using a local file.

The first method is the best since instructions sent over the kernel parameters will be added to the database immediately before the installer starts. So, we need to slightly tweak the isolinux/text.cfg file by putting in the OEM Install item these options:

default oem
label oem
  menu label ^OEM install
  kernel /install/vmlinuz
  append  file=/cdrom/preseed/oem.seed debian-installer/locale=ru_RU.UTF-8 console-setup/layoutcode=ru localechooser/translation/warn-light=true localechooser/translation/warn-severe=true console-setup/toggle=Alt+Shift initrd=/install/initrd.gz quiet –

You can change these parameters as needed. After that, all you have to do is create a master file with instructions for preseed, which will be named preseed/oem.seed.

Manual installation of Ubuntu with installimage

First of all, you will need to prepare the VPS by reinstalling it without a template. This means that the server should be clean - no operating system or additional software should be present. Then follow the instructions:

  1. Go to the VPS settings and select the Virtio controller type for SSD/HDD disks, and the VirtIO NIC.
  2. Boot the server into the Linux Rescue LiveCD, having previously enabled VNC access via the dedicated server control panel.
  3. Launch the VNC console, and reboot the VDS with a keyboard shortcut or any other method. When rebooting hold F12 to get to the boot menu.
  4. Here we choose iPXE from the list and a window pops up where we enter r and hit Enter.

At this point, Linux Rescue will start and you will be asked for the VNC username and password.

After all these steps, you can install Ubuntu on your VDS: run the installimage command and select the appropriate version of the operating system and its bit mode in the window that will pop up. Then you can change the server configuration at your own discretion, but you can do with the standard parameters. Confirm and continue with the installation, and when the process is complete, you only need to restart the server.

comprehensive manual on installing ubuntu on vps

Manually installing Ubuntu from an ISO image 

This method is suitable when many settings need to be fine-tuned and configured during the installation. The first thing you should do is create an installation media - for this we need any flash drive with a capacity of 2 GB or more. Connect it to your PC, then go to the official website and download the Ubuntu 20.04.3 LTS (Focal Fossa) image.

Then it is necessary to prepare a bootable flash. There are many different ways to do this, but we will use the balenaEtcher cross-platform program, as it is free, easy, and convenient. It allows you to work with Windows, Linux and macOS.

In this program, all you have to do is select the pre-loaded Ubuntu image, then specify the drive to create the installation media, and click on "Flash". After 1-2 minutes, you'll get a flash drive completely ready to install. Booting from it, you can select "Install Ubuntu Server", determine your preferred language, layout, set up network connections, Proxy, etc. In general, everything is quite typical and standard.

Initial system setup

Immediately after installation, you need to connect to the server via SSH, run the console and check for updates to the OS using three commands:

sudo apt update
sudo apt list --upgradable
sudo apt upgrade

After the server has downloaded and installed the necessary updates, Ubuntu must be restarted:

sudo reboot

Now let's proceed with the configuration. Open the console and check the current time:

date

Look at the list of available time zones:

timedatectl list-timezones

Select the appropriate time zone with the command. For example: 

sudo timedatectl set-timezone america/new_york

This will set the time in New York. 

Our next step is to prevent unauthorized access to the system. To do this we need to change the standard SSH port to some other, five-digit port. Open sudo vi /etc/ssh/sshd_config file and have a look. The default port is 22, change it to 53783 or any other suitable port.

Next, configure the network filter to minimize the chance of hacking. Enter the command:

sudo ufw allow OpenSSH

If you have already changed the port before, enter it:

sudo ufw allow 53783/tcp

Next, activate Netfilter firewall with the command:

sudo ufw enable

Confirm the operation with the letter Y and press Enter. Now the firewall will automatically run on the server and will protect it from intrusions. Also, we recommend reading our article about how to ensure the safety of renting a VPS server. We explain there in more detail all the nuances and settings to increase the protection of your VPS server running Ubuntu. Well, if you do not want to waste time on the installation and configuration, you can order a server with automatic installation of the operating system and control panel. The company HostZealot offers such a service. Contact the specialists for more detailed advice.

views 6m, 18s
views 2
Compartir

¿Te ha resultado útil este artículo?

Ofertas populares de VPS

Otros artículos sobre este tema

Remote monitoring of VPS
Remote monitoring of VPS
cookie

¿Acepta las cookies y la política de privacidad?

Utilizamos cookies para asegurar que damos la mejor experiencia en nuestro sitio web. Si continúa sin cambiar la configuración, asumiremos que acepta recibir todas las cookies del sitio web HostZealot.