manually-formatting-mounting-and-using-hetzner-volumes.md (1813B)
1 --- 2 title: "Manually formatting, mounting and using Hetzner volumes" 3 date: 2019-07-04T15:40:00 4 tags: ["Formats", "Linux", "Servers", "Snippets", "Software"] 5 --- 6 7 I've recently moved all my server infrastructure over to Hetzner, and to date everything's been going swimmingly. 8 9 The default partition options though aren't ideal, so I'm scrapping my existing volume and recreating it manually, properly. 10 11 Firstly, login to your Hetzner account and create your volume: 12 13 ``` 14 Volumes > Create Volume > Size in GB 15 Name whatever 16 Mount options Manual 17 Create & Buy Now 18 ``` 19 20 Now find the partition after logging into your server via issuing `lsblk`. In my case, this was `/dev/sdb` 21 22 You can now partition this new drive as a GPT volume by doing the following: 23 ``` 24 gdisk /dev/sdb 25 o 26 n 27 enter 28 enter 29 enter 30 w 31 enter 32 ``` 33 34 One partitioned, you can format this new partition as ext4, via the following: 35 ``` 36 sudo mkfs.ext4 /dev/sdb1 37 ``` 38 Seeing as though I'm going to be using this partition as extra storage for downloaded files I don't really need the reserved blocks it offers, which can be disabled via: 39 ``` 40 sudo tune2fs -m0 /dev/sdb1 41 ``` 42 43 Now, we'll make a mount point for the newly formatted volume: 44 ``` 45 mkdir $HOME/mountpoint 46 ``` 47 48 It's also worthwhile grabbing the disk's UUID via `sudo blkid /dev/sdb1 -s UUID -o value`. 49 50 Now we're going to add an entry in `/etc/fstab` so the partition will be mounted automatically. You'll need to edit this file as root and add the following line: 51 ``` 52 UUID=your-uuid-from-above /home/youruser/mountpoint ext4 discard,nofail,defaults 0 0 53 ``` 54 55 Now that your `fstab` file is ammended, you can remount all your partitions via: `sudo mount -a` 56 57 Last but not least, change the owner of the directory to prevent file permission issues: 58 ``` 59 sudo chown youruser:youruser /home/user/mountpoint -R 60 ```