-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
⭐️ detect logical volume and block device #4063
Conversation
Test Results3 004 tests 3 003 ✅ 1m 27s ⏱️ Results for commit 7842be0. ♻️ This comment has been updated with latest results. |
fcde09e
to
fb4e731
Compare
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 <[email protected]>
continue | ||
} | ||
} | ||
log.Debug().Msg("found match") | ||
for i := range d.Children { | ||
entry := d.Children[i] | ||
if entry.IsNotBootOrRootVolumeAndUnmounted() { | ||
devFsName := "/dev/" + entry.Name | ||
return &fsInfo{Name: devFsName, FsType: entry.FsType}, nil | ||
if strings.Contains(entry.FsType, "LVM2") && len(entry.Children) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we extract this into a IsLVMPartition
function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that way we dont repeat the logic in two places
if err != nil { | ||
return err | ||
} | ||
fsInfo.Name = strings.Trim(string(data), "\t\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can u put an example here of what u expect before the strings trim?
@@ -107,8 +108,34 @@ func (m *VolumeMounter) mountVolume(fsInfo *fsInfo) error { | |||
if fsInfo.FsType == "xfs" { | |||
opts = append(opts, "nouuid") | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we'll probably be able to organize this logic a bit more once #4101 is in as well.
that could allow us to kinda "tier" the options...like this LVM check feels like it could be a little earlier in the func?
We currently don't support LVM. Closing for now. |
Most modern Linux distributions use Logical Volume Manager (LVM) 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:
This PR 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: