Device Names in Linux

本文介绍了Linux系统中磁盘及分区的命名规则。包括软驱、SCSI、IDE等不同类型磁盘及其分区的命名方式,并举例说明了实际场景中的应用。

Linux disks and partition names may be different from other operating systems. You need to know the names that Linux uses when you create and mount partitions. Here's the basic naming scheme:

  • The first floppy drive is named /dev/fd0.

  • The second floppy drive is named /dev/fd1.

  • The first SCSI disk (SCSI ID address-wise) is named /dev/sda.

  • The second SCSI disk (address-wise) is named /dev/sdb, and so on.

  • The first SCSI CD-ROM is named /dev/scd0, also known as /dev/sr0.

  • The master disk on IDE primary controller is named /dev/hda.

  • The slave disk on IDE primary controller is named /dev/hdb.

  • The master and slave disks of the secondary controller can be called /dev/hdc and /dev/hdd, respectively. Newer IDE controllers can actually have two channels, effectively acting like two controllers.

  • The first XT disk is named /dev/xda.

  • The second XT disk is named /dev/xdb.

The partitions on each disk are represented by appending a decimal number to the disk name: sda1 and sda2 represent the first and second partitions of the first SCSI disk drive in your system.

Here is a real-life example. Let's assume you have a system with 2 SCSI disks, one at SCSI address 2 and the other at SCSI address 4. The first disk (at address 2) is then named sda, and the second sdb. If the sda drive has 3 partitions on it, these will be named sda1, sda2, and sda3. The same applies to the sdb disk and its partitions.

Note that if you have two SCSI host bus adapters (i.e., controllers), the order of the drives can get confusing. The best solution in this case is to watch the boot messages, assuming you know the drive models and/or capacities.

Linux represents the primary partitions as the drive name, plus the numbers 1 through 4. For example, the first primary partition on the first IDE drive is /dev/hda1. The logical partitions are numbered starting at 5, so the first logical partition on that same drive is /dev/hda5. Remember that the extended partition, that is, the primary partition holding the logical partitions, is not usable by itself. This applies to SCSI disks as well as IDE disks.

### PCIE Device ID Technical Information #### Understanding PCIe Device IDs A PCI Express (PCIe) device identifier is a unique code assigned to each type of PCIe card or component by its manufacturer. This identifier helps operating systems and drivers recognize specific hardware during system initialization and operation. The identification process involves two main components: - **Vendor ID**: A 16-bit number uniquely identifying the manufacturer. - **Device ID**: Another 16-bit value specifying the particular product from that vendor. These codes are standardized through organizations like PCI-SIG, ensuring interoperability across different platforms[^3]. #### Retrieving PCIe Device Information on Linux Systems On Unix-like operating systems such as Linux, users can retrieve detailed information about installed PCIe devices using command-line tools. One common utility for this purpose is `lspci`, which displays all detected PCI buses and connected devices along with their attributes including Vendor ID and Device ID. To list only the numeric values without descriptions: ```bash lspci -n ``` For more verbose output showing both human-readable names alongside numerical identifiers: ```bash lspci -nn ``` Additionally, one may use `grep` to filter results based on known parts of an expected match string: ```bash lspci | grep "NVIDIA" ``` This approach facilitates locating specific types of hardware quickly within large configurations[^2]. #### Programming Interface for Accessing PCIe Devices In application development environments where direct interaction with low-level hardware might be necessary, APIs provided by libraries such as libpciaccess allow programmers to query available resources programmatically. Here’s how it could look in C language when listing out found items' properties: ```c #include <stdio.h> #include <stdlib.h> #include <libpciaccess/pci.h> int main() { struct pci_system *sys; struct pci_device_iterator *iter; struct pci_device *dev; if ((sys = pci_system_init()) == NULL){ perror("Failed initializing PCI access"); exit(EXIT_FAILURE); } iter = pci_device_iterate(sys); while((dev = pci_device_next(iter)) != NULL){ printf("Vendor: %04x, Device: %04x\n", dev->vendor_id, dev->device_id); } pci_device_iter_free(iter); pci_system_cleanup(sys); return EXIT_SUCCESS; } ``` The above snippet initializes communication channels between user space programs and kernel modules responsible for managing peripheral connections before iterating over discovered entities printing pairs of hexadecimal numbers representing vendors and products respectively[^1]. --related questions-- 1. How does the PCI-SIG ensure uniqueness among Vendor IDs? 2. What other utilities besides lspci exist for querying PCIe configuration details under Windows OS? 3. Can you provide examples of situations where knowing exact PCIe Device IDs becomes crucial during troubleshooting processes?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值