Re: Some troubles with grub with buster point release 10.8

Carsten Aulbert <[email protected]>
Newsgroups gmane.linux.debian.fai
Message-ID <[email protected]>

On 11.02.21 09:53, Thomas Lange wrote:
>>>>>> On Thu, 11 Feb 2021 08:23:07 +0100, Carsten Aulbert <[email protected]> said:
> 
> 
>      > I assume udevadm would return any of the valid device links and by-path
>      > is always set, thus:
> 
>      > get_stable_devname() {
>      >      _DEV="$1"
> This does not work, because the order of links returned by udevadm
> changes with every call.

That's what I wanted to do but I "optimized" the function too much and 
it does not work anymore...

Thus, second try (not sure if I use the array correctly, but it seems to 
work on my test boxes, bonus point attempt to use BASIC style line 
numbers as index numbers to leave room for further possibilities ;-)):

get_stable_devname() {
     _DEV="$1"

     declare -a _RES

     # prefer SCSI over ATA over WWN over path 

     for i in $(udevadm info -r --query=symlink "$_DEV")
     do
         if [[ "$i" =~ /by-id/scsi ]]
         then
             _RES[10]="$i"
         elif [[ "$i" =~ /by-id/ata ]]
         then
             _RES[20]="$i"
         elif [[ "$i" =~ /by-id/wwn ]]
         then
             _RES[30]="$i"
         elif [[ "$i" =~ /by-path/ ]]
         then
             _RES[99]="$i"
         fi
     done

     echo "${_RES[@]::1}"
}

get_stable_devname /dev/sda



C
smime.p7s (application/pkcs7-signature, 5.1 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.