Installing Linux on USB – Part 4: noatime and relatime mount options
Welcome to the part 4 of “Installing Linux on USB” series. In part 3 we discussed which filesystems to use for USB hard drives and USB flash drives respectively. In this part we will discuss what are the differences between atime, noatime and relatime mount options for filesystems and how can they be used in case of USB flash drives to get better performance and extend the life of your USB flash drive. Although we are focusing on USB devices in this series, the content that is discussed in this post is almost true for any PATA/SATA drives also if you want to get better performance.
atime, noatime and relatime are basically mount options for file system like ext2, ext3, etc. By default all the file systems in Debian are mounted with atime option implicitly.
Let’s understand the meaning of these options:
1. atime – This option causes Linux to record the last (or latest) time when a particular file was accessed. This information is particularly helpful for sysadmins or some programs (specially mail programs) to know when a particular file was last used/accessed.
Downside of atime: However there is a big performance issue associated with using atime – too many unnecessary writes are being generated. For example, every time when is accessed (say read) a write to disk is made to update it’s last accessed time which indeed is a very expensive operation. Imagine a write for every read operation. This is true for files which are read from disk and cache. This causes a notable performance issue which often gets ignored by a novice Linux user.
Famous kernel developer Ingo Molnar said the following:
Atime updates are by far the biggest IO performance deficiency that Linux has today. Getting rid of atime updates would give us more everyday Linux performance than all the pagecache speedups of the past 10 years, _combined_.
2. noatime – This option stops recording the last file access time when the file is just read. The noatime option eliminates all the writes to the disk each time a file was just read which previously used to happen with atime. However a write is made to a disk in case if a file is being changed/written.
However some people say that this can causes some program to break:
Unfortunately, turning off atime unconditionally will occasionally break software. Some mail tools will compare modification and access times to determine whether there is unread mail or not. The tmpwatch utility and some backup tools also use atime and can misbehave if atime is not correct. For this reason, distributors tend not to make noatime the default on installed systems.
Also Debian’s popularity contest program (popcon) make use of last access time. So it might report bad data to Debian servers.
By turning this option on (= turning off atime), you can see a significant increase in performance of your Linux system. Linus Torvalds, creator of Linux kernel, said the following:
But yeah, “noatime,data=writeback” will quite likely be *quite* noticeable (with different effects for different loads), but almost nobody actually runs that way.
3. relatime – A filesystem mount with this option causes the access time to be updated if they are (before the update has occurred) earlier than the modification time. This significantly cuts down the writes caused by atime updates. However not many people use this option because they are simply not aware of it. Linus Torvalds noted the following:
The “relatime” thing that David mentioned might well be very useful, but it’s probably even less used than “noatime” is. And sadly, I don’t really see that changing (unless we were to actually change the defaults inside the kernel).
There was a patch written by Ingo Molar to make this option this the default option (for ext filesystems) in the kernel itself rather than relying on userspace tool like mount. However it still hasn’t made to the mainline kernel as of 2.6.28.
To summarize, relatime is a good compromise between atime (most expensive) and noatime (least expensive).
If you are looking for a technical discussion on atime and performance issues, please read this LKML thread.
If you are looking for a further technical discussion on relatime v/s noatime, please read this LKML thread.
How do I make my filesystem to use relatime or noatime feature?
There are many ways to do this. I will list some of them.
Method 1: Select the mount options during installation itself
In Debian Lenny:
As you can see the “defaults” are selected for your filesystem which basically means atime is enabled by default. Simply click on “defaults” line and you will get following options:
After select when you hit continue you will see something like this:
Now upon finishing installation when you boot your system your filesystem will use noatime and relatime attributes and should give you better performance.
Method 2: Through mount command
To use noatime give following command:
mount -o remount,noatime /
To use relatime give following command:
mount -o remount,relatime /
However these changes are not permanent and will be gone once you reboot/shutdown your system. To make these changes permanent you need to make changes to your /etc/fstab file as follow:
Method 2:: Through fstab file
Generally your fstab file will look like this if you did not select the mount options in Method 1 (during installation) above:
# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
/dev/sda1 / ext2 errors=remount-ro 0 1
/dev/sda5 none swap sw 0 0
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto 0 0
The above output means atime is enabled even though it is not listed anywhere because it is the default behavior.
Now we need to add the noatime or relatime option like this:
# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
/dev/sda1 / ext2 noatime,relatime,errors=remount-ro 0 1
/dev/sda5 none swap sw 0 0
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto 0 0
Note: You don’t need to give both the options (noatime and relatime) at the same time. You can either give noatime or relatime. However it seems that both the options can be given together.
Now after saving the fstab file in order to make these changes take effect you can either:
1. Reboot your system
2. Give the following command:
mount -o remount /
You can verify if the changes took effect or not by following command:
# cat /proc/mounts
rootfs / rootfs rw 0 0
none /sys sysfs rw,nosuid,nodev,noexec 0 0
none /proc proc rw,nosuid,nodev,noexec 0 0
udev /dev tmpfs rw,size=10240k,mode=755 0 0
/dev/sda1 / ext2 rw,noatime,relatime,errors=remount-ro 0 0
tmpfs /lib/init/rw tmpfs rw,nosuid,mode=755 0 0
usbfs /proc/bus/usb usbfs rw,nosuid,nodev,noexec 0 0
tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0
devpts /dev/pts devpts rw,nosuid,noexec,gid=5,mode=620 0 0
#
Hopefully this post has shed enough light as to how to get more performance out of your computer of which you weren’t aware.
As usual, please leave a comment/feedback if you have any. Comments encourages bloggers to post more and keep their spirits high.
Also please don’t forget to rate this post below.
Part 5: Installing Debian Linux on USB flash memory drives





