Initialize & Persistently Mount an External USB Disk on Ubuntu Server 24.04

— THIS GUIDE ERASES THE ENTIRE TARGET DISK —

Data-destructive warning: The steps below wipe the whole disk (wipefs -a, new GPT). Double-check the device path before running. There is no undo.


Why use a persistent mount

For a USB disk that will stay connected and be used as long-term server storage, I prefer a normal persistent mount instead of systemd automount.

Ubuntu Server does not provide the same desktop-style USB automount behavior by default. For a long-term data disk, I want the disk to stay mounted while the server is running.

In /etc/fstab, I use:

nofail → boot continues even if the USB disk is absent
x-systemd.device-timeout=10s → systemd waits only a short time for the disk during boot
noatime → reduces unnecessary metadata writes

I intentionally do not use x-systemd.automount or x-systemd.idle-timeout in this setup, because this disk is intended to stay mounted for long-term server use.


  1. Identify the correct USB disk
lsblk -dpno NAME,TRAN,TYPE,SIZE,MODEL \
| awk '$2=="usb" && $3=="disk"{print $1, $4, substr($0, index($0,$5))}'
/dev/sda 931.5G PSSD T7
lsblk -S -o NAME,TRAN,TYPE,SIZE,MODEL,SERIAL | awk '$2=="usb" && $3=="disk"'
sda  usb  disk 931.5G PSSD T7 A682101Y0SNLM7S
  • Device: /dev/sda
  • Model: PSSD T7
  • Serial: A682101Y0SNLM7S

  1. Remove old signatures (destructive)
sudo wipefs -a /dev/sda

  1. Create a clean GPT and a single partition (full disk)

Some USB bridges misreport “optimal I/O size” and make parted warn about alignment. Use -a minimal with 1 MiB start; alignment is correct.

sudo parted -s /dev/sda mklabel gpt
sudo parted -s -a minimal /dev/sda mkpart primary ext4 1MiB 100%
sudo parted -s /dev/sda name 1 data
sudo parted -s /dev/sda align-check minimal 1

sudo partprobe /dev/sda
sudo udevadm settle

The ext4 in mkpart is only a hint. The real filesystem is created next.


  1. Format the filesystem (EXT4)
sudo mkfs.ext4 -L DATA /dev/sda1

  1. Mount now & configure persistent mount

Mount by UUID:

sudo mkdir -p /mnt/data

UUID=$(sudo blkid -s UUID -o value /dev/sda1)
sudo mount "UUID=${UUID}" /mnt/data

Add one line to /etc/fstab (UUID method):

UUID=$(sudo blkid -s UUID -o value /dev/sda1)

echo "UUID=${UUID} /mnt/data ext4 defaults,noatime,nofail,x-systemd.device-timeout=10s 0 2" \
| sudo tee -a /etc/fstab

Apply & test:

sudo systemctl daemon-reload
sudo mount -a
findmnt /mnt/data
df -h /mnt/data

Why these options

  • nofail → boot continues even if the USB disk is unplugged
  • x-systemd.device-timeout=10s → systemd waits only a short time for the disk during boot
  • noatime → reduce unnecessary metadata writes
  • I intentionally do not use x-systemd.automount or x-systemd.idle-timeout in this long-term storage setup. The disk should stay mounted while the server is running.

Ownership & permissions

sudo chown $USER:$USER /mnt/data

Safe eject / power-off before unplug

For long-term server storage, the disk should normally stay connected. If you need to unplug it, unmount it first.

Find the stable by-id path of the USB disk:

ls -l /dev/disk/by-id/ | grep -iE 'usb|Samsung|T7|PSSD'

Then safely unmount and power off the disk:

sync
sudo umount /mnt/data
sudo udisksctl power-off -b /dev/disk/by-id/your-usb-disk-id

Replace /dev/disk/by-id/your-usb-disk-id with the actual by-id path of your USB disk.

Using /dev/disk/by-id/... is safer than /dev/sda because /dev/sda can change after reboot or when multiple disks are connected.

Did this guide save you time?

Support this site

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top