bash 命令强制关闭 USB 驱动器上的文件
我认为在 bash 脚本中进行同步会强制文件被完全写出。当我查看 U 盘时,它显示了我复制的所有文件,但在电源故障后,U 盘显示 0 个文件。我是否必须手动弹出驱动器,或者我可以在脚本中以编程方式执行某些操作吗?
I thought doing a sync in my bash script would force the file to be completely written out. When I looked at the thumb drive, it showed all the files I had copied, but after a power supply failure, the usb drive showed 0 files. Do I have to eject the drive manually or is there something I can do programmatically in my script?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想从 bash 脚本中弹出 USB 设备,只需在设备上执行简单的
umount
即可。例如If you want to eject the usb device from your bash script a simple
umount
on the device should do the trick. For example如果您的 USB 密钥使用日志文件系统,您还可以尝试使用 linux 同步指令来同步磁盘写入
you can also try to use the linux sync instruction that syncronize writing over disk if you're usb key is using a journalized file system