Sync your data in Linux

Assuming that you are using linux. If you are copying some content to your USB stick or copying file from one disk to another disk. If you want to ensure the data is safely copied, then sync is the command for you.
The man page says
sync writes any data buffered in memory out to disk. This can include (but is not limited to) modified superblocks, modified inodes, and delayed reads and writes.
This must be implemented by the kernel; The sync program does nothing but exercise the sync(2) system call.

$ cp somebigfile.doc  /mnt/usbdisk/
$ sync
# umount /mnt/usbdisk

Leave a Reply

Your email address will not be published. Required fields are marked *