6
 man uname
    -m, --machine             print the machine hardware name
    -i, --hardware-platform   print the hardware platform or "unknown"

What exactly is meant by hardware platform here and how is it different from the "machine hardware name"? I found some related questions on SE but there seems to be some contradictions among the accepted answers. Where can I find accurate information about this nomenclature?

Marco
  • 33,188
  • 10
  • 112
  • 146
Lavya
  • 1,545
  • 5
  • 18
  • 26

2 Answers2

4

POSIX uname defines -m but not -i. -m outputs the machine name as returned by the uname(2) system call, in the machine entry of the utsname structure. The possibles values are implementation-dependent; on Linux systems it's the kernel's architecture (x86_64, i686...), and can be modified by the process’ personality.

To get an idea of the variety of machine names used, check out config.guess: the first element of each set of values is a machine name, and you'll see macppc, alpha, Alpha, 21064...

GNU coreutils' uname defines -i as outputting the hardware platform name, if it can be determined. To understand what that means you need to look at the source code. If the system uname was built on supports sysinfo(SI_PLATFORM, ...) (which the autoconf macro claims is POSIX, but I haven't been able to verify that), then the hardware platform returned there is used. This works on SunOS and Solaris for example, but not on Linux. If sysinfo isn't usable, the sys/sysctl.h include is checked for HW_MODEL and HW_MACHINE_ARCH, and if they're both defined then the model given by sysctl() is used instead. This works on some BSD-type platforms.

In summary both values are implementation-dependent so it's hard to ascribe real meaning to them.

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164
  • 1
    wow. that's a great answer! thank you! In "on Linux systems it's the kernel's architecture", by kernel's architecture you mean the architecture the OS was compiled for? For example if I run a 32 bit Linux on a 64 bit machine, `uname -m` should give me i686 and not x86_64. Is that correct? – Lavya Jun 12 '15 at 05:27
  • 1
    Exactly, it's the architecture the kernel was compiled for. – Stephen Kitt Jun 12 '15 at 05:28
2

A bit more info in info uname:

`-i'
`--hardware-platform'
     Print the hardware platform name (sometimes called the hardware
     implementation).  Print `unknown' if the kernel does not make this
     information easily available, as is the case with Linux kernels.

`-m'
`--machine'
     Print the machine hardware name (sometimes called the hardware
     class or hardware type).

Basically classification types - you can have different hw implementations (-i) but with/in the same hw class (-m).

Used, for example, to differentiate between kernel modules shared by the same hw class and modules specific to a certain hw implementation.

Dan Cornilescu
  • 1,286
  • 9
  • 10
  • thanks! somehow my system (fedora 20) doesn't show these in theo output of `info uname`. I'll try to find the source of `uname` implementation to see where the program gets these information from. That will make it more clear. – Lavya Jun 12 '15 at 05:06
  • On Linux, `uname -i` is always `unknown`, so it can't be used to differentiate between kernel modules. – Stephen Kitt Jun 12 '15 at 05:11
  • Maybe on stock linux, but on embedded systems customisations might touch that area as well. – Dan Cornilescu Jun 12 '15 at 05:26
  • Not with the usual `uname` on Linux... (But yes, there's nothing preventing a specific system having its own `uname`.) – Stephen Kitt Jun 12 '15 at 05:30