Skip to content

Commit

Permalink
fix(mdraid): try to assemble the missing raid device (bsc#1226412)
Browse files Browse the repository at this point in the history
If some raid devices with specified UUIDs fail to be assembled in
initrd, we will try to assemble them again in this script to avoid
system falling into emergency mode. This patch is created because we can
offen see mdadm command failure during boot because of timing issue
introduced between mdadm and udevd.

(cherry picked from commit dracut-ng/dracut-ng@3fd4385)
  • Loading branch information
ldzhong authored and aafeijoo-suse committed Jun 25, 2024
1 parent 2ba612b commit 8c4596d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions modules.d/90mdraid/mdraid_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ _md_force_run() {
local _md
local _UUID
local _MD_UUID
local _LEFT_UUID
local _uuid

_MD_UUID=$(getargs rd.md.uuid -d rd_MD_UUID=)
[ -n "$_MD_UUID" ] || getargbool 0 rd.auto || return

if [ -n "$_MD_UUID" ]; then
_LEFT_UUID=$(str_replace "$_MD_UUID" "-" ":")
_MD_UUID=$(str_replace "$_MD_UUID" "-" "")
_MD_UUID=$(str_replace "$_MD_UUID" ":" "")

Expand All @@ -51,6 +54,9 @@ _md_force_run() {
)

[ -z "$_UUID" ] && continue
# remove the UUID already assembled from the list
_LEFT_UUID=$(str_replace "$_LEFT_UUID" "$_UUID" "")

_UUID=$(str_replace "$_UUID" ":" "")

# check if we should handle this device
Expand All @@ -65,6 +71,14 @@ _md_force_run() {
_md_start "${_md}"
done
fi

# try to assemble all the left md devices that should be assembled
# probably failed because of timing issue in the first beginning
if [ -n "$_LEFT_UUID" ]; then
for _uuid in ${_LEFT_UUID}; do
mdadm --assemble --scan --uuid="$_uuid"
done
fi
}

_md_force_run

0 comments on commit 8c4596d

Please sign in to comment.