意外的关机怎么会对linux计算机造成伤害?

意外关闭对Linux的危害是否和对其他操作系统的危害一样大?请继续阅读,我们将研究灾难性系统关闭对Linux文件系统的影响。...

意外的关机怎么会对linux计算机造成伤害?

意外关闭对Linux的危害是否和对其他操作系统的危害一样大?请继续阅读,我们将研究灾难性系统关闭对Linux文件系统的影响。

今天的问答环节是由SuperUser提供的,SuperUser是Stack Exchange的一个分支,是一个由社区驱动的问答网站分组。

问题

超级用户读者User208554对Linux文件结构很好奇,并关心他正在开发的应用程序/安装:

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.

判决结果如何?

答案

SuperUser contributor l0b0提供了对日志/非日志文件系统的一些见解:

This would depend on

  1. whether you’re using a journaling file system and
  2. how well the applicati*** are able to handle aborted processing.

C***ider 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.

斯图建议将操作系统和数据分离,并增加一个备用电池:

To help minimise the possibility of OS corruption, it’s probably best to have separate “system” and “data” partiti*** 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.

最后,Jenny D扩展了日志文件系统的建议:

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 ********* 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 c***ider 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.


有什么要补充的解释吗?在评论中发出声音。想从其他精通技术的Stack Exchange用户那里了解更多答案吗?在这里查看完整的讨论主题。

 

  • 发表于 2021-04-11 17:49
  • 阅读 ( 202 )
  • 分类:互联网

你可能感兴趣的文章

避免损坏智能手机的10个小贴士

... 你也应该时不时地完全关机。它不仅能让你从科技中得到休息,还能让你的**不时降温,并有可能延长**的使用寿命。 ...

  • 发布于 2021-03-11 03:22
  • 阅读 ( 569 )

每个操作系统如何保证您的安全

操作系统是允许程序在计算机上运行的中间人。它们将您的计算机资源分开,在应用程序之间分开,让您可以操作下面的硬件。简而言之,任何能运行程序的机器都需要一台,无论是macOS、Windows还是Linux。 ...

  • 发布于 2021-03-12 11:26
  • 阅读 ( 197 )

不,linux不需要防病毒或防火墙

...,这样你就不会通过文件传输将恶意软件传递给你的其他计算机或你的朋友和家人。 ...

  • 发布于 2021-03-12 20:15
  • 阅读 ( 187 )

从命令行关闭linux计算机的5种方法

...情况下!),可能会有一段时间你需要重新启动你的Linux计算机。这可能是因为有些东西不起作用。或者,您可以通过SSH连接到远程计算机或服务器,并希望它重新启动或完全关闭。 ...

  • 发布于 2021-03-14 17:35
  • 阅读 ( 217 )

为什么windows会崩溃?故障排除指南

... 本文将重点讨论什么是意外的计算机崩溃以及如何识别问题。计算机崩溃的发生有多种原因。对于普通的PC用户来说,PC崩溃通常被视为PC损坏或损坏的迹象。在现实中,PC机的关闭很少值得担心。只要...

  • 发布于 2021-03-17 13:14
  • 阅读 ( 327 )

你的mac电脑一直随机关机?这是你能做的

...Mac可能无法解决这个问题。在这种情况下,苹果建议重置计算机的系统管理控制器(SMC)。 ...

  • 发布于 2021-03-22 13:46
  • 阅读 ( 481 )

什么是linux beta版,您应该试试吗?

... 在计算机软件领域,beta版本是一个程序的迭代,它具有开发人员想要的所有特性,但仍然需要经过测试才能消除任何剩余的bug。 ...

  • 发布于 2021-03-23 09:59
  • 阅读 ( 169 )

如何更改linux密码

... 如果您与多个用户共享计算机,还可以使用passwd命令更改这些用户的密码: ...

  • 发布于 2021-03-28 02:28
  • 阅读 ( 185 )

如何使用命令行重新启动或关闭linux

...示如何从命令行干净、安全地重新启动或关闭Linux或macOS计算机。 我们要下去了 有时你只需要重新启动或完全关闭。如果您使用的是无GUI服务器,或者使用的是到远程计算机的SSH会话,那么命令行是您唯一的选择。Linux和类似Un...

  • 发布于 2021-04-03 15:33
  • 阅读 ( 155 )

水如何损坏电子设备

...,要小心水的腐蚀 即使你的**或其他电子设备经历了一次意外的游泳,仍然可以工作,但你还没有完全清醒过来,因为水的腐蚀也会对电子设备造成损坏。 这也许是无声**,因为即使你的**在暴露于水后仍能正常工作,但随后在*...

  • 发布于 2021-04-05 04:05
  • 阅读 ( 138 )
嗯不忘初心嗯
嗯不忘初心嗯

0 篇文章

相关推荐