Mount disk on OpenWRT

From Jwiki
Revision as of 17:55, 19 April 2025 by Gyurci08 (talk | contribs) (Created page with "Category:OpenWRT == Prerequisites == * Sufficient free USB port and a supported storage device (e.g., USB flash drive, SSD) * SSH or terminal access to your device Install required packages: opkg update opkg install block-mount e2fsprogs kmod-usb-storage kmod-fs-ext4 == Install == 1. Identify your drive: ls -al /dev/sd* 2. (Optional) Format the drive (WARNING: erases all data!): mkfs.ext4 /dev/sdb 3. Create the mount point: mkdir -p /mnt/data 4. Mou...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Prerequisites

  • Sufficient free USB port and a supported storage device (e.g., USB flash drive, SSD)
  • SSH or terminal access to your device

Install required packages:

opkg update opkg install block-mount e2fsprogs kmod-usb-storage kmod-fs-ext4

Install

1. Identify your drive:


ls -al /dev/sd*


2. (Optional) Format the drive (WARNING: erases all data!):


mkfs.ext4 /dev/sdb


3. Create the mount point:


mkdir -p /mnt/data


4. Mount the drive manually (for testing):


mount /dev/sdb /mnt/data df-h /mnt/data


5. Configure automount at boot:

Detect and import block devices:

block detect | uci import fstab


Set the mount point in fstab:

uci set fstab.@mount[-1].enabled='1' uci set fstab.@mount[-1].target='/mnt/data' uci commit fstab


Mount all drives now and on future boots:

/etc/init.d/fstab boot


Debug

Check if the drive is mounted:

df-h /mnt/data