Oct 022010
 

linux hardwareSu linux ci sono dei semplici comandi che permettono di visualizzare quello che il sistema operativo sta vedendo (che non sempre corrisponde con l’hardware presente nella macchina). Oggi vedremo alcuni di questi utili comandi che permettono di verificare il corretto riconoscimento di tutte le nostre periferiche.

lspci – lsusb – lshw

lspci

lspci è un utility per la visualizzazione di informazioni sui bus PCI nel sistema e dei dispositivi ad essi collegati.

Per impostazione predefinita, mostra un breve elenco di dispositivi. Utilizzare le opzioni descritte di seguito per richiedere un output più prolisso o produzione destinata per il parsing da altri programmi.



Alcune parti dell’output, soprattutto in modalità altamente dettagliata, sono probabilmente comprensibili solo ad esperti hacker PCI. Per la definizione esatta dei campi, si prega di consultare sia le specifiche PCI o il header.h ed i file /usr/include/linux/pci.h .

L’accesso ad alcune parti dello spazio di configurazione PCI è limitato a root su molti sistemi operativi, così le caratteristiche di lspci disponibili per gli utenti normali sono limitate. Tuttavia, lspci fa del suo meglio per mostrare quanto disponibile e segnare tutte le altre informazioni con il testo < access denied >.

Basic usage: lspci
Output

00:00.0 Host bridge: Intel Corporation 82855PM Processor to I/O Controller (rev 03)
00:01.0 PCI bridge: Intel Corporation 82855PM Processor to AGP Controller (rev 03)
00:1d.0 USB Controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #1 (rev 01)
00:1d.1 USB Controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #2 (rev 01)
00:1d.2 USB Controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #3 (rev 01)
00:1d.7 USB Controller: Intel Corporation 82801DB/DBM (ICH4/ICH4-M) USB2 EHCI Controller (rev 01)
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev 81)
00:1f.0 ISA bridge: Intel Corporation 82801DBM (ICH4-M) LPC Interface Bridge (rev 01)
00:1f.1 IDE interface: Intel Corporation 82801DBM (ICH4-M) IDE Controller (rev 01)
00:1f.3 SMBus: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) SMBus Controller (rev 01)
00:1f.5 Multimedia audio controller: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) AC'97 Audio Controller (rev 01)
00:1f.6 Modem: Intel Corporation 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) AC'97 Modem Controller (rev 01)
01:00.0 VGA compatible controller: ATI Technologies Inc Radeon Mobility M7 LW [Radeon Mobility 7500]
02:00.0 CardBus bridge: Texas Instruments PCI1520 PC card Cardbus Controller (rev 01)
02:00.1 CardBus bridge: Texas Instruments PCI1520 PC card Cardbus Controller (rev 01)
02:01.0 Ethernet controller: Intel Corporation 82540EP Gigabit Ethernet Controller (Mobile) (rev 03)
02:02.0 Network controller: AIRONET Wireless Communications Cisco Aironet Wireless 802.11b

Questo è il risultato sul mio portatile IBM modello T40.

lspci -v (or -vv, -vvv)

Ottieni un prolisso output (più V più prolisso è l’output) dei bus PCI.

Esempio di output

------------------------------------------------------------
02:01.0 Ethernet controller: Intel Corporation 82540EP Gigabit Ethernet Controller (Mobile) (rev 03)
Subsystem: IBM Device 0549
Flags: bus master, 66MHz, medium devsel, latency 64, IRQ 4
Memory at c0220000 (32-bit, non-prefetchable) [size=128K]
Memory at c0200000 (32-bit, non-prefetchable) [size=64K]
I/O ports at 8400 [size=64]
[virtual] Expansion ROM at c0240000 [disabled] [size=64K]
Capabilities: [dc] Power Management version 2
Capabilities: [f0] Message Signalled Interrupts: Mask- 64bit+ Queue=0/0 Enable-
Kernel driver in use: e1000
Kernel modules: e1000
02:02.0 Network controller: AIRONET Wireless Communications Cisco Aironet Wireless 802.11b
Subsystem: AIRONET Wireless Communications Device 5000
Flags: bus master, fast devsel, latency 64, IRQ 6
I/O ports at 8000 [size=256]
Memory at c0210000 (32-bit, non-prefetchable) [size=16K]
Memory at c0400000 (32-bit, non-prefetchable) [size=4M]
[virtual] Expansion ROM at c0800000 [disabled] [size=2M]
Capabilities: [40] Power Management version 2
Capabilities: [48] Vital Product Data
Kernel driver in use: airo
Kernel modules: airo
------------------------------------------------------------

Altri esempi:

Scheda Video

lspci -v | perl -ne '/VGA/../^$/ and /VGA|Kern/ and print'

Mostra la scheda video, i driver disponibili ed il driver in uso

root@laptop:/var/cache/apt/archives# lspci -v | perl -ne '/VGA/../^$/  and /VGA|Kern/ and print'
01:00.0 VGA compatible controller: ATI Technologies Inc Radeon Mobility M7 LW [Radeon Mobility 7500]
Kernel driver in use: radeon
Kernel modules: radeonfb, radeon

Schede di rete

lspci | grep Ether | awk '{ VAR=$1; split(VAR,ARR,"."); count[ARR[1]]++; LINE=$0; split(LINE,LINEARR,":"); LINECOUNT[ARR[1]]=LINEARR[3]; } END { for(i in count) { printf("PCI address: %snPorts: %dnCard Type: %sn", i, count[i], LINECOUNT[i]) } }'

mostra il numero di schede, porte per scheda e slot PCI.

PCI address: 02:01
Ports: 1
Card Type:  Intel Corporation 82540EP Gigabit Ethernet Controller (Mobile) (rev 03)

