[Solved] Would it be possible to add a Shutdown link in System menu

I'm using OpenWRT on a Raspberry Pi 4b, and it works great. I can't believe how well it works actually.

OpenWrt 22.03.5 r20134-5f15225c1e / LuCI openwrt-22.03 branch git-23.119.80898-65ef406

I can open a terminal and send the shutdown command from there but I usually just use the GUI for everything else.

I'm perfectly able to use the terminal, I was just wondering if it is possible for me to add it, or do you have any plans to add in the future?

It's not the primary application of luci-app-advanced-reboot, so you'd have to ignore the actual "advanced reboot" functions which are unsupported on your device. But the package also provides a "shutdown" option.

4 Likes

Yeah, I installed it and decided not to click the link since it warned me about partitions and such.

I was hoping for a "cleaner" option. It seems so logical for it to be there, especially since it's one simple command in the terminal.

I'll stick with the terminal for now. I rarely shutdown the router anyway. Only needed it while I was building it really.

I marked the topic as solved. Thanks.

I guess it would not be all that hard to make a small luci-app-shutdown package that introduces a minimal shutdown page, or maybe an extension to the "reboot" page.

You have to keep in mind that virtually no plastic/SoC routers have an actual "shutdown" and at best put the SoC in an infinite halt state. That's just recently changing with the advent of SBCs and X86 appliances.

2 Likes

You have to keep in mind that virtually no plastic/SoC routers have an actual "shutdown"

Yeah, I actually did think about that. I was just wanting a little more from this amazing piece of software.

While I was learning how to build mine, I had to unplug the power many many times. Since I never shutdown my other servers by just pulling the plug, I just felt wrong doing it to this one. I tried the shutdown command that I use in linux but it didn't work. After a while, I googled how to do it in the terminal.

Obviously I can accept it either way.

Out of curiosity, if you succeed in "shutdown/halt" from terminal, how are you going to trigger the booting of Raspberry without pulling the plug?

Ps. Note that in the default config, OpenWrt writes nothing to flash during operations, so pulling the plug should be quite safe. But orderly shutdown may be more important if you have installed add-on packages with disk activity.

1 Like

The command I used was poweroff in the terminal.

My assumption is that just like in my linux servers or laptop, it gracefully shuts down services and closes the OS in a preferred way than just pulling the plug. Of course I would have to turn off power with the power button inline on the power supply to the Raspberry Pi. I just wanted the software to shut down in a more proper way.

You wouldn't pull the plug on your Windows or Linux computer or even long press the power button on your laptop to just instantly remove power from the OS. It could possibly be in the middle of a process when power is removed, and corrupt a file or something.

1 Like

Ps. Note that in the default config, OpenWrt writes nothing to flash during operations,

I missed this part of your comment. I was unaware that it was known that OpenWRT writes nothing to flash during operations.

With that knowledge, I would be more willing to pull the plug when needed, rather than opening up a terminal.

Thank you for the info.

1 Like

The RaspberryPi (and some other more desktop'ish targets like x86, sunxi, powerpc, etc.) might actually do that (don't own an RPi myself, so can't check), most other -more traditional- routing targets won't (either they just reboot or go into a weird halt state, without actually powering down, nor being able to recover without pulling the plug).

ext4 might be a bit more sensitive than squashfs here (yes, the journal will help it recover, but ext4 would prefer a clean shutdown); but ext4 is more commonly used on RPi, sunxi, x86 targets than on others.

1 Like

Yeah, that is the main deviation from "full interactive operating systems" like Windows or Linux GUI.

Flash wear has always been problem, so it has been a design principle.

At boot OpenWrt may write a random seed for next boot, but otherwise all logging is done to RAM, etc. Only the intentional config file changes etc. similar actions are written to flash when the user changes config, but otherwise there is no write activity.

Most routers have static read-only rootfs + small read-write overlay with all the changes (provoiding also easy reset capability, by just deleting the overlay).
SD card based systems like Raspberry may differ from that, as there may be just the unified r/w partition, but the same "avoid writes" policy applies to all.

2 Likes

ext4 might be a bit more sensitive than squashfs here (yes, the journal will help it recover, but ext4 would prefer a clean shutdown); but ext4 is more commonly used on RPi, sunxi, x86 targets than on others.

I installed the ext4 version because I was familiar with it in Linux and RPI.
openwrt-22.03.5-bcm27xx-bcm2711-rpi-4-ext4-factory.img.gz

But I guess since OpenWRT is designed with this in mind, this is why they didn't bother to include a Shutdown link in the GUI. And I literally never concerned myself when pulling the plug on any other router I've ever owned. But for some reason when it came to the RPI, I felt I needed to shut it down.

I learned something tonight. Thanks.

And like @takimata already said, also because many of the earliest (and even current) chips do not offer a proper shutdown mode. Many react to shutdown with an immediate reboot. So, the "shutdown" output would actually be the same as "reboot".

2 Likes

I may rebuild my router with the SquashFS file system, after what I've learned tonight.

I wrote a tutorial on how I installed and setup my OpenWRT Raspberry Pi 4b WiFi Router.

In it, I said to expand the rootfs partition to fill the rest of the SD card.
I now feel that is not necessary. Especially if I redo the install with SquashFS, should I skip that step. The only reason I did it was because I saw a YouTube video where the guy did that.

Could you not use luci-app-commands for this?

7 Likes

Dude, that works. I didn't see that one in the Software List. I scrolled through the luci-app commands. I just didn't notice this one.

Thanks so much.

1 Like

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