Hetzner storage box provides various access protocols such as SCP, FTP, SFTP, and RSYNC for easy and secure access to the Storage Box for files uploads and downloading. You also have an option of integrating the Storage Box into your own file system via Webdav or Samba.

The storage box has the snapshots feature where you can take a snapshot of your Storage Box and restore when necessary. This ensures good data reliability and availability. Storage snapshots can be created manually or have them generated automatically based on your own personal configurations. Storage box capacity can be increased anytime from the web console to fit production data demands.

In this article we’ll see how to configure Hetzner Storage box and mount it on a Linux server. We’ll perform mounting on both Red hat based and Debian based systems. All Linux server configurations will be done via Ansible automation. The Ansible role that is used in this guide is available in galaxy.

Step 1: Order storage box server

The first step is making an order of Hetzner cloud storage box with the capacity that suit your business needs. Head over to hetzner robot order section.

Configure Mount Hetzner Storage box on Linux Server 01

Select storage capacity option.

Configure Mount Hetzner Storage box on Linux Server 02

Choose the location where your storage box server will be located

Configure Mount Hetzner Storage box on Linux Server 03

Confirm pricing and proceed to checkout.

Configure Mount Hetzner Storage box on Linux Server 04

Accept order obligation to complete the order

Configure Mount Hetzner Storage box on Linux Server 05

Once approved and provisioned it will be available under “Storage box” section.

Configure Mount Hetzner Storage box on Linux Server 06

Step 2: Enable Storage access options & reset access password

Enable supported methods that you’ll use to access your storage box. In this guide we’ll perform Samba share mount on a Linux server so Samba support must be enabled. I would also love to access storage using SCP and RSYNC, hence reason for enabling SSH support.

Configure Mount Hetzner Storage box on Linux Server 07

Take note of your storage box access details, namely:

  • User name
  • Samba Share
Configure Mount Hetzner Storage box on Linux Server 08

Lastly reset the user password used to access the storage box and to mount.

Configure Mount Hetzner Storage box on Linux Server 09

Step 3: Download Ansible role from galaxy

As stated earlier the role used in this guide is available in Ansible galaxy. Download the role to your local system:

$ ansible-galaxy install jmutai.hetzner_storage_box_role

Confirm the role is available locally. Default user roles path is ~/.ansible/roles

$ ls ~/.ansible/roles
jmutai.hetzner_storage_box_role

Create hosts inventory file

$ vim hosts
[servers]
188.30.226.18

Create playbook file:

vim hetzner_storage_box.yaml

Paste and modify the values accordingly in the file:

---
- name: Include Hetzner storage setup role
  hosts: servers #Server group / IP Address / Server hostname in hosts inventory
  roles:
  - jmutai.hetzner_storage_box_role
  vars:
    storage_box_username: <username>         #Storage box share username
    storage_box_password: <password>         #Storage box share user password
    hetzner_storage_box_fstab:
    - mountpoint: /mnt            #Where samba share is mounted in the server
      mount_system_user: root     #User in the server to mount
      mount_system_group: root    #Server user group managing mount

Ensure hosts, username, password values are set correctly.

Once done run the playbook to install required dependencies and configure fstab file.

$ ansible-playbook hetzner_storage_box.yaml -i hosts --user=centos --become --become-method=sudo

PLAY [188.30.226.18] ***********************************************************************************************************************************************

TASK [Gathering Facts] *******************************************************************************************************************************************
Enter passphrase for key '/Users/jkmutai/.ssh/id_rsa':
ok: [188.30.226.18]

TASK [Include Hetzner storage setup role] ************************************************************************************************************************

TASK [hetzner_storage : Include OS Specific variables] ***********************************************************************************************************
ok: [188.30.226.18] => (item=/Users/jkmutai/myhacks/ansible/roles/hetzner_storage/vars/RedHat.yml)

TASK [hetzner_storage : Install samba related packages] **********************************************************************************************************
changed: [188.30.226.18] => (item=samba-client)
ok: [188.30.226.18] => (item=samba-common)
changed: [188.30.226.18] => (item=cifs-utils)
ok: [188.30.226.18] => (item=rsync)
ok: [188.30.226.18] => (item=openssh-clients)

TASK [hetzner_storage : Copy credentials file] *******************************************************************************************************************
changed: [188.30.226.18]

TASK [hetzner_storage : Mount up hetzner samba share] ************************************************************************************************************
changed: [188.30.226.18] => (item={'mountpoint': '/mnt', 'mount_system_user': 'root', 'mount_system_group': 'root'})

PLAY RECAP *******************************************************************************************************************************************************
188.30.226.18               : ok=5    changed=3    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Initiate a new ssh session to the server and confirm new configurations added to the /etc/fstab file:

$ ssh [email protected]

Mount Samba share from fstab config:

sudo mount /mnt

Check storage total capacity and usage:

$ df -hT /mnt/
Filesystem                          Type  Size  Used Avail Use% Mounted on
//u269487.your-storagebox.de/backup cifs  500G  4.9G  496G   1% /mnt

You can create directories in the share and upload files:

sudo mkdir /mnt/techviewleo
sudo touch /mnt/techviewleo/test{1..5}.txt

$ sudo ls /mnt/techviewleo
test1.txt  test2.txt  test3.txt  test4.txt  test5.txt

$ sudo rm -rf /mnt/daylifetips/test{1..5}.txt

This is the end of our tutorial on how to configure Hetzner storage box and access the Samba share on a Linux system. In our future guides we’ll cover access to the storage via SCP, Rsync and WebDAV. Stay tuned!.

More guides on our website:

LEAVE A REPLY

Please enter your comment!
Please enter your name here