35

I've just installed 15.04 on my new laptop, and the installer suggested a computer name of carl-lenovo-g710.

The laptop is indeed a Lenovo G710, but how did the installer know that?

I tried sudo lshw | grep -i product, which yielded:

product: Intel(R) Pentium(R) CPU 3550M @ 2.30GHz
product: Xeon E3-1200 v3/4th Gen Core Processor DRAM Controller
product: 4th Gen Core Processor Integrated Graphics Controller
product: Xeon E3-1200 v3/4th Gen Core Processor HD Audio Controller
product: 8 Series/C220 Series Chipset Family USB xHCI
product: xHCI Host Controller
product: xHCI Host Controller
product: Flash Card Reader/Writer
product: Card  Reader
product: Lenovo EasyCamera
product: 8 Series/C220 Series Chipset Family MEI Controller #1
product: 8 Series/C220 Series Chipset Family USB EHCI #2
product: EHCI Host Controller
product: 8 Series/C220 Series Chipset High Definition Audio Controller
product: 8 Series/C220 Series Chipset Family PCI Express Root Port #2
product: QCA9565 / AR9565 Wireless Network Adapter
product: 8 Series/C220 Series Chipset Family PCI Express Root Port #3
product: QCA8172 Fast Ethernet
product: 8 Series/C220 Series Chipset Family USB EHCI #1
product: EHCI Host Controller
product: HM86 Express LPC Controller
product: 8 Series/C220 Series Chipset Family 6-port SATA Controller 1 [AHCI mode]
product: 8 Series/C220 Series Chipset Family SMBus Controller
product: DVDRAM GTA0N
product: ST1000LM024 HN-M

Then I tried sudo lshw | grep -i 710, which turned up nothing.

So lshw doesn't know the make and model. So where is this information stored?

3
  • 1
    Maybe dmidecode?
    – hanetzer
    Commented Apr 30, 2015 at 17:27
  • To clarify, you want to know where in the system that information is found/what detects it? Or how to find that information yourself? Commented May 1, 2015 at 3:55
  • @HiltonShumway Where in the system that information is found.
    – Carl H
    Commented May 1, 2015 at 8:40

2 Answers 2

37

The Ubuntu installer is called ubiquity. The changelog of ubiquity 2.3.18 mentions

"Use dmidecode to get a more unique suffix for the hostname (LP: #628087)."

The exact python code is:

def dmimodel():
    model = ''
    kwargs = {}
    if os.geteuid() != 0:
        # Silence annoying warnings during the test suite.
        kwargs['stderr'] = open('/dev/null', 'w')
    try:
        proc = subprocess.Popen(
            ['dmidecode', '--quiet', '--string', 'system-manufacturer'],
            stdout=subprocess.PIPE, universal_newlines=True, **kwargs)
        manufacturer = proc.communicate()[0]
        if not manufacturer:
            return
        manufacturer = manufacturer.lower()
        if 'to be filled' in manufacturer:
            # Don't bother with products in development.
            return
        if 'bochs' in manufacturer or 'vmware' in manufacturer:
            model = 'virtual machine'
            # VirtualBox sets an appropriate system-product-name.
        else:
            if 'lenovo' in manufacturer or 'ibm' in manufacturer:
                key = 'system-version'
            else:
                key = 'system-product-name'
            proc = subprocess.Popen(
                ['dmidecode', '--quiet', '--string', key],
                stdout=subprocess.PIPE,
                universal_newlines=True)
            model = proc.communicate()[0]
        if 'apple' in manufacturer:
            # MacBook4,1 - strip the 4,1
            model = re.sub('[^a-zA-Z\s]', '', model)
        # Replace each gap of non-alphanumeric characters with a dash.
        # Ensure the resulting string does not begin or end with a dash.
        model = re.sub('[^a-zA-Z0-9]+', '-', model).rstrip('-').lstrip('-')
        if model.lower() == 'not-available':
            return
        if model.lower() == "To be filled by O.E.M.".lower():
            return
    except Exception:
        syslog.syslog(syslog.LOG_ERR, 'Unable to determine the model from DMI')
    finally:
        if 'stderr' in kwargs:
            kwargs['stderr'].close()
    return model

LP: #628087

Edit: You can browse yourself the code by downloading it with:

cd /tmp
apt-get source ubiquity
2
  • 1
    So where does dmidecode get this information?
    – nanofarad
    Commented May 1, 2015 at 10:04
  • 9
    @hexafraction It's stored in read-only memory by the producer of your PC, Lenovo in this case, and available to the system administrator through an interface called DMI. That's what dmidecode reads. Windows can know it, too. Commented May 1, 2015 at 10:51
21

dmidecode shows all information about your system. Take a look using the command:

sudo dmidecode | grep -A 9 "System Information"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .