rocky-linux / rocky-tools

MIT License
393 stars 137 forks source link

Migration fails on multipath backed (EFI) drive. #169

Closed tuxjz closed 2 years ago

tuxjz commented 2 years ago

Migration script gives an error:

./migrate2rocky.sh: line 562: dm-0/partition: No such file or directory

Unable to gather EFI data: Can't find disk name or partition number for dm-0.

I have few servers booting out of SAN (using Fibre Channel with multipath) so root device is backed by multipathd mapper device and script isn't going well with that. I have tracked down, that it is starting to fail on line 561 efi_disk (lsblk doesn't give any output = empty string) and then on next line 562 - efi_partition fails for non existent partition (as mentioned above from the script log). IIRC when using multipath, partitions are mapped on different device-mapper "devices".

https://github.com/rocky-linux/rocky-tools/blob/92b35b59d9095c29a7cbc583e4d8c63663f5f79a/migrate2rocky/migrate2rocky.sh#L561 https://github.com/rocky-linux/rocky-tools/blob/92b35b59d9095c29a7cbc583e4d8c63663f5f79a/migrate2rocky/migrate2rocky.sh#L562

whole disk device is mpatha = /dev/mapper/mpatha = /dev/dm-0 efi partition is mpatha1 = /dev/mapper/mpatha1 = /dev/dm-2

# ll /dev/mapper/mpatha
lrwxrwxrwx. 1 root root 7 Mar  9 01:13 /dev/mapper/mpatha -> ../dm-0
# ll /dev/mapper/mpatha1
lrwxrwxrwx. 1 root root 7 Mar  9 01:13 /dev/mapper/mpatha1 -> ../dm-2
# lsblk /dev/sd{a,c,e,g}
NAME        MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINT
sda           8:0    0   50G  0 disk  
`-mpatha    253:0    0   50G  0 mpath 
  |-mpatha1 253:2    0  500M  0 part  /boot/efi
  |-mpatha2 253:3    0    1G  0 part  /boot
  `-mpatha3 253:4    0 48.5G  0 part  /
sdc           8:32   0   50G  0 disk  
`-mpatha    253:0    0   50G  0 mpath 
  |-mpatha1 253:2    0  500M  0 part  /boot/efi
  |-mpatha2 253:3    0    1G  0 part  /boot
  `-mpatha3 253:4    0 48.5G  0 part  /
sde           8:64   0   50G  0 disk  
`-mpatha    253:0    0   50G  0 mpath 
  |-mpatha1 253:2    0  500M  0 part  /boot/efi
  |-mpatha2 253:3    0    1G  0 part  /boot
  `-mpatha3 253:4    0 48.5G  0 part  /
sdg           8:96   0   50G  0 disk  
`-mpatha    253:0    0   50G  0 mpath 
  |-mpatha1 253:2    0  500M  0 part  /boot/efi
  |-mpatha2 253:3    0    1G  0 part  /boot
  `-mpatha3 253:4    0 48.5G  0 part  /

My monkey patch/workaround was to place multipaths to function as static vars:

efi_disk+=("/dev/mapper/mpatha")
efi_partition+=("1")

Then it completed migration successfully.

pajamian commented 2 years ago

Can you see if there's a reliable automated way to detect the partitions on your setup? I'll be happy to integrate it into migrate2rocky if there is.

pajamian commented 2 years ago

I'll be happy to revisit this if there is a way to determine the EFI partitions in any sort of automated way other than just knowing what they are. I'm closing this issue for now, please feel free to re-open it if you have further information.