- Include mkinitrd scripts from lvm2, device-mapper, mdadm and

nfs-client for 13.2 builds. The scripts will be removed from these
  packages, they are required here. (bnc#883863, bnc#883873,bnc#883876)

OBS-URL: https://build.opensuse.org/package/show/Virtualization/libguestfs?expand=0&rev=290
This commit is contained in:
Olaf Hering 2014-07-02 09:31:23 +00:00 committed by Git OBS Bridge
parent b8a3032516
commit a50be92a32
10 changed files with 448 additions and 0 deletions

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Jul 2 11:27:26 CEST 2014 - ohering@suse.de
- Include mkinitrd scripts from lvm2, device-mapper, mdadm and
nfs-client for 13.2 builds. The scripts will be removed from these
packages, they are required here. (bnc#883863, bnc#883873,bnc#883876)
-------------------------------------------------------------------
Thu Jun 5 17:10:57 UTC 2014 - mlatimer@suse.com

View File

@ -0,0 +1,25 @@
#!/bin/bash
#%stage: boot
#%depends: start
#%modules: $dm_modules dm-mod dm-snapshot
#%programs: /sbin/dmsetup /sbin/blockdev
# dm-crypt dm-zero dm-mirror
#%if: -n "$root_dm"
#
##### Device Mapper
##
## If the root device uses device mapper, this initializes and waits for the control file
##
## Command line parameters
## -----------------------
##
## root_dm=1 use device mapper
##
load_modules
# because we run before udev we need to create the device node manually
mkdir -p /dev/mapper
if [ ! -c /dev/mapper/control ] ; then
mknod /dev/mapper/control c 10 63
fi

View File

@ -0,0 +1,79 @@
#!/bin/bash
#%stage: volumemanager
#%depends: evms
#%programs: vgscan vgchange lvm
#%programs: sed
#%modules: linear
#%if: -n "$root_lvm2"
#
##### LVM (Logical Volume Management)
##
## This activates and waits for an LVM.
##
## Command line parameters
## -----------------------
##
## root_lvm2=1 use LVM
## root=/dev/mapper/... use this device as Volume Group
## vg_roots use this group as Volume Group
##
lvm2_get_vg() {
local param=$1
local vg_root vg_name
local sysdev
case $param in
/dev/disk/by-*/*)
vg_root=
;;
/dev/mapper/*)
vg_name=${o##root=/dev/mapper/}
vg_root=${vg_name%%-*}
;;
/dev/*)
set -- $(IFS=/ ; echo $param)
if [ "$#" = "3" ] ; then
# Check sysfs. If there are subdirectories
# matching this name it's a block device
for d in /sys/block/$2\!* ; do
if [ -d $d ] ; then
sysdev=$d
fi
done
# Not found in sysfs, looks like a VG then
if [ -z "$sysdev" ] ; then
vg_root=$2
fi
fi
;;
esac
echo $vg_root
}
# load the necessary module before we initialize the raid system
load_modules
if [ -n "$root_lvm2" ] ; then
o=$(get_param root)
# Fallback if 'root=' is not specified
[ -z "$o" ] && o=$rootdev
vg_root=$(lvm2_get_vg $o)
if [ "$vg_root" ] ; then
# We are waiting for a device-mapper device
root_major=$(sed -n 's/\(.*\) device-mapper/\1/p' /proc/devices)
fi
o=$(get_param resume)
vg_resume=$(lvm2_get_vg $o)
if [ "$vg_resume" ] ; then
resume_major=$(sed -n 's/\(.*\) device-mapper/\1/p' /proc/devices)
fi
fi
# initialize remebered and parameterized devices
for vgr in $vg_root $vg_resume $vg_roots; do
vgchange -a y $vgr
done
unset lvm2_get_vg

View File

@ -0,0 +1,32 @@
#!/bin/bash
#%stage: boot
#%depends: start
#%programs: /sbin/mdadm /sbin/mdmon
#%modules: raid0 raid1 raid10 raid456
#%if: -n "$need_mdadm"
#
##### MD (Software-)Raid
##
## This only sets the 'start_ro' module parameter to ensure
## arrays don't start resync until after the first write.
## All array assembly is performed by udev -> "mdadm -I"
##
## Command line parameters
## -----------------------
##
## need_mdadm=1 use MD raid
##
# load the necessary module before we initialize the raid system
load_modules
#check_for_device uses $md_major
#we depend on 'start' to ensure /proc/devices exists
md_major=$(sed -ne 's/\s*\([0-9]\+\)\s*md$/\1/p' /proc/devices)
# Always start md devices read/only. They will get set to rw as soon
# as the first write occurs. This way we can guarantee that no
# restore occurs before resume.
if [ -f /sys/module/md_mod/parameters/start_ro ]; then
echo 1 > /sys/module/md_mod/parameters/start_ro
fi

View File

@ -0,0 +1,70 @@
#!/bin/bash
#%stage: block
#%modules: nfs nfsv2 nfsv3 nfsv4
#%programs: mount.nfs mount.nfs4
#%if: "$rootfstype" = "nfs" -o "$need_nfs"
#
##### Network FileSystem
##
## This is where NFS gets mounted.
## If no root= option was given, the root device will be taken from the DHCP-server.
##
## Command line parameters
## -----------------------
##
## root=<server>:/<folder> the nfs root path
##
# Prefer NFS root setting via DHCP the fallback provided in config/*.
# So at first, consider the command line (that's why we check for "$cmd_root"
# being empty here. Then consider the DHCP setting. And finally consider the
# fallback via config/*.
if [ -n "$ROOTPATH" -a -z "$cmd_root" ] ; then
case "$ROOTPATH" in
iscsi:*)
;;
*:*)
rootfstype="nfs"
rootdev="$ROOTPATH" ;;
*)
if [ -n "$DHCPSIADDR" ]; then
rootdev="$DHCPSIADDR:$ROOTPATH"
rootfstype="nfs"
elif [ -n "$DHCPSNAME" ]; then
rootdev="$DHCPSNAME:$ROOTPATH"
rootfstype="nfs"
fi ;;
esac
if [ -n "$rootdev" ] ; then
echo >&2 "Using root device ($rootdev) provided via DHCP"
fi
fi
if [ "$rootfstype" = "nfs" ]; then
# load the nfs module before using it
load_modules
if [ -z "$rootdev" ]; then
echo "no local root= kernel option given and no root server set by the dhcp server."
echo "exiting to /bin/sh"
cd /
PATH=$PATH PS1='$ ' /bin/sh -i
fi
rootfsmod=
if [ -n "$rootflags" ] ; then
rootflags="${rootflags},nolock"
else
rootflags="nolock"
fi
# tell boot.rootfsck to skip warning
ROOTFS_FSCK=0
export ROOTFS_FSCK
else
dont_load_modules
fi
# Absolutely required for networking to function
ip link set dev lo up

View File

@ -0,0 +1,41 @@
#!/bin/bash
#
#%stage: devicemapper
#%depends: dmroot
#
# no dmsetup -> no dm
if [ -x "$(type -p dmsetup)" ]; then
dm_blockdev=
# if any device before was on dm we have to activate it
[ "$tmp_root_dm" ] && root_dm=1
blockdev="$(dm_resolvedeps_recursive $blockdev)"
[ "$?" = 0 ] && root_dm=1
# include dm when using dm based block devs
[ "$DM_BLOCK" ] && root_dm=1
# include modules
if [ -n "$root_dm" ] ; then
# Add all dm modules
dm_modules=
for table in $(dmsetup table | cut -f 4 -d ' ' | sort | uniq); do
if [ "$table" = "thin" ]; then table="thin-pool"; fi
if [ "$table" ] && [ "$table" != "linear" ] && [ "$table" != "striped" ] ; then
dm_modules="$dm_modules dm-$table"
fi
done
dm_modules="$dm_modules dm-mirror"
fi
# include dm block var from sysconfig
mkdir -p $tmp_mnt/etc/sysconfig
grep DM_BLOCK /etc/sysconfig/kernel > $tmp_mnt/etc/sysconfig/kernel
mkdir -p $tmp_mnt/usr/lib/udev/rules.d
cp /usr/lib/udev/rules.d/10-dm.rules $tmp_mnt/usr/lib/udev/rules.d/
cp /usr/lib/udev/rules.d/13-dm-disk.rules $tmp_mnt/usr/lib/udev/rules.d
cp /usr/lib/udev/rules.d/95-dm-notify.rules $tmp_mnt/usr/lib/udev/rules.d
save_var root_dm
save_var dm_modules
fi

View File

@ -0,0 +1,47 @@
#!/bin/bash
#
#%stage: volumemanager
#%depends: evms
#
# get information about the current blockdev
update_blockdev
# Check whether we are using LVM2 (only available when not using EVMS)
if [ -z "$root_evms" ] && [ -x "$(type -p lvdisplay)" ] ; then
lvm_blockdev=
for bd in $blockdev; do
update_blockdev $bd
vg_name=$(lvdisplay -c 2> /dev/null | sed -n "/:${blockmajor}:${blockminor}$/p")
vg_dev=${vg_name%%:*}
vg_name=${vg_name#*:}
vg_root=${vg_name%%:*}
if [ "$vg_root" ] ; then
local vg_blockdev
root_lvm2=1
realrootdev=${vg_dev## }
vg_blockdev=$(vgs --noheadings --options pv_name $vg_root 2> /dev/null | sed "s@,@\n@g" | sed "s@([0-9]*)@@g;s@ @@g" | sort | uniq)
lvm_blockdev="$lvm_blockdev $vg_blockdev"
[ $? -eq 0 ] || return 1
vg_roots="$vg_roots $vg_root"
else
lvm_blockdev="$lvm_blockdev $bd"
fi
done
blockdev="$lvm_blockdev"
fi
if use_script lvm2; then
tmp_root_dm=1 # lvm needs dm
mkdir -p $tmp_mnt/etc/lvm
mkdir -p $tmp_mnt/var/lock/lvm
cp -a /etc/lvm/lvm.conf $tmp_mnt/etc/lvm/
# udev rule for lvm2
mkdir -p $tmp_mnt/usr/lib/udev/rules.d
cp /usr/lib/udev/rules.d/11-dm-lvm.rules $tmp_mnt/usr/lib/udev/rules.d/
fi
save_var root_lvm2
save_var vg_roots

View File

@ -0,0 +1,120 @@
#!/bin/bash
#
#%stage: softraid
#
mdblockdev=
# Full mdadm.conf generated by mdadm.
# Contains all created MD RAIDs
mdadm_conf=
cont_list=
md_devs=
declare -A md_conf
# blockdev contains real devices (/dev/X) for root, resume, journal, dumb
for bd in $blockdev ; do
is_part_dev=false
case $bd in
/dev/md[_0-9]*p[0-9]* )
# Partitionable MD RAID. This is partition on RAID. Get the RAID
bd=${bd%%p[0-9]*}
is_part_dev=true
;;
/dev/md[0-9_]*)
;;
*)
mdblockdev="$mdblockdev $bd"
continue
;;
esac
# Check if this device is already added (possible for partitionable).
md_dev=`mdadm -D --export $bd | sed -n -e 's/^MD_DEVNAME=//p'`
if [ -z "$md_dev" ]; then
md_dev=${bd##/dev/}
else
bd="/dev/md/$md_dev"
fi
dup_found=false
for dup in $md_devs; do
if [ x"$dup" = x"$md_dev" ]; then
dup_found=true
break
fi
done
if $dup_found; then
if ! $is_part_dev; then
echo "setup-md.sh: $md_dev found multiple times" >&2
fi
continue
fi
mdconf=$(mdadm -Db "$bd")
if test -z "$mdconf"; then
mdblockdev="$mdblockdev $bd"
continue
fi
md_tmpblockdev=$(mdadm -Dbv $bd | sed -n "1D;s/,/ /g;s/^ *devices=//p")
mdblockdev="$mdblockdev $md_tmpblockdev"
md_devs="$md_devs $md_dev"
container=$(echo "$mdconf" | sed -rn 's/.* container=([^ ]*) .*/\1/p')
for cnt in $cont_list; do
if [ x"$container" = x"$cnt" ]; then
container=
break
fi
done
case "$container" in
"")
;;
/dev/*)
mdconf="$(mdadm -Db "$container")\\n$mdconf"
cont_list="$cont_list $container"
;;
[0-9a-f]*[0-9a-f])
if test -z "$mdadm_conf"; then
mdadm_conf=$(mdadm --examine --brief --scan)
fi
mdconf="$(echo "$mdadm_conf" | grep "UUID=$container")\\n$mdconf"
cont_list="$cont_list $container"
;;
*)
echo "unrecognized container for $md_dev: $container"
;;
esac
# If /etc/mdadm.conf contains a different name for this
# array, then use that.
md_uuid=`echo $mdconf | sed -n -e 's/.* UUID=\([0-9a-f:]*\).*/\1/p'`
if [ -f /etc/mdadm.conf -a -n "$md_uuid" ]; then
md_devname=`sed -n -e 's,^ARRAY */dev/\([^ ]*\) .*[Uu][Uu][Ii][Dd]='$md_uuid'.*,\1,p' /etc/mdadm.conf`
if [ -n "$md_devname" ]; then
mdconf=`echo $mdconf | sed -e 's,^ARRAY /dev/\([^ ]*\),ARRAY /dev/'$md_devname','`
fi
fi
md_conf["$md_dev"]="$mdconf"
root_md=1
done
# Any 'md' device is replaced by it's component disks.
blockdev="$mdblockdev"
if [ -n "$root_md" ] ; then
need_mdadm=1
echo "AUTO -all" > $tmp_mnt/etc/mdadm.conf
for md in $md_devs; do
echo -e "${md_conf["$md"]}" >> $tmp_mnt/etc/mdadm.conf
done
fi
if [ "x$need_mdadm" = "x1" ] ; then
for rule in \
63-md-raid-arrays.rules \
64-md-raid-assembly.rules; do
if [ -f /usr/lib/udev/rules.d/$rule ]; then
cp /usr/lib/udev/rules.d/$rule $tmp_mnt/usr/lib/udev/rules.d
elif [ -f /lib/udev/rules.d/$rule ]; then
cp /lib/udev/rules.d/$rule $tmp_mnt/lib/udev/rules.d
fi
done
fi
save_var need_mdadm

View File

@ -0,0 +1,9 @@
#!/bin/bash
#
#%stage: device
#
if [ "$rootfstype" = "nfs" ]; then
interface=${interface:-default}
save_var rootfstype
fi

View File

@ -160,6 +160,16 @@ Source42: libguestfs.mkinitrd.tar.bz2
Source789653: Pod-Simple-3.23.tar.xz
Source10: libguestfs.mkinitrd.boot.sh
Source11: libguestfs.mkinitrd.setup.sh
#
Source12: libguestfs.mkinitrd.boot-dm.sh
Source13: libguestfs.mkinitrd.setup-dm.sh
Source14: libguestfs.mkinitrd.boot-lvm2.sh
Source15: libguestfs.mkinitrd.setup-lvm2.sh
Source16: libguestfs.mkinitrd.boot-md.sh
Source17: libguestfs.mkinitrd.setup-md.sh
Source18: libguestfs.mkinitrd.boot-nfs.sh
Source19: libguestfs.mkinitrd.setup-nfs.sh
#
Source1220: libguestfs.mkinitrd.1220.patch
Source1210: libguestfs.mkinitrd.1210.patch
Source1110: libguestfs.mkinitrd.1110.patch
@ -632,6 +642,14 @@ head -n 1234 ext_cmds.txt missing_cmds.txt
ln -sfvbn mkinitrd-2.8.1 mkinitrd
ln -sfvbn mkinitrd/sbin/mkinitrd_setup mkinitrd_setup.sh
ln -sfvbn mkinitrd/sbin/mkinitrd mkinitrd.sh
cp -avL %{S:12} mkinitrd/scripts/boot-dm.sh
cp -avL %{S:13} mkinitrd/scripts/setup-dm.sh
cp -avL %{S:14} mkinitrd/scripts/boot-lvm2.sh
cp -avL %{S:15} mkinitrd/scripts/setup-lvm2.sh
cp -avL %{S:16} mkinitrd/scripts/boot-md.sh
cp -avL %{S:17} mkinitrd/scripts/setup-md.sh
cp -avL %{S:18} mkinitrd/scripts/boot-nfs.sh
cp -avL %{S:19} mkinitrd/scripts/setup-nfs.sh
cp -avb /lib/mkinitrd/scripts/* mkinitrd/scripts
mkdir -vp mkinitrd/setup mkinitrd/boot
ln -sfvbn lib/mkinitrd/bin mkinitrd/bin