12.04 NTFS – Fix Ubuntu Unmounting Drive Takes Forever

12.04ntfsunmount

I have Ubuntu 12.04 and when I try to unmount a drive after copying data, the Writing Data to Device takes forever, maybe as long and the copy process?
This is another thread about this: Unmounting drive in Xubuntu

As an explanation, I am backing up a file server using rsync, specifically grsync, one large folder at a time. So I finish a 1 TB backup which may take a full day or 24 hours (many small files), simply unmounting the drive can take hours or days when it says it is "writing data to disk". If I kill it then I get file system errors and have to fix them in windows which takes a while.

I tried different disks with similar results. It seems that Ubuntu either does not write or just writes poorly and/or causes file-system errors.

Is it possible to stop this, maybe disable write-back cache or something, just to make sure when I write something to disk, it is written completely without needing to write more when un-mounting. Thank You.

Best Answer

Are you using a 64-bit version of Linux with a lot of memory and the attached disk is a relatively slow one (any USB 2 will qualify)?

In that case the problem could be that Linux can locks/delay for long time on big writes on slow devices; it depends on caching too much data during writes. It's a known bug that should be fixed in newer kernels.

See http://lwn.net/Articles/572911/

Workaround: enter a shell root (do that with care --- you are now root for every command)

sudo -i

and issue:

echo $((16*1024*1024)) > /proc/sys/vm/dirty_background_bytes
echo $((48*1024*1024)) > /proc/sys/vm/dirty_bytes

If it works, you can add the two lines above to your /etc/rc.local file.

(This is a repost of my answer in U&L SE).

Related Question