Linux Administration help: Issues with listing disks via executable.

Notice: Page may contain affiliate links for which we may earn a small commission through services like Amazon Affiliates or Skimlinks.

Zevrant

New Member
Feb 7, 2024
6
0
1
Problem statement:

running as a user 'ls -l /dev/disk/by-id/' results in all disks and partitions being available.
running the same command from a golang executable omits the partitions for all disks except the os disk.

The intention here is an executable that takes a golden image and configures it based on the config files provided in a disk attached to the system.

dmesg shows that the executable is unable to lookup the blockdev for the device
e.g.
Code:
/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_drive-scsi1-part1: Can't lookup blockdev
This was working correctly up until recently, but a recent OS update seems to have broken it.


Things I've Tried:
This is not an SELinux issue as even disabling it does not fix the issue.
Running as root does not solve the issue
reloading the partition table for the root disk prior to attempting to access it
Code:
blockdev --rereadpt /dev/disk/by-id/DISK_ID_HERE
Current work around:
Manually parsing the symlink of the root disk of the partition i want to mount to, in this case /dev/sdb, and adding the partition number on the end will allow me to mount the partition, despite still creating a similar dmesg error failing to lookup blockdev.


The common advice seems to be to mount based on UUID, but i do not know the disk UUIDs ahead of time as these are virtual disks,.
 

otome

New Member
Jun 2, 2026
10
0
1
Is there /dev/sdb<part num> in you /dev directory?
And what is your kernel version?