[Kimchi-devel] [project-kimchi] Use sysfs to list all block device paths

Zhou Zheng Sheng zhshzhou at linux.vnet.ibm.com
Wed Dec 18 14:33:43 UTC 2013


Hi all,

I find block device information in sysfs is accurate and complete.

Firstly run
 lsblk -bPo NAME,MAJ:MIN

It shows
 NAME="vda" MAJ:MIN="253:0"
 NAME="vda1" MAJ:MIN="253:1"

When there is multipath, it shows
 NAME="35000cca68ac8e2fd" MAJ:MIN="253:0"
 NAME="35000cca68ac8e2fdp1" MAJ:MIN="253:1"

Then we parse the major and min, and cat the related sysfs uevent file
 cat /sys/dev/block/253\:0/uevent

It shows
 MAJOR=253
 MINOR=0
 DEVNAME=vda
 DEVTYPE=disk

When there is multipath, it shows
 MAJOR=253
 MINOR=0
 DEVNAME=dm-0
 DEVTYPE=disk

The "DEVNAME=vda" or "DEVNAME=dm-0" is the device node name under the
"/dev/"
So there can be
 /dev/vda
or
 /dev/dm-0

In fact, on my machine, the multipath device node is a link to dm-0
 /dev/mapper/35000cca68ac8e2fd -> ../dm-0

So we can show in front-end like following.
 vda1 (/dev/vda1)
 35000cca68ac8e2fd (/dev/dm-0)

The use mostly cares the name, the path is just supplement information.
User just asks front-end to use "vda1" or "35000cca68ac8e2fd" to create
pool, then we map the names to path.

In this way we don't need to blkid to determine the path, and can drop
the check on" blkid path being not None". Test on Fedora and Ubuntu.

Generally speaking, I also can accept a temp solution just assuming all
NAME listed by lsblk can be mapped to "/dev/NAME". We just need to check
if "/dev/NAME" does exist or not, if not, skip this device.

I'm afraid I have no time to finish a second version of the patch. Maybe
Aline or Daniel can help me. I feel very sorry to not have time to
finish the patch I started. Thanks very much!
-- 
Thanks and best regards!

Zhou Zheng Sheng / 周征晟
E-mail: zhshzhou at linux.vnet.ibm.com
Telephone: 86-10-82454397

-- 
project-kimchi mailing list <project-kimchi at googlegroups.com>
https://groups.google.com/forum/#!forum/project-kimchi
--- 
You received this message because you are subscribed to the Google Groups "project-kimchi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-kimchi+unsubscribe at googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



More information about the Kimchi-devel mailing list