using pagefile in ubuntu
When the memory usage reaches 95% and above I noticed that the disk activity and load graphs go up and some of my applications are killed by the system. In windows, if someone define a pagefile then the OS will try to use it at the expense of very slow response. Why ubuntu does not use SWAP in such a way?
Thanks for any reply, |
Ubuntu does use swap.
The reason why disk activity is going up is due to swap space being space alocated on disk(which is the same principle as pagefile in windows). As disks are slow this give you indeed a large performance hit. You can see the swap usage if you execute: Code:
free -m So there are 2 fixes here: 1. more memory 2. fix the application if it has a mem leak. |
But my applications are killed. I saw many times that the virtualbox for example is killed.
|
Quote:
Typically that is done by creating a swap partition when you install Ubuntu. But it can be done later adding a swap partition and/or a swap file. Quote:
Lack of memory may be causing disk usage due to paging anonymous pages to and from the swap space. But also due to paging non anonymous pages from other files. If there is no swap space or too little swap space, the anonymous pages are forced to stay in ram, resulting in more disk activity to swap the non anonymous pages. Quote:
Depending on the mix of memory use by the various processes, adding swap space would stop it from killing processes but probably not stop it from slowing down with excess disk activity when a lot is running. But maybe adding swap space would fix that as well. |
With 2GB RAM, here is the "fdisk -l" output:
Quote:
|
First find out if the swap space is already enabled. Please post the output of free -m as deadeyes suggested.
|
Code:
mahmood@localhost:~$ free -m |
Sda6 seems to be you're swap file
Sda6 do have a UUID In you're fstab file you should find sda6 under his UUID To find the UUID sudo su ls -l /dev/disk/by-uuid If you have discover the UUID sudo su nano /etc/fstab and add it to you're fstab file Instead of nano you can use kwrite or pico ore any other real linux text editor |
Code:
mahmood@localhost:~$ sudo ls -l /dev/disk/by-uuid/ Code:
mahmood@localhost:~$ cat /etc/fstab currently the "free -m" command shows: Code:
mahmood@localhost:~$ free -m |
The UUID you get from the command ls ls -l is the correct one
YOu should change the UUID in the FSTAB file accordingly Every time you delete and create a partition the UUID can change. |
fdisk shows there is a swap partition. free shows the swap partition isn't enabled.
It appears ronlau9 knows this topic a bit better than I do, but I'll ad a few details. I think changes for swap in fstab will take effect the next time you reboot. You might want to add the swap without rebooting or add it in a way that gives you better feedback if something else is wrong. (You would still need to fix fstab so the swap would be enabled on subsequent reboots). I think the command to enable the swap before reboot is sudo /sbin/swapon -U uuid (replacing uuid with the same value you also edit into fstab). Alternately, after editing fstab sudo /sbin/swapon -a That will use the info you put in fstab. I'm not sure, but it may be necessary to prepare the swap partition with mkswap before doing the swapon or the reboot. So if swapon fails, try using sudo /sbin/mkswap /dev/sda6 But first double check that sda6 is really the partition you have reserved for swap (in case something has changed since the fdisk output from post #5). |
Thanks,
I also used Code:
sudo mount -a Code:
mahmood@localhost:~$ free -m |
Quote:
Your output of free -m seems fine. Your swap is active and should be more then enough. As I said before, probably this is just getting a little more time before your system crashes anyway. As disk is used as memory, access will be slower, more swapping will be needed and this is a spiral effect. |
All times are GMT -5. The time now is 09:06 AM. |