четвъртък, 30 юли 2015 г.

How to clean up tmpfs without rebooting

The problem: my /tmp is always full.
I manually deleted stuff from it (it's generally safe) and also from /var/tmp (which might not be that safe) but this didn't help. It turned out the problem is that systemd mounts /tmp into the RAM trough tmpfs (or at least I understand it so, I might be wrong). So even though /tmp as a directory is empty, it's still full somewhere on the RAM. Which creates problems, because even though I have plenty of RAM, the system thinks your tmpfs is full, because its size is the one written in /etc/fstab
.
One thing to do is to change the memory limit to a higher number, but this makes sense only if you know how to reset the tmpfs. Well, it turned out there is a way.
Zero step: check with:
$df
that the problem is indeed in /tmp and not that your disk is simply full. 

Then, first before deleting anything, check that there's nothing important in your running apps that needs it. You can do:
$lsof /tmp
$fuser -m /tmp
To see what is currently using the /tmp directory. I guess it's a good idea to stop those processes before proceeding.
In mode details:
jane@linux $ fuser -m /tmp 
/tmp:                 2229  2258  3869c  6464 13163m 21380
jane@linux $ ps auxw|grep 21380
jane  7241  0.0  0.0  92088  2448 pts/1    S+   16:31   0:00 grep --colour=auto 21380
jane  8456  1.5  2.0 1856540 341412 ?      Sl  Jul28  46:02 /usr/lib64/firefox/plugin-container /usr/lib64/nsbrowser/plugins/libflashplayer.so -greomni /usr/lib64/firefox/omni.ja -appomni /usr/lib64/firefox/browser/omni.ja -appdir /usr/lib64/firefox/browser 21380 plugin
jane 21380 12.9 23.8 5670228 3889432 ?     Rl   Jul28 395:20 /usr/bin/firefox
Then you kill whatever is on your way.
Afterwards, you need to become
$su
And then 
$umount -l /tmp/
$mount  /tmp/
And ideally, you're a happy person. This should work safely, but still, it's a good idea to close or save anything important for you before umounting /tmp.
Btw, there is a way to turn off the mounting of the tmpfs to RAM by:
echo 'MINTMPKB=0' > /etc/default/mountoverflowtmp
but people are not recommending that and I didn't do it.

You can also mount /tmp with:
$mount -t tmpfs -o size=1048576,mode=1777 overflow /tmp
where the size should be whatever you like. Which probably is the better way to mount it, because automatically, it mount is with size=8156484, which probably is related to the amount of free RAM, but I'm not sure.
You can check your free RAM with:
$free -m -t

понеделник, 22 юни 2015 г.

Restart plasma-desktop without logging out

It turns out this is quite easy and works fine:
Alt+F2
killall plasma-desktop
Alt+F2
plasma-desktop & 
And that's it. It will take couple of seconds but it loads ok. Also, killing krunner and restarting it from Konsole doesn't seems to be a problem. For those of you, which see something like 4GB for plasma-desktop and 2GB for krunner. 
By the way, this seems to be the problem also with "kdesu firefox" not working (it returns a stub). 

четвъртък, 9 април 2015 г.

Cool uses of sed

I really fell in love with this site: sed - 20 examples to remove / delete characters from a file . 
To remove first character only if it is a specific character:
$ sed 's/^F//' file > file.new
Pretty cool when you need to deal with 10 000 incompatible ways to comment in Fortran.
Also, one Fortran note to self:
To fix deprecated assign to and go to:

(a) change each of the ASSIGN N TO NEXT (where N is some number) statement to a simple NEXT = N statement (where N is the same number), and

(b) replace each of the GO TO NEXT, (x, y, z, ...) statement with the following computed goto statement

GO TO (1,2,3,4,5,6,7,8,9,10,11) NEXT