How to make Linux faster
Posted: Mon Feb 22, 2010 6:08 pm
I am going to start by saying a couple of things. First off, thanks Fred for helping me sort this out. Second is that don't do this if you're not comfortable messing with fstab or the command line. Third is I take no responsibility if it borks your PC. (It shouldn't though). Fourth, please read the tutorial completely and make sure you understand it. If you don't, either don't do this, or ask questions. Just make sure you know what's going on. And finally, if you have a desktop PC, make sure you have a battery backup. Turning off journaling and having a power failure=bad times. Laptops will likely be okay as they have their own battery...
To start off, I will tell you a bit about atime. Basically it writes to the file you have done anything with, whether it's creating it, modifying it, or reading it. This can cause slowdowns cause it makes the disk spin more than it needs to. So what we want to do is simply turn it off. This way when you open a file, it will not write the atime, saving you from having your disk spin (more than necessary). This is great if you have USB linux distributions installed, as it will minimize writing to the disk, saving the USB disk. If the prospect of noatime is too much for you, inserting relatime will be a good option. This way, it only writes to atime if permissions (chmod/grp) or last write is later than the atime currently recorded. So basically, if you open a file, close it, and open it again, it wouldn't adjust atime.
Another note, cause the examples are long they may go to the next line. If this is the case, use the code copy and place it in a text editor without line-wrap on. This will give you the proper view then.
Now to dig into the how to.
First, switch to a root terminal with
We're going to keep using the root terminal, so don't exit it.
Next we edit the fstab.
It should look something like this:
Now anytime you see an ext4, change the types, add (for ext3 change it to barrier=0):
to it. I will demonstrate so you know where to stick it.
Save it and close gedit.
Make sure that when you add ,noatime,data=writeback,commit=60,nobarrier that there are no spaces in between the comma and the option. This will not work otherwise, and I don't know if/how much it could screw your PC up.
Now we're almost done, but don't forget to add this last step, or you could render your OS unbootable. In the root terminal:
and replace xx with the disk number.
For instance, since I did this to partition 1 and 3, I would have to do
And finally, if you want to keep the partition in the future but install another distro on it, make sure you use
on those partitions to turn them back to normal.
Thanks for reading and good luck!
To start off, I will tell you a bit about atime. Basically it writes to the file you have done anything with, whether it's creating it, modifying it, or reading it. This can cause slowdowns cause it makes the disk spin more than it needs to. So what we want to do is simply turn it off. This way when you open a file, it will not write the atime, saving you from having your disk spin (more than necessary). This is great if you have USB linux distributions installed, as it will minimize writing to the disk, saving the USB disk. If the prospect of noatime is too much for you, inserting relatime will be a good option. This way, it only writes to atime if permissions (chmod/grp) or last write is later than the atime currently recorded. So basically, if you open a file, close it, and open it again, it wouldn't adjust atime.
Another note, cause the examples are long they may go to the next line. If this is the case, use the code copy and place it in a text editor without line-wrap on. This will give you the proper view then.
Now to dig into the how to.
First, switch to a root terminal with
Code: Select all
sudo su
Next we edit the fstab.
Code: Select all
cp /etc/fstab /etc/fstab.bak
gedit /etc/fstab
Code: Select all
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
/dev/sda1 / ext4 errors=remount-ro 0 1
/dev/sda3 /home ext4 defaults 0 2
/dev/sda2 none swap sw 0 0
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0
Code: Select all
noatime,data=writeback,commit=60,nobarrier
Code: Select all
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
/dev/sda1 / ext4 errors=remount-ro,noatime,data=writeback,commit=60,nobarrier 0 1
/dev/sda3 /home ext4 defaults,noatime,data=writeback,commit=60,nobarrier 0 2
/dev/sda2 none swap sw 0 0
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0
Make sure that when you add ,noatime,data=writeback,commit=60,nobarrier that there are no spaces in between the comma and the option. This will not work otherwise, and I don't know if/how much it could screw your PC up.
Now we're almost done, but don't forget to add this last step, or you could render your OS unbootable. In the root terminal:
Code: Select all
tune2fs -o journal_data_writeback /dev/sdxx
For instance, since I did this to partition 1 and 3, I would have to do
Code: Select all
tune2fs -o journal_data_writeback /dev/sda1
tune2fs -o journal_data_writeback /dev/sda3
Code: Select all
sudo tune2fs -o journal_data_ordered /dev/sdxx
Thanks for reading and good luck!