3

I'm new in linux... not 100% newbies, perhaps 98%. I'm able to write some script but I'm not an expert on specific settings on Raspberry. I'm looking for a way to turn on/off my server when I need in order to avoid somebody hack it and has access to some information (ie, my picture on the toilet ˆˆ)

For that I've plan to turn on/off remotely the powersupply (simply on=off) , but is there any risk I lose my data on the SDcard taking into account that only a webserver (just displaying a webpage) is running ?

I'm using a RPI Zero Wifi

4
  • The risk exists, but is not too high. Nevertheless depending on how you trigger the power switch, you could combine it with a shutdown command to the Pi or have a firewall setting in your router that you can switch on/off instead of the power solution.
    – FelixJN
    Dec 16 '20 at 14:08
  • 1
    @Fiximan If the server is hacked it isn't a good idea to graceful shutdown. This is one of the very few cases where you should cut the power and risk data lost.
    – Ingo
    Dec 16 '20 at 18:47
  • @Ingo I think OP should clarify then whether we are talking about an emergency shutdown (as you interpreted) or a system that is simply manually shut down when not in use (as I understood).
    – FelixJN
    Dec 16 '20 at 19:31
  • @Fiximan I thought it's clearly stated. Quote: I'm looking for a way to turn on/off my server when I need in order to avoid somebody hack it and has access to some information
    – Ingo
    Dec 16 '20 at 19:49
2

There is always a risk of losing data on a sudden removal of power.

However, nowadays the risk is very low. A modern OS will probably be able to recover if one of its files is corrupted.

If your application is sitting entirely in RAM, with no paging, you will probably be able to recover easily from any loss that occurs.

1
1

only a webserver is running

Run ps ax on that Pi and observe how many other processes besides the webserver are running. And the webserver is not 100% safe either, as it will typically write to a log file as it runs.

On top of that, if you get hacked, there will likely be a backdoor installation in progress. As such, I would not care much about data integrity at this point, as I would be wiping the SD card clean anyway.

Having said that, I have journaling enabled on the SD card (you can check that with tune2fs -l /dev/mmcblk0p2 | grep has_journal) and no swap, and so far I have never had a non-recoverable disk error after a hard reboot.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.