23

Some times my laptop gets stuck due to excessive usage of RAM when I open bulky applications. So if it does not respond I shut down the laptop using the power button. Does this damage Ubuntu in any way? Can it give rise to security problems or vulnerabilities?

Braiam
  • 67,791
  • 32
  • 179
  • 269
M.Tarun
  • 5,001
  • 6
  • 33
  • 64
  • 3
    There's a good list of what to do when Ubuntu freezes that can help you out of the 'stuck computer' problems, which you can try before resorting to the power button. – Charles Green Jun 24 '14 at 13:31
  • 1
    If it's swapping like mad and not responding to input, you can try waiting a few hours. Odds are good that whatever program is causing the problems will allocate too much memory and be killed by the OS, at which point the system will stabilize and be usable again. – Mark Jun 25 '14 at 04:28
  • 1
    I always figure if the computer's been frozen for a while, and the hard drive's quiet, then either everything's been written to disk, or it's not going to be. – Wossname Jun 25 '14 at 05:13
  • How does one detect if an SSD is quiet(er)? – Nate Lockwood Jun 27 '14 at 13:39

5 Answers5

17

It won't cause security problems or vulnerabilities.
But it can cause damage on your OS and loss of data depending on the tasks that are running at the time.
That being said, your computer still shouldn't get stuck at high ram usage.

Pabi
  • 7,401
  • 3
  • 40
  • 49
6

Obviously you will loose the amount of data that is in your RAM at that time and hasn't been written to disk, yet. Also there is a theoretical chance of data/file-system corruption.

From my own experiences I can tell you that I'm hard-resetting my PC 4-5 times a day over the last 5 years and never had the problem of corrupted filesystems. I think ext3/ext4/ufs are pretty robust for this kind of failures.

In opposite to this I think NTFS is far more prone to this. On my Windows gaming rig I have a ~15% chance of file system corruption after a blue-screen and I'll have to to boot from disk to run a file system repair tool in that case ... **sigh**

s1lv3r
  • 358
  • 5
  • 14
  • 10
    why would you need to hard-reset that often? – Bogdacutu Jun 24 '14 at 19:09
  • ...in particular with a Linux kernel running. Of course on Windows, I'm still quite familiar with the lovely feeling of a couple of BSODs in a single day, but kernel panics I've only experienced like... 5 times in total or something. Swap-caused almost-freezes are rather more common of course (hardly the OS's fault), but this isn't really a reason for hard-reset, is it? Normally still quite easy to top out the process or just killall it. – leftaroundabout Jun 24 '14 at 23:00
  • 1
    @leftaroundabout: Kernel panics aren't the only way a system goes down; they're just one of the few ways the OS tells you about. :) Every month or so, my laptop likes to act up by leaving little bits of garbage on the screen for a little while before it just totally freezes. (I think my video card is flaking out.) Happens about the same in Windows, about as frequently...though Windows occasionally blue screens. (Seems it tries harder to recover and limp along.) – cHao Jun 25 '14 at 03:21
  • @Bogdacutu some drivers, especially video drivers, including intel, nouveau, and even nvidia blob, are quite a crap. I've experienced really frequent Oopses, which often led to full freeze, as well as just GPU hangs, all of which made me hard reset. Sometimes SysRq+REISUB worked, other times I just had to press reset button (or hold power button on laptops). – Ruslan Jun 25 '14 at 07:26
  • 1
    An ext4 filesystem can not be corrupted, which Ubuntu normally uses, because ext4 has a journal (half-written data will be discarded on next boot). – Ramchandra Apte Jun 25 '14 at 09:17
  • @RamchandraApte ironically, while it cannot, it sometimes does. – Ruslan Jun 25 '14 at 12:04
  • @Ruslan Could you elaborate? Your hard disk could be having problems. – Ramchandra Apte Jun 25 '14 at 14:53
  • @RamchandraApte: Unless ext4 is fully transactional (which i'm fairly certain it's not), you could easily half-write a file. Say you're incrementally creating a file, opening it and appending to it each time you have more data to put in it. Each write looks independent and complete. If the power cuts out during this process, the journal looks OK, but the file is in between "nothing" and "correct". – cHao Jun 25 '14 at 14:54
  • @RamchandraApte: And that's not even mentioning the caches on hard drives these days. A sync flushes the OS's buffers to the appropriate drives, but a drive might not write that data right away -- let alone in the order that the OS was told to. And all this assumes that everything works as advertised. :P – cHao Jun 25 '14 at 14:56
  • @RamchandraApte also, not only an HDD could be a reason — simplest problem could be kernel bugs, including bugs in the FS implementation. And, as cHao says, you're idealizing ext4 as a whole. – Ruslan Jun 25 '14 at 14:57
  • 1
    @Bogdacutu it's related to wine, I have to run a application which makes it freeze the system sometimes ... – s1lv3r Jun 26 '14 at 09:14
2

You run the risk of causing filesystem inconsistencies. It is better, even when out of RAM, as this normally still works in such situations, to use the alt-sysrq sequence, as that will attempt to shut things down as cleanly as possible (if it fails, then you're no worse off than if you pressed the power button, but if it succeeds then you're potentially better off). The sequence is as follows:

Hold down the alt key and the key marked "sys rq" at the same time (if you're on a laptop you might well need to hold down a special key on the laptop to get to the "sys rq" function). With those keys held down, press and release the following letters in the following order:

  1. R - this regains control of the keyboard from any applications that have grabbed keyboard focus
  2. E - attempt to cleanly terminate all processes
  3. I - attempt to immediately terminate all processes (will get rid of everything that failed from previous key)
  4. S - sync all filesystems (this is the most important part)
  5. U - remount all filesystems read-only (sometimes this is needed to flush data to disk)
  6. B - perform hard reboot (replace with O to turn off the power instead of rebooting)
1

Maybe this will help a little, by default ubuntu and others swappiness are set to 60 , when your system reaches 60% of ram usage it changes to swap which is slow.

  1. Open this file on gedit or nano using: gksudo gedit /etc/sysctl.conf OR sudo nano /etc/sysctl.conf

  2. Add this to the end of the file: vm.swapiness = 0

  3. Save the file and reboot.

Also when it gets slow you should check if it is really using swap which slows down the system, otherwise the above changes wont help.

Parto
  • 15,325
  • 24
  • 86
  • 117
user297579
  • 11
  • 1
0

In my case I don't hard boot intentionally, it happens on electrical trip and every time this so called ext4 corrupted. I run fsck on advanced boot. I can login afterwords but network manager stops working. Some dpkg dir lock. I end up in re installation. My MAC is for better here even WINDOWS .

tinlyx
  • 3,230