拔 U 盘前先执行 sync 刷盘

强制把内核缓存的写入全部落盘,避免拷贝'显示完成'却丢数据的坑。

Linux文件系统磁盘命令行落盘同步低风险
运行 sync(也可以指定目标:sync /挂载点),等命令符返回即表示所有缓存写入已写到存储介质上。

01命令

命令
$ sync

02作用说明

Linux 为了速度会把写入先缓存在内存里,所以文件管理器里'拷贝完成'并不代表数据已经真正写到盘上。sync 会请求内核把脏页和缓冲全部刷到磁盘;GNU coreutils 版本还支持只刷新某个文件或挂载点。命令返回时内核已确认数据落在存储介质上——这就是为什么拷贝大文件后进度条走完了,U 盘指示灯还要闪一阵。

03风险

风险低风险
使用条件coreutils (preinstalled)
!注意: sync 不会卸载设备,拔 U 盘仍应使用弹出/umount;如果 sync 卡住几分钟不返回,磁盘很可能出故障了。

04撤销

✓无需撤销——该命令不会改变持久状态。

05来源

  • sync(1) — Linux man page
    man7.org · community · 2026-09-17
    依据: Man page states sync 'synchronize cached writes to persistent storage' and documents -f/--data and -d options; confirms 'sync' and 'flush' semantics in the text.
  • sync(1) — Debian man page (coreutils)
    Debian manpages · community · 2026-09-17
    依据: Man page describes flushing file system buffers: 'force changed blocks to disk, update the super block', confirming the flush behavior.

最后验证: 2026-09-19 · 分类: 文件与文件夹

06相关方案