OpenWrt failed to load after extroot USB drive is attached

I just tested the way with two partitions on the same flash drive(ntfs and ext4)
Unfortunately this way works the same as with one ext4 partition

(parted) mkpart primary ext4 8455kB 100%
Warning: The resulting partition is not properly aligned for best performance: 16513s % 2048s != 0s
Ignore/Cancel? I
(parted) print all
Model: JetFlash TS256MJF110 (scsi)
Disk /dev/sda: 262MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type     File system  Flags
 1      65.5kB  8454kB  8389kB  primary  ntfs
 2      8455kB  262MB   254MB   primary
...
root@OpenWrt:~# mkfs.ext4 -L extroot ${DEVICE}
mke2fs 1.47.0 (5-Feb-2023)
Creating filesystem with 247740 1k blocks and 62000 inodes
Filesystem UUID: 079bbbfd-bafd-4f10-9e95-e9dd7b65e9bf
Superblock backups stored on blocks:
        8193, 24577, 40961, 57345, 73729, 204801, 221185

Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

root@OpenWrt:~# mount /dev/sda2 /mnt
NTFS signature is missing.
Failed to mount '/dev/sda2': Invalid argument
The device '/dev/sda2' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?

Therefore I can normally use such flash drives only as NTFS devices :frowning:

I've tried to use NTFS drive as extroot (/overlay).
I successfully configured it as extroot to mount by the label.

fstab.extroot=mount
fstab.extroot.label='extRootNTFS1Gb'
fstab.extroot.target='/overlay'

Unfortunately, NTFS file system isn't supported by Linux enough.

Thu Dec 19 18:20:56 2024 user.err kernel: [   17.380485] block: extroot: filesystem ntfs not supported by kernel
Thu Dec 19 18:20:56 2024 user.info kernel: [   17.391343] mount_root: switching to ubifs overlay

Do you know how to avoid the issue with the NTFS drive?

Full log:

