Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there a way to sync only one partition instead of all partitions?

Something like "sync /dev/sdc1".

share|improve this question
1  
No. As far as I am aware. Good question, though. –  Nikhil Mulley Jan 7 '12 at 19:26

4 Answers 4

If you mean the sync utility that flushes data in memory to disk, then the answer is no. This is due to the fact that sync is generally used during a shutdown or reboot procedure, where it's advisable to get data written safely to disk, and the real target of the operation is memory, not the disks, and getting that buffered data out of RAM to somewhere safe. The disks are just where the data ends up.

share|improve this answer

Mounting the partition with the sync option may be a solution.

share|improve this answer

you can remount with sync option and then remount it back with async:

mount -o remount,sync /mountpoint
mount -o remount,async /mountpoint

Using remount option will not mess with processes using remounted filesystem.

share|improve this answer

There is a standard function to synchronize data (and metadata) of one file: fsync. There is no standard or common shell command to access it, but you can use perl's sync method in IO::Handle:

perl -MIO::File -e 'new IO::File($ARGV[0], "r+")->sync()' filename

There is no standard or common function or shell command to synchronize just one partition.

On recent Linux systems, there is the syncfs system call (introduced in kernel 2.6.39, and exposed since glibc 2.14). I don't think this system call is exposed in coreutils or util-linux yet.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.