Monday, 24 October 2011

Slow NTFS-3G with Oneiric

This is a short post to inform anyone if ntfs-3g I/O has been painfully slow after upgrading to Oneiric Ocelot (Ubuntu 11.10).


I have always relied rather heavily on the NTFS filesystem. This is because I am not 100% free from using Windows. While Windows is rather annoying to use, some programs such as Microsoft Office simply do not work on Linux. To keep the environment as similar as possible, I have always mounted my Windows partition and have used ntfs-3g, a NTFS driver for Linux to access my 'shared' files.



My $HOME/Desktop/ folder for instance, is symlinked to /mnt/windows/Users/Wookie/Desktop/ so that my desktop can contain the same files on both *buntu and Windows. Now I do admit that this is not in any way an ideal method of doing what I wish to do, and I should really be using rsync for a safer 'syncing'. This has worked thus far though so I felt that I could keep it as it is.

The problem arose when I noticed after almost a full week of Oneiric, that all of my browser downloads (which were downloading to $HOME/Desktop/) were painfully slow. I was getting around 50kBps when I would usually get 500kBps. My write speed was somehow incredibly slow (read speeds were fine). It turned out that the problem was with ntfs-3g.



I tried the following:

  • chkdsk via Windows
  • Disk Defragmenter for all NTFS partitions
  • Many hours of Googling for similar cases

Not one of my Google results showed terrible write speeds with good read speeds. I did fortunately, find this forum post from the Gentoo Forums. It was here that I found a link to http://www.ntfs-3g.org/support.html#slow which was invalid. A quick Google got me the correct link: http://www.tuxera.com/community/ntfs-3g-faq/#slow.

One of the suggested problems was the usage of the sync option while loading the partition. As can be seen in my Oneiric Update post, I had used the option, sync in my ntfs partition entry for /etc/fstab.

/dev/sda2    /mnt/windows    ntfs-3g    sync,rw,user,auto,exec,utf8,uid=1000,gid=100    0    2

Changing the entry to:

/dev/sda2    /mnt/windows    ntfs-3g    rw,user,auto,exec,utf8,uid=1000,gid=100    0    2

and re-mounting the partition with:

sudo umount /mnt/windows
sudo mount /mnt/windows

fixed the problem. I was getting fast speeds of around 40MBps again!


You may be wondering why this has happened with an upgrade. This is because ntfs-3g introduced the 'sync' option only in a recent update! It is mentioned in the changelog:

STABLE Version 2011.1.15 (January 23, 2011)
        New: implemented the ‘sync’ mount option.

So silly me had been using a ghost option without realising it.
Just to make everything clearer, let me tell you about the sync option itself. The Linux man page for mount tells us this:

sync
    All I/O to the file system should be done synchronously. In case of media with limited number of write cycles (e.g. some flash drives) "sync" may cause life-cycle shortening.

So there we go, it's a matter of how often 'write'-ing occurs and obviously, writing speeds in general would decrease if every single byte had to be written immediately (instead of in chunks). As Tuxera's support page mentions: "do not use sync unless you have a good reason".