By default, Ubuntu uses 20% of RAM for file caches.
Solution
There are some tunable settings that influence how the Linux kernel deals with the file system cache.All of them are connected with dirty data (or dirty memory) - data that is written into the cache but not saved on disk.
- dirty_ratio - maximum percentage of dirty system memory
- dirty_bytes - the same as dirty_ratio but specified in bytes
- dirty_background_ratio - percentage of dirty system memory at which background writeback will start
- dirty_background_bytes - the same as dirty_background_ratio but specified in bytes
$ sudo bash -c 'echo $((64*1024*1024)) > /proc/sys/vm/dirty_background_bytes'
$ sudo bash -c 'echo $((128*1024*1024)) > /proc/sys/vm/dirty_bytes'
In this case, coping progress shows correct speed, and unmounting takes only several seconds.
To save this setting after reboot it’s required to add such a line into /etc/sysctl.conf:
vm.dirty_background_bytes = 67108864vm.dirty_bytes = 134217728
This option is applied to all disks - external and internal ones what can reduce system performance.