π§ OpenWrt Router β Extended Capabilities with USB Drive
π·οΈ Suggested blog slug:
openwrt-git-automation-setup
π Blog Entry: Format and Mount a USB Drive as ext4 on OpenWrt ππ§±π½
If you're using a router like the Linksys WRT3200ACM with OpenWrt, adding a USB drive unlocks powerful new features: Git repositories, scripting, backups, and more! π§ π‘
This post will show you how to safely format a USB stick to ext4
, mount it, and prepare it for automation or data storage. Perfect for developers and makers! βοΈπ¨βπ»
π§Ό Step 1: Clean the USB (Optional but Recommended)
To avoid legacy partition issues, clear the drive on your PC first:
π· On Windows:
diskpart
list disk
select disk X # Replace X with the USB disk number
clean
exit
Eject safely and plug it into your OpenWrt router.
π Step 2: Plug in and SSH into OpenWrt
ssh root@192.168.1.1
π§° Step 3: Install Required Tools
opkg update
opkg install kmod-usb-storage block-mount e2fsprogs fdisk
- Supports USB mounting, ext4 formatting, and partitioning.
π§± Step 4: Create and Format the Partition
Check your USB is detected:
ls /dev/sd*
Then partition and format:
fdisk /dev/sda
# Use: d (delete), n (new), p (primary), enter/enter, w (write)
mkfs.ext4 -L openwrt_usb /dev/sda1
π Step 5: Mount the USB Drive
mkdir -p /mnt/usb
mount /dev/sda1 /mnt/usb
df -h
β
You should see /mnt/usb
with your driveβs capacity listed.
π Optional: Mount Automatically on Boot
block detect | uci import fstab
block mount
Now your USB drive is ready to hold Git projects, scripts, backups, or anything else your OpenWrt system needs! π¦π§ β¨
𧬠Step 6 Clone Your Private Repo via SSH
cd /mnt/usb/projects/your-repo
git clone git@github.com:your-username/your-repo.git
π Conclusion
With your USB drive formatted and mounted, you can now leverage OpenWrt's capabilities for development, automation, and data management. Whether you're running scripts, managing backups, or hosting Git repositories, the possibilities are endless! ππ»