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











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
    2 days ago










  • @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
    2 days ago












  • Does this get you most of the way there?
    – number9
    2 days ago










  • @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
    2 days ago












  • @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
    yesterday















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
    2 days ago










  • @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
    2 days ago












  • Does this get you most of the way there?
    – number9
    2 days ago










  • @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
    2 days ago












  • @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
    yesterday













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 2 days ago









Rui F Ribeiro

38.2k1475123




38.2k1475123










asked 2 days ago









U. Windl

1314




1314








  • 2




    so, in short - what lsblk does?
    – frostschutz
    2 days ago










  • @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
    2 days ago












  • Does this get you most of the way there?
    – number9
    2 days ago










  • @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
    2 days ago












  • @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
    yesterday














  • 2




    so, in short - what lsblk does?
    – frostschutz
    2 days ago










  • @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
    2 days ago












  • Does this get you most of the way there?
    – number9
    2 days ago










  • @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
    2 days ago












  • @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
    yesterday








2




2




so, in short - what lsblk does?
– frostschutz
2 days ago




so, in short - what lsblk does?
– frostschutz
2 days ago












@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
2 days ago






@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
2 days ago














Does this get you most of the way there?
– number9
2 days ago




Does this get you most of the way there?
– number9
2 days ago












@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
2 days ago






@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
2 days ago














@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
yesterday




@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
yesterday















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

Entries order in /etc/network/interfaces

新発田市

Grub takes very long (several minutes) to open Menu (in Multi-Boot-System)