我对这个问题的回答是将其他几个帖子的回答(非常感谢)和我自己的经验结合在一起的结果。
背景:我有一个带NTFS文件系统的外部硬盘驱动器。我想偶尔插入。以前,该卷将挂载为“只读”。一旦修复该问题,卷上的文件就处于无法使用的状态。为了正确安装卷并使文件可访问,我必须执行以下操作:
仅供参考:我是一个知识分子用户。将这些命令调整为您喜欢的外壳。
$ sudo ksh
<password>
$ mv /sbin/mount_ntfs /sbin/mount_ntfs.orig
$ vi /sbin/mount_ntfs
然后粘贴以下内容:
#!/bin/ksh
# --- direct all script stdout to a temp file for examination
exec > /tmp/ntfs
# --- connect all stderr to stdout
exec 2>&1
# --- get the last argument on the command line - this is the mount point
eval echo \$$# |
read MOUNT_PT
echo "\${MOUNT_PT} = \"${MOUNT_PT}\""
echo
echo "Mounting $@"
# --- call the original ntfs mounter with the arguments handed in
/sbin/mount_ntfs.orig -o rw "$@"
echo "Mounted $@"
# --- show the result of the mounting operation
mount
# --- fix files at the newly mounted MOUNT_PT that are in the 'brok' state
find "${MOUNT_PT}" -type f |
while read FILE; do
# ---
# --- use 'SetFile' to modify the file status
# ---
# --- this command line assumes the 'SetFile' command has been installed
# --- and is available in your PATH
# ---
SetFile -c "" -t "" "${FILE}"
done
然后:
$ chmod a+x /sbin/mount_ntfs
$ chown root:wheel /sbin/mount_ntfs
现在,每当我插入磁盘时,都会将其安装为“读/写”,并且磁盘上的文件会重置为“ brok”状态。该脚本对我来说效果很好。你的旅费可能会改变。
请享用 -