-
Notifications
You must be signed in to change notification settings - Fork 247
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
Allow full migration of /dev/disk/by-id/devices #1450
Merged
Merged
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
0575003
Add migration capability to rename_diskbyid
schabrolles e779936
LogPrint if changes was made on a file by sed
schabrolles eb2d4a3
Avoid sed substitution if ID is the same.
schabrolles 6d9a00c
Add comment
schabrolles eccee69
remove by_id full path for better compatibility
schabrolles e958d28
remove by-id absolute PATH for better backward compatibility
schabrolles f408a69
create apply-mappings function
schabrolles 429e9b3
remove old 320_apply_mappings.sh reference
schabrolles 005f0a5
Add sanity check for UdevSymlinkName
schabrolles 9c316f9
Create UdevQueryName & UdevSymlinkName function
schabrolles 7a76d5e
Move apply-mappings function in layout-function.sh
schabrolles 96a3097
Update comment
schabrolles 3ffb715
Update comments
schabrolles 7866908
use Error() instead of BugIfErro in test varaible
schabrolles 9ef178f
Improve sed_monitor (thanks @schlomo)
schabrolles 63a01df
Use 4 blanks indentation
schabrolles 14c0626
Add get_part_device_name_format() function
schabrolles File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 29 additions & 14 deletions
43
usr/share/rear/layout/save/GNU/Linux/150_save_diskbyid_mappings.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,35 @@ | ||
# Remember the mappings if any for disk-by-id | ||
|
||
# be careful udevinfo is old, now we have udevadm | ||
# udevinfo -r -q name -n /dev/disk/by-id/scsi-360060e8015268c000001268c000065c0-part4 | ||
# udevadm info --query=name --name /dev/disk/by-id/dm-name-vg_fedora-lv_root | ||
UdevQueryName="" | ||
type -p udevinfo >/dev/null && UdevQueryName="udevinfo -r -q name -n" | ||
type -p udevadm >/dev/null && UdevQueryName="udevadm info --query=name --name" | ||
[[ -z "$UdevQueryName" ]] && { | ||
LogPrint "Could not find udevinfo nor udevadm (skip diskbyid_mappings)" | ||
return | ||
} | ||
|
||
ls /dev/disk/by-id | while read ID; | ||
do | ||
ID_NEW=$($UdevQueryName /dev/disk/by-id/$ID) | ||
echo $ID $ID_NEW | ||
done >$VAR_DIR/recovery/diskbyid_mappings | ||
# create diskbyid_mappings file: | ||
# we need to keep absolute PATH for device in order to be able to easily use apply_mappings() function. | ||
# and apply disk mapping during migration. | ||
# | ||
# example: scsi-360060e8015268c000001268c000065c0-part4 /dev/sda4 | ||
# wwn-0x600507680c82004cf8000000000000d8 /dev/mapper/maptha | ||
|
||
# get real device name from a symlink defined by udev | ||
# UdevQueryName() defined in lib/layout-function.sh | ||
ID_NEW=$(UdevQueryName /dev/disk/by-id/$ID) | ||
if [[ $ID_NEW =~ ^dm- ]]; then | ||
# If dm- device is a multipath, get its /dev/mapper/name instead of /dev/dm-X | ||
# as /dev/dm-X are not persistent across reboot and not used in disk mapping file. | ||
|
||
# get symlinks defined by udev from a device | ||
# UdevSymlinkName() defined in lib/layout-function.sh | ||
SYMLINKS=$(UdevSymlinkName /dev/$ID_NEW) | ||
set -- $SYMLINKS | ||
while [ $# -gt 0 ]; do | ||
if [[ $1 =~ /dev/mapper/ ]]; then | ||
ID_NEW=${1#/dev/} | ||
break | ||
else | ||
shift | ||
fi | ||
done | ||
fi | ||
echo $ID /dev/$ID_NEW | ||
done >$VAR_DIR/recovery/diskbyid_mappings | ||
|
||
[[ -f $VAR_DIR/recovery/diskbyid_mappings ]] && Log "Saved diskbyid_mappings" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why do you need to check this file after every call of
sed
? Isn't it enough to check it once at the end of thewhile
loop before printing out the change info?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.
this file will be written by
sed
if changes are made into$realfile
.But it is overwritten (no append).
So if on the last
sed
didn't make any change, the file$sed_change_monitor
will be empty even if a previoussed
made a change.