Làm thế nào để Ubuntu biết kiểu dáng và mẫu máy tính xách tay của tôi?


33

Tôi vừa cài đặt 15.04 trên máy tính xách tay mới của mình và trình cài đặt đề xuất tên máy tính là carl-lenovo-g710.

Máy tính xách tay thực sự là một chiếc Lenovo G710, nhưng làm thế nào trình cài đặt biết điều đó?

Tôi đã thử sudo lshw | grep -i product, mang lại:

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

Sau đó, tôi đã cố gắng sudo lshw | grep -i 710, mà không có gì.

Vì vậy, lshwkhông biết làm và mô hình. Vậy thông tin này được lưu trữ ở đâu?


1
Có lẽ dmidecode?
hanetzer

Để làm rõ, bạn muốn biết nơi nào trong hệ thống mà thông tin được tìm thấy / cái gì phát hiện ra nó? Hoặc làm thế nào để tự tìm thông tin đó?
Hilton Shumway

@HiltonShumway Nơi tìm thấy thông tin trong hệ thống.
Carl H

Câu trả lời:


37

Trình cài đặt Ubuntu được gọi là phổ biến . Thay đổi của sự phổ biến 2.3,18 đề cập

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

Mã python chính xác là:

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

Chỉnh sửa: Bạn có thể tự duyệt mã bằng cách tải xuống bằng:

cd /tmp
apt-get source ubiquity

1
Vậy dmidecodelấy thông tin này ở đâu?
ζ--

9
@hexafraction Nó được lưu trữ trong bộ nhớ chỉ đọc của nhà sản xuất PC, Lenovo trong trường hợp này và có sẵn cho quản trị viên hệ thống thông qua giao diện có tên DMI . Đó là những gì dmidecodeđọc được. Windows cũng có thể biết điều đó.
Federico Poloni

20

dmidecodehiển thị tất cả thông tin về hệ thống của bạn. Hãy xem bằng cách sử dụng lệnh:

sudo dmidecode | grep -A 9 "System Information"
Khi sử dụng trang web của chúng tôi, bạn xác nhận rằng bạn đã đọc và hiểu Chính sách cookieChính sách bảo mật của chúng tôi.
Licensed under cc by-sa 3.0 with attribution required.