Skip to content

Commit 4bdb4d8

Browse files
committed
autodetect kmods for mdraid
Signed-off-by: Zen <[email protected]>
1 parent 9104694 commit 4bdb4d8

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/ugrd/fs/mounts.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__author__ = 'desultory'
2-
__version__ = '4.16.5'
2+
__version__ = '4.16.6'
33

44
from pathlib import Path
55
from zenlib.util import contains, pretty_print
@@ -286,6 +286,7 @@ def get_virtual_block_info(self) -> dict:
286286
self['_dm_info'][virt_device.name]['uuid'] = (virt_device / 'dm/uuid').read_text().strip()
287287
elif (virt_device / 'md').exists():
288288
self['_dm_info'][virt_device.name]['uuid'] = (virt_device / 'md/uuid').read_text().strip()
289+
self['_dm_info'][virt_device.name]['level'] = (virt_device / 'md/level').read_text().strip()
289290
else:
290291
raise ValueError("Failed to get virtual device name: %s" % virt_device.name)
291292

@@ -394,11 +395,16 @@ def _autodetect_dm(self, mountpoint, device=None) -> None:
394395
@contains('autodetect_root_raid', "Skipping RAID autodetection, autodetect_root_raid is disabled.", log_level=30)
395396
@contains('hostonly', "Skipping RAID autodetection, hostonly mode is disabled.", log_level=30)
396397
def autodetect_raid(self, mount_loc, dm_num, dm_info) -> None:
397-
""" Autodetects MD RAID mounts and sets the raid config. """
398+
"""
399+
Autodetects MD RAID mounts and sets the raid config.
400+
Adds kmods for the raid level to the autodetect list.
401+
"""
398402
if 'ugrd.fs.raid' not in self['modules']:
399403
self.logger.info("Autodetected MDRAID mount, enabling the mdraid module.")
400404
self['modules'] = 'ugrd.fs.mdraid'
401405

406+
self['_kmod_auto'] = dm_info['level']
407+
402408

403409
@contains('autodetect_root_dm', "Skipping device mapper autodetection, autodetect_root_dm is disabled.", log_level=30)
404410
@contains('hostonly', "Skipping device mapper autodetection, hostonly mode is disabled.", log_level=30)
@@ -666,6 +672,8 @@ def resolve_blkdev_kmod(self, device) -> list[str]:
666672
return ['mmc_block']
667673
elif device_name.startswith('sr'):
668674
return ['sr_mod']
675+
elif device_name.startswith('md'):
676+
return ['md_mod']
669677
else:
670678
self.logger.error("[%s] Unable to determine kernel module for block device: %s" % (device_name, device))
671679
return []

0 commit comments

Comments
 (0)