32-bit, 64-bit CPU op-mode on Linux

19,460

Solution 1

lscpu is telling you that your architecture is i686 (an Intel 32-bit CPU), and that your CPU supports both 32-bit and 64-bit operating modes. You won't be able to install x64 built applications since they're built specifically for x64 architectures.

Your particular CPU can handle either the i386 or i686 built packages. There are a number of ways to verify your architecture & OS preferences.

lscpu

As you're already aware, you can use the command lscpu. It works well at giving you a rough idea of what you're CPU is capable of.

$ lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
CPU(s):                4
Thread(s) per core:    2
Core(s) per socket:    2
CPU socket(s):         1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 37
Stepping:              5
CPU MHz:               1199.000
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              3072K
NUMA node0 CPU(s):     0-3

/proc/cpuinfo

This is actually the data provided by the kernel that most of the tools such as lscpu use to display. I find this output a little nice in the fact that it shows you some model number info about your particular CPU. Also it will show you a section for each core that your CPU may have.

Here's output for a single core:

$ cat /proc/cpuinfo 
processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 37
model name  : Intel(R) Core(TM) i5 CPU       M 560  @ 2.67GHz
stepping    : 5
cpu MHz     : 1466.000
cache size  : 3072 KB
physical id : 0
siblings    : 4
core id     : 0
cpu cores   : 2
apicid      : 0
initial apicid  : 0
fpu     : yes
fpu_exception   : yes
cpuid level : 11
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 sse4_2 popcnt aes lahf_lm ida arat tpr_shadow vnmi flexpriority ept vpid
bogomips    : 5319.74
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:

Here's what the first 3 lines of each section for a core looks like:

$ grep processor -A 3 /proc/cpuinfo
processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 37
--
processor   : 1
vendor_id   : GenuineIntel
cpu family  : 6
model       : 37
--
processor   : 2
vendor_id   : GenuineIntel
cpu family  : 6
model       : 37
--
processor   : 3
vendor_id   : GenuineIntel
cpu family  : 6
model       : 37

The output from /proc/cpuinfo can also tell you the type of architecture your CPU is providing through the various flags that it shows. Notice these lines from the above command:

$ grep /proc/cpuinfo | head -1
    flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 sse4_2 popcnt aes lahf_lm ida arat tpr_shadow vnmi flexpriority ept vpid

The flags that end in _lm tell you that your processor support "long mode". Long mode is another name for 64-bit.

uname

This command can be used to determine what platform your kernel was built to support. For example:

64-bit kernel

$ uname -a
Linux grinchy 2.6.35.14-106.fc14.x86_64 #1 SMP Wed Nov 23 13:07:52 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux

32-bit kernel

$ uname -a
Linux skinner.bubba.net 2.6.18-238.19.1.el5.centos.plus #1 SMP Mon Jul 18 10:07:01 EDT 2011 i686 i686 i386 GNU/Linux

This output can be refined a bit further using the switches, [-m|--machine], [-p|--processor], and [-i|--hardware-platform].

Here's that output for the same above systems.

64-bit

$ uname -m; uname -p; uname -i
x86_64
x86_64
x86_64

32-bit

$ uname -m; uname -p; uname -i
i686
i686
i386

NOTE: There's also a short-form version of uname -m that you can run as a stand alone command, arch. It returns exactly the same thing as uname -m. You can read more about the arch command in the coreutils documentation.

excerpt

arch prints the machine hardware name, and is equivalent to ‘uname -m’.

hwinfo

Probably the best tool for analyzing your hardware has got to be hwinfo. This package can show you pretty much anything that you'd want/need to know about any of your hardware, right from the terminal. It's save me dozens of times when I'd need some info off of a chip on a system's motherboard or needed to know the revision of a board in a PCI slot.

You can query it against the different subsystems of a computer. In our case we'll be looking at the cpu subsystem.

$ hwinfo --cpu
01: None 00.0: 10103 CPU                                        
  [Created at cpu.301]
  Unique ID: rdCR.a2KaNXABdY4
  Hardware Class: cpu
  Arch: X86-64
  Vendor: "GenuineIntel"
  Model: 6.37.5 "Intel(R) Core(TM) i5 CPU       M 560  @ 2.67GHz"
  Features: fpu,vme,de,pse,tsc,msr,pae,mce,cx8,apic,sep,mtrr,pge,mca,cmov,pat,pse36,clflush,dts,acpi,mmx,fxsr,sse,sse2,ss,ht,tm,pbe,syscall,nx,rdtscp,lm,constant_tsc,arch_perfmon,pebs,bts,rep_good,xtopology,nonstop_tsc,aperfmperf,pni,pclmulqdq,dtes64,monitor,ds_cpl,vmx,smx,est,tm2,ssse3,cx16,xtpr,pdcm,sse4_1,sse4_2,popcnt,aes,lahf_lm,ida,arat,tpr_shadow,vnmi,flexpriority,ept,vpid
  Clock: 2666 MHz
  BogoMips: 5319.74
  Cache: 3072 kb
  Units/Processor: 16
  Config Status: cfg=new, avail=yes, need=no, active=unknown

