I understand that switching off a computer before executing a shutdown command can corrupt data being accessed by it at that moment in time, then if OpenWRT is Unix based, is it possible to damage the OS by using the power button to shut it down ?
Do you even have a power button on the router to begin with?
But OpenWrt is by default a operating system that is only run in ram memory once booted, so if you cut power during run time you canât damage any write process.
The firmware is protected (just after it is loaded). Black outs should* not do anything to it.
I'd be stupefied if you had a blackout that touched the firmware after loaded.
Very true....
The footnote indicated by your asterisk would be for example if you are bonkers enough to run OpenWrt on a virtual machine hosted on a server grade x86 running btrfs.
I know because I got called in to fix such a mess.
LMAO!!! FOTF.
I wish I knew how to run a VM.
I can't see the point to be honest. An "all in one solution"? All you need is a few $ for a "real" router and you have simplicity and resilience.
It ainât that hard, but the âVM run everything as normalâ is a big hype, especially on software made to run hardware. Software to run in software generally work better in VM. But you get yourself a lot of headache and extra work to get something working in VM that simply work on real hardware.
And Vbox seem to have a tendency to make images stop working if you donât use them for a while!?
Well, there are settings around and add-on packages that really can start to write data all the time to the flash just for fun.
I saw a topic before (I believe was answered by a developer) in which it was asked 'why is there no shutdown in LuCI, only reboot' and the answer I remember was -paraphrased- "because it is not necessary".
Technically there is a luci add-on, âadvaced-rebootâ that is made to shift boot partition on dual boot devices.
That add-on have a shutdown function down in the corner. But still, the function doesnât really do anything meaningful other than to put the CPU in full work of doing nothing.
This power down thing started in the beginning with computers that had HDD and if the power was cut to them the read head crash landed on the discs when they stopped rotating and damaged them.
But already in the early years of the millennia the HDD got better hardware to be able to retract the write head without power available.
But nowadays with flash and SSD you really have to work full time many years to make any damage to these memories.
Out of curiosity, can you explain how a blackout caused damage to a filesystem on such a configuration?
Why is
OpenWrt on a virtual machine hosted on a server grade x86 running btrfs
such a bad idea?
I'm not saying I agree with that configuration, just trying to understand where the flaws are.
I mentioned this somewhat jokingly, but it did actually happen.
Short version of the long story:
The power failed. Within seconds the rack ups dc circuit breaker popped, before the diesel generators kicked in. Once the generators came up the ups powered up in an error state - no power to the server rack. A staff member manually turned on the power to the rack. The servers in the rack began to boot but then the ups tripped the main circuit breakers powering the rack, while the btrfs filesystem was "fixing" itself.
The ups was taken out of circuit, but the server failed to boot up as the boot disk was badly corrupted and would not mount.
I fixed it by deleting the btrfs volume and DDing the standard x86-64 squashfs OpenWrt image. A waste of a raid array, but it was up and running very quickly, getting a support centre back online in record time.
Yes a bad idea. A purpose built router is dedicated to the job and, compared to a VM on a general purpose chunk of hardware, is simple and efficient. Sure it is great fun running OpenWrt as a VM, but in a real production environment this is just complexity for the sake of it with no advantage whatsoever.
The MF286D router does have a power button.. a reset button.. and no WPS button.
I wouldn't be surprised if the power button only cuts the main power cable for user convenience but inside the box, just as if you just pull the cord out but then have a loose cord laying around.
Routers doesnât have any APCI system like PC anyway.
Fascinating, thank you for the explanation!
I'd add that turning the (hardware-based) router off while in the middle of installing software or doing other actions that write to the underlying flash filesystem can possibly result in corruption of the flash. Incomplete writes, etc.
This ultimately is the reason to "Unmount USB disks before pulling them out", to make sure that there are no writes in progress that would be interrupted. Same thing applies for the router flash storage.
I would say no electronic memory hardware will really be expected to work if you pull the plug during a write or install process.
Some are more or less easy to recover and some are ready for the waste bin.
Config backups are your friend. Make them. Keep them. Make more.
If the config was being changed when power died, it may be corrupt and you may have to (follow the docs for your device and) boot OpenWrt in failsafe or recovery mode, then reload the config.
Not a tragedy, just inconvenient. And unlikely.
The simplest answer is that OpenWRT/consumer routers are designed to run entirely in RAM. So unless you are saving configuration changes, installing packages or updating the firmware - there's much less chance it will be writing to permanent storage when the power is turned off.
Plus configuration changes and package installation all happen on the overlay partition which only stores files different to those in the firmware. If you change the configuration files for example, it doesn't overwrite the files, it adds a new one into the overlay and the OS knows to use that one instead of the stock one.
If the overlay corrupts it likely can still boot the firmware that is stored on the read-only OS partition (which is only written to during firmware updates), it would just boot in default configuration.