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

Clash 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).
linux dependencies block-device
|
show 1 more comment
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).
linux dependencies block-device
2
so, in short - whatlsblkdoes?
– 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 outputscr_home, which in turn cannot be used as parameter for further inspection (/dev/cr_homedoes 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 -ashelps a bit, but it skips virtual devices (cr_homefor example).
– U. Windl
Nov 21 at 9:13
|
show 1 more comment
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).
linux dependencies block-device
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
linux dependencies block-device
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 - whatlsblkdoes?
– 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 outputscr_home, which in turn cannot be used as parameter for further inspection (/dev/cr_homedoes 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 -ashelps a bit, but it skips virtual devices (cr_homefor example).
– U. Windl
Nov 21 at 9:13
|
show 1 more comment
2
so, in short - whatlsblkdoes?
– 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 outputscr_home, which in turn cannot be used as parameter for further inspection (/dev/cr_homedoes 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 -ashelps a bit, but it skips virtual devices (cr_homefor 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
|
show 1 more comment
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
2
so, in short - what
lsblkdoes?– 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 outputscr_home, which in turn cannot be used as parameter for further inspection (/dev/cr_homedoes 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 -ashelps a bit, but it skips virtual devices (cr_homefor example).– U. Windl
Nov 21 at 9:13