Excellent software and practical tutorials
How to use OpenWrt to mount USB and install software on a USB drive
OpenWrt mount USB If your router has a small memory and the installation space is not that large, you can consider mounting OpenWrt on USB as system storage. In this way, OpenWrt will install the software package on the USB flash drive, and you don’t have to worry about the software size.
Refer to OpenWrt official documentation for mounting USB:https://openwrt.org/docs/guide-user/storage/usb-drives-quickstart
First you need to install the OpenWrt mount USB package list:
Step 1: Install the required software for OpenWrt to mount USB
- kmod-usb-ohci USB chip driver.
- kmod-usb2,kmod-usb3 USB2.0, USB3.0 driver.
- kmod-usb-storage,kmod-usb-storage-extraUSB,kmod-usb-storage-uasStorage driver.
- block-mount,blockedMount the program (after the installation is complete and the reboot is complete, the mount point option will appear under the system in the LuCI interface).
- kmod-fs-ext4,kmod-fs-vfat,ntfs-3g,kmod-fs-ntfsThey are ext4 partition format support, FAT partition format support, and NTFS partition format support. kmod-fs-ntf is the kernel driver for NTFS.
Packages that need to be installed:
- kmod-usb-ohci
- kmod-usb2
- kmod-usb3
- kmod-usb-core
- kmod-usb-storage
- kmod-usb-storage-extras
- kmod-usb-storage-uas
- block-mount
- blocked
- kmod-fs-msdos
- kmod-fs-ext4
- kmod-fs-vfat
- kmod-fs-ntfs
- ntfs-3g
- e2fsprogs
- cfdisk
- hd-idle
- luci-i18n-hd-idle-zh-cn
- smartmontools
You can install it in the system's operation interface or on the router through SSH. After the installation is complete, restart the router.
opkg update opkg install kmod-usb-ohci kmod-usb2 kmod-usb3 kmod-usb-core kmod-usb-storage kmod-usb-storage-extras kmod-usb-storage-uas block-mount blockd opkg install kmod-fs-msdos kmod-fs-ext4 kmod-fs-vfat kmod-fs-ntfs ntfs-3g e2fsprogs cfdisk hd-idle luci-i18n-hd-idle-zh-cn smartmontools
Step 2: Set the mount point
First, format the USB drive, convert it to ext4, SSH to the router, and use the command to format the USB drive to ext4. If e2fsprogs has not been installed before, you need to install e2fsprogs to format the USB drive. You can see the USB drive by looking at the /dev/ directory. If the USB drive has only one partition, the OpenWrt system will automatically recognize it as /dev/sda1
ls -al /dev/sd* mkfs.ext4 /dev/sda1 block detect | uci import fstab uci set fstab.@mount[0].enabled='1' && uci set fstab.@global[0].anon_mount='1' && uci commit fstab /sbin/block mount && service fstab enable # After the settings are complete, restart the router reboot
Create a new mount point
In the LUCI interface of Openwrt, System->Mount Point, Automatic Load Configuration, click Add at the mount point, and use UUID to mount, so that after restarting, the correct boot hard disk is always mounted. In this way, you can configure the automatic mounting of the USB flash drive. Select /overlay as the mount point and confirm, click Save and Apply.
Note: Be sure to check the mount pointEnabledOtherwise, the mount will fail.
After restarting the router, the system enters the USB system mode and the USB is mounted successfully. You can see that in the mounted file system, /dev/sda1 has been mounted on /overlay. At this time, the Openwrt system has been restored to factory settings, and the required software sources and software packages need to be reinstalled. Reinstall the software package in the USB system. You can install the software package in the LUCI management interface and the SSH terminal.
Regarding the swap partition, after the mount point is configured, you can generate a swap file swapfile in the parent system as a swap partition. Then restart and enter the new subsystem of the USB flash drive.
dd if=/dev/zero of=/mnt/sda1/swapfile bs=1024 count=500000 mkswap /mnt/sda1/swapfile swapon /mnt/sda1/swapfile
Enable swap partition
In the subsystem of the USB disk, reinstall the mount point related software, then SSH the router and create a swap file in the system with a size of 200MB as a swap partition. Please be patient when creating the swap partition.
SSH into the router and enter the following command to create a new swap partition:
#Create a new swapfile swap partition dd if=/dev/zero of=/overlay/swapfile bs=1024 count=200000 #Set swapfile as swap space mkswap /overlay/swapfile #Enable swap space swapon /overlay/swapfile #Check whether to add a swap partition free -h
If you want to delete the swap partition, you need to turn off the swap partition first and then delete it.
swapoff /overlay/swapfile rm /overlay/swapfile
Configuring swap partition
On the OpenWrt management page, System -> Mount Point, Swap Partition -> Click Add, select Custom in Device, and then enter the swap file we generated above /overlay/swapfile , check the Enable option above, save the application.
At this point, the settings for mounting the USB disk have been completed.
Extended reading: Differences between "NTFS", "FAT32", "exFAT" and file systems
FAT32
The 32-bit file allocation table [File Allocation Table: FAT] is called "FAT32". There are also "FAT16" and "FAT12" depending on the number of bits, but the main FAT these days is 32 bits.
This file system was primarily used in Windows 98/Me, but later operating systems continue to support it. It can be used with the latest versions of Windows 11, and can also be used with other operating systems such as MacOS and Linux.
If you format a "64GB" USB flash drive as "FAT32", it will only recognize a maximum of "32GB" according to Windows specifications. According to the "FAT32" standard, it can certainly handle 2TB, but if you want to format a storage device with a capacity greater than 32GB on Windows, you must use a third-party formatting program.
NTFS
NT file system [NTFS] is the standard file system of Windows NT series and is currently the mainstream file system of Windows.
Since it is an NT system, it can be used with Windows NT or later operating systems (2000/XP or later), but cannot be used with Windows 95, Windows 98, etc.
NTFS can theoretically manage 2 64 -1 cluster volumes (up to 16 EB), but this is also limited by computer performance.
However, for a cluster size of 2048 KB, Windows 10 version 1709 and later supports up to 8 petabytes (PB) (and file sizes). A "Peta" is 1,000 times larger than a "Tera". Hyperdimensional capabilities are supported, albeit limited.
Some new recording devices support "4KB" sector size, which allows larger devices to be managed more efficiently if both the operating system and storage device support 4K natively.
exFAT
exFAT [Extended File Allocation Table] is a file system that is improved on the basis of traditional FAT.
A file system optimized for flash devices such as USB flash drives and SD cards.
The biggest advantage is that it supports large disk and file sizes. If you use the latest Windows, it supports "volumes up to 512TB" and "files up to 128PiB", so you can assume that there are almost no practical limits for general use.
If you want to use an external HDD/SSD with your computer (like an extended drive) without moving it, you can set it to "NTFS" without any problems. When connected, formatting with "exFAT" instead of "NTFS" may manage data more efficiently.
However, despite the name FAT, it is not compatible with regular FAT32, so exFAT cannot be used on devices that only support FAT32.
“exFAT” is also compatible with Apple’s MacOS, so when sharing a storage device with Windows and Mac, “exFAT” is the most likely candidate.
If it's NTFS, MacOS may not be able to read it well. "FAT32" is also supported, but as expected, the data capacity limitations are strict, so if you're dealing with large amounts of data, "exFAT" would be a safe choice.