How to get ubi volume name by volume ID on linux terminal?

4.7k views Asked by At

We have 4 volumes on ubi0 and I want to rename the volume name during runtime(dynamically). I found one option is like getting ubinfo for corresponding volume and parsing result to get the volume name.

example:
ubi0
ubi0_0: 
Name:     name1
ubi0_1:
Name:     name_2
...........
like this till ubi0_4.

say if I want to get the volume 2 name then

ubinfo -d 0 -n 2 |grep "Name:" | sed -e 's|Name:||' -e 's/^ *//'
name_2

command details: -d <UBI device number> -----> ubi0(0)
                 -n <volume ID> -------> 2
ouptut of ubinfo -d 0 -n 2
Volume ID:   2 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        mm LEBs (xxxxx bytes, d MiB)
State:       OK
Name:        name_2
Character device major/minor: zzz:n

reaming is to get the Name string value.

Is there any other easier option to get the volume name by volume id?

1

There are 1 answers

0
kzyapkov On BEST ANSWER
volid=2
cat /sys/class/ubi/ubi0_$volid/name