Again, similar to /proc/cpuinfo this command shows you the makeup of each individual core in a multi-core system. Here's the first line from each section of a core, just to give you an idea.

$ hwinfo --cpu | grep CPU
01: None 00.0: 10103 CPU
  Model: 6.37.5 "Intel(R) Core(TM) i5 CPU       M 560  @ 2.67GHz"
02: None 01.0: 10103 CPU
  Model: 6.37.5 "Intel(R) Core(TM) i5 CPU       M 560  @ 2.67GHz"
03: None 02.0: 10103 CPU
  Model: 6.37.5 "Intel(R) Core(TM) i5 CPU       M 560  @ 2.67GHz"
04: None 03.0: 10103 CPU
  Model: 6.37.5 "Intel(R) Core(TM) i5 CPU       M 560  @ 2.67GHz"

getconf

This is probably the most obvious way to tell what architecture your CPU is presenting to the OS. Making use of getconf, your querying the system variable LONG_BIT. This isn't an environment variable.

# 64-bit system
$ getconf LONG_BIT
64

# 32-bit system
$ getconf LONG_BIT
32

lshw

Yet another tool, similar in capabilities to hwinfo. You can query pretty much anything you want to know about the underlying hardware. For example:

# 64-bit Kernel
$ lshw -class cpu
  *-cpu                   
   description: CPU
   product: Intel(R) Core(TM) i5 CPU       M 560  @ 2.67GHz
   vendor: Intel Corp.
   physical id: 6
   bus info: cpu@0
   version: Intel(R) Core(TM) i5 CPU       M 560  @ 2.67GHz
   slot: None
   size: 1199MHz
   capacity: 1199MHz
   width: 64 bits
   clock: 133MHz
   capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp x86-64 constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 sse4_2 popcnt aes lahf_lm ida arat tpr_shadow vnmi flexpriority ept vpid cpufreq
   configuration: cores=2 enabledcores=2 threads=4


# 32-bit Kernel
$ lshw -class cpu
  *-cpu:0
   description: CPU
   product: Intel(R) Core(TM)2 CPU          4300  @ 1.80GHz
   vendor: Intel Corp.
   physical id: 400
   bus info: cpu@0
   version: 6.15.2
   serial: 0000-06F2-0000-0000-0000-0000
   slot: Microprocessor
   size: 1800MHz
   width: 64 bits
   clock: 800MHz
   capabilities: boot fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe x86-64 constant_tsc pni monitor ds_cpl est tm2 ssse3 cx16 xtpr lahf_lm
   configuration: id=1
 *-logicalcpu:0
      description: Logical CPU
      physical id: 1.1
      width: 64 bits
      capabilities: logical
 *-logicalcpu:1
      description: Logical CPU
      physical id: 1.2
      width: 64 bits
      capabilities: logical

CPU op-mode(s)?

Several of the commands report that what looks to be a 32-bit CPU as supporting 32-bit & 64-bit modes. This can be a little confusing and misleading, but if you understand the history of CPU's, Intel specifically, you'll know that they have a history of playing games with their products where a CPU might have an instruction set that supports 16-bits, but can address more RAM that 2^16.

The same thing is going on with these CPUs. Most people know that a 32-bit CPU can address only 2^32 = 4GB of RAM. But there are versions of CPUs that can address more. These CPUs would often make use of a Linux kernel with the suffix PAE - Physical Address Extension. Using a PAE enabled kernel along with this hardware would allow you to address up to 64GB on a 32-bit system.

You might think well then why do I need a 64-bit architecture? The problem with these CPUs is that a single processes space is limited to 2^32, so if you have a large simulation or computational program that needed more than the 2^32 of addressable space in RAM, then this wouldn't have helped you with that.

Take a look at the wikipedia page on the P6 microarchitecture (i686) for more info.

TL;DR - So what the heck is my CPU's architecture?

In general it can get confusing because a number of the commands and methodologies above are using the term "architecture" loosely. If you're interested in whether the underlying OS is 32-bit or 64-bit use these commands:

  • lscpu
  • getconf LONG_BIT
  • uname

If on the other hand you want to know the CPU's architecture use these commands:

  • /proc/cpuinfo
  • hwinfo
  • lshw

