19

After checking test blog posts from different authors, I know EXT4 is the fastest for 3y already in 2011. However, there are also other settings that make an SSD faster which I found in: http://www.howtogeek.com/62761/how-to-tweak-your-ssd-in-ubuntu-for-better-performance/

sudo gedit /etc/fstab

  • Add to / partition noatime,nodiratime
  • If kernel is >2.6.33, also add discard
  • tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0

And https://wiki.ubuntu.com/MagicFab/SSDchecklist

sudo gedit /etc/fstab

  • Add to / partition noatime, and that's it

  • And the data=writeback mounting option _if you formatted the disk without journaling. Otherwise add data=ordered which s[h]ould be a good compromise between full journaling and none at all.

  • tmpfs /tmp tmpfs nodev,nosuid,noexec,mode=1777 0 0

Why only noatime? How can I know if the disk is without journaling from installation? What's faster? No Journaling or opposite? And diff no journaling data=writeback or journaled data=ordered?

Why tmpfs /tmp differs in both articles, how do they differ, and which is better and why?

All of this is about SSD, but can I use the same settings in HDD? I want to find an answer for HDD and SSD as I've made one-time scripts for setting it up in my https://wiki.ubuntu.com/Kangarooo/AfterCleanInstallation.

4 Answers 4

12

The howtogeek site is the more responsible of the two sites you mentioned. The atime tweaks are just metadata optimization that pipeline when a file will receive a certain timestamp update. It's applicable regardless of the media you use, it also depends on how sensitive your application is to the coherency of that metadata. Most desktop users won't miss it.

Now as for disabling journaling... that's just crazy. That's the whole point of using these advanced file systems: better performance while securing data integrity. Understand that if you make this trade you're exchanging your personal data for a modest increase in speed. I personally wouldn't recommend it. Most people don't keep good backup's to begin with to compensate for taking this risk.

Partition alignment does matter but not tweaking that bit won't kill you either. It really depends on how heavily the disk is accessed. Assuming it's unaligned, if you had tons of I/O going on a regular basis (server) you would see an improvement. On average desktop usage, who knows, probably not appreciable.

I would disregard that Ubuntu wiki you mentioned except for the notion that partition alignment is valuable. Here's a more responsible link:

http://www.ibm.com/developerworks/linux/library/l-4kb-sector-disks/index.html?ca=dgr-lnxw074KB-Disksdth-LX

Some of the recommendations in that Ubuntu wiki are just plain wrong, like the reconfiguration of tmpfs using "nodev". It's already a RAMFS!

Moving firefox cache to /tmp may increase speed in your current session. Though it might be a security hazard (not secured in your home anymore) and it will be rebuilt on each boot since tmpfs isn't persistent.

Summary:

Adding discard to ext4 options is prudent, writeback is the default mode, leave journaling settings alone, the atime tweaks are fine, and the switch to deadline or nop scheduler might also be useful, partition alignment is optional. The rest is bunk.

4
  • The atime tweaks are fine but ultimately pointless. relatime is a great compromise and will only cause an atime write if the file has been modified since last being accessed. This cuts down on atime writes drastically already without losing atime functionality completely.
    – Caesium
    Nov 22, 2011 at 11:48
  • 1
    I agree that relatime is the best compromise however I was limiting my analysis to the facts presented. A lot of these tweaks really don't matter unless you have server workloads. I'm talking about performance, not wear leveling. The most important thing this user can do is enable discard support. I've owned an SSD for 1.5 years now and have never tweaked it, works great, manages its own discards.
    – ppetraki
    Nov 22, 2011 at 13:11
  • 1
    Why would nodev be stupid? It does not make the system aware that the filesystem is a device, but prevents device files from being treated as devices. You can test the different using sudo mknod -m666 test c 1 3 (which creates a file test that acts as a writable null device, i.e. /dev/null). On a filesystem mounted nodev, echo > test and cat test fails, regardless if you run it as root or not.
    – Lekensteyn
    Nov 22, 2011 at 13:47
  • I know what the man page says. Could you please explain then how this has any impact on performance whatsoever, especially in the context of an SSD?
    – ppetraki
    Nov 22, 2011 at 14:56
4

The discard option is no longer suggested for SSD-hosted filesystems, as it slows things down because the Linux kernel has a non-optimized implementation of the command. (IIRC, TRIM requests only use one ATA sector range at a time, making it slow.)

Instead, create a daily cron job that runs fstrim -v / (or whatever your SSD partitions are). This is the solution that Ubuntu 14.04 LTS will be shipping with.

2
  • "discard option is no longer suggested" — Source, please?
    – eMPee584
    Jul 7, 2019 at 13:56
  • 1
    … Found this post by an XFS dev marc.info/?l=linux-xfs&m=133047907914622&w=2: "online discard is not really a smart thing to use for consumer SSDs […] precisely because discard is a very slow and non-queuable operation on most hardware that supports it." So systemctl enable fstrim.timer it is..
    – eMPee584
    Jul 7, 2019 at 14:13
2

In addition to ppetraki's answer, if flash wear is a concern, you should mount a RAM file system for your /tmp folder.

tmpfs /tmp tmpfs defaults,size=15%,mode=1777 0 0
tmpfs /var/tmp tmpfs defaults,size=10%,mode=1777 0 0

But don't move your /var/log files to RAM unless you're sure you won't crash ;) AND you've already installed all your server packages that create new /var/log directories (like apache) and don't like to have them disappear between boots:

tmpfs /var/log tmpfs defaults,mode=0755 0 0 
tmpfs /var/log/apt tmpfs defaults 0 0
none /var/cache unionfs dirs=/tmp:/var/cache=ro 0 0

This is a blend of JR0cket's answer and other blog articles on the topic.

1

Do not enable 'noexec' on /tmp or you will face problem with certain 3D drivers which require executing from /tmp. NVIDIA drivers for modern hardware have this requirement, any application you have will segfault (like xscreensaver glmatrix) if you have 'noexec' enabled.

1
  • So i can add line without noexec? Like this? tmpfs /tmp tmpfs nodev,nosuid,mode=1777 0 0
    – Kangarooo
    May 7, 2012 at 9:17

You must log in to answer this question.

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