#!/bin/bash # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # ex: ts=8 sw=4 sts=4 et filetype=sh dracutfunctions=/usr/lib/dracut/dracut-functions hostonly=1 check() { local _rootdev _usrdev _needed # No point trying to support lvm if the binaries are missing type -P lvm >/dev/null || return 1 . $dracutfunctions [[ $debug ]] && set -x is_lvm() { [[ $(get_fs_type /dev/block/$1) = LVM2_member ]]; } [[ $hostonly ]] && { _rootdev=$(find_root_block_device) if [[ $_rootdev ]]; then # root lives on a block device, so we can be more precise about # hostonly checking echo "Checking / via $_rootdev" check_block_and_slaves is_lvm "$_rootdev" && _needed=1 else # root is not on a block device, use the shotgun approach blkid | grep -q LVM2_member && _needed=1 fi [[ $_needed ]] || { _usrdev=$(find_block_device /usr) if [[ $_usrdev ]]; then echo "Checking /usr via $_usrdev" check_block_and_slaves is_lvm "$_usrdev" && _needed=1 fi } } echo "_needed=$_needed" [[ $_needed ]] } check echo $?