root@OpenWrt:~# block info; uci show fstab; logread | sed -n -e "/- preinit -/,/- init -/p"
/dev/ubiblock0_0: UUID="a9962274-5781b041-710e6e96-15a1febb" VERSION="4.0" MOUNT="/rom" TYPE="squashfs"
/dev/ubi0_1: UUID="43ccb23c-6047-4a18-aa93-668a9c35b8c1" VERSION="w5r0" MOUNT="/overlay" TYPE="ubifs"
/dev/sda1: UUID="D250B84250B82F5B" LABEL="extRootNTFS1Gb" TYPE="ntfs"
fstab.@global[0]=global
fstab.@global[0].anon_swap='0'
fstab.@global[0].anon_mount='0'
fstab.@global[0].auto_swap='1'
fstab.@global[0].auto_mount='1'
fstab.@global[0].delay_root='5'
fstab.@global[0].check_fs='0'
fstab.@mount[0]=mount
fstab.@mount[0].target='/mnt/sda1'
fstab.@mount[0].uuid='F808FA8E08FA4B60'
fstab.@mount[0].enabled='0'
fstab.extroot=mount
fstab.extroot.label='extRootNTFS1Gb'
fstab.extroot.target='/overlay'
fstab.rwm=mount
fstab.rwm.device='/dev/ubi0_1'
fstab.rwm.target='/rwm'
Thu Dec 19 18:20:56 2024 user.info kernel: [    7.398170] init: - preinit -
Thu Dec 19 18:20:56 2024 kern.info kernel: [    7.871745] usb 1-2: new high-speed USB device number 2 using xhci-mtk
Thu Dec 19 18:20:56 2024 kern.notice kernel: [    8.182409] random: jshn: uninitialized urandom read (4 bytes read)
Thu Dec 19 18:20:56 2024 kern.notice kernel: [    8.303492] random: jshn: uninitialized urandom read (4 bytes read)
Thu Dec 19 18:20:56 2024 kern.notice kernel: [    8.353879] random: jshn: uninitialized urandom read (4 bytes read)
Thu Dec 19 18:20:56 2024 kern.info kernel: [    8.701215] mtk_soc_eth 1e100000.ethernet eth0: configuring for fixed/rgmii link mode
Thu Dec 19 18:20:56 2024 kern.info kernel: [    8.714067] mtk_soc_eth 1e100000.ethernet eth0: Link is Up - 1Gbps/Full - flow control rx/tx
Thu Dec 19 18:20:56 2024 kern.info kernel: [    8.714491] mt7530-mdio mdio-bus:1f lan1: configuring for phy/gmii link mode
Thu Dec 19 18:20:56 2024 kern.info kernel: [    8.730048] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
Thu Dec 19 18:20:56 2024 kern.notice kernel: [   11.063671] UBIFS (ubi0:1): Mounting in unauthenticated mode
Thu Dec 19 18:20:56 2024 kern.notice kernel: [   11.069656] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 474
Thu Dec 19 18:20:56 2024 kern.notice kernel: [   11.151357] UBIFS (ubi0:1): recovery needed
Thu Dec 19 18:20:56 2024 kern.notice kernel: [   11.387619] UBIFS (ubi0:1): recovery completed
Thu Dec 19 18:20:56 2024 kern.notice kernel: [   11.392242] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "rootfs_data"
Thu Dec 19 18:20:56 2024 kern.notice kernel: [   11.400044] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
Thu Dec 19 18:20:56 2024 kern.notice kernel: [   11.409960] UBIFS (ubi0:1): FS size: 38219776 bytes (36 MiB, 301 LEBs), max 311 LEBs, journal size 1904640 bytes (1 MiB, 15 LEBs)
Thu Dec 19 18:20:56 2024 kern.notice kernel: [   11.421600] UBIFS (ubi0:1): reserved for root: 1805213 bytes (1762 KiB)
Thu Dec 19 18:20:56 2024 kern.notice kernel: [   11.428189] UBIFS (ubi0:1): media format: w5/r0 (latest is w5/r0), UUID 43CCB23C-6047-4A18-AA93-668A9C35B8C1, small LPT model
Thu Dec 19 18:20:56 2024 user.info kernel: [   11.455604] mount_root: loading kmods from internal overlay
Thu Dec 19 18:20:56 2024 user.info kernel: [   11.663868] kmodloader: loading kernel modules from /tmp/overlay/upper/etc/modules-boot.d/*
Thu Dec 19 18:20:56 2024 kern.notice kernel: [   12.106975] SCSI subsystem initialized
Thu Dec 19 18:20:56 2024 kern.info kernel: [   12.138738] usb-storage 1-2:1.0: USB Mass Storage device detected
Thu Dec 19 18:20:56 2024 kern.info kernel: [   12.146095] scsi host0: usb-storage 1-2:1.0
Thu Dec 19 18:20:56 2024 kern.info kernel: [   12.151287] usbcore: registered new interface driver usb-storage
Thu Dec 19 18:20:56 2024 kern.info kernel: [   12.162973] usbcore: registered new interface driver uas
Thu Dec 19 18:20:56 2024 user.info kernel: [   12.169031] kmodloader: done loading kernel modules from /tmp/overlay/upper/etc/modules-boot.d/*
Thu Dec 19 18:20:56 2024 kern.info kernel: [   12.169466] mt7530-mdio mdio-bus:1f lan1: Link is Up - 1Gbps/Full - flow control rx/tx
Thu Dec 19 18:20:56 2024 kern.info kernel: [   12.169515] IPv6: ADDRCONF(NETDEV_CHANGE): lan1: link becomes ready
Thu Dec 19 18:20:56 2024 user.info kernel: [   12.318658] block: attempting to load /tmp/ubifs_cfg/upper/etc/config/fstab
Thu Dec 19 18:20:56 2024 user.info kernel: [   12.332834] block: extroot: device not present, retrying in 5 seconds
Thu Dec 19 18:20:56 2024 kern.notice kernel: [   13.152845] scsi 0:0:0:0: Direct-Access     USB 2.0  Flash Disk       0.00 PQ: 0 ANSI: 2
Thu Dec 19 18:20:56 2024 kern.notice kernel: [   13.163424] sd 0:0:0:0: [sda] 2015231 512-byte logical blocks: (1.03 GB/984 MiB)
Thu Dec 19 18:20:56 2024 kern.notice kernel: [   13.171257] sd 0:0:0:0: [sda] Write Protect is off
Thu Dec 19 18:20:56 2024 kern.debug kernel: [   13.176113] sd 0:0:0:0: [sda] Mode Sense: 00 00 00 00
Thu Dec 19 18:20:56 2024 kern.err kernel: [   13.176446] sd 0:0:0:0: [sda] Asking for cache data failed
Thu Dec 19 18:20:56 2024 kern.err kernel: [   13.181986] sd 0:0:0:0: [sda] Assuming drive cache: write through
Thu Dec 19 18:20:56 2024 kern.info kernel: [   13.193434]  sda: sda1
Thu Dec 19 18:20:56 2024 kern.notice kernel: [   13.197968] sd 0:0:0:0: [sda] Attached SCSI removable disk
Thu Dec 19 18:20:56 2024 user.err kernel: [   17.380485] block: extroot: filesystem ntfs not supported by kernel
Thu Dec 19 18:20:56 2024 user.info kernel: [   17.391343] mount_root: switching to ubifs overlay
Thu Dec 19 18:20:56 2024 user.warn kernel: [   17.411851] urandom-seed: Seeding with /etc/urandom.seed
Thu Dec 19 18:20:56 2024 kern.info kernel: [   17.499790] mt7530-mdio mdio-bus:1f lan1: Link is Down
Thu Dec 19 18:20:56 2024 user.info kernel: [   17.520109] procd: - early -
Thu Dec 19 18:20:56 2024 user.info kernel: [   17.523329] procd: - watchdog -
Thu Dec 19 18:20:56 2024 user.info kernel: [   18.159620] procd: - watchdog -
Thu Dec 19 18:20:56 2024 user.info kernel: [   18.167350] procd: - ubus -
Thu Dec 19 18:20:56 2024 kern.notice kernel: [   18.267279] random: ubusd: uninitialized urandom read (4 bytes read)
Thu Dec 19 18:20:56 2024 kern.notice kernel: [   18.279570] random: ubusd: uninitialized urandom read (4 bytes read)
Thu Dec 19 18:20:56 2024 kern.notice kernel: [   18.287512] random: ubusd: uninitialized urandom read (4 bytes read)
Thu Dec 19 18:20:56 2024 user.info kernel: [   18.303110] procd: - init -

Finally, I installed the big packages on the NTFS flash drive.
Solution details:
I did as @brada4 suggested.
I configured the NTFS flash drive to automount as /mnt/usbExt
Then I added the mounting point to the /etc/opkg.conf as usbExt place.

dest usbExt /mnt/usbExt

Additionally, I added /mnt/usbExt to the PATH and LD_LIBRARY_PATH environment variables.

mkdir -p /etc/profile.d
tee /etc/profile.d/custom.sh << "EOF"
...
export PATH=/mnt/usbExt/usr/bin:${PATH}
export LD_LIBRARY_PATH=/mnt/usbExt/usr/lib:/mnt/usbExt/lib:${LD_LIBRARY_PATH}

(or you may use any other text editor to create /etc/profile.d/custom.sh and modify it)

Then I installed x-ray core and v2raya as
opkg install -d usbExt xray-core v2raya

further upgrades are simple:

opkg upgrade xray-core
Upgrading xray-core on usbExt from 24.11.30-r1 to 24.12.18-1...

I am unsure if the creation environment variables are required or helpful because v2rayA can't find XRay-Core even with the variables provided till I create the soft link.

cd /usr/bin
ln -s /mnt/usbExt/usr/bin/xray xray

Additionally, I corrected the parameters in the /etc/init.d/v2raya
from

PROG="/usr/bin/v2raya"
XDG_DATA_HOME="/usr/share"

to

PROG="/mnt/usbExt/usr/bin/v2raya"
XDG_DATA_HOME="mnt/usbExt/usr/share"

I keep "as-is" config and log configuration because it isn't big.

        append_env "config" "/etc/v2raya"
        append_env "log_file" "/var/log/v2raya/v2raya.log"

Finally, it looks:

root@OpenWrt:~#  block info; uci show fstab;
/dev/ubiblock0_0: UUID="a9962274-5781b041-710e6e96-15a1febb" VERSION="4.0" MOUNT="/rom" TYPE="squashfs"
/dev/ubi0_1: UUID="43ccb23c-6047-4a18-aa93-668a9c35b8c1" VERSION="w5r0" MOUNT="/overlay" TYPE="ubifs"
/dev/sda1: UUID="D250B84250B82F5B" LABEL="extRootNTFS1Gb" MOUNT="/mnt/usbExt" TYPE="ntfs"
fstab.@global[0]=global
fstab.@global[0].anon_swap='0'
fstab.@global[0].anon_mount='0'
fstab.@global[0].auto_swap='1'
fstab.@global[0].auto_mount='1'
fstab.@global[0].delay_root='5'
fstab.@global[0].check_fs='1'
fstab.@mount[0]=mount
fstab.@mount[0].target='/mnt/usbExt'
fstab.@mount[0].uuid='D250B84250B82F5B'
fstab.@mount[0].enabled='1'
fstab.rwm=mount
fstab.rwm.device='/dev/ubi0_1'
fstab.rwm.target='/rwm'
fstab.extroot=mount
fstab.extroot.uuid='43ccb23c-6047-4a18-aa93-668a9c35b8c1'
fstab.extroot.target='/overlay'

root@OpenWrt:~# env
...
LD_LIBRARY_PATH=/mnt/usbExt/usr/lib:/mnt/usbExt/lib::
....
PATH=/mnt/usbExt/usr/bin:/usr/sbin:/usr/bin:/sbin:/bin

No reason to feed ntfs obsession. You can get ext4 driver for windoes.

I don't like NTFS but I already have 4 old flash drives (more than 10 years old) with the embedded NTFS. As you may see from the first part of the topic, If I change a filesystem on a pen drive with embedded NTFS, It can't be mounted as the overlay or by automount because even "mount" without parameters displays errors in the output. However, these devices mount well with the NTFS filesystem and can be used for automount.
The flash drive volumes (256 Mb, 1 Gb, 8 Gb, 16 Gb) are exactly what I need to extend the router storage.
I also decided to try all possible ways with existing USB storages because I have another router rt-n56u_b1 with 16MB of internal storage.
Hopefully, I now have a clear way to extend its memory with an existing USB drive and will flash it to OpenWRT shortly.

Additional notes:
In the documentation, I see an in-kernel NTFS driver similar to native Linux filesystems.

With kernel 5.15 onward the new ntfs3 driver may be used instead which aims to improve performance as an in-kernel driver similar to native Linux filesystems and has become the recommended approach. Both are available in OpenWrt, however below is written for ntfs-3g.

Maybe further I'll try this way (this is a proprietary driver developed by paragon-software with a limited free version available).

Another useful thing - A volume label can be used to automount disk instead of UUID (if they are used together uuid has higher priority):

uci set fstab.@mount[0].label='extRootNTFS1Gb'

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.