-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⭐️ detect logical volume and block device
Most modern Linux distributions use [Logical Volume Manager (LVM)](https://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)) as a device mapper, in such cases, we need to guess the block device so that we can mount the attached disk, if not, we will get the error: ``` DBG found block device children=[{"fstype":"vfat","name":"sdd1","uuid":"6BDD-84EA"},{"fstype":"xfs","label":"boot","name":"sdd2","uuid":"9dd560e5-b943-4e7f-b05f-e79021d9b117"},{"name":"sdd3"},{"name":"sdd4"},{"children":[{"fstype":"xfs","name":"rocky-root","uuid":"73976867-73e1-4771-8799-d725d54fa440"}],"fstype":"LVM2_member","name":"sdd5","uuid":"VtYqiy-LKfB-HUNG-1JMw-z1J2-erkv-J1DxAs"}] mountpoint= name=sdd DBG found match DBG found target volume device name=/dev/sdd5 DBG mount volume to scan dir device=/dev/sdd5 fstype=LVM2_member opts= scandir=/tmp/cnspec-scan4160323020 x failed to mount dir error="no such device" attached-fs=/dev/sdd5 fs-type=LVM2_member opts= scan-dir=/tmp/cnspec-scan4160323020 x unable to complete mount step error="no such device" ``` This commit adds a detection for LVM devices, if one is found, we try to detect the block device and use it to mount the volume. Tested on a running VM, works as expected: ``` DBG found block device children=[{"fstype":"vfat","name":"sdd1","uuid":"6BDD-84EA"},{"fstype":"xfs","label":"boot","name":"sdd2","uuid":"9dd560e5-b943-4e7f-b05f-e79021d9b117"},{"name":"sdd3"},{"name":"sdd4"},{"children":[{"fstype":"xfs","name":"rocky-root","uuid":"73976867-73e1-4771-8799-d725d54fa440"}],"fstype":"LVM2_member","name":"sdd5","uuid":"VtYqiy-LKfB-HUNG-1JMw-z1J2-erkv-J1DxAs"}] mountpoint= name=sdd DBG found match DBG found target volume device name=/dev/rocky-root DBG logical volume detected, getting block device name=/dev/rocky-root uuid=73976867-73e1-4771-8799-d725d54fa440 DBG block device found, setting as new device name device=/dev/mapper/rocky-root DBG mount volume to scan dir device=/dev/mapper/rocky-root fstype=xfs opts=nouuid scandir=/tmp/cnspec-scan3433523306 DBG load filesystem path=/tmp/cnspec-scan3433523306 ``` Signed-off-by: Salim Afiune Maya <afiune@mondoo.com>
- Loading branch information
Showing
6 changed files
with
139 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,4 +113,4 @@ | |
] | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,4 @@ | |
] | ||
} | ||
] | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
providers/os/connection/snapshot/testdata/rocky9_attached.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"blockdevices": [ | ||
{"name":"sda", "fstype":null, "label":null, "uuid":null, "fsavail":null, "fsuse%":null, "mountpoint":null, | ||
"children": [ | ||
{"name":"sda1", "fstype":"ext4", "label":"cloudimg-rootfs", "uuid":"32c589b5-7835-4684-9994-62e8fb26cd85", "fsavail":"26.9G", "fsuse%":"7%", "mountpoint":"/"}, | ||
{"name":"sda14", "fstype":null, "label":null, "uuid":null, "fsavail":null, "fsuse%":null, "mountpoint":null}, | ||
{"name":"sda15", "fstype":"vfat", "label":"UEFI", "uuid":"9915-EF3D", "fsavail":"98.3M", "fsuse%":"6%", "mountpoint":"/boot/efi"} | ||
] | ||
}, | ||
{"name":"sdb", "fstype":null, "label":null, "uuid":null, "fsavail":null, "fsuse%":null, "mountpoint":null, | ||
"children": [ | ||
{"name":"sdb1", "fstype":"ext4", "label":null, "uuid":"be29f4fb-2bb8-430b-9c2a-f76604ef10c6", "fsavail":"3.7G", "fsuse%":"0%", "mountpoint":"/mnt"} | ||
] | ||
}, | ||
{"name":"sdd", "fstype":null, "label":null, "uuid":null, "fsavail":null, "fsuse%":null, "mountpoint":null, | ||
"children": [ | ||
{"name":"sdd1", "fstype":"vfat", "label":null, "uuid":"6BDD-84EA", "fsavail":null, "fsuse%":null, "mountpoint":null}, | ||
{"name":"sdd2", "fstype":"xfs", "label":"boot", "uuid":"9dd560e5-b943-4e7f-b05f-e79021d9b117", "fsavail":null, "fsuse%":null, "mountpoint":null}, | ||
{"name":"sdd3", "fstype":null, "label":null, "uuid":null, "fsavail":null, "fsuse%":null, "mountpoint":null}, | ||
{"name":"sdd4", "fstype":null, "label":null, "uuid":null, "fsavail":null, "fsuse%":null, "mountpoint":null}, | ||
{"name":"sdd5", "fstype":"LVM2_member", "label":null, "uuid":"VtYqiy-LKfB-HUNG-1JMw-z1J2-erkv-J1DxAs", "fsavail":null, "fsuse%":null, "mountpoint":null, | ||
"children": [ | ||
{"name":"rocky-root", "fstype":"xfs", "label":null, "uuid":"73976867-73e1-4771-8799-d725d54fa440", "fsavail":null, "fsuse%":null, "mountpoint":null} | ||
] | ||
} | ||
] | ||
}, | ||
{"name":"sr0", "fstype":null, "label":null, "uuid":null, "fsavail":null, "fsuse%":null, "mountpoint":null} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters