如何在 SuSE Linux 中以编程方式检测SATA驱动器拔出?
有谁知道我可以使用一种方法以编程方式检测 SATA 硬盘驱动器是否已拔出?当我们需要检测驱动器的删除时,我们的文件系统以只读模式安装。前几天我们注意到,我们能够拔掉硬盘驱动器,一切都继续顺利运行,直到下次我们尝试从磁盘上的文件读取时。
Does anyone know of a method I can use to programmatically detect if a SATA hard drive has been unplugged? Our file system is mounted in READ-ONLY mode when we need to detect the removal of the drive. We noticed the other day that we were able to unplug a hard drive and everything continued to run without a hitch until the next time we attempted to read from a file on disk.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
出于多种原因,解析 dmesg 的输出是一个坏主意,其中最重要的是它效率低下并且依赖于内核中 printk 碰巧使用的格式。
在现代 Linux 系统上,硬件更改通常通过 udev 反过来,将通过 D-BUS 向上传播更改事件。
您可能想搜索如何处理记忆棒的插入和移除;这些方法应该非常相似。
Parsing the output of
dmesg
is a bad idea for several reasons, not the least of which it being inefficient and dependent on the format that theprintk
in the kernel happens to use.On modern Linux systems, hardware changes are usually handled through udev which, in turn, will propagate change events up through D-BUS.
You may want to search how the insert and removal of memory sticks is handled; the methods should be fairly similar.