mdraid: better handling of various UUID formats
parent
a762dedb60
commit
746135dd1e
|
|
@ -39,6 +39,9 @@ _md_force_run() {
|
||||||
_offroot=$(strstr "$(mdadm --help-options 2>&1)" offroot && echo --offroot)
|
_offroot=$(strstr "$(mdadm --help-options 2>&1)" offroot && echo --offroot)
|
||||||
|
|
||||||
if [ -n "$_MD_UUID" ]; then
|
if [ -n "$_MD_UUID" ]; then
|
||||||
|
_MD_UUID=$(str_replace "$_MD_UUID" "-" "")
|
||||||
|
_MD_UUID=$(str_replace "$_MD_UUID" ":" "")
|
||||||
|
|
||||||
for _md in /dev/md[0-9_]*; do
|
for _md in /dev/md[0-9_]*; do
|
||||||
[ -b "$_md" ] || continue
|
[ -b "$_md" ] || continue
|
||||||
_UUID=$(
|
_UUID=$(
|
||||||
|
|
@ -50,6 +53,7 @@ _md_force_run() {
|
||||||
)
|
)
|
||||||
|
|
||||||
[ -z "$_UUID" ] && continue
|
[ -z "$_UUID" ] && continue
|
||||||
|
_UUID=$(str_replace "$_UUID" ":" "")
|
||||||
|
|
||||||
# check if we should handle this device
|
# check if we should handle this device
|
||||||
strstr " $_MD_UUID " " $_UUID " || continue
|
strstr " $_MD_UUID " " $_UUID " || continue
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
MD_UUID=$(getargs rd.md.uuid -d rd_MD_UUID=)
|
MD_UUID=$(getargs rd.md.uuid -d rd_MD_UUID=)
|
||||||
|
# normalize the uuid
|
||||||
|
MD_UUID=$(str_replace "$MD_UUID" "-" "")
|
||||||
|
MD_UUID=$(str_replace "$MD_UUID" ":" "")
|
||||||
|
|
||||||
if ( ! [ -n "$MD_UUID" ] && ! getargbool 0 rd.auto ) || ! getargbool 1 rd.md -d -n rd_NO_MD; then
|
if ( ! [ -n "$MD_UUID" ] && ! getargbool 0 rd.auto ) || ! getargbool 1 rd.md -d -n rd_NO_MD; then
|
||||||
info "rd.md=0: removing MD RAID activation"
|
info "rd.md=0: removing MD RAID activation"
|
||||||
|
|
@ -12,13 +15,12 @@ else
|
||||||
[ -e "$f" ] || continue
|
[ -e "$f" ] || continue
|
||||||
while read line || [ -n "$line" ]; do
|
while read line || [ -n "$line" ]; do
|
||||||
if [ "${line%%UUID CHECK}" != "$line" ]; then
|
if [ "${line%%UUID CHECK}" != "$line" ]; then
|
||||||
|
for uuid in $MD_UUID; do
|
||||||
|
printf 'ENV{ID_FS_UUID}=="%s", GOTO="md_uuid_ok"\n' "$(expr substr $uuid 1 8)-$(expr substr $uuid 9 4)-$(expr substr $uuid 13 4)-$(expr substr $uuid 17 4)-$(expr substr $uuid 21 12)"
|
||||||
|
done;
|
||||||
printf 'IMPORT{program}="/sbin/mdadm --examine --export $tempnode"\n'
|
printf 'IMPORT{program}="/sbin/mdadm --examine --export $tempnode"\n'
|
||||||
for uuid in $MD_UUID; do
|
for uuid in $MD_UUID; do
|
||||||
uuid=$(str_replace "$uuid" "-" "")
|
printf 'ENV{MD_UUID}=="%s", GOTO="md_uuid_ok"\n' "$(expr substr $uuid 1 8):$(expr substr $uuid 9 8):$(expr substr $uuid 17 8):$(expr substr $uuid 25 8)"
|
||||||
uuid=$(str_replace "$uuid" ":" "")
|
|
||||||
uuid="$(expr substr $uuid 1 8)-$(expr substr $uuid 9 4)-$(expr substr $uuid 13 4)-$(expr substr $uuid 17 4)-$(expr substr $uuid 21 12)"
|
|
||||||
printf 'ENV{MD_UUID}=="%s", GOTO="md_uuid_ok"\n' $uuid
|
|
||||||
printf 'ENV{ID_FS_UUID}=="%s", GOTO="md_uuid_ok"\n' $uuid
|
|
||||||
done;
|
done;
|
||||||
printf 'GOTO="md_end"\n'
|
printf 'GOTO="md_end"\n'
|
||||||
printf 'LABEL="md_uuid_ok"\n'
|
printf 'LABEL="md_uuid_ok"\n'
|
||||||
|
|
@ -29,12 +31,7 @@ else
|
||||||
mv "${f}.new" "$f"
|
mv "${f}.new" "$f"
|
||||||
done
|
done
|
||||||
for uuid in $MD_UUID; do
|
for uuid in $MD_UUID; do
|
||||||
if strstr "$uuid" "-"; then
|
uuid="$(expr substr $uuid 1 8):$(expr substr $uuid 9 8):$(expr substr $uuid 17 8):$(expr substr $uuid 25 8)"
|
||||||
# convert ID_FS_UUID to MD_UUID format
|
|
||||||
uuid=$(str_replace "$uuid" "-" "")
|
|
||||||
uuid=$(str_replace "$uuid" ":" "")
|
|
||||||
uuid="$(expr substr $uuid 1 8):$(expr substr $uuid 9 8):$(expr substr $uuid 17 8):$(expr substr $uuid 25 8)"
|
|
||||||
fi
|
|
||||||
wait_for_dev "/dev/disk/by-id/md-uuid-${uuid}"
|
wait_for_dev "/dev/disk/by-id/md-uuid-${uuid}"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue