summaryrefslogtreecommitdiff
path: root/python/vyos/system
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2023-12-11 13:55:09 -0600
committerJohn Estabrook <jestabro@vyos.io>2023-12-16 20:37:11 -0600
commitcfa2aeb73110e257fe6adde74c1f1240d35e2a32 (patch)
tree6ff852d7ca5343a6caf4dab204d63b670c638170 /python/vyos/system
parent300f902f823be2d031f1ed3b7574332ed51b88b5 (diff)
downloadvyos-1x-cfa2aeb73110e257fe6adde74c1f1240d35e2a32.tar.gz
vyos-1x-cfa2aeb73110e257fe6adde74c1f1240d35e2a32.zip
image-tools: T5806: deactive raid arrays
(cherry picked from commit e3cd779d0bd8dd8be6231c7b2028326a03e6a06c)
Diffstat (limited to 'python/vyos/system')
-rw-r--r--python/vyos/system/raid.py32
1 files changed, 21 insertions, 11 deletions
diff --git a/python/vyos/system/raid.py b/python/vyos/system/raid.py
index 616d1adf7..5b33d34da 100644
--- a/python/vyos/system/raid.py
+++ b/python/vyos/system/raid.py
@@ -19,7 +19,7 @@ from pathlib import Path
from shutil import copy
from dataclasses import dataclass
-from vyos.utils.process import cmd
+from vyos.utils.process import cmd, run
from vyos.system import disk
@@ -44,16 +44,12 @@ def raid_create(raid_members: list[str],
"""
raid_devices_num: int = len(raid_members)
raid_members_str: str = ' '.join(raid_members)
- if Path('/sys/firmware/efi').exists():
- for part in raid_members:
- drive: str = disk.partition_parent(part)
- command: str = f'sgdisk --typecode=3:A19D880F-05FC-4D3B-A006-743F0F84911E {drive}'
- cmd(command)
- else:
- for part in raid_members:
- drive: str = disk.partition_parent(part)
- command: str = f'sgdisk --typecode=3:A19D880F-05FC-4D3B-A006-743F0F84911E {drive}'
- cmd(command)
+ for part in raid_members:
+ drive: str = disk.partition_parent(part)
+ # set partition type GUID for raid member; cf.
+ # https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs
+ command: str = f'sgdisk --typecode=3:A19D880F-05FC-4D3B-A006-743F0F84911E {drive}'
+ cmd(command)
command: str = f'mdadm --create /dev/{raid_name} -R --metadata=1.0 \
--raid-devices={raid_devices_num} --level={raid_level} \
{raid_members_str}'
@@ -69,6 +65,20 @@ def raid_create(raid_members: list[str],
return raid
+def clear():
+ """Deactivate all RAID arrays"""
+ command: str = 'mdadm --examine --scan'
+ raid_config = cmd(command)
+ if not raid_config:
+ return
+ command: str = 'mdadm --run /dev/md?*'
+ run(command)
+ command: str = 'mdadm --assemble --scan --auto=yes --symlink=no'
+ run(command)
+ command: str = 'mdadm --stop --scan'
+ run(command)
+
+
def update_initramfs() -> None:
"""Update initramfs"""
mdadm_script = '/etc/initramfs-tools/scripts/local-top/mdadm'