Specifically you want to look for fields where it says things like "width: 64" or "width: 32" if you're using a tool like lshw, or look for the flags:

  • lm: Long Mode (x86-64: amd64, also known as Intel 64, i.e. 64-bit capable)
  • lahf_lm: LAHF/SAHF in long mode

The presents of these 2 flags tells you that the CPU is 64-bit. Their absences tells you that it's 32-bit.

See these URLs for additional information on the CPU flags.

References

man pages

articles:

Solution 2

If your kernel is a 32 bit linux kernel, you won't be able to run 64 bit programs, even if your processor supports it.

Install a 64 bit kernel (and whole OS of course) to run 64 bit

Solution 3

For completeness: since on most 64-bit architectures it is possible to run 32-bit code, in both kernel space and user space, one should not forget that there are actually 4 possible combinations:

  • 32-bit user space on a 32-bit kernel
  • 64-bit user space on a 64-bit kernel
  • 32-bit user space on a 64-bit kernel
  • both 64-bit and 32-bit user space(s) on a 64-bit kernel

uname is the usual way for determining kernel variant. For user-space, file is quite good at recognising executables: file $SHELL or file /sbin/init are convenient idioms. Just the existence of both /lib/*.so and /lib64/*.so is usually good indication, that the system sports both user space variants.

Solution 4

To know if the installed Ubuntu is of 32 or 64 bits:

a) getconf LONG_BIT

b) uname -m

If it shows i686 or i386 it means 32 bits. If it shows x86_64 it means 64 bits.

If the CPU is of 32 bits Ubuntu must be of 32 bits. If the CPU is of 64 bits it can work in 64 or 32 bits. So we can choose: Ubuntu can be of 32 bits or of 64 bits.

To know if the CPU is of 32 or 64 bits:

a) grep -w lm /proc/cpuinfo

If we see lm in red is of 64 bits. Otherwise is of 32 bits.

b) sudo lshw | grep "description: CPU" -A 12 | grep width

It says clearly what we want to know.

A command for both infos:

lscpu

We just need to a look to the first 2 lines of the output: “Architecture” informs about the installed Linux version: “i686″ represents one of 32 bits, while “x86_64″ stands for a 64 bits one. “CPU op-mode(s)” informs about the CPU. “32-bit” represents one of 32 bits, while “32-bit, 64-bit” or “64-bit” stands for a 64 bits one.

Share:
19,460

Related videos on Youtube

Zak
Author by

Zak

Updated on September 18, 2022

Comments

  • Zak
    Zak over 1 year

    I'm confused. Running Fedora Linux, lscpu yields:

    Architecture:            i686
    CPU op-mode(s):          32-bit, 64-bit
    ...
    

    But when I try to install a 64-bit program (Chrome) I get error like:

    Package /....x86_64.rpm has incompatible architecture x86_64. Valid architectures are ['i686', 'i586', 'i486', i386']

    I'm less interested in being able to install Chrome and more interested in why lscpu says that my CPU can run in 64-bit mode; clearly this can't mean I can run 64-bit programs. Can anyone clarify?

    • Raza
      Raza almost 11 years
      can you share output of cat /proc/cpu, I think at the bootup you can select if you want to boot in 64 or 32 bit mode
    • Renan
      Renan almost 11 years
      Are you using a 32-bit OS or a 64-bit one?
    • Zak
      Zak almost 11 years
      @Salton I have a /proc/cpuinfo. But this raises more curious questions. The *_lm flags indicate both my processors support long mode, but the address sizes are "36 bits physical, "..
  • djangofan
    djangofan almost 11 years
    Can you explain why a 32-bit OS can have a 64-bit "op-mode" ? Your answer implies that it can.
  • slm
    slm almost 11 years
    That's correct. See my updates, lmk if that makes sense.
  • Zak
    Zak almost 11 years
    Clearly a great answer. Thanks so much! Intel playing games
  • Zak
    Zak almost 11 years
    So just to be clear though, lscpu is somewhat misleading in that "Architecture: i686" actually refers to running a 32-bit OS.
  • slm
    slm almost 11 years
    correct. see my additions.
  • slm
    slm almost 11 years
    Googling for this information there was a lot of confusion around this particular topic. This question shows up on a lot of the SE sites. Many of the answers on those sites were confused about this topic as well. So this was an attempt to try and provide an all inclusive answer to the topic, not just to answer the OP's question.
  • peterph
    peterph over 10 years
    Yes I somehow considered the 64-bit hardware implicitly by writing on most 64-bit architectures.
  • m3nda
    m3nda almost 9 years
    If your cpu supports VT-x/AMD- you still can use 64 bit programs under a 32 OS using virtualization software like Virtualbox/WMware.