2024 Autor: Peter John Melton | [email protected]. Zuletzt bearbeitet: 2023-12-16 04:41
Die heutige Question & Answer-Sitzung wird von SuperUser zur Verfügung gestellt - einer Unterteilung von Stack Exchange, einer Community-basierten Gruppierung von Q & A-Websites.
Die Frage
Der SuperUser Reader User208554 ist neugierig auf Linux-Dateistrukturen und besorgt über eine App / Installation, an der er gerade arbeitet:
I am developing an application on a Linux embedded board (runs Debian) e.g. Raspberry Pi, Beagle Board/Bone, or olimex. The boards works on an environment that the electricity is cut unexpectedly (it is far too complicated to place PSU, etc.) and it would happen every day a couple times. I wonder if the unexpected power cuts would cause problem on the Linux Operation System? If it is something that I should worry about, what would you suggest to prevent the damages on OS against the unexpected power cuts?
PS. The application needs to writes some data to the storage medium (SD card), I think it would not be suitable to mount it as read-only.
Also, was ist das Urteil?
Die Antwort
Der SuperUser-Mitwirkende l0b0 bietet einige Einblicke in Dateisysteme für Journaling / Nicht-Journaling:
This would depend on
- whether you’re using a journaling file system and
- how well the applications are able to handle aborted processing.
Consider for example an application which processes a file and writes the results as they are computed (one output line per input line) to another file. If the power is cut during processing, and the same application is run after restarting, it can’t just restart processing from the start of the input file – that would mean the output file would contain duplicate information.
It could be very difficult to say anything definite about a hypothetical complex system, but most stable Linux software seems to be able to handle crashes quite nicely.
Stu schlägt vor, Betriebssystem und Daten zu trennen und ein Batterie-Backup hinzuzufügen:
To help minimise the possibility of OS corruption, it’s probably best to have separate “system” and “data” partitions on the SD card. That way you can mount the “system” partition read-only and use a highly-resilient FS on the “data” partition.
Additionally, most of those boards have very low power requirements, so a battery backup is possible. The “LiPo rider” board for the Raspberry Pi can be used as a basic UPS to provide a clean shutdown on power loss.
Schließlich erweitert Jenny D den Vorschlag für das Journaling-Dateisystem:
Unexpected power cuts may cause corruption of file system data – e.g. if a process has started writing to a file, but not yet finished writing it, the file may end up only half written. Now imagine if the power cut happens when you’re half way through a kernel upgrade…
As l0b0 wrote, using a journaling file system will help, since it will be able to keep track of what has actually gotten done. In addition to the wikipedia info that l0b0 linked, you may be interested in Do Journaling Filesystems Guarantee Against Corruption After a Power Failure as well.
You as a programmer obviously need to consider carefully how to handle writing to files so that it becomes an atomic process (i.e. it’s either fully done or not done at all, but never ever half done). It’s a fairly complex issue.
Haben Sie etwas zur Erklärung hinzuzufügen? Ton aus in den Kommentaren. Möchten Sie mehr Antworten von anderen technisch versierten Stack Exchange-Benutzern lesen? Hier geht es zum vollständigen Diskussionsthread.
Empfohlen:
Wie Sie über Ihren Browser angesteckt werden können und wie Sie sich schützen können
In einer perfekten Welt kann Ihr Computer nicht über Ihren Browser infiziert werden. Browser sollen Webseiten in einer nicht vertrauenswürdigen Sandbox ausführen und sie vom Rest Ihres Computers isolieren. Leider passiert das nicht immer.
Können Magneten die Festplatte eines Laptops beschädigen oder abwischen?
Ob unsere Computerhardware neu oder etwas älter ist, es schadet nie, etwas Vorsicht walten zu lassen, um Beschädigungen zu vermeiden. Können Magnete eine Festplatte beschädigen oder löschen? Der heutige Q & A-Beitrag von SuperUser hat die Antwort auf eine besorgte Leserfrage.
So erstellen Sie ein Testlabor, mit dem Sie die Geek School verfolgen können (ohne Ihren PC zu beschädigen)
Unsere Artikel zu Geek Schools können ziemlich kompliziert werden, und es gibt keinen Grund, eine Menge verrücktes Zeug auf Ihrem eigenen Desktop-PC zu machen. Stattdessen können Sie einfach VirtualBox verwenden, um virtuelle Maschinen für all Ihre Tests zu erstellen. So geht's
Der Befehl "Remote Shutdown" (Remote-Herunterfahren) wird Windows remote herunterfahren
In Windows 10/8/7 erfahren Sie, wie Sie den Befehl zum Remote-Herunterfahren oder den Neustart-Befehl verwenden. Verwenden Sie dazu den Befehl "shutdown", das Dialogfeld "Remote-Herunterfahren" oder die Befehlszeile.
Beenden, Abbrechen, Verhindern, Herunterfahren des Systems Herunterfahren in Windows 10/8/7
Erfahren Sie, wie Sie das Herunterfahren des Systems oder den Neustart in Windows 10/8/7 beenden, verhindern oder abbrechen. Nützlich, wenn Sie ein versehentliches Herunterfahren des Computers abbrechen möchten.