# Tutorial : Setup RancherOS - Baremetal - Hetzner

**URL:** <https://forums.suse.com/t/tutorial-setup-rancheros-baremetal-hetzner/14555>\
**Category:** RancherOS\
**Created:** [June 17, 2019, 2:39pm UTC](https://forums.suse.com/t/tutorial-setup-rancheros-baremetal-hetzner/14555 "2019-06-17T14:39:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zwordi](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/zwordi/32/4898_2.png) [@zwordi](https://forums.suse.com/u/zwordi)\
**Post date:** [June 17, 2019, 2:39pm UTC](https://forums.suse.com/t/tutorial-setup-rancheros-baremetal-hetzner/14555/1 "2019-06-17T14:39:57Z")

</div>

# Setup of an RancherOs Server using RancherOS iso on Hetzner dedicated server provider

* * *

## This document will not talk about setting an Rancher Platform or building cloud-config.yml file or joining a rancher-kubernetes cluster. You need to speak a bit of Linux tools to be able to handle this properly.

# Preparations

1. Order your server
2. Ask for a KVM connection with an usb-key with the latest version of RancherOS
3. Boot directly on the key using bios features
4. You are now on a running live-iso Rancher that you are gonna use to setup the server properly
5. Run the command `sudo passwd rancher` then enter a dumb password to be able to acces to your server through SSH with password authentication
6. Run the command `sudo ros console switch debian` to swith to a debian console with apt commands
7. Run again the ‘5’ command to be able to reconnect by SSH as the system console has been destroyed by the ‘6’
8. You are now connected with SSH on a debian-like console
9. Run the command `sudo apt-get update; sudo apt-get install mdadm -y` to have the minimum required tools available
10. You can run all the commands with sudo or directly as root (your choices)

* * *

# Disks - Raid - Filesystems - Label

Depending on the type of server that you are using but on this case we have 2\*1.8TB of disk and 2\*256GB of SSD.  
We are going to use 4 partitions on the 1.8TB disk for the system and local storage that we will use the ssd as another storage for high I/O operations.

## Partitions

My 1.8TB disk are available on the server as `/dev/sdc` and `/dev/sdd` wich mean that the SSD disks are available as `/dev/sda` and `/dev/sdb`.  
I’m creating the partition on the 1.8TB with the `fdisk` utility with a **dos** partition table not a **GPT**! (Important)  
Name of the partitions doesn’t really matters at this moment as it’s just a guide for the next steps.

| Device | Name | Size | Id | Type | Boot Flag |
| --- | --- | --- | --- | --- | --- |
| /dev/sdc1 | RANCHER\_BOOT | 500M | 83 | Linux | Yes |
| /dev/sdc2 | RANCHER\_SWAP | 2G | fd | Linux raid autodetect | No |
| /dev/sdc3 | RANCHER\_OEM | 5G | 83 | Linux | No |
| /dev/sdc4 | RANCHER\_STATE | 1.8T | 83 | Linux | No |

I’m duplicating theses partition table to the other disk of 1.8TB with the following commands :  
`sfdisk --dump /dev/sdc | sfdisk --no-reread /dev/sdd`

For the SSD disks i’m creating only one partition using the full disk capacity

| Device | Name | Size | Id | Type | Boot Flag |
| --- | --- | --- | --- | --- | --- |
| /dev/sda1 | RANCHER\_SSD | 238.5G | 83 | Linux | No |

I’m duplicating theses partition table to the other disk of 1.8TB with the following commands :

| `sfdisk --dump /dev/sda | sfdisk --no-reread /dev/sdb` |
| --- |

## Raid-Array

Now that ours disks are ready we can now build our Software Raid arrays:

```auto
mdadm --create /dev/md1 --level=1 --metadata=1.0 --raid-devices=2 /dev/sdc1 /dev/sdd1
mdadm --create /dev/md2 --level=1 --metadata=1.2 --raid-devices=2 /dev/sdc2 /dev/sdd2
mdadm --create /dev/md3 --level=1 --metadata=1.2 --raid-devices=2 /dev/sdc3 /dev/sdd3
mdadm --create /dev/md4 --level=1 --metadata=1.2 --raid-devices=2 /dev/sdc4 /dev/sdd4
mdadm --create /dev/md5 --level=1 --metadata=1.2 --raid-devices=2 /dev/sda1 /dev/sdb1

```

You can monitor the status of the raids by looking on this file :

`cat /proc/mdstat`

* * *

```auto
Personalities : [raid1] 
md5 : active raid1 sdb1[1] sda1[0]
      249926976 blocks super 1.2 [2/2] [UU]
      bitmap: 0/2 pages [0KB], 65536KB chunk

md124 : active raid1 sdc1[0] sdd1[1]
      511936 blocks super 1.0 [2/2] [UU]
      	resync=DELAYED
      
md125 : active raid1 sdc2[0] sdd2[1]
      2095104 blocks super 1.2 [2/2] [UU]
      
md126 : active raid1 sdc3[0] sdd3[1]
      5238784 blocks super 1.2 [2/2] [UU]
      
md127 : active raid1 sdc4[0] sdd4[1]
      1945530432 blocks super 1.2 [2/2] [UU]
      [===============>.....] resync = 76.1% (1481158464/1945530432) finish=77.5min speed=99784K/sec
      bitmap: 6/15 pages [24KB], 65536KB chunk

unused devices: <none>

```

The resync progress bar is about the state of sync between the 1.8TB disks, you can imagine that it’s not an easys steps for theses disks to be on sync. I recommand to wait the complete sync of the array before moving to production.

## Filesystems

Now that we have our disks (raid-array) ready we can go on creating filesystem

```auto
mkswap -L RANCHER_SWAP /dev/md2
mkfs.ext4 -L RANCHER_BOOT /dev/md1
mkfs.ext4 -L RANCHER_OEM /dev/md3
mkfs.ext4 -L RANCHER_STATE /dev/md4
mkfs.ext4 -L RANCHER_SSD /dev/md5

```

## Setup

At this point, you have your disks, raid array and filesystems correctly setup the only stuff to do now is to install RancherOS using your cloud-config.yml file:  
`ros install -t noformat -a rancher.state.mdadm_scan -d /dev/md4 -c cloud-config.yml`

The `-t` tell rancherOS to not format the partition as we have already done it.  
the `-a` tell rancherOS to add a kernel instructions on the bootloader to look after raid-array  
The `-d` tell rancherOS where to install the OS.  
the `-c` is the location of the cloud-config.yml file which could be locally on the server or using an URL.

Congrats, you should have a running RancherOS server available throught SSH worldwide (with the appropriate authentication setup). !!!

## Extra Steps - SSD Mountpoints

_Depends on your server hardware and options_

We didn’t use the RANCHER\_SSD raid array as this point as we are going to instruct RancherOS to mount it automaticly. At the time of his creation ( on the RancherOS iso) it was named `/dev/md5` but now on the living RancherOS his named `/dev/md124`.  
In order to do that prepare a file like this one ex: cloud-mount.yml

```auto
#cloud-config
mounts:
- ["/dev/md124", "/ssd-storage", "ext4", ""]

```

Then run the following command :  
`ros config merge -i cloud-cmd.yml`

This will add the mount instructions to the config of RancherOS and at the next reboot we should have the ssd-raid-array available at the /ssd-storage location which can be use as storage on the Kubernetes level.

The default location of the RancherOS configuration is :  
`/var/lib/rancher/conf/cloud-config.yml`

## Extra Steps- Optionnal - Swap activation

In order to have some swap available for the system you can use the following file (cloud-cmd.yml):

```auto
#cloud-config
runcmd:
- swapon -L RANCHER_SWAP

```

Then run the following command :  
`ros config merge -i cloud-cmd.yml`

This will add an extra instruction during the boot process to enable the swap using the partition labeled as **RANCHER\_SWAP**.

**Enabling swap on systems running docker can be problematic on some workflows.**

# Author Notes

I just did a big mashup of all the sources. Please free to add some comments in order to help other to achive theirs goals in using RancherOS. I’ve been using the Ubuntu as the base OS but i consider RancherOS to be a nice choices in order to reduce the load on maintaining an OS and an Rancher setup with all the things that could happens on boths areas.  
The main avantages for me is the low needs of ressources in order to be running and an easy command line and syntax.

# Bibliography-Sources

[RancherOS-Documentation - Custom Layout Partition](https://rancher.com/docs/os/v1.x/en/about/custom-partition-layout/)  
[RancherOS-Documentation - Configuration](https://rancher.com/docs/os/v1.x/en/installation/configuration/)  
[Medium Article - Rancher OS & Raid - Simon Thulbourn](https://medium.com/@sthulb/rancher-os-raid-fc1128385de6)  
[Gist from Kimmo Lankila (krisnod)](https://gist.github.com/krisnod/56ff894f400cce7c742fb11fb2fde9cf)  
[Software Raid](https://en.wikipedia.org/wiki/RAID#SOFTWARE)

---

<div class="post-metadata">

**Author:** ![1386studio](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/1386studio/32/5535_2.png) [@1386studio](https://forums.suse.com/u/1386studio)\
**Post date:** [August 28, 2019, 3:04am UTC](https://forums.suse.com/t/tutorial-setup-rancheros-baremetal-hetzner/14555/2 "2019-08-28T03:04:34Z")

</div>

I get the following error:

 ![Ubuntu-rsts-2019-08-28-11-02-31](https://us1.discourse-cdn.com/flex022/uploads/suse/original/2X/b/bac9723b83bbfafdbb9e5b6dde675130a80ce637.png)  
How can I solve this? Thanks!

---

<div class="post-metadata">

**Author:** ![zwordi](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/zwordi/32/4898_2.png) [@zwordi](https://forums.suse.com/u/zwordi)\
**Post date:** [August 28, 2019, 9:12am UTC](https://forums.suse.com/t/tutorial-setup-rancheros-baremetal-hetzner/14555/3 "2019-08-28T09:12:00Z")

</div>

Hello,

You have the root cause directly on your output.  
You didn’t provide the cloud-config.yml with the `-c` option on the `ros install` command.

Check again the links on the biblio about the Configuration of RancherOS.
