What's new

eject USB question

  • 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!

Rincewind

New Around Here
Hello all,

I am just wondering whether it is possible to run a script when ejecting a USB drive by pressing the 'Remove' button of the N66U's web admin interface.

It would be great if I could stop some running services (like lighttp, rtorrent, etc.) and deactivate swap before unmounting.

Has someone any idea how to do this?

Thank you in advance!

Regards,
RW
 
Hello all,

I am just wondering whether it is possible to run a script when ejecting a USB drive by pressing the 'Remove' button of the N66U's web admin interface.

It would be great if I could stop some running services (like lighttp, rtorrent, etc.) and deactivate swap before unmounting.

Has someone any idea how to do this?

Thank you in advance!

Regards,
RW

The tricky part is it would have to be a blocking script (i.e. one that doesn't return until the script is done running). If the script gets stuck for some reason, it could lead to unexpected issues.
 
I'll implement it for the next release. Worst case scenario is the unmount will never happen if your script blocks it - you would be able to get around that by killing the rogue script over telnet, so not a big deal.
 
Merlin, thank you very much for the quick reply and for the future implementation! Your custom firmware is awesome!

Anyway, what I practically would like to do is simply run a few scripts from init.d with 'stop' option. If these written properly, I believe there won't be any problem.

Thanks again!

RW
 
Note that Asuswrt already runs app_stop.sh if you are unmounting the disk where you have Optware set up. That script should stop any service started by Optware, and also turn swap off.
 
You are right, thank you for this useful info! :)
Nonetheless, I was not aware of it, because simply pressing 'Remove' button always caused efsck run after next mount, so I assumed that Optware services had not been stopped.
Right now I realized that screen has not been stopped when rtorrent shut down.
I fixed this, so my problem seems to be solved. :)

However, the pre-unmount script feature still would be nice.
Thank you for your help!

RW
 
Although, now the services are stopped fine, my swap is not turned off by app_stop.sh.
Is there a special way to activate the swap with Asuswrt?
I use the following command in /jffs/scripts/post-mount:
swapon /dev/sdb6
(and I can manually turn it off by:
swapoff /dev/sdb6
)
 
Asuswrt uses a swapfile instead of a swap partition.

nvram set apps_swap_enable=1
nvram set apps_swap_size=33000
nvram commit

(set the size to the desired size)

Swapfile gets created on the same partition as Optware is installed.
 
I tried enabling swap this way, but unfortunately it does not seem to work.
I checked it with 'free' command and on the 'Sysinfo page', which said no swap used or available any.

I found an earlier post mentioning this swap feature (thanks to Merlin again :) ), has anyone tried it with any success?

TIA!

RW
 

Latest threads

Sign Up For SNBForums Daily Digest

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