Script Detection of Processor Architecture

Larry Lindsey gtg306b at
Fri May 19 00:01:54 CEST 2006

I'm trying to write a script that will automagically detect what kind of CPU the
machine its running on has, so that I can tell FAI which of a set of precompiled
kernels it should install, from a list of 586mmx, p3, p4, or amd-k8.

I'd also like to determine the number of processors running on the machine, to
tell FAI whether to install an SMP-enabled kernel or not.

Unforunately, I can't depend on checking which architecture the currently
running kernel is (could be a 386-targetted kernel running on a dual AMD64, for

I've tried the uname -m and arch commands, but these don't seem to differentiate
between the various i686 architectures, for instance. Parsing the "model name"
field of /proc/cpuinfo doesn't work, either, for instance, because of the
various kinds of Xeons on the market (the model name doesn't reflect what kind
of core the Xeon is based on, and there are several of these).

One thing that might work would be to build a look-up table based on the "cpu
model" "family" and "stepping" fields in /proc/cpuinfo, but I haven't been able
to find one that is anything near complete.

Is there anything I'm overlooking? Does anyone know how to do this?

Thanks in advance.

More information about the linux-fai mailing list