How can I get parent, children, siblings of a block device in Linux?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I need an algorithm, that can determine the possible children, parents and siblings for any given block device (virtual or physical). In the past I have solved that problem for multipath devices and LVM Logical Volumes, but I'd like to have a complete algorithm.



For example a multipath device is given. That device could have four paths (disks), and the device could be partitioned. One partition could be part of an MD-RAID, the RAID could be partitioned, too, and one such partition could be used as LVM Physical Volume (PV) to build a Volume Group (VG) with several Logical Volumes (LV).










share|improve this question



















  • 2




    so, in short - what lsblk does?
    – frostschutz
    Nov 20 at 12:59










  • @frostschutz: Did you try? In my case when staring at an LV (/dev/sys/home), I get the PV only, but not the parent of the PV (for example). And it outputs cr_home, which in turn cannot be used as parameter for further inspection (/dev/cr_home does not exist; it's a device-mapper device (dm-8)). So in short: Why did you think this would be the solution?
    – U. Windl
    Nov 20 at 13:07











  • Does this get you most of the way there?
    – number9
    Nov 20 at 13:30










  • @U.Windl it resolves PV parent fine for me (disk->partition->raid->luks->lvm) and that's usually considered good enough™. It stops at loop devices though. There are other kinds of virtual block devices (like NBD), those could be anything really (up to userspace to decide), no sane way to cover everything
    – frostschutz
    Nov 20 at 14:15











  • @number9: I did read that question before asking my own. lsblk -as helps a bit, but it skips virtual devices (cr_home for example).
    – U. Windl
    Nov 21 at 9:13














up vote
0
down vote

favorite












I need an algorithm, that can determine the possible children, parents and siblings for any given block device (virtual or physical). In the past I have solved that problem for multipath devices and LVM Logical Volumes, but I'd like to have a complete algorithm.



For example a multipath device is given. That device could have four paths (disks), and the device could be partitioned. One partition could be part of an MD-RAID, the RAID could be partitioned, too, and one such partition could be used as LVM Physical Volume (PV) to build a Volume Group (VG) with several Logical Volumes (LV).










share|improve this question



















  • 2




    so, in short - what lsblk does?
    – frostschutz
    Nov 20 at 12:59










  • @frostschutz: Did you try? In my case when staring at an LV (/dev/sys/home), I get the PV only, but not the parent of the PV (for example). And it outputs cr_home, which in turn cannot be used as parameter for further inspection (/dev/cr_home does not exist; it's a device-mapper device (dm-8)). So in short: Why did you think this would be the solution?
    – U. Windl
    Nov 20 at 13:07











  • Does this get you most of the way there?
    – number9
    Nov 20 at 13:30










  • @U.Windl it resolves PV parent fine for me (disk->partition->raid->luks->lvm) and that's usually considered good enough™. It stops at loop devices though. There are other kinds of virtual block devices (like NBD), those could be anything really (up to userspace to decide), no sane way to cover everything
    – frostschutz
    Nov 20 at 14:15











  • @number9: I did read that question before asking my own. lsblk -as helps a bit, but it skips virtual devices (cr_home for example).
    – U. Windl
    Nov 21 at 9:13












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I need an algorithm, that can determine the possible children, parents and siblings for any given block device (virtual or physical). In the past I have solved that problem for multipath devices and LVM Logical Volumes, but I'd like to have a complete algorithm.



For example a multipath device is given. That device could have four paths (disks), and the device could be partitioned. One partition could be part of an MD-RAID, the RAID could be partitioned, too, and one such partition could be used as LVM Physical Volume (PV) to build a Volume Group (VG) with several Logical Volumes (LV).










share|improve this question















I need an algorithm, that can determine the possible children, parents and siblings for any given block device (virtual or physical). In the past I have solved that problem for multipath devices and LVM Logical Volumes, but I'd like to have a complete algorithm.



For example a multipath device is given. That device could have four paths (disks), and the device could be partitioned. One partition could be part of an MD-RAID, the RAID could be partitioned, too, and one such partition could be used as LVM Physical Volume (PV) to build a Volume Group (VG) with several Logical Volumes (LV).







linux dependencies block-device






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 at 13:54









Rui F Ribeiro

38.2k1475125




38.2k1475125










asked Nov 20 at 12:46









U. Windl

1314




1314







  • 2




    so, in short - what lsblk does?
    – frostschutz
    Nov 20 at 12:59










  • @frostschutz: Did you try? In my case when staring at an LV (/dev/sys/home), I get the PV only, but not the parent of the PV (for example). And it outputs cr_home, which in turn cannot be used as parameter for further inspection (/dev/cr_home does not exist; it's a device-mapper device (dm-8)). So in short: Why did you think this would be the solution?
    – U. Windl
    Nov 20 at 13:07











  • Does this get you most of the way there?
    – number9
    Nov 20 at 13:30










  • @U.Windl it resolves PV parent fine for me (disk->partition->raid->luks->lvm) and that's usually considered good enough™. It stops at loop devices though. There are other kinds of virtual block devices (like NBD), those could be anything really (up to userspace to decide), no sane way to cover everything
    – frostschutz
    Nov 20 at 14:15











  • @number9: I did read that question before asking my own. lsblk -as helps a bit, but it skips virtual devices (cr_home for example).
    – U. Windl
    Nov 21 at 9:13












  • 2




    so, in short - what lsblk does?
    – frostschutz
    Nov 20 at 12:59










  • @frostschutz: Did you try? In my case when staring at an LV (/dev/sys/home), I get the PV only, but not the parent of the PV (for example). And it outputs cr_home, which in turn cannot be used as parameter for further inspection (/dev/cr_home does not exist; it's a device-mapper device (dm-8)). So in short: Why did you think this would be the solution?
    – U. Windl
    Nov 20 at 13:07











  • Does this get you most of the way there?
    – number9
    Nov 20 at 13:30










  • @U.Windl it resolves PV parent fine for me (disk->partition->raid->luks->lvm) and that's usually considered good enough™. It stops at loop devices though. There are other kinds of virtual block devices (like NBD), those could be anything really (up to userspace to decide), no sane way to cover everything
    – frostschutz
    Nov 20 at 14:15











  • @number9: I did read that question before asking my own. lsblk -as helps a bit, but it skips virtual devices (cr_home for example).
    – U. Windl
    Nov 21 at 9:13







2




2




so, in short - what lsblk does?
– frostschutz
Nov 20 at 12:59




so, in short - what lsblk does?
– frostschutz
Nov 20 at 12:59












@frostschutz: Did you try? In my case when staring at an LV (/dev/sys/home), I get the PV only, but not the parent of the PV (for example). And it outputs cr_home, which in turn cannot be used as parameter for further inspection (/dev/cr_home does not exist; it's a device-mapper device (dm-8)). So in short: Why did you think this would be the solution?
– U. Windl
Nov 20 at 13:07





@frostschutz: Did you try? In my case when staring at an LV (/dev/sys/home), I get the PV only, but not the parent of the PV (for example). And it outputs cr_home, which in turn cannot be used as parameter for further inspection (/dev/cr_home does not exist; it's a device-mapper device (dm-8)). So in short: Why did you think this would be the solution?
– U. Windl
Nov 20 at 13:07













Does this get you most of the way there?
– number9
Nov 20 at 13:30




Does this get you most of the way there?
– number9
Nov 20 at 13:30












@U.Windl it resolves PV parent fine for me (disk->partition->raid->luks->lvm) and that's usually considered good enough™. It stops at loop devices though. There are other kinds of virtual block devices (like NBD), those could be anything really (up to userspace to decide), no sane way to cover everything
– frostschutz
Nov 20 at 14:15





@U.Windl it resolves PV parent fine for me (disk->partition->raid->luks->lvm) and that's usually considered good enough™. It stops at loop devices though. There are other kinds of virtual block devices (like NBD), those could be anything really (up to userspace to decide), no sane way to cover everything
– frostschutz
Nov 20 at 14:15













@number9: I did read that question before asking my own. lsblk -as helps a bit, but it skips virtual devices (cr_home for example).
– U. Windl
Nov 21 at 9:13




@number9: I did read that question before asking my own. lsblk -as helps a bit, but it skips virtual devices (cr_home for example).
– U. Windl
Nov 21 at 9:13















active

oldest

votes











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f482967%2fhow-can-i-get-parent-children-siblings-of-a-block-device-in-linux%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f482967%2fhow-can-i-get-parent-children-siblings-of-a-block-device-in-linux%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)