21

I have a low profile machine but with a lot of fast RAM, 4 Gb, which is really an amount of memory that i probably will never use, not even an half, since i just use this machine for coding and browsing the web.

The HDD is really slow and so the overall performance are bad when booting, caching or starting new program, I'm wondering if Ubuntu can provide some setting or utility to solve this situation and let my system rely more on the RAM usage.

Glutanimate
  • 21,763
user1717079
  • 313
  • 1
  • 2
  • 4

4 Answers4

13

You should install Preload which will preload the software you use the most in your RAM (it'll learn which software to preload on its own). That's very easy to setup:

sudo apt-get install preload

You probably don't need to touch it, but if you want you can edit the options in /etc/preload.conf

Ugo
  • 390
11

You can add the following line to /etc/fstab to mount your /tmp directory into the RAM.

tmpfs   /tmp       tmpfs   defaults,noatime,nodiratime,mode=1777   0  0

This can be done with other directories, too. E.g. when you are compiling your code you can put the folder where the object files are placed and linked into RAM.

But pay attention. Data in folders that are mounted this way will be lost on any case of shutdown. Keep that in mind.

Besides from my knowledge there are many other helpful ressources available on this topic. For example this thread.

cauon
  • 1,733
  • 12
  • 21
6

What is RAM?

RAM, or random access memory, is a type of storage system known as volatile storage. That is, it only holds data while it has power. In other words, any changes you make to it, if you don't write it to a persistent storage device, will be lost at any time the RAM loses power.

What is a hard drive?

Hard drives, or disk drives (or hard disk drives), are a different type of storage system known as persistent storage. This means that the data stays even when deprived of power. CDs, DVDs, floppy disks, and USB thumb drives also fall under this category.

What happens when I boot, write to cache, or start new programs?

In order to maintain your system between reboots, the OS has to write what it has in the RAM into a persistent storage device, usually the primary hard drive. Conversely, in order to restore that information, or to start applications, it has to load that data into the RAM from the storage device. This even happens with live CDs, even though everything is running in memory, it has to first read everything from the CD (or USB drive). It also happens even with the tools/ideas cauon and Ugo have suggested, because at some point or another, data has to be read from or written to a disk in order to persist between boots (specifically Preload will not improve boot time).

If you have fast RAM, then your bottleneck will be somewhere in the read from/write to disk process, usually either in the speed of the data connection or the speed of the drive.

What can I do to improve the speed of these operations?

To improve the speed of all three of your mentioned operations, you'll need to do some hardware upgrading.

Get a faster connection. Parallel ATA connections (PATA, the gray ribbon in older machines) is going to be slower than SATA connections (Serial ATA, the newer, smaller cables). If you can and haven't already, upgrade to a SATA drive. If you go the USB drive route (outlined below), then make sure you're using a USB 2.0 (or, even better, speed-wise, 3.0) drive and port. USB devices and ports will clock down to the speed of the slower thing, so even if you have a 3.0 port, if the device it 2.0, you will only get 2.0 speeds.

Get a faster storage device. Platter-based hard drives are measured in RPMs, and generally come in three speeds - 5400 rpm, 7200 rpm, and 10k rpm. If you have a 5400 rpm drive, upgrade to at least a 7200. Additionally, Solid State drives (including USB thumb drives) are faster than platter-based drives. If you can afford it, upgrade to a solid state drive. Alternatively, you can install Ubuntu on a USB drive and run it from there (keep in mind, though, that such a set up will be limited to the speed of your USB port, so make sure you use at least a USB 2.0 port and drive).

Shauna
  • 3,034
1

try zram (once called compcache), it is a compressed swap in the memory!

the package for ubuntu 12.10 is zram-config, no need to boot.

swapon -s will show something like:

Filename                                Type            Size    Used    Priority
/dev/sda2                               partition       1023860 0       -1
/dev/sdc4                               partition       976892  0       -2
/dev/zram0                              partition       761876  0       5
/dev/zram1                              partition       761876  0       5
/dev/zram2                              partition       761876  0       5
/dev/zram3                              partition       761876  0       5

I have 6GB ram and 4 core cpu, so one swap for each core using half in a total, of the ram! (for a good reason)

Read what ppl is saying about compcache and zram!

well, if non zram are being used, boot or try to, IYKWYAD (if you know what you are doing), swapoff them, to see zram ones be filled and improve overall performace.