slh*_*hck 1 osx-snow-leopard external-hard-drive macos
我有一个 LaCie USB 磁盘,当它连接到我的 MacBook Pro 时不会停止读取或写入。它一直在发出噪音,即使我没有对它做任何事情。驱动器不会正常弹出(即弹出并向下旋转),而是我必须强制弹出它并且驱动器随后仍在运行。
如果我将驱动器连接到我的 Windows 7 PC,它运行得非常好。
我已经看到这种行为几个星期了,不记得我是否安装了可能导致问题的任何东西。该驱动器正在使用 FAT32。
有没有人知道一种方法来找出哪个程序使驱动器执行所有这些读取或写入操作?
有几个命令行工具可以帮助跟踪此类事情。要找出导致磁盘活动的原因,我会使用fs_usage
. 这是一个在我从 bash 创建文件时使用它来查看我的备用卷的示例:
$ sudo fs_usage | grep /Volumes/Spare
Password: [enter admin password; it will not echo]
08:56:10 open /Volumes/Spare/somefile 0.000827 bash
08:56:10 lstat64 /Volumes/Spare 0.000029 fseventsd
08:56:10 getattrlist /Volumes/Spare 0.000017 Finder
08:56:10 getattrlist /Volumes/Spare 0.000030 Finder
08:56:10 getattrlist /Volumes/Spare 0.000013 Finder
08:56:10 access_extended /Volumes/Spare 0.000045 Finder
08:56:10 lstat64 /Volumes/Spare/somefile 0.000038 mdworker
08:56:10 getattrlist /Volumes/Spare/somefile 0.000023 mdworker
08:56:10 getattrlist /Volumes/Spare/somefile 0.000034 mdworker
08:56:10 open /Volumes/Spare/somefile 0.000027 mdworker
08:56:10 getattrlist /Volumes/Spare/somefile 0.000018 mdworker
08:56:10 open /Volumes/Spare/somefile 0.000016 mdworker
08:56:10 getattrlist /Volumes/Spare/somefile 0.000017 mdworker
08:56:10 getattrlist /Volumes/Spare/somefile 0.000012 mdworker
^C
Run Code Online (Sandbox Code Playgroud)
(注意:当fs_usage
通过管道传输到另一个命令时,它会格式化其输出以显示 132 列 - 为了使其可读,您应该加宽终端窗口以匹配。另外,使用 control-C 退出)。这里有趣的列是第三个(文件路径)和最后一个(进程名称)——在这个例子中,bash 创建了 /Volumes/Spare/somefile,Finder 注意到有些东西已经改变并检查了文件夹的属性,以及 mdworker(Spotlight 的一部分) ) 注意到新文件并检查它以添加到卷的搜索索引。
此类事情的另一个有用工具是lsof
(列出打开的文件):
$ sudo lsof | grep /Volumes/Spare
mds 30 root txt REG 14,4 2 430 /Volumes/Spare/.Spotlight-V100/Store-V1/Stores/0DF7E0C0-E376-45EF-81DC-0F0C64676526/0.indexGroups
mds 30 root txt REG 14,4 2056 435 /Volumes/Spare/.Spotlight-V100/Store-V1/Stores/0DF7E0C0-E376-45EF-81DC-0F0C64676526/0.indexDirectory
mds 30 root txt REG 14,4 8 436 /Volumes/Spare/.Spotlight-V100/Store-V1/Stores/0DF7E0C0-E376-45EF-81DC-0F0C64676526/0.indexCompactDirectory
mds 30 root txt REG 14,4 2731 400 /Volumes/Spare/.Spotlight-V100/Store-V1/Stores/0DF7E0C0-E376-45EF-81DC-0F0C64676526/live.0.indexGroups
mds 30 root txt REG 14,4 1024 406 /Volumes/Spare/.Spotlight-V100/Store-V1/Stores/0DF7E0C0-E376-45EF-81DC-0F0C64676526/live.0.indexCompactDirectory
[...etc...]
Run Code Online (Sandbox Code Playgroud)
这里进程名在第一列,文件路径在最后(而且显示更宽)。在这个例子中,所有的东西都是 mds(Spotlight 的另一部分),它的索引数据库是打开的。
虽然fs_usage
有利于随着时间的推移查看活动(但不会显示打开但不活动的文件),lsof
提供哪些程序正在使用哪些文件的快照(但不会显示它们的活动程度,并且会错过那些文件)重新打开,使用,然后立即关闭)。总之,这些工具可以很好地了解正在发生的事情。
归档时间: |
|
查看次数: |
1919 次 |
最近记录: |