#!/bin/sh

PREREQ="vdev cryptroot"

prereqs()
{
   echo "$PREREQ"
}

case $1 in
prereqs)
   prereqs
   exit 0
   ;;
esac

. /scripts/functions

# This was necessary because LVM autodetect is completely broken.
if [ -x /usr/sbin/lvm ]; then
   log_begin_msg "Activanting LVM with sysinit (vdev environment)..."
   
   # Force LVM to scan the blocks using sysinit to populate its internal cache
   /usr/sbin/lvm vgscan --mknodes \
        --config "activation { udev_sync=0 udev_rules=0 }" >/dev/null 2>&1
   
   # The status change will now work because the internal cache already recognises the drives
   /usr/sbin/lvm vgchange --sysinit -ay \
        --config "activation { udev_sync=0 udev_rules=0 }" >/dev/null 2>&1
   
   log_end_msg
fi
