Friday, November 9, 2018

SOLVED: Start multipath before LVM (Proxmox/Debian/SAN/QLogic HBA). Boot from multipathed LVM root device.


Problem: Proxmox see duplicated disks instead of one. And cannot boot from it (LVM fails).
Even if multipath-tools-boot is installed and initramfs is updated(as well as grub config).

Cause: possibly initramfs scripts order is broken (thus multipath is not ready yet and LVM can see only duplicated disks)
Solution: Join all necessary steps in one quick custom script and rebuild initramfs with it.
  1. Create file /etc/initramfs-tools/scripts/local-top/forcelvm with following content
  2. #!/bin/sh
    # See man INITRAMFS-TOOLS(8). Section HEADER.
    # https://manpages.debian.org/jessie/initramfs-tools/initramfs-tools.8.en.html
    
    PREREQ=""
    prereqs()
    {
       echo "$PREREQ"
    }
    case $1 in
    prereqs)
       prereqs
       exit 0
       ;;
    esac
    . /scripts/functions
    # Begin real processing below this line
    
    # Load driver for your HBA
    /sbin/modprobe qla2xxx
    # Load device-mapper multipath support
    /sbin/modprobe dm_multipath
    
    # Start multipath
    # WARNING!!! Your /etc/multipath.conf, /etc/multipath/bindings should be configured prior to this!
    
    /sbin/multipath -v3
    /sbin/multipath -ll
    
    # Check how it works. To debug 
    blkid
    sleep 5
    vgchange -ay
    
    if [ -x /sbin/kpartx -a -x /sbin/dmsetup ]; then
         /sbin/dmsetup ls --target multipath --exec "/sbin/kpartx -a -p -part" >/dev/null
    fi
    
    # tmp. Checking again
    #tmp_my_debug=`blkid`
    #echo $tmp_my_debug
    
    # To debug initramfs:
    # You can boot your kernel with "debug" option
    # and then check /run/initramfs/initramfs.debug after boot
    # https://wiki.debian.org/InitramfsDebug 
    
    # N.B. Useful commands when dropped into the initramfs shell:
    # blkid, multipath -v3, multipath -ll, vgchange -ay and "exit" ;)
  3. Make it executable
    chmod +x /etc/initramfs-tools/scripts/local-top/forcelvm
  4. Rebuild your initramfs:
    sudo update-initramfs -u -k all
    
  5. Rebuild your grub cfg:
     sudo update-grub

1 comment:

  1. apt-get install multipath-tools-boot
    worked for me on proxmox 6.4 without this script.

    ReplyDelete