Ubuntu如何知道我的笔记本电脑的品牌和型号?

我刚在我的新笔记本上安装了15.04版本,并且安装程序建议使用一个名为"carl-lenovo-g710"的计算机名称。
这台笔记本确实是联想G710,但是安装程序是怎么知道的呢?
我尝试了"sudo lshw | grep -i product"命令,结果如下:
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

然后我尝试了sudo lshw | grep -i 710,但没有找到任何结果。
所以lshw不知道制造商和型号。那么这些信息存储在哪里呢?

1可能是用dmidecode呢? - hanetzer
澄清一下,你想知道在系统中信息存储在哪里/是什么检测到了它?还是想知道如何自己找到这些信息? - Hilton Shumway
@HiltonShumway 在系统中,这些信息存储在哪里? - Carl H
2个回答

Ubuntu安装程序称为ubiquity。Ubiquity 2.3.18的变更日志提到:
"Use dmidecode to get a more unique suffix for the hostname (LP: #628087)."

准确的Python代码如下:
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

编辑: 你可以通过下载代码自己浏览。

cd /tmp
apt-get source ubiquity

1那么,dmidecode 是从哪里获取这些信息的呢? - nanofarad
9@hexafraction 这些信息存储在您的个人电脑制造商(例如联想)提供的只读内存中,并通过名为DMI的接口向系统管理员提供。这就是dmidecode所读取的内容。Windows也可以获取这些信息。 - Federico Poloni

dmidecode显示有关您的系统的所有信息。使用以下命令查看:

sudo dmidecode | grep -A 9 "System Information"