SOLVED - How to force reboot via CLI

Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions
Goto page 1, 2  Next
Author Message
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6388
Location: UK, London, just across the river..

PostPosted: Sun Dec 19, 2021 13:06    Post subject: SOLVED - How to force reboot via CLI Reply with quote
Moderator note 10.23.23: Moved to General Forum from Atheros - kp69

Hi guy's
It seems its not my first time that happens, but sometimes after CLI flash i loose control over the router and cannot reboot or execute any other command...like shell is gone...47874>47893
I can use dropbear but no commands or GUI access..
apart of physical reboot is there a way how to reactivate shell via SSh?


root@WR1043NDv2:~# reboot
-sh: nvram: I/O error
-sh: chmod: I/O error
-sh: /tmp/.rc_shutdown: Permission denied
-sh: /sbin/reboot: I/O error
root@WR1043NDv2:~#startservice httpd
-sh: nvram: I/O error

_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 55179 WAP
TP-Link WR1043NDv2 -DD-WRT 55303 Gateway/DoT,Forced DNS,AP Isolation,Ad-Block,Firewall
TP-Link WR1043NDv2 -DD-WRT 55303 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear R7800 --DD-WRT 55363 Gateway/DoT,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 55363 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Broadcom
Netgear R7000 --DD-WRT 55363 Gateway/SmartDNS/DoH,AD-Block,Firewall,Forced DNS,x3VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913


Last edited by Alozaros on Sun Oct 22, 2023 13:03; edited 1 time in total
Sponsor
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 14102
Location: Texas, USA

PostPosted: Mon Dec 20, 2021 17:54    Post subject: Reply with quote
Whatever shutdown scripts you are running should probably be removed or disabled when you are upgrading via CLI as it seems to cause issues. If you have the same issues upgrading via webUI, then you should probably consider this when upgrading by any method. To answer your question: the only option is a reboot by power switch, most likely, since I don't know if 'poweroff' will get you in trouble.
_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
DD-WRT Releases 2023 (PolitePol)
DD-WRT Releases 2023 (RSS Everything)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
giuliomagnifico
DD-WRT User


Joined: 11 Apr 2016
Posts: 454
Location: Italy

PostPosted: Tue Dec 21, 2021 10:39    Post subject: Reply with quote
Already tried reboot -f (force)?
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6388
Location: UK, London, just across the river..

PostPosted: Tue Dec 21, 2021 13:46    Post subject: Reply with quote
giuliomagnifico wrote:
Already tried reboot -f (force)?


10's giuliomagnifico as it came into my mind, i tried it too, but it seams for some odd reason, shell is down, it happens, sometimes...once in a while..

KP-69 noting in the shutdown script that will interfere...and if i have no physical access to the button or power switch, it's funny...have to wait...its a company router, where only i have control over it and its locked in the IT network room Razz ...

In fact router is fully functional..
so, my idea was if i can break something, like shutdown/kill vital process via htop and force it to autoshutdown kind of...or a way to restart shell..

_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 55179 WAP
TP-Link WR1043NDv2 -DD-WRT 55303 Gateway/DoT,Forced DNS,AP Isolation,Ad-Block,Firewall
TP-Link WR1043NDv2 -DD-WRT 55303 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear R7800 --DD-WRT 55363 Gateway/DoT,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 55363 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Broadcom
Netgear R7000 --DD-WRT 55363 Gateway/SmartDNS/DoH,AD-Block,Firewall,Forced DNS,x3VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12814
Location: Netherlands

PostPosted: Tue Dec 21, 2021 14:02    Post subject: Reply with quote
Why not upload the file as "firmware.bin" it will update automatically (and reboot etc) if cron is running
_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 14102
Location: Texas, USA

PostPosted: Tue Dec 21, 2021 17:08    Post subject: Reply with quote
Alozaros wrote:
KP-69 noting in the shutdown script that will interfere...and if i have no physical access to the button or power switch, it's funny...have to wait...its a company router, where only i have control over it and its locked in the IT network room Razz

Nothing to see here... you bricked one of these because your shutdown script hung the router, and I am not the one who said this in the emails Rolling Eyes

https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=330820
https://forum.dd-wrt.com/phpBB2/viewtopic.php?p=1250813#1250792

egc wrote:
Why not upload the file as "firmware.bin" it will update automatically (and reboot etc) if cron is running

https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=331072

