In this article, we will focus on installing CentOS 7 on Hetzner Root Servers. Hetzner is a cloud hosting company providing auctions for physical server hardware for very competitive prices with a per/month billing model.

We will be doing this installation on a Hetzner root server with the following specs.

CPU: Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz (12 cores)
Memory: 64GB RAM
Disk: 2 x 1024GB NVMe SSDs
Network: 1Gbit
IPV4 Adresses: 1 x IPV4 public address

Note that with Hetzner Root servers, you get a single IPv4 public IP address but you can request for additional IP or subnet for use.

Step 1: Boot to Rescue Mode

Login to your Hetzner console for Root servers and navigate to Servers section under Main functions.

Main functions > Servers > Server Label > Rescue

Select the Operating system to use in rescue mode, CPU Architecture, and public key and click on “Activate rescue system“.

Reboot the server under “Reset” server section.

Step 2: Create Root Server Configuration.

SSH to the server in rescue mode using root user and password shown during Rescue activation.

$ ssh [email protected]

 Welcome to the Hetzner Rescue System.
 This Rescue System is based on Debian 9 (stretch) with a newer
   kernel. You can install software as in a normal system.
 To install a new operating system from one of our prebuilt
   images, run 'installimage' and follow the instructions.
 More information at http://wiki.hetzner.de
 
 Rescue System up since 2019-07-04 23:34 +02:00
 Last login: Sat Jul  6 09:03:05 2019 from 41.90.217.125
 Hardware data:
 CPU1: Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz (Cores 12)
    Memory:  64339 MB
    Disk /dev/nvme0n1: 1024 GB (=> 953 GiB) 
    Disk /dev/nvme1n1: 1024 GB (=> 953 GiB) 
    Total capacity 1907 GiB with 2 Disks
 Network data:
    eth0  LINK: yes
          MAC:  b4:2e:99:47:fa:5c
          IP:   xxxxxxxxxxxxxxxxxx
          IPv6: xxxxxxxxxxxxxxxxxx
          Intel(R) PRO/1000 Network Driver
 [email protected] ~ # 

My root server has two disks @512GB. I’ll configure them in non-redundant RAID 1 (stripping) configuration. Let’s create a Hetzner server configuration to be used by installimage for a new operating system from one of our prebuilt images.

$ vim  install-config.txt
DRIVE1 /dev/nvme0n1
DRIVE2 /dev/nvme1n1
SWRAID 1
SWRAIDLEVEL 0
BOOTLOADER grub
HOSTNAME myrootserver.computingforgeeks.com
PART /boot ext3 512M
PART lvm vg0 200G
#PART lvm vg0 all

LV vg0 root / xfs 50G
LV vg0 swap swap swap 16G
LV vg0 var /var  xfs  100G
LV vg0 tmp /tmp  xfs  30G

IMAGE /root/.oldroot/nfs/install/../images/CentOS-76-64-minimal.tar.gz

Once the configuration is done, install image and create partitions.

# installimage -a -c install-config.txt

The installation should start.

Installation process.

Hetzner Online GmbH - installimage

  Your server will be installed now, this will take some minutes
             You can abort at any time with CTRL+C ...

         :  Reading configuration                           done 
         :  Loading image file variables                    done 
         :  Loading centos specific functions               done 
   1/17  :  Deleting partitions                             done 
   2/17  :  Test partition size                             done 
   3/17  :  Creating partitions and /etc/fstab              done 
   4/17  :  Creating software RAID level 0                  done 
   5/17  :  Creating LVM volumes                            done 
   6/17  :  Formatting partitions
         :    formatting /dev/md/0 with ext3                done 
         :    formatting /dev/vg0/root with xfs             done 
         :    formatting /dev/vg0/swap with swap            done 
         :    formatting /dev/vg0/var with xfs              done 
         :    formatting /dev/vg0/tmp with xfs              done 
   7/17  :  Mounting partitions                             done 
   8/17  :  Sync time via ntp                               done 
         :  Importing public key for image validation       done 
   9/17  :  Validating image before starting extraction     done 
  10/17  :  Extracting image (local)                        done 
  11/17  :  Setting up network config                       done 
  12/17  :  Executing additional commands
         :    Setting hostname                              done 
         :    Generating new SSH keys                       done 
         :    Generating mdadm config                       done 
         :    Generating ramdisk                            done 
         :    Generating ntp config                         done 
  13/17  :  Setting up miscellaneous files                  done 
  14/17  :  Configuring authentication
         :    Fetching SSH keys                             done 
         :    Disabling root password                       done 
         :    Disabling SSH root login without password     done 
         :    Copying SSH keys                              done 
  15/17  :  Installing bootloader grub                      done 
  16/17  :  Running some centos specific functions          done 
  17/17  :  Clearing log files                              done 

                  INSTALLATION COMPLETE
   You can now reboot and log in to your new system with
  the same password as you logged in to the rescue system.

Once the installation is complete, reboot the server.

# shutdown -r now

Login and confirm server installation.

[[email protected] ~]# cat /etc/os-release 
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

Update CentOS and install basic packages.

sudo yum -y update
sudo yum -y install vim wget curl bash-completion epel-release telnet

You now have a successful installation of CentOS 7 on Hetzner root server. Stay connected for more articles.

Deploy VM Instances on Hetzner Cloud with Terraform

How to Provision VMs on KVM with Terraform