I have written a tutorial about speed up Ubuntu response time by optimizing the usage of swap area, and that’s avoiding swapping processes out of physical memory for as long as possible. Here’s another way using
ramdisk to get better performance and fast response for Ubuntu.
Ramdisk is part of system memory. Ubuntu by default uses a half of physical memory (RAM) as ramdisk, and it is mounted onto
/dev/shm, it can be used just like normal disk space (create files and folders and manipulate them with better performance rather if they were stored on the hard disk). If ramdisk uses more than a half of RAM, data will be moved into the swap space. If ramdisk uses less, the remaining can still do what RAM’s doing.
Set upper limit of ramdisk
As is said above, ramdisk by default can use a half of RAM. If you want to change the upper limit, follow the steps below:
1. Edit /etc/fstab by your favourate editor:
gksudo gedit /etc/fstab
2. Find this line and change to make it looks like this(add this line if not exist, and change 512M to what you like.):
tmpfs /dev/shm tmpfs defaults,size=512M 0 0
3. Reboot or re-mount
Mount /tmp onto ramdisk
To make it easy to use, you can mount a directory into
/dev/shm by following commands:
mkdir /dev/shm/tmp chmod 1777 /dev/shm/tmp mount --bind /dev/shm/tmp /tmp