Sometimes my Ubuntu 16.04 LTS (i3 and 4GB RAM) system hangs so badly that I cannot copy paste text.

I normally have System Monitor open to monitor my usage, and when I check it I find that I have enough resources for hang-free usage.

System Monitor shows CPU load 5-10% with only 1 spike >50% and around 50% free memory

What should I inspect? System Monitor seems unreliable? I have enough HDD free space.


Hard Drive specifications

Command: sudo smartctl -a /dev/sda

Result:

smartctl 6.5 2016-01-24 r4214 [x86_64-linux-4.4.0-121-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===

Model Family: Western Digital Blue Mobile
Device Model: NDC ND10JPVX-7SJC3T0
Serial Number: WXC1A17AD6CD

LU NNN Device Id: 5 0014ee 607557602
Firmware Version: 02.01A02

User Capacity: 1,000,204,886,016 bytes [1.00 TB]

Sector Sizes: 512 bytes logical, 4096 bytes physical

Rotation Rate: 5400 rpm

Device is: In smartctl database [for details use: -P show]
ATA Version is: ACS-2 (minor revision not indicated)

SATA Version is: SATA 3.0, 6.0 Gb/s (current: 6.0 Gb/s)

Local Time is: Fri May 4 09:48:31 2018 IST

SMART support is: Available - device has SMART capability.
SMART support is: Enabled
  • Well, you are swapping. What does top show for memory usage? – ubfan1 May 2 at 2:54
  • ill try to get that screenshot when it hangs. its difficult to take details when it hangs bad. will still try. – Srinath Ganesh May 2 at 3:00
  • to add in more points, it mostly happens after I have some heavy Graph Database operations that hangs and I kill those processes. – Srinath Ganesh May 2 at 3:01
  • 1
    Is the OS 32 bit or 64 bit? What about the Graph Database? Regarding taking a screenshot, you could take a photo with your phone, or SSH in from a different system and leave top running. That way, you could take screenshot of the terminal (or even copy and paste the terminal text) on the non-hung system. – mpb May 2 at 3:11
  • Its a 64 bit Ubuntu 16.04 LTS (i3 and 4GB RAM), I generally do some heavy processing of Apache TinkerPop library on NEO4J DB. Then it takes up all the RAM and a lot of swap memory, and many times processor. But then I kill all the processes that of Java then the System Monitor reports a drop in usage, and it looks like the load is low. but some how for 5mins+ my System becomes very un-responsive. I'll try the mentioned things to get more details. – Srinath Ganesh May 2 at 3:17
up vote 2 down vote accepted
+100

This question has many possible answers:

What type of hard drive does the computer has?

If you have a regular HDD what's making your system to hang is the swapping process, the OS is using hard drive memory to store information that should be stored in RAM.

If you're using a SSD drive swapping is also slow but not as much as the first case. Check your 'swappiness' by reading /proc/sys/vm/swappiness file, default is 60, you could try changing it to 10 (or even less) and see what happens. This way the system will swap only when 90% of the RAM memory is busy.

From : https://www.kernel.org/doc/Documentation/sysctl/vm.txt

swappiness

This control is used to define how aggressive the kernel will swap memory pages. Higher values will increase agressiveness, lower values decrease the amount of swap.

The default value is 60.

To change the swappiness level your need to run this command:

echo 10  | sudo tee --append  /proc/sys/vm/swappiness

You can also try lower values.

If nothing works, you should consider upgrading to 8 GB RAM or running heavy processes on a cloud virtual machine (AWS, Google Cloud, etc.)

  • added HDD info i.stack.imgur.com/4JI9y.png – Srinath Ganesh May 4 at 5:01
  • 1
    Your hard drive is really slow! You have a 5400 rpm drive. – Philippe Delteil May 4 at 14:16
  • Let me know if you have any improvements changing the swappiness level. – Philippe Delteil May 4 at 14:17
  • first attempt of disabling swapping meant almost all of 4gb RAM was used, going to try a few more things of percentage threashold – Srinath Ganesh May 4 at 14:33
  • 2
    Yes, nowadays 4 GB it's a very small amount of memory. My cellphone has more RAM. I can't work properly without at least 12 GB. Any chance of updating your hardware? – Philippe Delteil May 5 at 3:35

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.