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.

Select storage capacity option.

Choose the location where your storage box server will be located

Confirm pricing and proceed to checkout.

Accept order obligation to complete the order

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

Step 2: Enable Storage access options & reset 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.

Take note of your storage box access details, namely:

  • User name
  • Samba Share

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

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

Create hosts inventory file

$ vim hosts

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
  - jmutai.hetzner_storage_box_role
    storage_box_username: <username>         #Storage box share username
    storage_box_password: <password>         #Storage box share user password
    - 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 [] ***********************************************************************************************************************************************

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

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

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

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

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

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

PLAY RECAP *******************************************************************************************************************************************************               : 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/daylifetips
$ sudo touch /mnt/daylifetips/test{1..5}.txt
$ sudo ls /mnt/daylifetips
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:

LPIC 101 – Maintaining The Integrity of Linux Filesystems

Install WordPress With Nginx and PHP-FPM on FreeBSD 13

Best Books To Learn Julia Programming Language