Mik*_*b49 5 linux encryption hard-drive ubuntu external-hard-drive
如何在 Linux 中永久关闭外部 USB 驱动器的写入缓存(我使用的是 Ubuntu)?
我试过了:
命令行方法: hdparm -W0 /dev/sdb <---- 有效但仅适用于当前驱动器并在重新启动后重置。
hdparm "-k1" 标志应该强制它保持设置,但它说:
HDIO_SET_KEEPSETTINGS 失败:参数无效
HDIO_GET_KEEPSETTINGS 失败:参数无效
配置文件方法(似乎是另一种永久执行的方法):我发现的下一件事是修改位于 /etc 中的“hdparm.conf”文件。但是,这似乎要求您提前知道驱动器号“sdb、sdc...”等。
无论如何,您如何覆盖所有驱动器,或者特别是所有 USB 外部设备?
关键问题是..我不确定连接这些USB外部驱动器的顺序,因此驱动器号会改变,所以我不能只命名“sdb”,因为它可能不是“sdb”.. .
这是一种情况,即使对于甚至没有连接的驱动器号,hdparm.conf 也可以多次输入条目?这样,无论连接什么驱动器,它都会抢先关闭 write_cache。或者这会搞砸什么?
可能的/etc/hdparm.conf示例(这行得通吗?):
/dev/sda {
write_cache = off
}
/dev/sdb {
write_cache = off
}
/dev/sdc {
write_cache = off
}
/dev/sdd {
write_cache = off
}
Run Code Online (Sandbox Code Playgroud)
同样,这些驱动器甚至可能还不存在......只是抢先覆盖尽可能多的字母,所以无论如何,write_cache 是关闭的。我认为必须有比这更好的方法..
还有其他想法吗?或者更好的方法?谢谢!
小智 3
您需要使用 -K 选项。来自 man hdparm
\n\n -k Get/set the "keep_settings_over_reset" flag for the drive. When this flag is set, the drive will preserve the -dmu settings\n over a soft reset, (as done during the error recovery sequence). This option defaults to off, to prevent drive reset loops\n which could be caused by combinations of -dmu settings. The -k option should therefore only be set after one has achieved\n confidence in correct system operation with a chosen set of configuration settings. In practice, all that is typically nec\xe2\x80\x90\n essary to test a configuration (prior to using -k) is to verify that the drive can be read/written, and that no error logs\n (kernel messages) are generated in the process (look in /var/adm/messages on most systems).\n\n -K Set the drive\xc2\xb4s "keep_features_over_reset" flag. Setting this enables the drive to retain the settings for -APSWXZ over a\n soft reset (as done during the error recovery sequence). Not all drives support this feature.\n
Run Code Online (Sandbox Code Playgroud)\n
归档时间: |
|
查看次数: |
12138 次 |
最近记录: |