_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
DD-WRT Releases 2023 (PolitePol)
DD-WRT Releases 2023 (RSS Everything)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6388
Location: UK, London, just across the river..

PostPosted: Tue Dec 21, 2021 17:09    Post subject: Reply with quote
egc wrote:
Why not upload the file as "firmware.bin" it will update automatically (and reboot etc) if cron is running


yep my next move... Razz

_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 55179 WAP
TP-Link WR1043NDv2 -DD-WRT 55303 Gateway/DoT,Forced DNS,AP Isolation,Ad-Block,Firewall
TP-Link WR1043NDv2 -DD-WRT 55303 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear R7800 --DD-WRT 55363 Gateway/DoT,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 55363 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Broadcom
Netgear R7000 --DD-WRT 55363 Gateway/SmartDNS/DoH,AD-Block,Firewall,Forced DNS,x3VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913
yoyoma2
DD-WRT User


Joined: 24 Sep 2016
Posts: 371

PostPosted: Tue Dec 21, 2021 20:09    Post subject: Reply with quote
I would try /sbin/reboot like easyddup does since by default reboot is a function in /etc/profile

Welcome to "the general mass.." Wink ref. first reply to easyddup thread.
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 14102
Location: Texas, USA

PostPosted: Tue Dec 21, 2021 21:51    Post subject: Reply with quote
I'm sure there is a valid explanation for what caused this, but we'll never get it. I have a couple of these in service myself with DD-WRT and have no issues upgrading via webUI or CLI or using a reboot command via ssh. There's more to the picture than meets the eye here. Not trying to play rugby here or be rude, it's just pretty obvious that there is something wrong and it is user-induced.
_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
DD-WRT Releases 2023 (PolitePol)
DD-WRT Releases 2023 (RSS Everything)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6388
Location: UK, London, just across the river..

PostPosted: Wed Dec 22, 2021 6:39    Post subject: Reply with quote
kernel-panic69 wrote:
I'm sure there is a valid explanation for what caused this, but we'll never get it. I have a couple of these in service myself with DD-WRT and have no issues upgrading via webUI or CLI or using a reboot command via ssh. There's more to the picture than meets the eye here. Not trying to play rugby here or be rude, it's just pretty obvious that there is something wrong and it is user-induced.


it could be (not that you are rude Razz )... up to a use err..
the odd bit... it happens on random basis...not only on my 1043v2 and not every time...for example with almost identical set up, it happened on 1 of the 1043v2 but not on the other 1043v2...

_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 55179 WAP
TP-Link WR1043NDv2 -DD-WRT 55303 Gateway/DoT,Forced DNS,AP Isolation,Ad-Block,Firewall
TP-Link WR1043NDv2 -DD-WRT 55303 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear R7800 --DD-WRT 55363 Gateway/DoT,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 55363 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Broadcom
Netgear R7000 --DD-WRT 55363 Gateway/SmartDNS/DoH,AD-Block,Firewall,Forced DNS,x3VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6388
Location: UK, London, just across the river..

PostPosted: Sun Oct 22, 2023 12:35    Post subject: Reply with quote
this started to happens every time i flash via CLI (ssh) and than try to reboot R7800..

reboot
/tmp/.rc_shutdown: line 2: /opt/etc/init.d/rc.unslung: not found
-sh: /sbin/reboot: I/O error

for the record..it wasn't like that and its been all alright ever since, it now happens again on random basis on various routers...

