Mount disk on OpenWRT: Difference between revisions
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..." |
No edit summary |
||
| Line 8: | Line 8: | ||
Install required packages: | Install required packages: | ||
<syntaxhighlight lang="bash"> | |||
opkg update | opkg update | ||
opkg install block-mount e2fsprogs kmod-usb-storage kmod-fs-ext4 | opkg install block-mount e2fsprogs kmod-usb-storage kmod-fs-ext4 | ||
</syntaxhighlight> | |||
== Install == | == Install == | ||
| Line 15: | Line 17: | ||
1. Identify your drive: | 1. Identify your drive: | ||
<syntaxhighlight lang="bash"> | |||
ls -al /dev/sd* | ls -al /dev/sd* | ||
</syntaxhighlight> | |||
2. (Optional) Format the drive (WARNING: erases all data!): | 2. (Optional) Format the drive (WARNING: erases all data!): | ||
<syntaxhighlight lang="bash"> | |||
mkfs.ext4 /dev/sdb | mkfs.ext4 /dev/sdb | ||
</syntaxhighlight> | |||
3. Create the mount point: | 3. Create the mount point: | ||
<syntaxhighlight lang="bash"> | |||
mkdir -p /mnt/data | mkdir -p /mnt/data | ||
</syntaxhighlight> | |||
4. Mount the drive manually (for testing): | 4. Mount the drive manually (for testing): | ||
<syntaxhighlight lang="bash"> | |||
mount /dev/sdb /mnt/data | mount /dev/sdb /mnt/data | ||
df-h /mnt/data | df -h /mnt/data | ||
</syntaxhighlight> | |||
5. Configure automount at boot: | 5. Configure automount at boot: | ||
| Line 42: | Line 44: | ||
Detect and import block devices: | Detect and import block devices: | ||
<syntaxhighlight lang="bash"> | |||
block detect | uci import fstab | block detect | uci import fstab | ||
</syntaxhighlight> | |||
Set the mount point in fstab: | Set the mount point in fstab: | ||
<syntaxhighlight lang="bash"> | |||
uci set fstab.@mount[-1].enabled='1' | uci set fstab.@mount[-1].enabled='1' | ||
uci set fstab.@mount[-1].target='/mnt/data' | uci set fstab.@mount[-1].target='/mnt/data' | ||
uci commit fstab | uci commit fstab | ||
</syntaxhighlight> | |||
Mount all drives now and on future boots: | Mount all drives now and on future boots: | ||
<syntaxhighlight lang="bash"> | |||
/etc/init.d/fstab boot | /etc/init.d/fstab boot | ||
</syntaxhighlight> | |||
== Debug == | == Debug == | ||
| Line 61: | Line 66: | ||
Check if the drive is mounted: | Check if the drive is mounted: | ||
df-h /mnt/data | <syntaxhighlight lang="bash"> | ||
df -h /mnt/data | |||
</syntaxhighlight> | |||
Latest revision as of 17:57, 19 April 2025
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