Can I get tar to not use the filesystem cache when reading files?
I think this has been answered here:
There is the nocache utility, which can prepended to a command like ionice and nice. It works by preloading a library which adds
posix_fadvise
with thePOSIX_FADV_DONTNEED
flag to any open calls.In simple terms, it advises the kernel that caching is not needed for that particular file; the kernel will then normally not cache the file. See here for the technical details.
It does wonders for any huge copy jobs, e. g. if you want to backup a multi terabyte disk in the background with the least possible impact on you running system, you can do something along
nice -n19 ionice -c3 nocache cp -a /vol /vol2
.