Attach the HDD, make sure the power supply is strong enough.
I am using a Western Digital 2.5" 500GB HDD with USB 2.0 (WDC_WD5000BMVV
). I think they where sold as Elements Portable SE as produced in ~2010-2011.
For testing purposes I attached the drive to my Windows PC and formatted it exFAT.
Attach the HDD to the Raspberry Pi. Make sure the red LED stays on and there are no voltage messages
vcgencmd get_throttled
→ throttled=0x0
in my case it's 0x50000
meaning there was a) under voltage and b) cpu throttling, both at least once nothing currently
Use lsblk
to see the attached drive:
lsblk -o NAME,SIZE,LABEL,VENDOR,MODEL,SERIAL,FSTYPE
NAME SIZE LABEL VENDOR MODEL SERIAL FSTYPE
sda 465.8G WD WDC_WD5000BMVV-11GNWS0 WD-WXA1AB0X0193
`-sda1 465.8G backup_srv ext4
mmcblk0 119.3G 0x900c530e
|-mmcblk0p1 256M bootfs vfat
`-mmcblk0p2 119G rootfs ext4
Check the drive again with fdisk
:
sudo fdisk -l /dev/sda
:Disk /dev/sda: 465.76 GiB, 500105740288 bytes, 976769024 sectors
Disk model: Elements 1023
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x77755cd6
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 976764927 976762880 465.8G 7 HPFS/NTFS/exFAT
Using fdisk
:
sudo fdisk /dev/sda
Welcome to fdisk (util-linux 2.36.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
To generate a new partition table, using GPT:
Command (m for help):
gCreated a new GPT disklabel (GUID: 02020FFD-D5C5-B546-A875-6A18D2A66EA1).
The device contains 'dos' signature and it will be removed by a write command. See fdisk(8) man page and --wipe option for more details.
Now create a new, single partition:
Command (m for help):
nPartition number (1-128, default 1):
ENTERFirst sector (2048-976768990, default 2048):
ENTERLast sector, +/-sectors or +/-size{K,M,G,T,P} (2048-976768990, default 976768990):
ENTERCreated a new partition 1 of type 'Linux filesystem' and of size 465.8. GiB.
Partition #1 contains a exfat signature.
Do you want to remove the signature? [Y]es/[N]o:
yThe signature will be removed by a write command.
Command (m for help):
wThe partition table has been altered.
Syncing disks.
umount /dev/sda1
sudo mkfs.ext4 /dev/sda1
mke2fs 1.46.2 (28-Feb-2021)
Creating filesystem with 122095867 4k blocks and 30531584 inodes
Filesystem UUID: 79a158c7-466e-496d-9a4c-e62a4d673d20
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000
Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks):
done
Writing superblocks and filesystem accounting information: done
Optionally give the partition a label:
sudo e2label /dev/sda1 backup_srv
Now the drive is ready to be used. Check it's infos:
lsblk -o NAME,STATE,SIZE,FSTYPE,MOUNTPOINT,PATH,PTTYPE,PARTTYPENAME,VENDOR,MODEL
NAME STATE SIZE FSTYPE MOUNTPOINT PATH PTTYPE PARTTYPENAME VENDOR MODEL
sda running 465.8G /dev/sda gpt WD WDC_WD5000BMVV-11GNWS0
`-sda1 465.8G ext4 /dev/sda1 gpt Linux filesystem
mmcblk0 119.3G /dev/mmcblk0 dos
|-mmcblk0p1 256M vfat /boot /dev/mmcblk0p1 dos W95 FAT32 (LBA)
`-mmcblk0p2 119G ext4 / /dev/mmcblk0p2 dos Linux
Create a mount point:
sudo mkdir -p /media/usb/backup_srv
Mount the drive:
sudo mount -L backup_srv /media/usb/backup_srv
sudo mount /dev/sda1 /media/usb/backup_srv
So currently backups are made to ~/backup/<server_name>/<app_name>/
. Each app has it's on borg repository.
The plan is to move those repositories to the HDD.
Now we need permissions. I do this with a new group:
sudo groupadd remote_backup
sudo usermod -a -G remote_backup root
sudo usermod -a -G remote_backup pg
getent group | grep remote_backup
to see the group memberssudo chgrp -c -R remote_backup /media/usb/backup_srv
sudo chmod g+w /media/usb/backup_srv/
Now copy the directory (if permissions is denied, relog with your user):
cp -r ~/backup/ /media/usb/backup_srv
mv ~/backup ~/backup.bak
(move files temporary, remove them later)Using symlinks does not work here, they cannot be mounted on the host doing the backups.
I am mounting the directory via SSHFS now using the new HDD.
Example:
sshfs -o allow_other,default_permissions,IdentityFile=~/.ssh/id_rsa -p 22 backup-user@your-server.example:/media/usb/backup_srv/backup ~/mnt/your-server-backup
The backups might fail now because the repository got moved. Change the config of borgmatic temporary and allow moved repo using relocated_repo_access_is_ok: true
.