is there any chance to force the reboot via CLI, anyhow ? (consider im away of the unit)... Razz
-i tried...to unmount the USB (it doesn't matter, it happens again)
-I tried to stop USB from GUI and removed the shutdown script as well the USB itself..there is no more this report /tmp/.rc_shutdown: line 2: /opt/etc/init.d/rc.unslung: not found, but it still ends with -sh: /sbin/reboot: I/O error
currently happens on R7800 since i moved to 53714 from 53694 but it happened when i moved from k4 to k6.1 for first time...
-tried various command to reboot/restart/shutdown still end with -sh: /sbin/reboot: I/O error
-tried various services to restart..but some come up with -sh: /sbin/reboot: I/O error..
-i used the name firmware.bin it didn't reboot...-sh: /sbin/reboot: I/O error...


Ive found the cure: Razz
this will immediately reboot the system...

echo b > /proc/sysrq-trigger

_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 55179 WAP
TP-Link WR1043NDv2 -DD-WRT 55303 Gateway/DoT,Forced DNS,AP Isolation,Ad-Block,Firewall
TP-Link WR1043NDv2 -DD-WRT 55303 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear R7800 --DD-WRT 55363 Gateway/DoT,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 55363 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Broadcom
Netgear R7000 --DD-WRT 55363 Gateway/SmartDNS/DoH,AD-Block,Firewall,Forced DNS,x3VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 14102
Location: Texas, USA

PostPosted: Sun Oct 22, 2023 14:09    Post subject: Reply with quote
Alozaros wrote:
Ive found the cure: Razz
this will immediately reboot the system...

echo b > /proc/sysrq-trigger

Something I hadn't considered earlier in the discussion, thanks for the update. It's still safest to use the /tmp/firmware.bin method, as long as you're not concerned with bricking. 10x again for the follow-up, Aloz!

_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
DD-WRT Releases 2023 (PolitePol)
DD-WRT Releases 2023 (RSS Everything)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
yoyoma2
DD-WRT User


Joined: 24 Sep 2016
Posts: 371

PostPosted: Sun Oct 22, 2023 14:51    Post subject: Reply with quote
kernel-panic69 wrote:
Alozaros wrote:
Ive found the cure: Razz
this will immediately reboot the system...

echo b > /proc/sysrq-trigger

Something I hadn't considered earlier in the discussion, thanks for the update. It's still safest to use the /tmp/firmware.bin method, as long as you're not concerned with bricking. 10x again for the follow-up, Aloz!

When the I/O error happens with /sbin/reboot is the file there at all with ls? Should easyddup look for a particular error return code from /sbin/reboot after attempting to run it?

Running Alozaros's alternative reboot command is great if the normal/clean reboot command is missing/failing. If someone can get into the state where /sbin/reboot fails could you share the output of these commands so easyddup could reliably detect this situation?

ls -l /sbin/reboot
/sbin/reboot ; echo $?

Using the /tmp/firmware.bin method might work too but seems like a bigger change since the current method has many years of testing behind it.

Thanks for all the suggestions.
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6388
Location: UK, London, just across the river..

PostPosted: Sun Oct 22, 2023 16:39    Post subject: Reply with quote
yoyoma2 i guess even in a CLI flash, there are some services that shut down...

in my case after the cli flash, there was no more sbin directory to access...after reboot it reappeared....

as i said i had a believe it happens due to the USB or something..unfortunately..its not USB related, more likely something odd..

output is 0 (zero) and router rebooted...
/sbin/reboot ; echo $?
0

ls -l /sbin/reboot - output is ok it lists the stuff ...

but as i said i had to go trough lots of different try's and nothing..until ive found
echo b > /proc/sysrq-trigger would reboot...

_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 55179 WAP
TP-Link WR1043NDv2 -DD-WRT 55303 Gateway/DoT,Forced DNS,AP Isolation,Ad-Block,Firewall
TP-Link WR1043NDv2 -DD-WRT 55303 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear R7800 --DD-WRT 55363 Gateway/DoT,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 55363 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Broadcom
Netgear R7000 --DD-WRT 55363 Gateway/SmartDNS/DoH,AD-Block,Firewall,Forced DNS,x3VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913
mwchang
DD-WRT Guru


Joined: 26 Mar 2013
Posts: 1851
Location: Hung Hom, Hong Kong

PostPosted: Mon Oct 23, 2023 4:27    Post subject: Reply with quote
giuliomagnifico wrote:
Already tried reboot -f (force)?

Try "reboot -n"!?

I usually run "sync" three times before rebooting my Linux and router... old habit... Smile

Now that I saw this question, it seemed that DD-WRT's /sbin/reboot is not exactly what I expected in from standard Linux. You don't really need the "-n". There is no "--help" as well.

And DD-WRT does not have shutdown the command as well. Smile

Alozaros wrote:
but as i said i had to go trough lots of different try's and nothing..until ive found
echo b > /proc/sysrq-trigger would reboot...

Related:

Linux Magic System Request Key Hacks — The Linux Kernel documentation
https://www.kernel.org/doc/html/v4.18/admin-guide/sysrq.html

_________________
Router: Asus RT-N18U (rev. A1)

Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!

Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
GitHub: https://github.com/changmw/changmw
Goto page 1, 2  Next Display posts from previous:    Page 1 of 2
Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum