Re: /sys/block and /dev and partitions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Aug 15, 2015 at 6:35 PM, Loic Dachary <loic@xxxxxxxxxxx> wrote:
> Hi Sage,
>
> On 15/08/2015 16:28, Sage Weil wrote:
>> On Sat, 15 Aug 2015, Loic Dachary wrote:
>>> Hi,
>>>
>>> Is there a portable and consistent way to figure out if a given /dev/XXX
>>> path (for instance /dev/dm-1) is a partition of a whole device ?
>>> Although checking /sys/block/dm-1/dm/name for a number at the end (like
>>> mpatha1 or mpatha2) would probably work, it feels like a fragile hack.
>>> Looking into /sys/block/dm-1/slaves will lead to
>>> /sys/block/dm-1/slaves/dm-0 and we can check that
>>> /sys/block/dm-*/subsystem is class/block. But that does not necessarily
>>> mean dm-1 is a partition of dm-0, just that it's a slave of dm-0.
>>
>> Take a look at is_partition in ceph-disk, whih is the best I came up with.
>> Basically it checks if the device name appears as /sys/block/*/$foo...

For regular devices, you can access() /sys/dev/block/maj:min/partition.
If it's there, it's a partition - no need to iterate over /sys/block.

>
> That is consistently updated for /dev/sdb or /dev/vdb but things are different when using multipath. I'll rely on /sys/block/dm-?/dm/name instead until a better solution is found.

A better way might be to rely on the fact that a dm partition will
necessarily have its uuid prefixed by "part".  In that case, it should
be safe to assume that the thing in slaves is a whole disk - I think
that's what various util-linux tools do.  However, IIRC the dm uuid is
optional, so that won't work on a dm device without a uuid.

Thanks,

                Ilya
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux