Làm thế nào có thể Shutdown bất ngờ làm hại một máy tính Linux?

Mục lục:

Làm thế nào có thể Shutdown bất ngờ làm hại một máy tính Linux?
Làm thế nào có thể Shutdown bất ngờ làm hại một máy tính Linux?

Video: Làm thế nào có thể Shutdown bất ngờ làm hại một máy tính Linux?

Video: Làm thế nào có thể Shutdown bất ngờ làm hại một máy tính Linux?
Video: Hướng dẫn cách lấy lại key và kích hoạt key bản quyền win 10 - YouTube 2024, Có thể
Anonim
Việc tắt máy đột xuất có hại như Linux đối với các hệ điều hành khác không? Đọc tiếp khi chúng tôi điều tra các tác động của việc tắt hệ thống thảm họa trên các hệ thống tệp Linux.
Việc tắt máy đột xuất có hại như Linux đối với các hệ điều hành khác không? Đọc tiếp khi chúng tôi điều tra các tác động của việc tắt hệ thống thảm họa trên các hệ thống tệp Linux.

Phiên Hỏi & Đáp hôm nay đến với chúng tôi theo lịch sự của SuperUser - một phân khu của Stack Exchange, một nhóm các trang web Hỏi & Đáp do cộng đồng điều hành.

Câu hỏi

Người đọc SuperUser User208554 tò mò về cấu trúc tệp Linux và quan tâm đến ứng dụng / cài đặt mà anh ấy đang làm việc:

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.

Vậy phán quyết là gì?

Câu trả lời

Người đóng góp SuperUser l0b0 cung cấp một số thông tin chi tiết về các hệ thống tập tin journaling / non-journaling:

This would depend on

  1. whether you’re using a journaling file system and
  2. 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 gợi ý tách hệ điều hành và dữ liệu cũng như thêm bản sao lưu pin:

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.

Cuối cùng, Jenny D mở rộng trên đề xuất hệ thống tệp nhật ký:

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.

Có cái gì để thêm vào lời giải thích? Âm thanh trong các ý kiến. Bạn muốn đọc thêm câu trả lời từ những người dùng Stack Exchange có hiểu biết công nghệ khác? Xem toàn bộ chuỗi thảo luận tại đây.

Đề xuất: