I'm writing a backup script which

  1. Copies the data to backup disk.
  2. Flushes the backup disk.
  3. Performs a hash integrity check.

Before I used to do sleep(60) for waiting a minute so that data is automatically flushed by the kernel. Which I guess is overkill so now I'm trying sudo hdparm -F --verbose /dev/disk but it reports error - HDIO_DRIVE_CMD(flushcache) failed: Invalid exchange multiple times.

I'm wondering is there any standard way to flush the cache to hard disk. I think there is because usb-creator-gtk does it, umount does it.

I'm using Ubuntu x64 9.10

PS: I'm trying to avoid "sync" because this page says that it is not safe. http://ubuntuforums.org/showthread.php?t=589975

Edit
Report