What's new

Entware Re-mounting attached USB storage without physically unplug and replug

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Limpi

Occasional Visitor
Hey!
I have an Asus RT-AX86U and Merlin v388.1.

After I eject an attached device (SSD attached to USB 3.0 port) on the router's web GUI and it gets "unmounted" status,
is there a way to re-mount it without physically unplug and replug the device?
If this is not possible through web GUI, then I would also welcome an SSH command line solution!

(I need this for example when I want to run an e2fsck -vfy /dev/sdb1 command.
I must unmount the device to run it and then I want to mount it again.
But without going to the router and unplug and replug the device... :))
 
Last edited:
I created this solution:

mkdir /tmp/mnt/ASUS-480GB
mount -t ext4 -o rw,nodev,noatime,data=ordered UUID="9e8ab443-3e41-445f-8829-3ccb949eff07" /tmp/mnt/ASUS-480GB
swapon /tmp/mnt/ASUS-480GB/myswap.swp
service restart_nasapps


I could not find the script that is actually running when a storage device is plugged in to a USB port... :(
Where is it? :)
 
My solution before is not good, many things still do not happen at re-mount, for example this:
Dec 24 14:07:08 kernel: scsi 16:0:0:0: Direct-Access Patriot Burst 0301 PQ: 0 ANSI: 6
Dec 24 14:07:08 kernel: sd 16:0:0:0: Attached scsi generic sg1 type 0
Dec 24 14:07:08 kernel: sd 16:0:0:0: [sdc] 937703088 512-byte logical blocks: (480 GB/447 GiB)
Dec 24 14:07:08 kernel: sd 16:0:0:0: [sdc] 4096-byte physical blocks
Dec 24 14:07:08 kernel: sd 16:0:0:0: [sdc] Write Protect is off
Dec 24 14:07:08 kernel: sd 16:0:0:0: [sdc] Disabling FUA
Dec 24 14:07:08 kernel: sd 16:0:0:0: [sdc] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
Dec 24 14:07:08 kernel: sd 16:0:0:0: [sdc] Attached SCSI disk

I don't know what is doing this, but without it copying files to the SSD is extremly slow...

Where is the script located that is running after plugging in a sotrage device to an USB 3.0 port?
 
Just run hotplug2 from the command line. That's it.

But there is a small problem with it: after the hotplug2 command the attached SSD gets a new ID:
/dev/sdc1 instead of the original /dev/sdb1.
Can I force it somehow to use the old one? So always the /dev/sdb1?
 
Why do you feel the need to fsck like that?

If there's actually a good reason to unmount then remount, simply ssh in, "umount <whatever>", perform the task(s), then "mount <whatever>" when done, without unregistering the device from the system like "ejecting" it does.

The umount will not succeed if any process has an open file descriptor, but you'll be told that at the attempt.
 
But there is a small problem with it: after the hotplug2 command the attached SSD gets a new ID:
/dev/sdc1 instead of the original /dev/sdb1.
Can I force it somehow to use the old one? So always the /dev/sdb1?
Yes, give the filesystem a volume label. That way it will always try to use that as the mountpoint rather than sda1, sdb1, sdc1, etc.
 
Why do you feel the need to fsck like that?

If there's actually a good reason to unmount then remount, simply ssh in, "umount <whatever>", perform the task(s), then "mount <whatever>" when done, without unregistering the device from the system like "ejecting" it does.

The umount will not succeed if any process has an open file descriptor, but you'll be told that at the attempt.

Yeah, that is a good question!

I just want to run the
e2fsck -vfy /dev/sdb1
command, but it tells me
e2fsck 1.45.6 (20-Mar-2020)
/dev/sdb1 is mounted.
e2fsck: Cannot continue, aborting.


I want to unmount the device just for the time I run the check on it.
But when I run
umount /tmp/mnt/ASUS-480GB
it tells me
umount: can't unmount /tmp/mnt/ASUS-480GB: Device or resource busy
as you told me!

So far I could only solve this problem with ejecting the storage through the web admin UI.

How else can I make it not busy?
I figured out this command:
service stop_nasapps
But unfortunately that is still not enough, unmount still says busy after it.

Can you help me how to do this including the proper mount command after the check?
(I suppose mount /tmp/mnt/ASUS-480GB will be not enough, it needs switches and maybe the UUID too,
which I know from blkid, it is "9e8ab443-3e41-445f-8829-3ccb949eff07". The file system is EXT4 with journaling enabled.
My guess is this:
mount -t ext4 -o rw,nodev,noatime,data=ordered UUID="9e8ab443-3e41-445f-8829-3ccb949eff07" /tmp/mnt/ASUS-480GB
But I am not sure.)

Where can I found a documentation of ASUS router commands?
I mean like these:
hotplug2
service restart_nasapps

(I think this ones work too:
service restart_samba
service stop_nasapps
service start_nasapps
service stop_samba
service start_samba

But the service command has no help and if I start it with something crazy, like
service avatar_the_way_of_water
It still just says

Done.

LOL!)
 
Last edited:
Yes, give the filesystem a volume label. That way it will always try to use that as the mountpoint rather than sda1, sdb1, sdc1, etc.

But it already has a label and still, when I eject the device (sdb1) at the web admin UI and then run
hotplug2
the device will be changed to sdc1.

(And later the kernel is still looking for sdb1:
Dec 24 22:31:41 kernel: Buffer I/O error on dev sdb1, logical block 58228736, lost sync page write
Dec 24 22:31:41 kernel: JBD2: Error -5 detected when updating journal superblock for sdb1-8.
Dec 24 22:31:41 kernel: Aborting journal on device sdb1-8.

Which is very strange. I think ejecting the device should stop all journaling too.
Maybe it is because I also have my swap file on it... But that is only a guess.)
 
any idea how to "re-plug" USB flash drive (32GB USB stick) without doing it physically

Code:
admin@RT-AC68U-XXXX:/tmp/home/root# hotplug2
[sighandler]: No more events to be processed, quitting.
[cleanup]: Waiting for children.
[cleanup]: All children terminated.
admin@RT-AC68U-XXXX:/tmp/home/root#

I have enabled Health Check of USB flash drive (once per month) but after unmount, it doesn't mount back :(
 
I have enabled Health Check of USB flash drive (once per month) but after unmount, it doesn't mount back :(
This is probably the same reason why hotplug2 doesn't work. Look for messages in the syslog when the Health Check runs and try and fix that problem.
 

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top