Skip to content

Linux sync Guide

Mattscreative edited this page Dec 5, 2025 · 2 revisions

Linux sync Guide

Complete beginner-friendly guide to sync on Linux, covering Arch Linux, CachyOS, and other distributions including flushing buffers, data synchronization, and safe shutdown preparation.


Table of Contents

  1. Understanding sync
  2. sync Basics
  3. Buffer Flushing
  4. Safe Shutdown
  5. Troubleshooting

Understanding sync

What is sync?

sync flushes file system buffers.

Uses:

  • Flush buffers: Write cached data to disk
  • Data safety: Ensure data is written
  • Shutdown preparation: Prepare for shutdown
  • Data integrity: Maintain data integrity

Why it matters:

  • Data safety: Ensures data is saved
  • System stability: Prevents data loss
  • Shutdown safety: Safe system shutdown

sync Basics

Flush Buffers

Basic usage:

# Flush all buffers
sync

# Writes all cached data to disk

Multiple Calls

Safe flush:

# Multiple sync calls
sync; sync; sync

# Ensures all data is written

Buffer Flushing

Write Cached Data

Force write:

# Force write cached data
sync

# Writes all buffered data to disk

Specific Filesystem

Filesystem sync:

# Sync specific filesystem
sync /dev/sda1

# Syncs specific device

Safe Shutdown

Before Shutdown

Prepare shutdown:

# Before shutdown
sync

# Then shutdown
sudo shutdown -h now

Before Unmount

Before unmounting:

# Before unmount
sync
sudo umount /mnt

# Ensures data is written

Troubleshooting

sync Not Found

Check installation:

# sync is part of coreutils
# Usually pre-installed

# Check sync
which sync

Summary

This guide covered sync usage, buffer flushing, and data synchronization for Arch Linux, CachyOS, and other distributions.


Next Steps


This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.

Clone this wiki locally