Sunday, June 4, 2017

How to estimate available physical memory on Linux?




Several resources around the net (apologies for not having links handy) recommend to determine the total amount of available physical memory on a Linux system by the second value on the "-/+ buffers/cache" line in the output of free, with the explanation that buffers and cache may be discarded immediately if a process tries to allocate more memory than is unused at the time ("Mem:" line of free). I've found this statement to be consistently empirically wrong, meaning allocating more memory than is "unused" fails frequently.



Researching about this, I've found the "MemAvailable:" line in /proc/meminfo, and this explanation:



Subject: provide estimated available memory in /proc/meminfo

Many load balancing and workload placing programs check /proc/meminfo
to estimate how much free memory is available. They generally do this
by adding up "free" and "cached", which was fine ten years ago, but

is pretty much guaranteed to be wrong today.

It is wrong because Cached includes memory that is not freeable as
page cache, for example shared memory segments, tmpfs, and ramfs,
and it does not include reclaimable slab memory, which can take up
a large fraction of system memory on mostly idle systems with lots
of files.

Currently, the amount of memory that is available for a new workload,
without pushing the system into swap, can be estimated from MemFree,

Active(file), Inactive(file), and SReclaimable, as well as the "low"
watermarks from /proc/zoneinfo.


My problem is that the system available for me to run my programs on has a 3.2.0 kernel which apparently does not provide "MemAvailable".



My question: How can I (approximately) compute the amount of available physical memory myself, using that memory information that is available to me?



MemTotal:       16536344 kB
MemFree: 8615224 kB

Buffers: 241896 kB
Cached: 1341944 kB
SwapCached: 100232 kB
Active: 5320768 kB
Inactive: 2021312 kB
Active(anon): 4298508 kB
Inactive(anon): 1483164 kB
Active(file): 1022260 kB
Inactive(file): 538148 kB
Unevictable: 32 kB

Mlocked: 32 kB
SwapTotal: 9918460 kB
SwapFree: 7730432 kB
Dirty: 56 kB
Writeback: 0 kB
AnonPages: 5720696 kB
Mapped: 103628 kB
Shmem: 23432 kB
Slab: 432516 kB
SReclaimable: 356780 kB

SUnreclaim: 75736 kB
KernelStack: 7320 kB
PageTables: 69764 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 18186632 kB
Committed_AS: 12325296 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 120924 kB

VmallocChunk: 34351227352 kB
HardwareCorrupted: 0 kB
AnonHugePages: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
DirectMap4k: 103240 kB
DirectMap2M: 16738304 kB



PS: I realize the actual computation is detailed in the kernel patch I linked to, but I'm having a hard time relating this to the output that is available to me.


Answer



Here's a Perl script that estimates MemAvailable for kernel versions older than 3.14:



https://github.com/famzah/linux-memavailable-procfs



It replicates the same calculations done in the kernel, but using only info available to user-space in pre-3.14 kernels.


Friday, June 2, 2017

windows 8 - External monitor connection works with HDMI but not VGA

I smashed my laptop screen so I have to use an external monitor. I can connect with an HDMI cord but not with VGA. I want VGA so I can listen to sound via headphones on the laptop, it's an Acer E1 series running Windows 8. Can anyone suggest a solution to get the VGA connection working?

Windows 7 login screen show only last user and "Other User" icons after profile problem



I recently had a profile problem with my Windows 7 PC. My original profile in the registry had ".bak" appended to it and a new profile was created. I was unable to login with the new profile. I fixed this immediate problem by logging on in safe mode. This enabled me to restore my original profile.



However, since that moment the login screen now operates differently. Instead of showing icons for all the users with accounts on the PC, it now only shows two icons. The first icon is the last user who logged on and the second icon always shows "Other User". I have tried several different solutions recommended by other people with similar problems, but none of them have fixed the problem. I think the person who started this thread has the same problem, but none of the proposed solutions helped him either.



Any help much appreciated.


