1

I need to get the next device name to be created of the centos or other unix like system, e.g. if the current device name is vda to vdf like in below, I need to get the vdg as my result

[root@VM-0-10-centos ~]# lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sr0     11:0    1 154.5M  0 rom  
vda    253:0    0   200G  0 disk 
└─vda1 253:1    0   200G  0 part /
vdb    253:16   0    10G  0 disk 
vdc    253:32   0    10G  0 disk 
vdd    253:48   0    10G  0 disk 
vde    253:64   0    10G  0 disk 
vdf    253:80   0    10G  0 disk 

this case is pretty simple, however, if I attach, detached volumes multiple times, the device name might be disconnect in the last letter or there might be more than 3 letters in the device name, so my question is, how should I get the next device name accurately?

is there any command in the linux I could use? the reason I am asking this question is that I am now refactoring a script to create and attach a new SPDK device into the vm, the script create a new device name by its own, e.g. if the max device is vdf, then it use vdg as the next device name and sent to vstation for the attaching, even if there is unused discontinuous device name, (e.g. if there is vdb,vdc, vdf in the current list, the script use vdg but actaully we could use vdd), so instead of the having the script to decide which device name I could use, I am think if it possible to let os to decide which one I could use next.

BR Larry

3
  • Do you know the PCI device ID of the device being attached? Commented Sep 25, 2022 at 15:36
  • Please make sure there is no XY problem here. Edit the question if there is. What do you need the next device name for? Commented Sep 25, 2022 at 16:54
  • The next name may be sr1 or vdg or something else, depending on the type of the next device connected. You need a mentalist or a constraint (e.g. "the next vd* device"). Commented Sep 25, 2022 at 17:02

0

You must log in to answer this question.

Browse other questions tagged .