Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to find the device through the device number in Linux

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Today, I will talk to you about how to find a device through the device number in Linux. Many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

# cat / proc/devicesCharacter devices: 1 mem 4 / dev/vc/0 4 tty 4 ttyS 5 / dev/tty 5 / dev/console 5 / dev/ptmx 6 lp 7 vcs 10 misc 13 input 14 sound 21 sg 29 fb116 alsa128 ptm136 pts162 raw180 usb189 usb_device202 cpu/msr203 cpu/cpuid216 rfcomm249 blkwatch_272250 hidraw251 usbmon252 bsg253 pcmcia254 rtc Block devices: 1 ramdisk 2 fd259 blkext 7 loop 8 sd 9 md 11 sr 65 sd 66 sd 67 sd 68 sd 69 sd 70 sd 71 sd128 sd129 sd130 sd131 sd132 sd133 sd134 sd135 sd253 device-mapper254 mdp

As shown above, the command displays the primary number of the character device and the block device. If you want to check a major number, you can

[root@mylnx01 ~] # cat / proc/devices | grep 253253 pcmcia253 device-mapper

Device Mapper,Device Mapper is a mapping framework mechanism from logical device to physical device provided by Linux 2.6. under this mechanism, users can easily make management strategies for storage resources according to their own needs. At present, popular logical volume managers under Linux, such as LVM2 (Linux Volume Manager 2 version), EVMS (Enterprise Volume Management System), dmraid (Device Mapper Raid Tool) and so on, are all implemented based on this mechanism.

Secondary device number check

[root@mylnx01 ~] # ls-l / dev or ll / dev [root@mylnx01 ~] # ll / dev | grep 253 | grep-v grepbrw-rw---- 1 root root 253, 0 Jul 17 23:08 dm-0brw-rw---- 1 root root 253, 1 Jul 17 23:08 dm-1brw-rw---- 1 root root 253, 2 Jul 17 23:08 dm-2brw-rw---- 1 root root 253, 3 Jul 17 23:08 dm-3brw-rw---- 1 root root 253 4 Jul 17 23:09 dm-4brw- 1 root root 253, 1 Jul 17 23:09 root

However, the following error message was encountered in the log message of a server, and the block device with secondary number 253 dev 14 could not be found through / server. As shown below

Jul 19 05:02:01 mylnx01 kernel: BLKWATCH ERR: Attempt to get a sector index out of the bitmap bounds.Jul 19 05:02:01 mylnx01 kernel: BLKWATCH ERR: Critical error 1 happened for device 253 ll 14. Additional info: Failed to mark block as dirty. [root@getlnx01 ~] # ll / dev | grep 253 | grep-v grep

Because the device is a VG, the above command cannot find the device, but you can view it with the command dmsetup. As follows:

# dmsetup lsVolGroup03-LogVol00--PS--user--snapshot-cow (253,15) VolGroup05-LogVol00-real (253,5) VolGroup03-LogVol00--PS--user--snapshot (253,16) VolGroup00-LogVol00-real (253,0) VolGroup00-LogVol00--PS--user--snapshot (253,3) VolGroup01-LogVol00--PS--user--snapshot-cow (253,23) VolGroup05-LogVol00 (253,6) VolGroup04-LogVol00-real (253,9) VolGroup04-LogVol00 10) VolGroup05-LogVol00--PS--user--snapshot (253,8) VolGroup04-LogVol00--PS--user--snapshot-cow (253,11) VolGroup03-LogVol00 (253,14) VolGroup02-LogVol00--PS--user--snapshot (253,20) VolGroup03-LogVol00-real (253,13) VolGroup02-LogVol00 (253,18) VolGroup02-LogVol00--PS--user--snapshot-cow (253,19) VolGroup01-LogVol00 (253,22) VolGroup02-LogVol00-real 17) VolGroup00-LogVol01 (253,4) VolGroup04-LogVol00--PS--user--snapshot (253,12) VolGroup00-LogVol00 (253,1) VolGroup05-LogVol00--PS--user--snapshot-cow (253,7) VolGroup01-LogVol00--PS--user--snapshot (253,24) VolGroup00-LogVol00--PS--user--snapshot-cow (253,2) VolGroup01-LogVol00-real (253,21)

With regard to the main use of the secondary number, this blog introduces part of the main number and the secondary number.

1. Distinguish the actual devices controlled by the device driver

2. Distinguish the equipment for different uses (misc series equipment)

3. Distinguish the partition of block devices (partition)

In general, in order for an application to distinguish between the types of devices it controls, the kernel uses a major setting number. When there are multiple similar devices, in order to select one of them, the device driver uses a secondary number.

# ll / dev/ | grep sd # or command ll / dev/ | grep diskbrw-r- 1 root disk 8, 0 Jul 17 23:08 sdabrw-r- 1 root disk 8, 1 Jul 17 23:10 sda1brw-r- 1 root disk 8, 2 Jul 17 23:08 sda2brw-r- 1 root disk 8, 3 Jul 17 23:08 sda3brw-r- 1 root disk 8 16 Jul 17 23:08 sdbbrw-r- 1 root disk 8, 17 Jul 17 23:08 sdb1brw-r- 1 root disk 8, 18 Jul 17 23:08 sdb2brw-r- 1 root disk 8, 21 Jul 17 23:08 sdb5brw-r- 1 root disk 8, 32 Jul 17 23:08 sdcbrw-r- 1 root disk 8, 33 Jul 17 23:08 sdc1brw-r- 1 root disk 8 34 Jul 17 23:08 sdc2brw-r- 1 root disk 8, 37 Jul 17 23:08 sdc5brw-r- 1 root disk 8, 48 Jul 17 23:08 sddbrw-r- 1 root disk 8, 49 Jul 17 23:08 sdd1brw-r- 1 root disk 8, 50 Jul 17 23:08 sdd2brw-r- 1 root disk 8, 51 Jul 17 23:08 sdd3brw-r- 1 root disk 8 53 Jul 17 23:08 sdd5brw-r- 1 root disk 8, 64 Jul 17 23:08 sdebrw-r- 1 root disk 8, 65 Jul 17 23:08 sde1brw-r- 1 root disk 8, 66 Jul 17 23:08 sde2brw-r- 1 root disk 8, 67 Jul 17 23:08 sde3brw-r- 1 root disk 8, 69 Jul 17 23:08 sde5brw-r- 1 root disk 8 80 Jul 17 23:08 sdfbrw-r- 1 root disk 8, 81 Jul 17 23:08 sdf1brw-r- 1 root disk 8, 85 Jul 17 23:08 sdf5brw-r- 1 root disk 8, 96 Jul 17 23:08 sdgbrw-r- 1 root disk 8, 97 Jul 17 23:08 sdg1brw-r- 1 root disk 8, 98 Jul 17 23:08 sdg2brw-r- 1 root disk 8 Jul 17 23:08 sdg5brw-r- 1 root disk 8,112 Jul 17 23:08 sdhbrw-r- 1 root disk 8,113 Jul 17 23:08 sdh2brw-r- 1 root disk 8,117 Jul 17 23:08 sdh6 what is the Linux system Linux is a free-to-use and freely distributed UNIX-like operating system Is a POSIX-based multi-user, multi-tasking, multi-threaded and multi-CPU operating system, using Linux to run major Unix tools, applications and network protocols.

After reading the above, do you have any further understanding of how to find the device through the device number in Linux? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report