AKGuidebooks Home Server Admin

Part 4: Store files

15. Add hard drives#

What you'll do: connect a USB hard drive, prepare it for Linux, and make it appear automatically at a folder (for example /srv/files) every time the server starts. Time: 30 minutes per drive.

The plan#

flowchart LR
  S["Server internal disk<br/>Linux + programs"]
  A["Drive 1 → /srv/files<br/>your data"]
  B["Drive 2 → /srv/backup<br/>backups only"]
  S --- A
  S --- B
  A -. "Chapter 17: nightly copy" .-> B

Use at least two drives: one for your files and one for backups. One drive alone is not a backup.

Power

Small 2.5" drives get power from USB. Large 3.5" drives need their own power adapter or a powered enclosure.

Step 1: List disks BEFORE plugging in#

Type on: the server
lsblk -o NAME,SIZE,MODEL,FSTYPE,MOUNTPOINTS

Note what's there. The internal disk is usually nvme0n1 or sda.

Step 2: Plug in ONE drive and list again#

Type on: the server
lsblk -o NAME,SIZE,MODEL,FSTYPE,MOUNTPOINTS

The new line is your drive, for example:

NAME   SIZE MODEL              FSTYPE MOUNTPOINTS
sdb    931G Expansion_Desk
└─sdb1 931G                    ntfs

Here the drive is sdb. Your letter may differ. Check it by its size and model.

Stop: does this drive have files you need?

If FSTYPE shows something (like ntfs, exfat, apfs), the drive probably contains data. The next step erases it completely. Copy anything you need off it first, using another computer.

Step 3: Erase and prepare the drive#

Replace sdX with your letter (e.g. sdb). Type carefully.

Type on: the server: ERASES the drive
sudo apt install parted
sudo parted /dev/sdX --script mklabel gpt mkpart files ext4 0% 100%
sudo mkfs.ext4 -L files /dev/sdX1

Note the 1 at the end of the last line: it targets the partition, not the whole drive. -L files gives the drive the label "files".

Step 4: Find the drive's permanent ID#

Drive letters (sdb, sdc…) can change. The UUID never changes.

Type on: the server
sudo blkid /dev/sdX1

Copy the part after UUID="…", for example 3f2a9c1e-7b4d-4e2a-9f1c-0a1b2c3d4e5f.

Step 5: Mount it automatically at startup#

Type on: the server
sudo mkdir -p /srv/files
sudo nano /etc/fstab

Add this as one line at the end, with your UUID:

Add to: /etc/fstab
UUID=3f2a9c1e-7b4d-4e2a-9f1c-0a1b2c3d4e5f  /srv/files  ext4  defaults,nofail,x-systemd.device-timeout=10s  0  2

Don't skip nofail

Without nofail, the server can refuse to start when the drive is unplugged, and you'd need a screen and keyboard to fix it.

Save, exit, then:

Type on: the server
sudo systemctl daemon-reload
sudo mount -a
df -h /srv/files

df should show your drive's size on /srv/files. If mount -a prints an error, re-open /etc/fstab and check for typos before restarting.

Step 6: Make it yours#

Type on: the server
sudo chown alex:alex /srv/files

Step 7: Test a restart#

Type on: the server
sudo reboot

Reconnect after 2 minutes and run df -h /srv/files. The drive should be there.

Second drive (backup)#

Repeat steps 2–7 with these changes:

Instead of Use
mkpart files and -L files mkpart backup and -L backup
/srv/files /srv/backup
sudo chown alex:alex … skip (backups belong to the system)

Done when: after a restart, df -h /srv/files /srv/backup shows both drives.

Next: 16. Share folders with Mac and Windows

Made by Anish · 2026