Se molti dispositivi sono indicati come “Unknown device” (sconosciuti) è utile utilizzare il comando ‘update-pciids’ per poterli visualizzare correttamente.

E’ anche possibile utilizzare lspci -n e poi incollare il risultato su questa pagina web, verranno visualizzati i dispositivi e se sono presenti o meno driver linux per gestirli

Vedi anche il wiki

lsusb

lsusb è un’utilità per la visualizzazione di informazioni sui bus USB del sistema e dei dispositivi ad essi collegati.

 lsusb
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 009: ID 05e3:0702 Genesys Logic, Inc. USB 2.0 IDE Adapter
Bus 001 Device 008: ID 152d:2352 JMicron Technology Corp. / JMicron USA Technology Corp.
Bus 001 Device 006: ID 046d:c315 Logitech, Inc. Classic New Touch Keyboard
Bus 001 Device 005: ID 046d:c01d Logitech, Inc. MX510 Optical Mouse
Bus 001 Device 004: ID 050d:3201 Belkin Components F1DF102U/F1DG102U Flip KVM
Bus 001 Device 002: ID 0424:2524 Standard Microsystems Corp. USB MultiSwitch Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Anche con lsusb è possibile utilizzare l’opzione -v per avere un output più dettagliato.

lshw

lshw (hardware Lister) è un piccolo strumento per fornire informazioni dettagliate sulla configurazione hardware della macchina. Si può riportare l’esatta configurazione della memoria, la versione del firmware, la configurazione della scheda madre, la versione della CPU e la velocità, la configurazione della cache, velocità del bus, ecc su sistemi compatibili con DMI, come x86-compatibili o sistemi EFI (IA-64) e su alcune macchine PowerPC.

Il comando base fornisce un output molto esteso su tutto l’hardware riconosciuto, con l’opzione -short si ha una vista un po più compatta.

lshw -short

H/W path           Device      Class          Description
=========================================================
system         237475G
/0                             bus            237475G
/0/0                           memory         144KiB BIOS
/0/6                           processor      Intel(R) Pentium(R) M processor 1500MHz
/0/6/a                         memory         32KiB L1 cache
/0/6/b                         memory         1MiB L2 cache
/0/2c                          memory         1536MiB System Memory
/0/2c/0                        memory         512MiB SODIMM DDR Synchronous
/0/2c/1                        memory         1GiB SODIMM DDR Synchronous
/0/100                         bridge         82855PM Processor to I/O Controller
/0/100/1                       bridge         82855PM Processor to AGP Controller
/0/100/1/0                     display        Radeon Mobility M7 LW [Radeon Mobility 7500]
/0/100/1d                      bus            82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controll
/0/100/1d.1                    bus            82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controll
/0/100/1d.2                    bus            82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controll
/0/100/1d.7                    bus            82801DB/DBM (ICH4/ICH4-M) USB2 EHCI Controller
/0/100/1e                      bridge         82801 Mobile PCI Bridge
/0/100/1e/0                    bridge         PCI1520 PC card Cardbus Controller
/0/100/1e/0.1                  bridge         PCI1520 PC card Cardbus Controller
/0/100/1e/1        eth0        network        82540EP Gigabit Ethernet Controller (Mobile)
/0/100/1e/2        eth1        network        Cisco Aironet Wireless 802.11b
/0/100/1f                      bridge         82801DBM (ICH4-M) LPC Interface Bridge
/0/100/1f.1        scsi0       storage        82801DBM (ICH4-M) IDE Controller
/0/100/1f.1/0      /dev/sda    disk           40GB HITACHI_DK23EB-4
/0/100/1f.1/0/1    /dev/sda1   volume         17GiB Windows NTFS volume
/0/100/1f.1/0/2    /dev/sda2   volume         2871MiB Windows FAT volume
/0/100/1f.1/0/3    /dev/sda3   volume         16GiB Extended partition
/0/100/1f.1/0/3/5  /dev/sda5   volume         66MiB Linux filesystem partition
/0/100/1f.1/0/3/6  /dev/sda6   volume         494MiB Linux swap / Solaris partition
/0/100/1f.1/0/3/7  /dev/sda7   volume         16GiB Linux filesystem partition
/0/100/1f.1/1      /dev/cdrom  disk           UJDA745 DVD/CDRW
/0/100/1f.3                    bus            82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) SMBus Controller
/0/100/1f.5                    multimedia     82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) AC'97 Audio Contr
/0/100/1f.6                    communication  82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) AC'97 Modem Contr
/0/1               scsi5       storage
/0/1/0.0.0         /dev/sdb    disk           20GB ATCS04-0
/0/1/0.0.0/1       /dev/sdb1   volume         18GiB Windows FAT volume
/0/2               scsi4       storage
/0/2/0.0.0         /dev/sdc    disk           250GB SCSI Disk
/0/2/0.0.0/1       /dev/sdc1   volume         232GiB Windows NTFS volume

lshw ha anche un frontend grafico, invocabile con il comando lshw -X , questa modalità e’ molto comoda per navigare il proprio hardware e visualizzare i vari componenti.

Altri esempi:

lshw -html > hardware.html

Crea una panoramica dell’hardware presente nel computer.
Al termine del comando aprite il file .html con il vostro browser.

sudo lshw -C cpu|grep width

Nel risultato è possibile vedere se la CPU è a 32 o 64 bit.

Popular Posts:

Flattr this!

  3 Responses to “Conosci il tuo hardware su Linux”

  1. great information 😉

  2. Great
    I skimmed over it thinking I knew all that, then saw you pipe it to an html file.
    That was new, thanks

  3. I’ve used lspci and lsusb before. Then, as when looking through your outputs, I’m always confused by the multiple nearly identical “bus”, “bridge” and “controller” entries.

Leave a Reply to sunawang Cancel reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

*