
1. Check the information of USB storage in the boot log
# dmesg
[ 5.720000] usbcore: registered new interface driver usbfs
[ 5.730000] usbcore: registered new interface driver hub
[ 5.740000] usbcore: registered new device driver usb
[ 5.740000] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 5.750000] ehci-platform: EHCI generic platform driver
[ 5.760000] ehci-platform ehci-platform: EHCI Host Controller
[ 5.760000] ehci-platform ehci-platform: new USB bus registered, assigned bus number 1
[ 5.770000] ehci-platform ehci-platform: irq 3, io mem 0x1b000000
[ 5.800000] ehci-platform ehci-platform: USB 2.0 started, EHCI 1.00
[ 5.800000] hub 1-0:1.0: USB hub found
[ 5.810000] hub 1-0:1.0: 2 ports detected
[ 5.810000] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[ 5.820000] ohci-platform: OHCI generic platform driver
[ 5.820000] ohci-platform ohci-platform: Generic Platform OHCI controller
[ 5.830000] ohci-platform ohci-platform: new USB bus registered, assigned bus number 2
[ 5.840000] ohci-platform ohci-platform: irq 14, io mem 0x1c000000
[ 5.910000] hub 2-0:1.0: USB hub found
[ 5.910000] hub 2-0:1.0: 2 ports detected
[ 6.140000] usb 1-1: new high-speed USB device number 2 using ehci-platform
[ 6.720000] init: - preinit -
[ 7.250000] ar71xx: pll_reg 0xb8050010: 0x11110000
[ 7.250000] eth0: link up (1000Mbps/Full duplex)
[ 7.270000] random: procd urandom read with 11 bits of entropy available
[ 10.540000] jffs2: notice: (383) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found.
[ 10.570000] mount_root: loading kmods from internal overlay
[ 11.460000] SCSI subsystem initialized
[ 11.460000] uhci_hcd: USB Universal Host Controller Interface driver
[ 11.470000] usb-storage 1-1:1.0: USB Mass Storage device detected
[ 11.480000] scsi host0: usb-storage 1-1:1.0
[ 11.490000] usbcore: registered new interface driver usb-storage
[ 11.740000] block: attempting to load /tmp/jffs_cfg/upper/etc/config/fstab
[ 11.760000] block: extroot: not configured
[ 11.760000] mount_root: switching to jffs2 overlay
[ 11.800000] eth0: link down
[ 11.820000] procd: - early -
[ 11.820000] procd: - watchdog -
[ 12.490000] scsi 0:0:0:0: Direct-Access Generic- SD/MMC 1.00 PQ: 0 ANSI: 0 CCS
[ 12.560000] procd: - ubus -
[ 13.170000] sd 0:0:0:0: [sda] 30220288 512-byte logical blocks: (15.4 GB/14.4 GiB)
[ 13.200000] sd 0:0:0:0: [sda] Write Protect is off
[ 13.200000] sd 0:0:0:0: [sda] Mode Sense: 03 00 00 00
[ 13.200000] sd 0:0:0:0: [sda] No Caching mode page found
[ 13.210000] sd 0:0:0:0: [sda] Assuming drive cache: write through
[ 13.240000] sda: sda1
[ 13.250000] sd 0:0:0:0: [sda] Attached SCSI removable disk
2. Use fdisk to partition the USB storage
root@WNDR3800:~# fdisk /dev/sda
Welcome to fdisk (util-linux 2.25.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
# Check disk information
Command (m for help): p
Disk /dev/sda: 14.4 GiB, 15472787456 bytes, 30220288 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000
Device Boot Start End Sectors Size Id Type
/dev/sda1 8192 30220287 30212096 14.4G 7 HPFS/NTFS/exFAT
# Delete partition
Command (m for help): d
Selected partition 1
Partition 1 has been deleted.
# Create new partition, just press enter, enter
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-30220287, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-30220287, default 30220287):
Created a new partition 1 of type 'Linux' and of size 14.4 GiB.
# Save
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy
The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).
# Reboot
root@WNDR3800:~# reboot
3. Format with ext4
# Check command parameters
root@WNDR3800:~# mkfs.ext4
Usage: mkfs.ext4 [-c|-l filename] [-b block-size] [-C cluster-size]
[-i bytes-per-inode] [-I inode-size] [-J journal-options]
[-G flex-group-size] [-N number-of-inodes]
[-m reserved-blocks-percentage] [-o creator-os]
[-g blocks-per-group] [-L volume-label] [-M last-mounted-directory]
[-O feature[,...]] [-r fs-revision] [-E extended-option[,...]]
[-t fs-type] [-T usage-type ] [-U UUID] [-jnqvDFKSV] device [blocks-count]
# Format
root@WNDR3800:~# mkfs.ext4 -b 4096 -L Ext4U01 /dev/sda1
mke2fs 1.42.12 (29-Aug-2023)
Creating filesystem with 3777280 4k blocks and 944704 inodes
Filesystem UUID: 355a69cf-7a07-4752-a97d-f81a6956c786
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: 2/116
done
# Completion
# If you want to set as swap partition
mkswap /dev/sda1
Setting up swapspace version 1, size = 523235840 bytes
4. After reboot (let it auto-mount), check the file system. If df does not have the -T parameter, you can directly use the mount command to check the format
root@WNDR3800:~# df -h -T
Filesystem Type Size Used Available Use% Mounted on
rootfs rootfs 12.1M 3.5M 8.6M 29% /
/dev/root squashfs 2.3M 2.3M 0 100% /rom
tmpfs tmpfs 61.5M 264.0K 61.3M 0% /tmp
/dev/mtdblock5 jffs2 12.1M 3.5M 8.6M 29% /overlay
overlayfs:/overlay overlay 12.1M 3.5M 8.6M 29% /
tmpfs tmpfs 512.0K 0 512.0K 0% /dev
/dev/sda1 ext4 14.1G 36.0M 13.3G 0% /mnt/sda1
[root@TIMEPLUG_CF37:/root]#mount
rootfs on / type rootfs (rw)
/dev/root on /rom type squashfs (ro,relatime)
proc on /proc type proc (rw,noatime)
sysfs on /sys type sysfs (rw,noatime)
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime)
/dev/mtdblock7 on /overlay type jffs2 (rw,noatime)
overlayfs:/overlay on / type overlayfs (rw,noatime,lowerdir=/,upperdir=/overlay)
tmpfs on /dev type tmpfs (rw,relatime,size=512k,mode=755)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
/dev/sda1 on /mnt/sda1 type ext4 (rw,relatime,data=ordered)
/dev/mtdblock6 on /mnt/mtdblock6 type squashfs (ro,relatime)
5. Performance testing. Requires hdparm, if not available, install via opkg install hdparm
root@WNDR3800:~# hdparm -Tt /dev/sda
/dev/sda:
Timing cached reads: 256 MB in 2.01 seconds = 127.67 MB/sec
Timing buffered disk reads: 44 MB in 3.09 seconds = 14.24 MB/sec
and dd
root@WNDR3800:/mnt/sda1# time dd count=128 bs=1M if=/dev/zero of=test.test
128+0 records in
128+0 records out
real 0m 28.65s
user 0m 0.00s
sys 0m 0.74s
Calculate the approximate write speed as 128/28.64=4.47MB/s
Update 2017-10-08: Errors occurred when mounting a certain 2.5-inch USB 3.0 hard drive enclosure from unitek, causing it to be mounted as read-only. The specific error is as follows:
Thu Oct 5 18:57:15 2023 kern.info kernel: [ 19.904000] EXT4-fs (sda1): mounting ext3 file system using the ext4 subsystem
Thu Oct 5 18:57:15 2023 kern.info kernel: [ 19.968000] sd 0:0:0:0: [sda] Invalid command failure
Thu Oct 5 18:57:15 2023 kern.info kernel: [ 19.972000] sd 0:0:0:0: [sda]
Thu Oct 5 18:57:15 2023 kern.warn kernel: [ 19.976000] Result: hostbyte=0x00 driverbyte=0x08
Thu Oct 5 18:57:15 2023 kern.info kernel: [ 19.980000] sd 0:0:0:0: [sda]
Thu Oct 5 18:57:15 2023 kern.warn kernel: [ 19.984000] Sense Key : 0x5 [current]
Thu Oct 5 18:57:15 2023 kern.info kernel: [ 19.988000] sd 0:0:0:0: [sda]
Thu Oct 5 18:57:15 2023 kern.warn kernel: [ 19.992000] ASC=0x24 ASCQ=0x0
Thu Oct 5 18:57:15 2023 kern.info kernel: [ 19.992000] sd 0:0:0:0: [sda] CDB:
Thu Oct 5 18:57:15 2023 kern.warn kernel: [ 19.996000] cdb[0]=0x2a: 2a 08 00 00 38 48 00 00 08 00
Thu Oct 5 18:57:15 2023 kern.err kernel: [ 20.000000] end_request: critical target error, dev sda, sector 14408
Thu Oct 5 18:57:15 2023 kern.err kernel: [ 20.008000] Buffer I/O error on device sda1, logical block 1545
Thu Oct 5 18:57:15 2023 kern.warn kernel: [ 20.016000] lost page write due to I/O error on sda1
Thu Oct 5 18:57:15 2023 kern.err kernel: [ 20.020000] JBD2: Error -5 detected when updating journal superblock for sda1-8.
Thu Oct 5 18:57:15 2023 kern.warn kernel: [ 20.028000] EXT4-fs warning (device sda1): ext4_clear_journal_err:4637: Filesystem error recorded from previous mount: IO failure
Thu Oct 5 18:57:15 2023 kern.warn kernel: [ 20.040000] EXT4-fs warning (device sda1): ext4_clear_journal_err:4638: Marking fs in need of filesystem check.
Thu Oct 5 18:57:15 2023 kern.warn kernel: [ 20.056000] EXT4-fs (sda1): warning: mounting fs with errors, running e2fsck is recommended
Thu Oct 5 18:57:15 2023 kern.info kernel: [ 20.068000] EXT4-fs (sda1): recovery complete
Thu Oct 5 18:57:15 2023 kern.info kernel: [ 20.072000] sd 0:0:0:0: [sda] Invalid command failure
Thu Oct 5 18:57:15 2023 kern.info kernel: [ 20.076000] sd 0:0:0:0: [sda]
Thu Oct 5 18:57:15 2023 kern.warn kernel: [ 20.080000] Result: hostbyte=0x00 driverbyte=0x08
Thu Oct 5 18:57:15 2023 kern.info kernel: [ 20.084000] sd 0:0:0:0: [sda]
Thu Oct 5 18:57:15 2023 kern.warn kernel: [ 20.088000] Sense Key : 0x5 [current]
Thu Oct 5 18:57:15 2023 kern.info kernel: [ 20.092000] sd 0:0:0:0:
Thu Oct 5 18:57:15 2023 kern.warn kernel: [ 20.096000] ASC=0x24 ASCQ=0x0
Thu Oct 5 18:57:15 2023 kern.info kernel: [ 20.100000] sd 0:0:0:0: [sda] CDB:
Thu Oct 5 18:57:15 2023 kern.warn kernel: [ 20.100000] cdb[0]=0x2a: 2a 08 00 00 38 48 00 00 08 00
Thu Oct 5 18:57:15 2023 kern.err kernel: [ 20.108000] end_request: critical target error, dev sda, sector 14408
Thu Oct 5 18:57:15 2023 kern.err kernel: [ 20.112000] Buffer I/O error on device sda1, logical block 1545
Thu Oct 5 18:57:15 2023 kern.warn kernel: [ 20.120000] lost page write due to I/O error on sda1
Thu Oct 5 18:57:15 2023 kern.err kernel: [ 20.124000] JBD2: Error -5 detected when updating journal superblock for sda1-8.
Thu Oct 5 18:57:15 2023 kern.err kernel: [ 20.132000] Aborting journal on device sda1-8.
Thu Oct 5 18:57:15 2023 kern.info kernel: [ 20.136000] EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts:
and
Thu Oct 5 18:57:17 2023 kern.crit kernel: [ 22.264000] EXT4-fs error (device sda1): ext4_journal_check_start:56: Detected aborted journal
Thu Oct 5 18:57:17 2023 kern.crit kernel: [ 22.272000] EXT4-fs (sda1): Remounting filesystem read-only
Thu Oct 5 18:57:19 2023 daemon.err block: /dev/sda1 is already mounted on /mnt/sda1
After replacing with another hard drive enclosure (hard drive unchanged), the error disappears.