View Full Version : HOW TO: mount /tmp to ram for increased preformance.
modmadmike
January 29th, 2009, 12:05 PM
If you watch a lot of youtube video's or run a lot of programs that cache to /tmp you will notice that it can be incredibly slow while multi-tasking because the other programs are using the disk too. As long as you have enough ram you can mount /tmp as to your ram. However, use at your own risk - programs that cache backup data to /tmp (Like firefox [although open office does not]) will not be able to restore your previous session after rebooting. If that is no problem then continue on reading.
Open your /etc/fstab as root in your favourite text editor (I will be using gedit because it is by far the most simple) by launching it from the terminal.
sudo gedit /etc/fstab
Add this line to the end.
##RAMDISK##
none /tmp tmpfs defaults,size=424m 0 0
You can change the size to whatever amount you want in megabytes but do not go over half of your ram. <Ctrl>+<s> and <Ctrl>+<q>
Reboot, yes this is needed, you can mount -a but its pointless because then your xserver will crash because the display property will become unset.
Enjoy much faster website loads!
Also a tip for youtube users, the video is stores in /tmp so you dont need to use a flash down-loader to save a youtube video - just copy the file to your folder of choice after watching it.
EDIT*
The size parameter is optional as I have found out from experience so you might want to use this instead to save RAM!
##RAMDISK##
none /tmp tmpfs defaults 0 0
EDIT**
Okay I just found out how to do this without rebooting but its not quite as simple. Continue from the last step before rebooting, exit everything, and <ctrl>+<F1>. Enter your username and password. Run these commands.
sudo -i
gdm stop
rm -fR /tmp/*
mount /tmp ##or mount -a
gdm restart
EDIT***
Do not use this trick if you use proprietary types of enterprise software, because they store files in /tmp for security reasons.
waster
March 27th, 2009, 08:02 PM
not sure about the value of this (RAM caches disk anyway), but you certainly don't need the 1 and 2 at the end.
From man /etc/fstab:
The fifth field, (fs_freq), is used for these filesystems by the dump(8) com‐
mand to determine which filesystems need to be dumped. If the fifth field is
not present, a value of zero is returned and dump will assume that the
filesystem does not need to be dumped.
The sixth field, (fs_passno), is used by the fsck(8) program to determine the
order in which filesystem checks are done at reboot time. The root filesys‐
tem should be specified with a fs_passno of 1, and other filesystems should
have a fs_passno of 2. Filesystems within a drive will be checked sequen‐
tially, but filesystems on different drives will be checked at the same time
to utilize parallelism available in the hardware. If the sixth field is not
present or zero, a value of zero is returned and fsck will assume that the
filesystem does not need to be checked.
modmadmike
March 27th, 2009, 08:08 PM
oh noes!!!!!!!!!! my /etc/fstab disappeared after using webmin (and looking to update it)!!!!!!!!!!!! better not restart no matter what till I fix this lol!
modmadmike
March 27th, 2009, 08:10 PM
oh phew I just typed /ect/fstab instead of /etc/fstab rofl
Bossieman
April 2nd, 2009, 02:23 PM
Thanks! Works like a charm!
dcstar
April 3rd, 2009, 02:54 AM
If you watch a lot of youtube video's or run a lot of programs that cache to /tmp you will notice that it can be incredibly slow while multi-tasking because the other programs are using the disk too. As long as you have enough ram you can mount /tmp as a ramdisk.
.......
A tmpfs mount is NOT a "ramdisk" mount. A "ramdisk" is a totally different thing that is set up with a kernel boot parameter and removes a set amount of RAM for use.
A tmpfs mount will use your Virtual Memory as required, which will be RAM as well as Swap, so in a heavily loaded system it could well be using disk space.
http://en.wikipedia.org/wiki/TMPFS
Using /tmp in this manner can certainly improve "performance", but it also can cause issues in things like DVD creation if a temporary image file (~8GB) happens to be created in that folder.....
Cowchip7
April 16th, 2009, 09:07 AM
I am thinking about trying this out, since I have 2gb ram. If I wast to reverse the changes I made, I am assuming I would only have to enter:
sudo gedit /etc/fstab
and then delete the following line of code (the code I previously added). Is that correct?
##RAMDISK##
none /tmp tmpfs defaults 0 0
:popcorn:
binbash
April 16th, 2009, 09:44 AM
I am thinking about trying this out, since I have 2gb ram. If I wast to reverse the changes I made, I am assuming I would only have to enter:
sudo gedit /etc/fstab
and then delete the following line of code (the code I previously added). Is that correct?
##RAMDISK##
none /tmp tmpfs defaults 0 0
:popcorn:
Yep
modmadmike
April 28th, 2009, 06:32 PM
A tmpfs mount is NOT a "ramdisk" mount. A "ramdisk" is a totally different thing that is set up with a kernel boot parameter and removes a set amount of RAM for use.
A tmpfs mount will use your Virtual Memory as required, which will be RAM as well as Swap, so in a heavily loaded system it could well be using disk space.
http://en.wikipedia.org/wiki/TMPFS
Using /tmp in this manner can certainly improve "performance", but it also can cause issues in things like DVD creation if a temporary image file (~8GB) happens to be created in that folder.....
Thanks for pointing that out, but at the time it seemed simpler to use the term "ramdisk" lol
yakshbuntu
August 13th, 2011, 11:14 PM
If you watch a lot of youtube video's or run a lot of programs that cache to /tmp you will notice that it can be incredibly slow while multi-tasking because the other programs are using the disk too. As long as you have enough ram you can mount /tmp as to your ram. However, use at your own risk - programs that cache backup data to /tmp (Like firefox [although open office does not]) will not be able to restore your previous session after rebooting. If that is no problem then continue on reading.
Open your /etc/fstab as root in your favourite text editor (I will be using gedit because it is by far the most simple) by launching it from the terminal.
sudo gedit /etc/fstab
Add this line to the end.
##RAMDISK##
none /tmp tmpfs defaults,size=424m 0 0
You can change the size to whatever amount you want in megabytes but do not go over half of your ram. <Ctrl>+<s> and <Ctrl>+<q>
Reboot, yes this is needed, you can mount -a but its pointless because then your xserver will crash because the display property will become unset.
Enjoy much faster website loads!
Also a tip for youtube users, the video is stores in /tmp so you dont need to use a flash down-loader to save a youtube video - just copy the file to your folder of choice after watching it.
EDIT*
The size parameter is optional as I have found out from experience so you might want to use this instead to save RAM!
##RAMDISK##
none /tmp tmpfs defaults 0 0
EDIT**
Okay I just found out how to do this without rebooting but its not quite as simple. Continue from the last step before rebooting, exit everything, and <ctrl>+<F1>. Enter your username and password. Run these commands.
sudo -i
gdm stop
rm -fR /tmp/*
mount /tmp ##or mount -a
gdm restart
EDIT***
Do not use this trick if you use proprietary types of enterprise software, because they store files in /tmp for security reasons.
Thanks
DroidVPN
December 1st, 2011, 10:26 AM
A tmpfs mount is NOT a "ramdisk" mount. A "ramdisk" is a totally different thing that is set up with a kernel boot parameter and removes a set amount of RAM for use.
A tmpfs mount will use your Virtual Memory as required, which will be RAM as well as Swap, so in a heavily loaded system it could well be using disk space.
http://en.wikipedia.org/wiki/TMPFS
Using /tmp in this manner can certainly improve "performance", but it also can cause issues in things like DVD creation if a temporary image file (~8GB) happens to be created in that folder.....
Do you know how to setup a real ramdisk?
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.