Answer




I'm on a domain here, so I can't verify my ideas, but concerning the newest post in the thread you linked to, here is my thinking:



To display the user accounts and their profile images windows must scan the
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\
subkeys of the registry. If there are some some half-broken entries left after your repair of the user account, Windows cannot reliably read that profile. Instead of just skipping the profile and displaying the rest, which would practically disable the half-broken profile, it goes into the alternate logon mode. That mode doesn't need to display all the icons and names, and allows you to enter any profile's username. One could say it's somewhat more "robust" in this respect.



So my suggestion is to go to the ProfileList\ in the Registry and look for broken, double or superflous entries and export-then-delete them. Don't try renaming them, because ALL the subkeys of this entry are scanned, regardless of the names.



This is also in line with Ibrahim77's solution oveer there which basically is: except for your Administrator account, delete all profiles, delete all ProfileList\ Subkeys, delete all Profile Folders and start anew.


backup - Flash based storage. Do i need to re-plug them back in to my PC from time to time? (Memory cards & SSD's)

I've bought some memory cards for the purpose of backing up & storing my pictures and videos in case my PC's hard drive fails or the data on it becomes unreadable. The hard drive may not fail for a few years and so i'm wondering if from time to time i need to insert the memory cards back into the PC for it to somehow re-energise them or check the files on the cards for problems? I'm aware they retain data when the power is switched off, but does it need refreshing from time to time? I got wondering because of reading that hard drives need to have their data refreshed from time to time to stop data degradation, but i'm unsure if this applies to flash based storage too.



I suspect not, but actually don't really know for sure and so apologies if it seems like a bit of a dumb question. I would hate to plug the cards back in-in a few years only to find that i didn't apply standard procedures. Is there a recommended time limit before the cards should be replaced with complete new copies too?



I'm now thinking of buying a solid state drive too but would only want to turn it on once per year when i do the yearly album and movie backup. Would the same question about memory cards ect also receive the same answer when applied to SSD's too, if the SSD was left on a shelf?



I suppose my question could just be: Is it ok to leave memory cards or SSD's on the shelf for a few years at a time without ever plugging them back in?



Many thanks for any help.

keyboard shortcuts - Lotus Notes 8.5 and 9: On Workspace, menu not accessible with Alt+[char], but Alt followed by [char] works

I am a frequent user of key shortcuts and I noticed, that menu shortcuts (for example Alt+F for File, Alt+V for View) do not work on Workspace page set as Home (I do not use Welcome page from bookmarks.nsf). When I press Alt, release it (menu gets focus) and then shortcut letter (F or V from previous example), menus are shown as expected.


This happens when the client starts. Once I open any database and return to workspace, menu shortcuts work. This problem is reproduced with startpage instead of workspace - unless I open any application, menu shortcuts don't work.


Preferences "Show extended accelerators" and "Use Accessibility Keyboard navigation" seem to have no effect on this.


Is there anything I can do with that?


OS: Windows 7 Enterprise x64. Lotus Notes Release 9.0 SHF141

linux - How do I make a bootable USB flash drive that can run memtest?

It seems that the canonical instructions for making a bootable USB flash drive that runs memtest are at:


http://forum.canardpc.com/showthread.php?t=28875


However, after following them to a T, I boot up the new machine and get:


"could not find kernel image: linux"


Do I need to set up a lilo.conf first?

New laptop battery charging only until 37% and keeping alive after reaching 0%

I just bought a new battery for my laptop (Sony VAIO). When I plugged it the first time it was 66% charged. I use it until I reached 5% and after that I started charging it. It just got charged until 46%, after one or two more iterations of the same process, it only charges now until 37%.


The funny thing is that when it reaches 0%, I am able to use the battery like half an hour more. Is like the charging values have been shifted (from 100% to 37% and from 0% to negative value) weird isn't it?


Has anybody seen this behavior before that can make some suggestion on how fix it?


Thanks in advance.

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...