Email Subscription









January 30th, 2009 at 1:49 am
[...] Part 4: noatime and relatime mount options [...]
February 3rd, 2009 at 11:38 pm
[...] mount options to “noatime” and “relatime”. We discussed all this in our part 4 of this [...]
February 3rd, 2009 at 11:49 pm
[...] Part 4: noatime and relatime mount options [...]
February 27th, 2009 at 1:21 pm
here are my /etc/fstab entries in Mandriva 2009
it seems that the realtime option is enabled by default, no wonder it works faster than ubuntu.
# Entry for /dev/sda5 :
UUID=b95b4f73-769f-452f-83df-6829c5145231 / ext3 relatime 1 1
# Entry for /dev/sda7 :
UUID=1938fe72-dc4c-46c8-8b37-10f4643ead03 /home ext3 relatime 1 2
/dev/sr0 /media/cdrom auto umask=0,users,iocharset=utf8,noauto,ro,exec 0 0
none /proc proc defaults 0 0
# Entry for /dev/sdb3 :
UUID=e29468e7-a7cb-4854-8b59-334bbb8ad3d1 /share ext3 relatime 1 2
# Entry for /dev/sda6 :
UUID=d5ce2a19-e6c5-42c7-a382-e6998e7611af swap swap defaults 0 0
thanks for sharing this i really had no idea about this.
Reply to this comment
Mike Reply:
November 18th, 2010 at 9:27 am
No need to bash Ubuntu. Relatime is the default in Ubuntu. My fstab entries say “relatime.”
Reply to this comment
January 24th, 2011 at 7:05 pm
I have a fedora server in my company having 2.6.26 kernel, when i saw the /proc/mounts file, i found relatime being enabled. Neither i nor anyone else made any changes, does it come by default now.
Reply to this comment
tunak tunak Reply:
July 3rd, 2012 at 7:13 am
das es goot!
Reply to this comment
October 20th, 2011 at 3:15 am
[...] noatime mount option GA_googleAddAttr("AdOpt", "1"); GA_googleAddAttr("Origin", "other"); GA_googleAddAttr("theme_bg", "ffffff"); GA_googleAddAttr("theme_text", "444444"); GA_googleAddAttr("theme_link", "cd4517"); GA_googleAddAttr("theme_border", "2F2019"); GA_googleAddAttr("theme_url", "AD92C3"); GA_googleAddAttr("LangId", "1"); GA_googleAddAttr("Autotag", "technology"); GA_googleAddAttr("Tag", "disk-management"); GA_googleAddAttr("Tag", "file-system"); GA_googleAddAttr("Tag", "linux"); GA_googleAddAttr("Tag", "technical"); GA_googleAddAttr("Tag", "device-file"); GA_googleAddAttr("Tag", "ext2"); GA_googleAddAttr("Tag", "ext4"); GA_googleAddAttr("Tag", "file-system"); GA_googleAddAttr("Tag", "hard-disk-drive"); GA_googleAddAttr("Tag", "journaling-file-system"); GA_googleAddAttr("Tag", "linux"); GA_googleAddAttr("Tag", "ntfs"); GA_googleFillSlot("wpcom_sharethrough"); Share this:FacebookTwitterMoreStumbleUponRedditDiggLike this:LikeBe the first to like this post. [...]
September 3rd, 2012 at 8:39 am
[...] Relatime mount option Resizing virtual machine harddrives [...]