DEV Community

loading...

waybackmachine October 19'

Iru.
Updated on ・3 min read

... because it's always fun to go back in time and remember how it was back then ...

Linux month!

dirtylittlethings :: Linux sysrq to avoid work disruption due to OOM

Finally, this month I spent some € buying more RAM for my desktop computer (was stuck with 8Gb).

Being working with microservices, docker, and Kubernetes, I barely could handle work without having some OOM (out of memory) disruptions that freeze my computer and required a hard-restart during my day.

A good trick I learnt a long time ago when some process starts eagerly taking too much memory, it's to kill it quickly with the Magic SysRq Key

The magic SysRq key is a key combination understood by the Linux kernel, which allows the user to perform various low-level commands regardless of the system's state. It is often used to recover from freezes or to reboot a computer without corrupting the filesystem.

In order to invoke it, the wakeup call key combination is Alt + SysRq followed by the key sequence combination of letters that will force the desired low-lvl commands.

The most famous key sequence is reisub from the acronym of "raising elephants is so utterly boring", which nicely reboots the computer.

But if you don't want to get into such a drastic solution, and just need to kill the most memory consuming process that will provoke the OOM on your system, you can avoid this restart and just kill it! Going back to your business with no big nuisance.

For that, the combination would be Alt + SysRq + rf wich key sequience I remember from "really fucked".

Bear in mind that in order this to work, you have to enable the kernel level sysrq calls.

The easiest way to do this it's just enabling all the levels with the value '1'.

# set value '1'
$ sudo vim /etc/sysctl.d/10-magic-sysrq.conf

# apply config
$ sudo sysctl -p
Enter fullscreen mode Exit fullscreen mode

Give it a try!! Just need to open your favourite browser, open some streaming site on one tab and probably this will be the killing target.

Source: SysRq level setup


dirtylittlethings :: logrotate

$ man logrotate
logrotate ‐ rotates, compresses, and mails system logs.

logrotate is designed to ease administration of systems that generate large numbers of log files. It allows automatic rotation, compression, removal, and mailing of log files. Each log file may be handled daily, weekly, monthly, or when it grows too large

Can't remember how many times I performed a cron-based / manual log purge... shame on me :|

Easy to install and configure.
Probably your Linux system is already making use of it.

$ cat /etc/logrotate.d/dpkg
/var/log/dpkg.log {
    monthly
    rotate 12
    compress
    delaycompress
    missingok
    notifempty
    create 644 root root
}
Enter fullscreen mode Exit fullscreen mode

the w00t? :: The kibibytes!

No, it's not the chibi version of a Kilobyte.

The difference between the Binary Prefix as opposed to the more common Decimal Prefix, is that the first one takes 10 as the base of the power multiplication, while the second is 2 based.

1 GiB = 2^30 = 1.073.741.824 bytes
1 GB = 10^9  = 1.000.000.000 bytes
Enter fullscreen mode Exit fullscreen mode

Because of the industry usage of these 10 based scales, and the deviation that implies the misuse of them, standardization organizations (in this case, the specific the IEC 80000-13:2008 clause 4), created round 1998 the new binary scale system for the base power of 2.

New terms such as kibibyte, mebibyte and gibibyte were born, having the symbols KiB, MiB, and GiB, to denote 1024 bytes, 1048576 bytes, and 1073741824 bytes, respectively.

What a mess in distress!

You can check the usage of these values in common cloud providers nowadays (like Azure, Amazon,..), but the easiest way to check it is just with an ls (list directory content) command.

Take a look at the difference between these three command parameters

$ ls -l
$ ls -lh
$ ls -l --si
Enter fullscreen mode Exit fullscreen mode

takemymoney :: Awesome Linux Software List

These lists always end up in the forget-me-not box but it's worth having a look at it when trying to replace common Windows apps in Linux toolbox.

Hope you find something useful!

Awesome Linux Software List

Discussion (0)