9

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.

1 Answer 1

8

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).

6
  • you called it exactly. I am using usb 3.0 external drives. The system only supports 2.0 and has 48 GB of ram. Would a 3.0 card help that much? My transfers as is are anyway well under 10 mb/s which is well below the 2.0 maximum, which is why I don't understand why it can't write in the run-time. Jan 24, 2014 at 15:49
  • Thank you, will try the fix and it should do exactly what I need. Thank you again. Jan 24, 2014 at 15:54
  • I am not sure if an USB3 drive would help a lot. Surely it will help... If it helped please upvote the answer, and if it solves the problem remember to mark it as the solution to help others.
    – Rmano
    Jan 24, 2014 at 15:54
  • Was wondering what is up with my USB sticks. Thanks for the answer.
    – inimene
    Apr 16, 2016 at 10:33
  • 1
    @ssi-anik modern Ubuntu has systemd, and things are quite more complex. I have to admit that I lost touch a bit, but unix.stackexchange.com/questions/471824/… seems to have answers
    – Rmano
    Nov 9, 2021 at 18:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .