Re: How to flush cache of certain disk?
On Thu, 06 May 2010 12:46:19 +0300, Alexander Batischev wrote:
> On my netbook I'm using automatic USB sticks mount through udev rules,
> and I already used to running 'sync' command before unplugging stick, so
> no data will be lost. But if I have few sticks inserted and some
> information copying on one of them, if I run 'sync' I have to wait while
> copying ends, because:
>
> a) sync command drops cache on disk, but copying process fill it again;
> sync will work until all the caches are dropped to disks
Dunno if this would fit your needs, but there is a "sync" option for
mount points you can use to ensure all removable devices (or only the
ones you select) get mounted with "-o sync" flag.
But I would be a bit reluctant to use that, because as per "man mount"
page that flag can shorten the life of flash drive based devices with a
limited number of write operations.
> b) I can't unplug stick when it stops to flash because I can't be sure
> that there are no more parts of cache needed to be flushed on that disk.
>
> So here is my question - how can I run sync for only one device?
To avoid data loss you have to "umount" the device first (or just "eject"
if that options is available in your system). Umount/eject operation
should care the data is correctly stored in the media before powering off
or unplugging the device.
Greetings,
--
Camaleón
Reply to: