Detecting amount of memory?

Corey Kovacs cjk at techma.com
Tue Dec 21 13:41:06 UTC 2010


Another way to do this is grep for the zone info from dmesg and do the calcs on that info. You need to account for low mem as well which is usually about 800+kb. Also dma etc. I can't remember if dmidecode is available during a kickstart but you could also run that and grep for the dimms (Size: ) should let you see what I mean assuming your not building VMs. 

Sent from my iPod

On Dec 21, 2010, at 1:00 PM, Ohad Levy <ohadlevy at gmail.com> wrote:

> bc will round the value down,  you need to change your calculation to round up  or using a different scale.
> 
> You would need to try it out, maybe something in the spirit of :
> 
> echo "scale 1; $memKB/1024.... |bc
> if memGB -ge 5.5 ...
> 
> Ohad
> 
> 
> On Tue, Dec 21, 2010 at 2:18 PM, Patrick Lists <ks-list at puzzled.xs4all.nl> wrote:
> Hi,
> 
> I trying to create a kickstart script on CentOS 5.5 that installs an RPM
> depending on the amount of memory in the box. For example if the box has
> >= 6GB memory then install RPM2 else install RPM1. With some Googling I
> now have the following snippet:
> 
> %pre
> memKB=$(free|grep Mem|awk '{print$2}')
> memGB=$(echo "($memKB/1024)/1024"|bc)
> BIGMEM=""
> if [ "$memGB" -ge 6 ]; then
>    BIGMEM="6GB"
> fi
> 
> %post
> yum install foobar$BIGMEM-1.0-1.rpm
> 
> The problem is that on a box with 6GB memory this snippet says it does
> not have 6GB mem:
> 
> memKB = 6123716 KB
> memGB = 5 GB
> 
> Anyone know what I am doing wrong?
> 
> Thanks!
> Patrick
> 
> _______________________________________________
> Kickstart-list mailing list
> Kickstart-list at redhat.com
> https://www.redhat.com/mailman/listinfo/kickstart-list
> 
> _______________________________________________
> Kickstart-list mailing list
> Kickstart-list at redhat.com
> https://www.redhat.com/mailman/listinfo/kickstart-list

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/kickstart-list/attachments/20101221/ff1af5a7/attachment.htm>


More information about the Kickstart-list mailing list