How to make Linux faster

Write tutorials here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Do not start a support topic here please. Before you post please read this

How to make Linux faster

Postby Acid_1 on 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
Code: Select all
sudo su

We're going to keep using the root terminal, so don't exit it.

Next we edit the fstab.

Code: Select all
cp /etc/fstab /etc/fstab.bak
gedit /etc/fstab


It should look something like this:
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


Now anytime you see an ext4, change the types, add (for ext3 change it to barrier=0):
Code: Select all
noatime,data=writeback,commit=60,nobarrier

to it. I will demonstrate so you know where to stick it.

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


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:
Code: Select all
tune2fs -o journal_data_writeback /dev/sdxx

and replace xx with the disk number.

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


And finally, if you want to keep the partition in the future but install another distro on it, make sure you use
Code: Select all
sudo tune2fs -o journal_data_ordered /dev/sdxx

on those partitions to turn them back to normal.

Thanks for reading and good luck!
Last edited by Acid_1 on Wed Feb 24, 2010 12:01 am, edited 6 times in total.
Website: Forkwhilefork
User avatar
Acid_1
Level 5
Level 5
 
Posts: 817
Joined: Thu Nov 01, 2007 11:12 pm
Location: Saskatchewan, Canada

Linux Mint is funded by ads and donations.
 

Re: How to make Linux faster

Postby remoulder on Mon Feb 22, 2010 6:21 pm

Good stuff, we'll blame you when everyone starts trashing their systems then! :lol:

Acid_1 wrote:when you open a file, it will not write the atime, saving you from having your disk spin


Bit unsure about this bit though. Surely the disk has to be spinning to read the file in the first place?
[Edit] your original post and add [SOLVED] once your question is resolved.

“The people are my God” stressing the factor determining man’s destiny lies within man not in anything outside man, and thereby defining man as the dominator and remoulder of the world.
User avatar
remoulder
Level 17
Level 17
 
Posts: 7667
Joined: Fri May 09, 2008 1:14 pm

Re: How to make Linux faster

Postby Acid_1 on Mon Feb 22, 2010 6:28 pm

remoulder wrote:Good stuff, we'll blame you when everyone starts trashing their systems then! :lol:

Acid_1 wrote:when you open a file, it will not write the atime, saving you from having your disk spin


Bit unsure about this bit though. Surely the disk has to be spinning to read the file in the first place?


You're correct. I suppose it would've been better worded as keeping the writes down.
Website: Forkwhilefork
User avatar
Acid_1
Level 5
Level 5
 
Posts: 817
Joined: Thu Nov 01, 2007 11:12 pm
Location: Saskatchewan, Canada

Re: How to make Linux faster

Postby Fred on Mon Feb 22, 2010 10:12 pm

Acid_1,

A couple little points.
Now anytime you see an ext2/3/4, change the types, add

Code: Select all
noatime,data=writeback,commit=60,nobarrier

This is for ext4 only. For ext3 it has to be "barrier=0" instead of "nobarier." I know it is silly that they did that but they did. :-)

Also, ext2 doesn't have a journal so "data=writeback" and "nobarrier" are not options that are available in that file system.

To reiterate the cautions, when you are using writeback and/or nobarrier power failures are a big deal. Data corruption/lose is likely to occur if a power failure occurs. That is why UPS is recommended for desktops.

Fred
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

Re: How to make Linux faster

Postby Acid_1 on Wed Feb 24, 2010 12:02 am

Thank you Fred. Your advice has been heeded and added to the tutorial.
Website: Forkwhilefork
User avatar
Acid_1
Level 5
Level 5
 
Posts: 817
Joined: Thu Nov 01, 2007 11:12 pm
Location: Saskatchewan, Canada


Return to Tutorials

Who is online

Users browsing this forum: No registered users and 13 guests