While OpenWRT does have wiki page about this topic here it's a bit difficult to easily tell what do to in order to get it working. Here's very short tutorial on how to partition and enable auto mount of your storage. I've also added a swap partition as a few applications such as MiniDLNA and Transmission tends to hog quite a bit during some operations.

Requires: block-mount, fdisk (busybox's version) and filesystem and USB subsystem (modules).

In my case I used an empty (well, invalid partition table) USB HDD so there are no partitions available.

  • First when you plug it in you'll get a few kernel messages
[  152.791517] usb 1-1.1: new high-speed USB device number 3 using orion-ehci
[  152.935444] usb-storage 1-1.1:1.0: USB Mass Storage device detected
[  152.951619] scsi0 : usb-storage 1-1.1:1.0
[  153.952121] scsi 0:0:0:0: Direct-Access     Disk     Name             ES2O PQ: 0 ANSI: 2 CCS
[  153.963425] sd 0:0:0:0: [sda] 625142448 512-byte logical blocks: (320 GB/298 GiB)
[  153.971914] sd 0:0:0:0: [sda] Write Protect is off
[  153.976733] sd 0:0:0:0: [sda] Mode Sense: 28 00 00 00
[  153.977407] sd 0:0:0:0: [sda] No Caching mode page found
[  153.982777] sd 0:0:0:0: [sda] Assuming drive cache: write through
[  153.992033] sd 0:0:0:0: [sda] No Caching mode page found
[  153.997391] sd 0:0:0:0: [sda] Assuming drive cache: write through
[  154.455456]  sda: unknown partition table
[  154.464693] sd 0:0:0:0: [sda] No Caching mode page found
[  154.470056] sd 0:0:0:0: [sda] Assuming drive cache: write through
[  154.476224] sd 0:0:0:0: [sda] Attached SCSI disk
  • Start fdisk to add a partition table and partitions to the drive
    fdisk /dev/sda
  • Type o to a new partition table
  • Type n to add a new partition
  • Type p to select primary partition type
  • Type 1 to set it as first partition
  • Leave blank to use default cylinder value as we want to use the beginning of the drive
  • Type +512M to make it 512Mbyte in size (swap partition)
  • Type n to add another partition
  • Type p to select primary partition type
  • Type 2 to set it as second partition
  • Leave blank to use default cylinder value, this will set start point at the first free cylinder
  • Leave blank as we want to allocate the rest of the drive
  • Type t to alter partition type
  • Type 1 to select the first partition
  • Type 82 to change it to a Linux swap partition
  • Type w to write your change to disk and close fdisk
  • Create swap filesystem
    mkswap /dev/sda1
  • Enable swap
    swapon /dev/sda1
  • Create ext4 filesystem for storage
    mkfs.ext4 /dev/sda2
  • Open /etc/config/fstab to enable auto mounting of USB HDD
    nano /etc/config/fstab
  • Change values of anon_swap and anon_mount from 0 to 1
  • Save changes and exit

Done! You just need to reboot for changes to apply.