Part 2 - Drive Setup#

If you haven’t already, read Part 1 - Overview and Architecture before continuing. This part covers preparing the external hard drive and setting up the folder structure on the Linux server. For Phase 1, this server lives on your LAN.

Environment used in this guide:

Setting Value
OS Ubuntu Server
User account archive
Server hostname rsync-server

Prepare the Hard Drive#

Identify the Drive#

Plug in your USB hard drive and confirm it connected at USB 3.0 speed (5000M). If it shows 480M, try a different port.

archive@rsync-server:~$ lsusb -t
...
/:  Bus 010.Port 001: Dev 001, Class=root_hub, Driver=xhci_hcd/15p, 5000M
    |__ Port 001: Dev 002, If 0, Class=Mass Storage, Driver=uas, 5000M
archive@rsync-server:~$ lsblk -o NAME,MODEL,SERIAL,SIZE,TRAN,UUID,MOUNTPOINT,PATH
NAME MODEL SERIAL  SIZE TRAN UUID                                   MOUNTPOINT PATH

sdb  BUP B XXXXXX  3.6T usb                                                    /dev/sdb
└─sdb1
                   3.6T      xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx   /mnt/backu /dev/sdb1 

Identify your external drive in the output. Verify the model, serial number, and size before proceeding. In this example, the USB HDD appears as /dev/sdb with its partition at /dev/sdb1.

Wipe the Drive#

Warning: The following command destroys all partitions and filesystem data on the target drive. Verify you have the correct device. If you are unsure, unplug all other drives first.

If the drive is mounted, unmount it first:

sudo umount /dev/sdb

Wipe the existing filesystem and partition table:

wipefs -a /dev/sdb

This removes filesystem signatures and partition metadata. It does not securely erase the underlying data. Use dd if you need a secure wipe.

Partition the Drive#

Create a new GPT partition table and a single partition using fdisk:

sudo fdisk /dev/sdb

At the prompt, run these commands in order:

Command Action
g Create new GPT partition table
n Create new partition
Enter Accept all defaults
w Write changes and exit

Confirm the partition was created:

lsblk

You should see sdb1 listed under sdb.

Format the Partition#

Format the new partition as ext4:

sudo mkfs -t ext4 /dev/sdb1

Mount the Filesystem#

Create the Mount Point#

Linux uses /mnt for mounting external drives. Create a folder there:

sudo mkdir /mnt/backup_hdd

Configure Automatic Mounting#

Find the partition UUID for /dev/sdb1 in the output:

archive@rsync-server:~$ sudo blkid
/dev/sdb1: UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" BLOCK_SIZE="4096" TYPE="ext4" 
...

Open /etc/fstab:

sudo nano /etc/fstab

Add the following line, replacing the UUID with your own from blkid:

UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /mnt/backup_hdd ext4 defaults 0 2

This tells the system to identify the partition by UUID rather than device name, so the mount point survives reconnection or port changes.

Reboot to apply:

sudo reboot

Confirm the drive mounted correctly:

archive@rsync-server:~$ lsblk
NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
...
sdb                         8:16   0  3.6T  0 disk 
└─sdb1                      8:17   0  3.6T  0 part /mnt/backup_hdd

Configure Folder Structure#

Why Not Write Directly to the Mount Point#

The mount point /mnt/backup_hdd always exists as a folder on the root filesystem, even when the USB drive is not connected. If the drive fails to mount, any backup job writing to that path will silently fill your system drive instead.

The solution is to create a directory on the external drive’s filesystem. If the drive is unplugged, the directory disappears with it.

Create the Backup Directory#

sudo mkdir /mnt/backup_hdd/synology_share

When the drive is mounted, this folder is present. When the drive is disconnected, it disappears. The mount point /mnt/backup_hdd remains, but synology_share does not.

Set Permissions#

Take ownership of the directory:

sudo chown archive:archive /mnt/backup_hdd/synology_share

Apply 750 permissions:

sudo chmod 750 /mnt/backup_hdd/synology_share

Permission breakdown:

Entity Permission
Owner (archive) Read, write, execute
Group (archive) Read, execute
Other None

Leave /mnt/backup_hdd owned by root. Only the synology_share directory needs to be accessible to the archive account.