How to install/reinstall Linux on a VPS manually

3 minute read

In this tutorial, I’ll show you how to reinstall or install another version or a completely different Linux OS for your VPS manually.

This tutorial will come in handy if you want to install/upgrade to an unsupported Linux version from your hosting provider or wanted a customized partition scheme on your server.

Requirements:

  • Networking access
  • VNC/KVM/IPMI access of the target machine which will handle the installation, UART/SERIAL access only might work with extra configuration
  • The targeted installation machine must either be VPS using full virtualization (KVM/QEMU/VMware/VBOX) or is a dedicated server running on barebone hardware, OpenVZ or any kind of kernel virtualization or containers are not supported.
  • You’re not afraid of command line
  • root access of the Linux server

Note:

  • This tutorial might not always be working if the virtualization/hardware of the targeted machine is using some weird driver/non-standard hardware configuration.
  • Some VPS providers set Static IP for their clients, make sure you’ve written down the current IP configuration on the current pre-installed OS for later on, just in case!

1. Getting the machine to boot the netboot version of the OS you wanted to install

Here you can see my pre-installed OS is Ubuntu 16.04 LTS, now I’ll try to get the beta version of Ubuntu which is 19.04 install on the same machine.

_config.yml

First, you need to change the GRUB configuration so it will allow you to see the boot menu by editing the /etc/default/grub and comment out (or delete) the line GRUB_TIMEOUT_STYLE=hidden.

_config.yml

Then execute the command update-grub2 for generating the new boot config file.

Then you check for the location of the first partition of your boot drive, here my VPS vda1 are mounted as /, I’m going to download the netboot version of Ubuntu which is just the 2 fileslinux (kernel) and initrd.gz (ramdisk) to /

Those two files are located HERE

_config.yml

Now you open the VNC/KVM/IPMI of the VPS and then reboot it, it will look something like this

_config.yml

This depends on your GRUB version, it might take you to the GRUB menu and start counting or it will be counting without showing the GRUB menu like what mine did, you could even holding [SHIFT] when the machine is booting for accessing the GRUB menu.

_config.yml

You have to quickly press [ESC] for it to stop the automated boot and then press [c] for accessing the GRUB command-line

_config.yml

Now you get to the command-line part, type it as above, you could remove the priority=low for setup without Advanced mode, for me I like the Advanced mode so I put the priority=low in there, the Advanced mode will allow you to do much more customization for your installation like custom kernel selection, doesn’t force you to create standard user account…


2. Install the OS using netboot installer

_config.yml

Now when you get to this part then it’s pretty easy down the line, just do what it asks you to do, starting off by Choose language then it will take you to the next necessary step when you’ve finished it, don’t select the random step here if you don’t know what you are doing.

_config.yml

As I’ve said before, you could even do manual partitioning on the current disk of the server without any limitation, the setup is currently on RAM so it doesn’t care if the disk contents get nuked or anything !! Your old data will get nuked if you decide to format/erase the partitions !!

_config.yml

If you decided to go with the Advanced mode as I do, you will get to this part which allows you to chose the appropriate kernel for your machine, usually select linux-generic is fine but since this is a VPS and there won’t be any new device get connected to it, I choose the linux-virtual for lightweight.

_config.yml

Also, this part if you’re using a VPS then I’d recommend to chose targeted because it will make your boot process faster since the initrd will be smaller.

_config.yml

You could even install a desktop environment or some recommended software suits your needs… But you can always install those later and I’m not the person who wants a desktop environment on their server so… I’ll pass

After some waiting, the setup will say it’s finished, just do what it wanted you to do.

_config.yml

And setup finished, my VPS is running Ubuntu 19.04, now you have to install ssh server to remote it later on.


Here’s some common OS’s netboot:

Ubuntu: 19.04 18.10 18.04

Debian: 9.0 8.0

CentOS: 7.0

Fedora: 29

Updated:

Leave a comment