bash 命令强制关闭 USB 驱动器上的文件

发布于 2025-01-05 00:01:26 字数 113 浏览 2 评论 0原文

我认为在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

挽清梦 2025-01-12 00:01:26

如果您想从 bash 脚本中弹出 USB 设备,只需在设备上执行简单的 umount 即可。例如

mount /dev/usb /mnt/usb
# Your copy operations here... then on success:
umount /mnt/usb

If you want to eject the usb device from your bash script a simple umount on the device should do the trick. For example

mount /dev/usb /mnt/usb
# Your copy operations here... then on success:
umount /mnt/usb
喵星人汪星人 2025-01-12 00:01:26

如果您的 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文