UbuntuThis forum is for the discussion of Ubuntu Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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
Normally linux would not kill processes. In the end your swapfile and memory is full and you just get a crash.
So there are 2 fixes here:
1. more memory
2. fix the application if it has a mem leak.
If you had allocated and enabled enough swap space, Ubuntu would use it.
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:
Originally Posted by deadeyes
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).
I'm pretty sure that Ubuntu (unlike Windows) does not default to allocating swap (pagefile) space when needed. The user needs to allocate enough in advance.
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:
Normally linux would not kill processes.
Actually it does kill processes when out of memory.
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.
Distribution: Mandriva 2009 X86_64 suse 11.3 X86_64 Centos X86_64 Debian X86_64 Linux MInt 86_64 OS X
Posts: 2,369
Rep:
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
mahmood@localhost:~$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'vol_id --uuid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
# / was on /dev/sda5 during installation
UUID=2e1d191f-1bc8-4d80-8195-84adf80ffdd3 / ext4 relatime,errors=remount-ro 0 1
# swap was on /dev/sda6 during installation
UUID=60345e61-670e-43de-8087-805603f74c85 none swap sw 0 0
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0
#/home/mahmood/sources/splash.iso /media/splash iso9660 ro,loop,auto 0 0
/dev/sda2 /home/mahmood ext4 nodev,nosuid 0 2
As you can see, the UUID in the ls -l command for SWAP is different from that in the fstab file. Should I only paste that UUID to the fstab file and restart? Are other options " swap sw 0 0" fine?
Distribution: Mandriva 2009 X86_64 suse 11.3 X86_64 Centos X86_64 Debian X86_64 Linux MInt 86_64 OS X
Posts: 2,369
Rep:
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).
Actually it does kill processes when out of memory.
Indeed... you can see that on the screen however then it is too late already.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.