initramfs: lvm sysroot

Only activate the Clear Linux OS rootfs volume.

Add lvm conf file to allow pvscan, but prevent starting the
lvmetad service. Otherwise, if non-root lvms exist, all lvms
are active and the Host OS will hang when starting lvmetad service.

Add new lvm2-mount-sysroot.service to only activate the rootfs
which is identified by the CLR_ROOT logical volume name.

Signed-off-by: Mark D Horn <mark.d.horn@intel.com>
This commit is contained in:
Mark D Horn
2020-06-22 11:56:15 -07:00
committed by Josue David Hernandez
parent e53a847e1a
commit 40e678ea00
3 changed files with 91 additions and 0 deletions

View File

@@ -0,0 +1,78 @@
# Configuration section devices.
# How LVM uses block devices.
devices {
# Configuration option devices/obtain_device_list_from_udev.
# Obtain the list of available devices from udev.
# This avoids opening or using any inapplicable non-block devices or
# subdirectories found in the udev directory. Any device node or
# symlink not managed by udev in the udev directory is ignored. This
# setting applies only to the udev-managed device directory; other
# directories will be scanned fully. LVM needs to be compiled with
# udev support for this setting to apply.
obtain_device_list_from_udev = 1
# Configuration option devices/filter.
# Limit the block devices that are used by LVM commands.
# Run vgscan after changing the filter to regenerate the cache.
# See the use_lvmetad comment for a special case regarding filters.
#
# Example
# Accept every block device:
# filter = [ "a|.*/|" ]
# Reject the cdrom drive:
# filter = [ "r|/dev/cdrom|" ]
# Work with just loopback devices, e.g. for testing:
# filter = [ "a|loop|", "r|.*|" ]
# Accept all loop devices and ide drives except hdc:
# filter = [ "a|loop|", "r|/dev/hdc|", "a|/dev/ide|", "r|.*|" ]
# Use anchors to be very specific:
# filter = [ "a|^/dev/hda8$|", "r|.*/|" ]
#
# This configuration option has an automatic default value.
# filter = [ "a|.*/|" ]
# Configuration option devices/global_filter.
# Limit the block devices that are used by LVM system components.
# Because devices/filter may be overridden from the command line, it is
# not suitable for system-wide device filtering, e.g. udev and lvmetad.
# Use global_filter to hide devices from these LVM system components.
# The syntax is the same as devices/filter. Devices rejected by
# global_filter are not opened by LVM.
# This configuration option has an automatic default value.
# global_filter = [ "a|.*/|" ]
# global_filter = [ "a|.*CLR_ROOT.*|", "r|.*|" ]
}
# Configuration section global.
# Miscellaneous global LVM settings.
global {
# Configuration option global/use_lvmetad.
# Use lvmetad to cache metadata and reduce disk scanning.
# When enabled (and running), lvmetad provides LVM commands with VG
# metadata and PV state. LVM commands then avoid reading this
# information from disks which can be slow. When disabled (or not
# running), LVM commands fall back to scanning disks to obtain VG
# metadata. lvmetad is kept updated via udev rules which must be set
# up for LVM to work correctly. (The udev rules should be installed
# by default.) Without a proper udev setup, changes in the system's
# block device configuration will be unknown to LVM, and ignored
# until a manual 'pvscan --cache' is run. If lvmetad was running
# while use_lvmetad was disabled, it must be stopped, use_lvmetad
# enabled, and then started. When using lvmetad, LV activation is
# switched to an automatic, event-based mode. In this mode, LVs are
# activated based on incoming udev events that inform lvmetad when
# PVs appear on the system. When a VG is complete (all PVs present),
# it is auto-activated. The auto_activation_volume_list setting
# controls which LVs are auto-activated (all by default.)
# When lvmetad is updated (automatically by udev events, or directly
# by pvscan --cache), devices/filter is ignored and all devices are
# scanned by default. lvmetad always keeps unfiltered information
# which is provided to LVM commands. Each LVM command then filters
# based on devices/filter. This does not apply to other, non-regexp,
# filtering settings: component filters such as multipath and MD
# are checked during pvscan --cache. To filter a device and prevent
# scanning from the LVM system entirely, including lvmetad, use
# devices/global_filter.
use_lvmetad = 0
}

View File

@@ -0,0 +1 @@
../lvm2-mount-sysroot.service

View File

@@ -0,0 +1,12 @@
[Unit]
Description=LVM2 mount sysroot before switching to rootfs
DefaultDependencies=no
Before=initrd-root-device.target
[Service]
Type=oneshot
ExecStart=-/bin/lvm lvchange --select lv_name=~CLR_ROOT -a y
TimeoutStartSec=0
[Install]
WantedBy=initrd-root-device.target