Compare commits

..

65 Commits
0.9 ... 001

Author SHA1 Message Date
Harald Hoyer
7d14418ce8 dracut.spec and NEWS update 2009-09-02 15:54:44 +02:00
Harald Hoyer
147b37e72e version 001 2009-09-02 15:42:16 +02:00
Harald Hoyer
816bb48d74 reordered blkid/vol_id rules 2009-09-02 15:26:02 +02:00
Peter Rajnoha
6c2905c425 LVM/DM rules in dracut
I've looked at the LVM rules used in dracut just recently
and it needs fixing - we should react to change events only
for DM devices, so we have to skip vol_id/blkid call on ADD:

KERNEL=="dm-[0-9]*", ACTION=="add", GOTO="lvm_end"

Also, MD devices have their own rules, where vol_id/blkid
is called and where the symlinks are created (when looking
into raw initrd, this is in  64-md-raid.rules).

Also, if those rules are meant to be for DM devices only,
maybe we should skip symlink creation for the other devices
there, to keep the rules clean and straightforward. I think
we shouldn't create/recreate symlinks for non-dm devices in
LVM/DM rules (..should be in appropriate rules for that type
of device):

KERNEL!="dm-[0-9]*", GOTO="lvm_end"
2009-09-02 13:53:29 +02:00
Harald Hoyer
194f7d125f 90*/*cleanup.sh: fixed redirection to /dev/null 2009-09-01 15:59:31 +02:00
Harald Hoyer
8ef0be5671 dracut-lib: try to set UDEVVERSION, if not set 2009-09-01 15:51:51 +02:00
Harald Hoyer
b809e77f54 plymouth: in the generic case, only install text and details themes 2009-09-01 15:51:51 +02:00
Harald Hoyer
780afa9876 release any raid/crypt/lvm device assembled, but not in use 2009-09-01 15:51:51 +02:00
Harald Hoyer
5ebc1acb7f selinux-loadpolicy.sh: redirect output of selinux load_policy 2009-09-01 15:51:50 +02:00
Harald Hoyer
59580f28a1 dracut-functions: do not try to clear logfile, if not writable 2009-09-01 15:42:28 +02:00
Harald Hoyer
533d7dc4ab dracut-function: add check for volume group members
see https://bugzilla.redhat.com/show_bug.cgi?id=506189

not all members of a linear volume group are listed in /sys slaves
2009-09-01 15:42:28 +02:00
Harald Hoyer
ec74fa8789 split dracut in network / non-network 2009-09-01 15:42:28 +02:00
Harald Hoyer
988061a5ee dracut.spec: removed s390 conditionals 2009-09-01 15:42:28 +02:00
Harald Hoyer
c10d53bf0c dracut.spec: fixed gittag 2009-09-01 15:42:28 +02:00
Harald Hoyer
54b87586aa fixed gitrpm 2009-09-01 15:42:27 +02:00
Harald Hoyer
461ff22cd5 new test/TEST-13-ENC-RAID-LVM 2009-09-01 15:42:27 +02:00
Harald Hoyer
b1a4919cb2 TEST-12-RAID-DEG/test.sh: add rdinfo 2009-09-01 15:42:27 +02:00
Harald Hoyer
c1d670a893 65-md-incremental-imsm.rules: also check on "change" 2009-09-01 15:42:27 +02:00
Harald Hoyer
b6bf29b054 lvm.rules: blkid for cciss devices 2009-09-01 15:42:27 +02:00
Harald Hoyer
5c6a593f2e add udevsettle function and settle after raid/lvm/crypto activities 2009-09-01 15:42:27 +02:00
Harald Hoyer
f4c36b28f6 mdraid_start: check if raid is already active before trying to run it 2009-09-01 15:42:27 +02:00
Harald Hoyer
73e649b5f5 dracut.spec: require policycoreutils 2009-09-01 15:42:26 +02:00
Harald Hoyer
ba72631039 add hostonly to dracut.conf 2009-09-01 15:42:26 +02:00
Warren Togami
a89fb6daa5 Write netboot config for passing to OS as requested in https://bugzilla.redhat.com/show_bug.cgi?id=515771#c18 2009-08-31 19:34:27 -04:00
Harald Hoyer
6568d86aec instmods(): fixed "instmods =drivers/md" 2009-08-28 13:33:57 +02:00
Hans de Goede
3508cc816e Add fcoe booting support
Supported cmdline formats:
fcoe=<networkdevice>:<dcb|nodcb>
fcoe=<macaddress>:<dcb|nodcb>

Note currently only nodcb is supported, the dcb option is reserved for
future use.

Note letters in the macaddress must be lowercase!

Examples:
fcoe=eth0:nodcb
fcoe=4A:3F:4C:04:F8:D7:nodcb
2009-08-28 12:53:56 +02:00
Harald Hoyer
ffa264f077 dracut.8: document rootfstype and rootflags 2009-08-28 12:53:03 +02:00
Harald Hoyer
84c2266f1a network/installkernel: it's eth_type_trans and not eth_type_transfer 2009-08-27 13:06:46 +02:00
Harald Hoyer
973c23b0d6 should_source_module(): refined check
Do not bail out early if no install exists.
Check also for installkernel.
2009-08-27 12:53:38 +02:00
Victor Lowther
9ede1929b2 Oops, clean up broken get_fs_type implementation.
While we are at it, make a couple of other fixups.
2009-08-22 12:04:11 -05:00
Victor Lowther
054e038512 Add accurate --hostonly checking for 95iscsi 2009-08-21 22:22:40 -05:00
Victor Lowther
fb8923f681 Minor fixups to kernel module loading
Also rewrite filter_kernel_modules to make it a little easier to read.
2009-08-20 22:21:33 -05:00
Victor Lowther
240cc7c480 Abstract out hostonly vs. generic module installation differences.
This introduces filter_kernel_modules, which should be used to install
all kernel modules that match whatever criteria you want.

If running in --hostonly, filter_kernel_modules will only consider
modules that are loaded in the kernel, otherwise it will consider
all the modules installed on the system for the appropriate kernel.

This drastically reduces initramfs generation time when using --hostonly
by eliminating lots of unneeded filesystem activity.
2009-08-20 15:52:45 -05:00
Victor Lowther
8d04a1287d Some updates to the README files 2009-08-20 14:14:21 -05:00
Victor Lowther
16df64ef1f Abstract out vol_id vs. blkid usage.
vol_id seems to be going away, and blkid can be used as a drop-in replacement
for it.
2009-08-20 07:28:04 -05:00
Victor Lowther
f76ef3aa3d Speed up loading block drivers when running with --hostonly
Instead of grovelling through all the modules available for the
kernel looking for block devices, only look at the modules that are
actually loaded. This speeds things up by a rather large amount
when generating the initramfs with --hostonly.

While we are at it, only load the filesystem module that will actually
be used for the root filesystem when running in --hostonly instead
of all the filesystem modules that happen to be loaded at the time.
2009-08-19 22:21:29 -05:00
Victor Lowther
59c88f499f Abstract out vol_id vs. blkid usage
Since different distros may or may not use vol_id in udev, and blkid
is generally replacing vol_id, abstract them out into a function which
tries to use vol_id first and blkid second, on the assumption that
blkid can take over for vol_id if vol_id is no longer there.
2009-08-19 22:21:07 -05:00
Harald Hoyer
afe25d0ccc {crypt,dmraid,,lvm,mdraid}/check use blkid if no vol_id found 2009-08-19 17:11:29 +02:00
Harald Hoyer
bdccc34e7e Makefile: add hostimage target for a hostonly image
call it with root priviledges
2009-08-19 17:10:38 +02:00
Harald Hoyer
495a964322 nbd/check: moved host-only checks and added ";" 2009-08-19 17:09:53 +02:00
Harald Hoyer
9defc609e8 dracut-functions: check for existance of slave devices before opening it 2009-08-19 17:08:57 +02:00
Harald Hoyer
68b26290f0 udev-rules: install vol_id 2009-08-19 11:12:42 +02:00
Harald Hoyer
d41f7ae750 rsyslogd-start.sh: read correct filters file 2009-08-19 10:59:37 +02:00
Marc Grimme
e15bc1f330 Syslog support for dracut
This module provides syslog functionality in the initrd.
This is especially interesting when complex configuration being
used to provide access to the device the rootfs resides on.

When this module is installed into the ramfs it is triggered by
the udev event from the nic being setup (online).

Then if syslog is configured it is started and will forward all
kernel messages to the given syslog server.

The syslog implementation is detected automatically by finding the
apropriate binary with the following order:
rsyslogd
syslogd
syslog-ng
Then if detected the syslog.conf is generated and syslog is started.

Bootparameters:
syslogserver=ip    Where to syslog to
sysloglevel=level  What level has to be logged
syslogtype=rsyslog|syslog|syslogng
                   Don't auto detect syslog but set it
2009-08-19 10:40:02 +02:00
Jeremy Katz
a607b7d4b8 Fix syntax error in conditional
Fix a typo in the conditionals.  Not sure how I didn't notice these
before
2009-08-19 10:34:06 +02:00
Victor Lowther
1a4c4015bc Modify nbd hostonly checking to use check_block_and_slaves.
This allows hostonly nbd checking to work in more exotic situations,
such as mdraid/dmraid/lvm/crypt on top of nbd.
2009-08-16 18:22:21 -05:00
Victor Lowther
d7df77d172 Modified lvm hostonly checking to use dracut-functions 2009-08-16 15:29:59 -05:00
Victor Lowther
7e2b4f8367 Make mdraid checking use common functionality in dracut-functions 2009-08-16 15:29:59 -05:00
Victor Lowther
bc9ae19deb Make dmraid checking use common functionality in dracut-functions 2009-08-16 15:29:50 -05:00
Victor Lowther
17829e94aa Move common rootfs finding and backing store tree checking to dracut-functions 2009-08-16 15:29:50 -05:00
Victor Lowther
e0dca0e43c Minor spacing fixups in dracut-finctions 2009-08-16 15:29:49 -05:00
Victor Lowther
4e207ec862 The network check script sources , so it must use /bin/bash 2009-08-16 15:29:49 -05:00
Victor Lowther
b5ccf21d2b Make the lvm check script really check to see if root is on an lvm device
somehow when run in hostonly mode.
2009-08-16 15:29:42 -05:00
Victor Lowther
62bde8ed7e make mdraid check script really check to see of the rootfs is on an
mdraid block device when run in hostonly mode.
2009-08-16 15:29:27 -05:00
Victor Lowther
dc670134f8 Make hostonly check for dmraid only pass if root is really on
a dmraid volume somehow.
2009-08-16 15:29:18 -05:00
Victor Lowther
39d6cb5df4 Make hostonly checking in 90crypt only pass if root is really on an
encrypted block device somewhere along the chain.
2009-08-16 15:28:56 -05:00
Victor Lowther
ddfd1d10a0 Split kernel module loading into smaller chunks.
This prepares to more tightly integrate dracut-gencmdline with the
rest of the dracut scripts
2009-08-16 15:28:45 -05:00
Victor Lowther
0c1a8ebc37 More quotation fixups in dracut-functions 2009-08-15 10:56:36 -05:00
Victor Lowther
bd4c4bcb76 Simplify dracut_install a bit, an make a minor fixup to check_module_deps 2009-08-15 07:55:59 -05:00
Victor Lowther
161efa1f40 Some quotation cleanups in dracut-functions.
Quotes are generally not needed in when assigning one variable to another,
and are also not needed inside [[ ]] comaprisons, as word splitting and
pathname expansion are not performed in these cases.
2009-08-15 07:38:26 -05:00
Victor Lowther
ebdddd29d3 Get rid of redundant NONL stuff in dracut-gencmdline 2009-08-14 22:54:38 -05:00
Victor Lowther
2790d5b2ed Update dracut-catimages to make it much more robust in the face of
image filenames with spaces, carriage returns, and other such nasty
characters in them.  Bash arrays are very useful for these sorts of things.
2009-08-14 22:51:25 -05:00
Victor Lowther
98adb06ea3 No need to quote variable expansion in [[ ]] 2009-08-14 22:36:41 -05:00
Victor Lowther
0b90cfaa9f Bashify drivers_dir check 2009-08-14 22:31:04 -05:00
Harald Hoyer
ded38dbfbd dracut.spec add NEWS to dracut and dracut-tools 2009-08-14 18:03:33 +02:00
72 changed files with 1036 additions and 260 deletions

View File

@@ -1,4 +1,4 @@
VERSION=0.9
VERSION=001
GITVERSION=$(shell [ -d .git ] && git rev-list --abbrev-commit -n 1 HEAD |cut -b 1-8)
prefix = /usr
@@ -54,7 +54,12 @@ rpm: clean dracut-$(VERSION).tar.bz2
rm -fr BUILD BUILDROOT
gitrpm: dracut-$(VERSION)-$(GITVERSION).tar.bz2
rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" --define "_specdir $$PWD" --define "_srcrpmdir $$PWD" --define "_rpmdir $$PWD" --define "gittag $(GITVERSION)" -ba dracut.spec
echo "%define gittag $(GITVERSION)" > dracut.spec.git
cat dracut.spec >> dracut.spec.git
mv dracut.spec dracut.spec.bak
mv dracut.spec.git dracut.spec
rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" --define "_specdir $$PWD" --define "_srcrpmdir $$PWD" --define "_rpmdir $$PWD" --define "gittag $(GITVERSION)" -ba dracut.spec
mv dracut.spec.bak dracut.spec
rm -fr BUILD BUILDROOT
check: all
@@ -73,5 +78,8 @@ testimages: all
./dracut -l -a debug --no-kernel -f test-dracut.img $(shell uname -r)
@echo wrote test-dracut.img
hostimage: all
./dracut -H -l -a debug -f test-$(shell uname -r).img $(shell uname -r)
@echo wrote test-$(shell uname -r).img

24
NEWS
View File

@@ -1,3 +1,27 @@
dracut-001
==========
- better --hostonly checks
- better lvm/mdraid/dmraid handling
- fcoe booting support
Supported cmdline formats:
fcoe=<networkdevice>:<dcb|nodcb>
fcoe=<macaddress>:<dcb|nodcb>
Note currently only nodcb is supported, the dcb option is reserved for
future use.
Note letters in the macaddress must be lowercase!
Examples:
fcoe=eth0:nodcb
fcoe=4A:3F:4C:04:F8:D7:nodcb
- Syslog support for dracut
This module provides syslog functionality in the initrd.
This is especially interesting when complex configuration being
used to provide access to the device the rootfs resides on.
dracut-0.9
==========
- let plymouth attach to the terminal (nice text output now)

10
README
View File

@@ -21,8 +21,10 @@ as hooks are guaranteed to be the path to slow-down.
Most of the initrd generation functionality in dracut is provided by a bunch
of generator modules that are sourced by the main dracut script to install
specific functionality into the initrd. They live in the modules.d subdirectory,
and use functionality provided by dracut-functions to do their work.
specific functionality into the initrd. They live in the modules.d
subdirectory, and use functionality provided by dracut-functions to do their
work.
Some general rules for writing modules:
* Use one of the inst family of functions to actually install files
on to the initrd. They handle mangling the pathnames and (for binaries,
@@ -59,13 +61,13 @@ the documentation, git access, etc.
Git Repository:
http://dracut.git.sourceforge.net/
git://dracut.git.sourceforge.net/gitroot/dracut
git://dracut.git.sourceforge.net/gitroot/dracut/dracut
Trac Instance:
http://apps.sourceforge.net/trac/dracut/
The git tree can be found at
git://dracut.git.sourceforge.net/gitroot/dracut for now. See the TODO
git://dracut.git.sourceforge.net/gitroot/dracut/dracut for now. See the TODO
file for things which still need to be done and HACKING for some
instructions on how to get started. There is also a mailing list that
is being used for the discussion -- initramfs@vger.kernel.org. It is

View File

@@ -8,3 +8,6 @@ To build a generic initramfs, you have to install the following software package
* mdadm
* net-tools iproute
Generic initramfs'es are huge (usually over 10 megs in size uncompressed), but
should be able to automatically boot any bootable configuration with appropriate
boot flags (root device, network configuration information, etc.)

View File

@@ -35,7 +35,7 @@ check: Dracut calls this program to check and see if a module can be installed
are present. It should exit with a 0 if they are, and a 1 if they are
not.
When called with -H, it should perform the same check that it would
When called with -h, it should perform the same check that it would
without any options, and it should also check to see if the
functionality the module implements is being used on the host system.
For example, if this module handles installing support for LUKS
@@ -43,9 +43,12 @@ check: Dracut calls this program to check and see if a module can be installed
encrpted volumes are available and the host system has the root
partition on an encrypted volume, 1 otherwise.
When called with -d, it should output a list of dracut modules
that it relies upon. An example would be the nfs and iscsi modules,
which rely on the network module to detect and configure network
interfaces.
Check may take additional options in the future.
We will most likely grow a module dependency checking system in the
near future, and check will need to handle a -d option when we do.
Any other files in the module will not be touched by dracut directly.

27
dracut
View File

@@ -80,7 +80,7 @@ while (($# > 0)); do
-v|--verbose) beverbose="yes";;
-c|--conf) conffile="$2"; shift;;
-l|--local) allowlocal="yes" ;;
-H|--hostonly) hostonly="-h" ;;
-H|--hostonly) hostonly_l="yes" ;;
-i|--include) include_src="$2"; include_target="$3"; shift 2;;
-I|--install) install_items="$2"; shift;;
-*) printf "\nUnknown option: %s\n\n" "$1" >&2; usage; exit 1;;
@@ -110,9 +110,14 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
[[ $drivers_dir_l ]] && drivers_dir=$drivers_dir_l
[[ $fw_dir_l ]] && fw_dir=$fw_dir_l
[[ $do_strip_l ]] && do_strip=$do_strip_l
[[ $hostonly_l ]] && hostonly=$hostonly_l
[[ $dracutbasedir ]] || dracutbasedir=/usr/share/dracut
[[ $fw_dir ]] || fw_dir=/lib/firmware
[[ $do_strip ]] || do_strip=yes
# eliminate IFS hackery when messing with fw_dir
fw_dir=${fw_dir//:/ }
[[ $hostonly = yes ]] && hostonly="-h"
[[ $allowlocal && -f "$(dirname $0)/dracut-functions" ]] && dsrc="$(dirname $0)" || dsrc=$dracutbasedir
@@ -136,7 +141,7 @@ esac
[[ $1 ]] && outfile=$(readlink -f $1) || outfile="/boot/initrd-$kernel.img"
srcmods="/lib/modules/$kernel/"
[ -n "$drivers_dir" ] && srcmods="$drivers_dir"
[[ $drivers_dir ]] && srcmods="$drivers_dir"
export srcmods
if [[ -f $outfile && ! $force ]]; then
@@ -155,7 +160,7 @@ chmod 755 "$initdir"
export initdir hookdirs dsrc dracutmodules drivers \
fw_dir drivers_dir debug beverbose no_kernel kernel_only
if [[ "$kernel_only" != "yes" ]]; then
if [[ $kernel_only != yes ]]; then
# Create some directory structure first
for d in bin sbin usr/bin usr/sbin usr/lib etc proc sys sysroot tmp dev/pts var/run; do
mkdir -p "$initdir/$d";
@@ -170,11 +175,11 @@ check_modules
for moddir in "$dsrc/modules.d"/[0-9][0-9]*; do
mod=${moddir##*/}; mod=${mod#[0-9][0-9]}
if strstr "$mods_to_load" " $mod "; then
if [[ "$kernel_only" = "yes" ]]; then
[[ -x "$moddir/installkernel" ]] && . "$moddir/installkernel"
if [[ $kernel_only = yes ]]; then
[[ -x $moddir/installkernel ]] && . "$moddir/installkernel"
else
. "$moddir/install"
if [[ "$no_kernel" != "yes" && -x "$moddir/installkernel" ]]; then
if [[ $no_kernel != yes && -x $moddir/installkernel ]]; then
. "$moddir/installkernel"
fi
fi
@@ -187,7 +192,7 @@ echo $mods_to_load
## final stuff that has to happen
# generate module dependencies for the initrd
if [ -d "$initdir/lib/modules/$kernel" ]; then
if [[ -d $initdir/lib/modules/$kernel ]]; then
if ! depmod -a -b "$initdir" $kernel; then
echo "\"depmod -a $kernel\" failed."
exit 1
@@ -207,10 +212,10 @@ for item in $install_items; do
done
unset item
[[ "$beverbose" = "yes" ]] && (du -c "$initdir" | sort -n)
[[ $beverbose = yes ]] && (du -c "$initdir" | sort -n)
# strip binaries
if [ "$do_strip" = "yes" ] ; then
if [[ $do_strip = yes ]] ; then
for p in strip objdump sed grep find; do
if ! which $p >/dev/null 2>&1; then
derror "Could not find '$p'. You should run $0 with '--nostrip'."
@@ -219,7 +224,7 @@ if [ "$do_strip" = "yes" ] ; then
done
fi
if [ "$do_strip" = "yes" ] ; then
if [[ $do_strip = yes ]] ; then
for f in $(find "$initdir" -type f \( -perm -0100 -or -perm -0010 -or -perm -0001 \) -exec file {} \; |
grep -v ' shared object,' |
sed -n -e 's/^\(.*\):[ ]*ELF.*, not stripped/\1/p'); do
@@ -240,7 +245,7 @@ fi
( cd "$initdir"; find . |cpio -R 0:0 -H newc -o |gzip -9 > "$outfile"; )
[[ "$beverbose" = "yes" ]] && ls -lh "$outfile"
[[ $beverbose = yes ]] && ls -lh "$outfile"
exit 0

View File

@@ -70,7 +70,7 @@ done
outfile=$1; shift
if [ -z "$outfile" ]; then
if [[ -z $outfile ]]; then
derror "No output file specified."
usage
exit 1
@@ -78,45 +78,47 @@ fi
baseimage=$1; shift
if [ -z "$baseimage" ]; then
if [[ -z $baseimage ]]; then
derror "No base image specified."
usage
exit 1
fi
if [ -f $outfile -a -z "$force" ]; then
if [[ -f $outfile && ! $force ]]; then
derror "Will not override existing initramfs ($outfile) without --force"
exit 1
fi
if [ -z "$no_imagedir" -a ! -d "$imagedir" ]; then
if [[ ! $no_imagedir && ! -d $imagedir ]]; then
derror "Image directory $overlay is not a directory"
exit 1
fi
if [ -z "$no_overlay" -a ! -d "$overlay" ]; then
if [[ ! $no_overlay && ! -d $overlay ]]; then
derror "Overlay $overlay is not a directory"
exit 1
fi
if [ -z "$no_overlay" ]; then
if [[ ! $no_overlay ]]; then
ofile="$imagedir/90-overlay.img"
dinfo "Creating image $ofile from directory $overlay"
( cd "$overlay"; find . |cpio --quiet -H newc -o |gzip -9 > "$ofile"; )
fi
if [ -z "$no_imagedir" ]; then
images=$(for i in $imagedir/*.img;do [ -f $i ] || continue; echo $i; done)
if [[ ! $no_imagedir ]]; then
for i in "$imagedir/"*.img; do
[[ -f $i ]] && images+=("$i")
done
fi
images="$images $@"
images+=($@)
dinfo "Using base image $baseimage"
cat $baseimage > $outfile
cat "$baseimage" > "$outfile"
for i in $images; do
for i in "${images[@]}"; do
dinfo "Appending $i"
cat $i >> $outfile
cat "$i" >> "$outfile"
done
dinfo "Created $outfile"

View File

@@ -22,30 +22,113 @@ IF_RTLD=""
IF_dynamic=""
# Generic substring function. If $2 is in $1, return 0.
strstr() { [[ ! ${1#*$2*} = $1 ]]; }
strstr() { [[ $1 =~ $2 ]]; }
# Log initrd creation.
if ! [[ $dracutlogfile ]]; then
[[ $dsrc = /usr/share/dracut ]] && \
dracutlogfile=/var/log/dracut.log || \
dracutlogfile=/tmp/dracut.log
[[ -w "$dracutlogfile" ]] || dracutlogfile=/tmp/dracut.log
>"$dracutlogfile"
dracutlogfile=/var/log/dracut.log || \
dracutlogfile=/tmp/dracut.log
# [[ -w $dracutlogfile ]] || dracutlogfile=/tmp/dracut.log
if [[ -w $dracutlogfile ]]; then
>"$dracutlogfile"
fi
fi
dwarning() {
echo "W: $@" >&2
[[ -w "$dracutlogfile" ]] && echo "W: $@" >>"$dracutlogfile"
[[ -w $dracutlogfile ]] && echo "W: $@" >>"$dracutlogfile"
}
dinfo() {
[[ $beverbose ]] && echo "I: $@" >&2
[[ -w "$dracutlogfile" ]] && echo "I: $@" >>"$dracutlogfile"
[[ -w $dracutlogfile ]] && echo "I: $@" >>"$dracutlogfile"
}
derror() {
echo "E: $@" >&2
[[ -w "$dracutlogfile" ]] && echo "E: $@" >>"$dracutlogfile"
[[ -w $dracutlogfile ]] && echo "E: $@" >>"$dracutlogfile"
}
get_fs_env() {
if [[ -x /lib/udev/vol_id ]]; then
eval $(/lib/udev/vol_id --export $1)
elif find_binary blkid >/dev/null; then
eval $(blkid -o udev $1)
else
return 1
fi
}
get_fs_type() (
get_fs_env $1 || return
echo $ID_FS_TYPE
)
get_fs_uuid() (
get_fs_env $1 || return
echo $ID_FS_UUID
)
# finds the major:minor of the block device backing the root filesystem.
find_block_device() {
local rootdev blkdev fs type opts misc
while read blkdev fs type opts misc; do
[[ $blkdev = rootfs ]] && continue # skip rootfs entry
[[ $fs = $1 ]] && { rootdev=$blkdev; break; } # we have a winner!
done < /proc/mounts
[[ -b $rootdev ]] || return 1 # oops, not a block device.
# get major/minor for the device
ls -nLl "$rootdev" | \
(read x x x x maj min x; maj=${maj//,/}; echo $maj:$min)
}
find_root_block_device() { find_block_device /; }
# Walk all the slave relationships for a given block device.
# Stop when our helper function returns success
# $1 = function to call on every found block device
# $2 = block device in major:minor format
check_block_and_slaves() {
local x
[[ -b /dev/block/$2 ]] || return 1 # Not a block device? So sorry.
"$1" $2 && return
check_vol_slaves "$@" && return 0
[[ -d /sys/dev/block/$2/slaves ]] || return 1
for x in /sys/dev/block/$2/slaves/*/dev; do
[[ -f $x ]] || continue
check_block_and_slaves $1 $(cat "$x") && return 0
done
return 1
}
get_numeric_dev() {
ls -lH "$1" | { read a b c d maj min rest; printf "%d:%d" ${maj%%,} $min;}
}
# ugly workaround for the lvm design
# There is no volume group device,
# so, there are no slave devices for volume groups.
# Logical volumes only have the slave devices they really live on,
# but you cannot create the logical volume without the volume group.
# And the volume group might be bigger than the devices the LV needes.
check_vol_slaves() {
for i in /dev/mapper/*; do
lv=$(get_numeric_dev $i)
if [[ $lv = $2 ]]; then
vg=$(lvm lvs --noheadings -o vg_name $i 2>/dev/null)
# strip space
vg=$(echo $vg)
if [[ $vg ]]; then
for pv in $(lvm vgs --noheadings -o pv_name "$vg" 2>/dev/null); \
do
check_block_and_slaves $1 $(get_numeric_dev $pv) \
&& return 0
done
fi
fi
done
return 1
}
# $1 = file to copy to ramdisk
@@ -55,7 +138,7 @@ derror() {
inst_simple() {
local src target
[[ -f $1 ]] || return 1
src=$1 target="${initdir}${2:-$1}"
src=$1 target=${initdir}${2:-$1}
[[ -f $target ]] && return 0
mkdir -p "${target%/*}"
dinfo "Installing $src"
@@ -69,10 +152,10 @@ inst_library() {
local src=$1 dest=${2:-$1}
[[ -f $initdir$dest ]] && return 0
if [[ -L $src ]]; then
reallib="$(readlink -f "$src")"
reallib=$(readlink -f "$src")
lib=${src##*/}
inst_simple "$reallib" "$reallib"
mkdir -p ${initdir}${dest%/*}
mkdir -p "${initdir}${dest%/*}"
(cd "${initdir}${dest%/*}" && ln -s "$reallib" "$lib")
else
inst_simple "$src" "$dest"
@@ -115,15 +198,15 @@ inst_binary() {
lib_regex='^(/lib[^/]*).*'
if [[ $FILE =~ $lib_regex ]]; then
TLIBDIR=${BASH_REMATCH[1]}
BASE="${FILE##*/}"
BASE=${FILE##*/}
# prefer nosegneg libs, then unoptimized ones.
for f in "$TLIBDIR/i686/nosegneg" "$TLIBDIR"; do
[[ -f $f/$BASE ]] || continue
FILE="$f/$BASE"
FILE=$f/$BASE
break
done
inst_library "$FILE" "$TLIBDIR/$BASE"
IF_dynamic="yes"
IF_dynamic=yes
continue
fi
inst_library "$FILE"
@@ -150,7 +233,7 @@ inst_symlink() {
[[ -L $1 ]] || return 1
[[ -L $target ]] && return 0
realsrc=$(readlink -f "$src")
[[ $realsrc = ${realsrc##*/} ]] && realsrc="${src%/*}/$realsrc"
[[ $realsrc = ${realsrc##*/} ]] && realsrc=${src%/*}/$realsrc
inst "$realsrc" && ln -s "$realsrc" "$target"
}
@@ -166,10 +249,10 @@ find_rule() {
# udev rules always get installed in the same place, so
# create a function to install them to make life simpler.
inst_rules() {
local target="/etc/udev/rules.d"
local target=/etc/udev/rules.d
mkdir -p "$initdir/lib/udev/rules.d" "$initdir$target"
for rule in "$@"; do
rule=$(find_rule $rule) && \
rule=$(find_rule "$rule") && \
inst_simple "$rule" "$target/${rule##*/}"
done
}
@@ -203,32 +286,27 @@ inst_hook() {
}
dracut_install() {
local optional=
if [[ $1 = '-o' ]]; then
local optional=yes
shift
fi
while (($# > 0)); do
# Might be nice to optionally install a binary
if [ "$1" == "-o" ]; then
optional="yes"
shift
continue
fi
if inst "$1" ; then
shift
continue
fi
if [ "$optional" == "yes" ]; then
dwarning "Skipping program $1 as it cannot be found and is flagged to be optional"
shift
continue
else
derror "Failed to install $1"; exit 1
fi
if ! inst "$1" ; then
if [[ $optional = yes ]]; then
dwarning "Skipping program $1 as it cannot be found and is flagged to be optional"
else
derror "Failed to install $1"
exit 1
fi
fi
shift
done
}
check_module_deps() {
local moddir dep ret
# if we are already set to be loaded, we do not have to be checked again.
strstr "$mods_to_load" " $1 "
strstr "$mods_to_load" " $1 " && return
# turn a module name into a directory, if we can.
moddir=$(echo ${dsrc}/modules.d/??${1})
[[ -d $moddir && -x $moddir/install ]] || return 1
@@ -249,11 +327,11 @@ check_module_deps() {
should_source_module() {
local dep
[[ -x $1/install ]] || return 1
if [[ "$kernel_only" = "yes" ]]; then
if [[ $kernel_only = yes ]]; then
[[ -x $1/installkernel ]] && return 0
return 1
fi
[[ -x $1/install ]] || [[ -x $1/installkernel ]] || return 1
[[ -x $1/check ]] || return 0
"$1/check" $hostonly || return 1
for dep in $("$1/check" -d); do
@@ -280,16 +358,72 @@ check_modules() {
done
}
# install kernel modules, and handle installing all their dependencies as well.
# Install a single kernel module along with any firmware it may require.
# $1 = full path to kernel module to install
install_kmod_with_fw() {
local modname=${1##*/} fwdir found
modname=${modname%.ko}
inst_simple "$1" "/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" || \
return 0 # no need to go further if the module is already installed
for fw in $(modinfo -k $kernel -F firmware $1 2>/dev/null); do
found=''
for fwdir in $fw_dir; do
if [[ -d $fwdir && -f $fwdir/$fw ]]; then
inst_simple "$fwdir/$fw" "/lib/firmware/$fw"
found=yes
fi
done
if [[ $found != yes ]]; then
dwarning "Possible missing firmware ${fw} for module ${mod}.ko"
fi
done
}
# Do something with all the dependencies of a kernel module.
# Note that kernel modules depend on themselves using the technique we use
# $1 = function to call for each dependency we find
# It will be passed the full path to the found kernel module
# $2 = module to get dependencies for
# rest of args = arguments to modprobe
for_each_kmod_dep() {
local func=$1 kmod=$2 cmd modpapth options
shift 2
modprobe "$@" --ignore-install --show-depends $kmod 2>/dev/null | \
while read cmd modpath options; do
[[ $cmd = insmod ]] || continue
$func $modpath
done
}
# filter kernel modules to install certian modules that meet specific
# requirements.
# $1 = function to call with module name to filter.
# This function will be passed the full path to the module to test.
# The behaviour of this function can vary depending on whether $hostonly is set.
# If it is, we will only look at modules that are already in memory.
# If it is not, we will look at all kernel modules
# This function returns the full filenames of modules that match $1
filter_kernel_modules () (
if [[ $hostonly = '' ]]; then
filtercmd='find "$srcmods/kernel/drivers" -name "*.ko"'
else
filtercmd='cut -d " " -f 1 </proc/modules|xargs modinfo -F filename -k $kernel'
fi
for modname in $(eval $filtercmd); do
"$1" "$modname" && echo "$modname"
done
)
# install kernel modules along with all their dependencies.
instmods() {
[[ "$no_kernel" = "yes" ]] && return
[[ $no_kernel = yes ]] && return
local mod mpargs modpath modname cmd
while (($# > 0)); do
mod=${1%.ko}
case $mod in
=*) # This introduces 2 incompatible meanings for =* arguments
# to instmods. We need to decide which one to keep.
if [ "$mod" = "=ata" -a -f $srcmods/modules.block ] ; then
if [[ $mod = =ata && -f $srcmods/modules.block ]] ; then
instmods $mpargs $(egrep 'ata|ahci' "${srcmods}/modules.block")
elif [ -f $srcmods/modules.${mod#=} ]; then
instmods $mpargs $(cat ${srcmods}/modules.${mod#=} )
@@ -297,13 +431,16 @@ instmods() {
instmods $mpargs $(find "$srcmods" -path "*/${mod#=}/*")
fi
;;
--*) mpargs+=" $mod";;
--*)
mod=${mod##*/}
mpargs+=" $mod";;
i2o_scsi)
# Must never run this diagnostic-only module
shift; continue;
;;
*) mod=${mod##*/}
# if we are already installed, skip this module and go on
*)
mod=${mod##*/}
# if we are already installed, skip this module and go on
# to the next one.
[[ -f $initdir/$1 ]] && { shift; continue; }
# If we are building a host-specific initramfs and this
@@ -311,31 +448,10 @@ instmods() {
[[ $hostonly ]] && ! grep -q "$mod" /proc/modules && {
shift; continue;
}
modprobe $mpargs --ignore-install --set-version $kernel -d ${srcmods%%/lib/modules/*}/ \
--show-depends $mod 2>/dev/null | \
while read cmd modpath options; do
[[ $cmd = insmod ]] || continue
modname=${modpath##*/}
modname=${modname%.ko}
if [[ ${mod/-/_} != ${modname/-/_} ]]; then
dinfo "Installing dependencies for $mod ($modpath)"
instmods $mpargs $modname
fi
inst_simple "$modpath" "/lib/modules/$kernel/${modpath##*/lib/modules/$kernel/}"
for fw in $(modinfo -k $kernel -F firmware $modpath 2>/dev/null); do
unset found
IFS=:
for fwdir in $fw_dir; do
if [ -d "$fwdir" -a -f $fwdir/$fw ]; then
inst_simple "$fwdir/$fw" "/lib/firmware/$fw"
found=yes
fi
done
if [ "$found" != "yes" ]; then
dwarning "Possible missing firmware ${fw} for module ${mod}.ko"
fi
done
done
# ok, load the module, all its dependencies, and any firmware
# it may require
for_each_kmod_dep install_kmod_with_fw $mod \
--set-version $kernel -d ${srcmods%%/lib/modules/*}/
;;
esac
shift

View File

@@ -21,22 +21,11 @@
function error() {
local NONL=""
if [ "$1" == "-n" ]; then
NONL="-n"
shift
fi
echo $NONL "$@" >&2
echo "$@" >&2
}
function vecho() {
return
local NONL=""
if [ "$1" == "-n" ]; then
NONL="-n"
shift
fi
is_verbose && echo $NONL "$@"
is_verbose && echo "$@"
}
# module dep finding and installation functions
@@ -52,18 +41,11 @@ moduledep() {
[ -n "$deps" ] && vecho ": $deps" || vecho
}
if [ $UID != 0 ]; then
error "$0 must be run as root."
exit 1
fi
export MALLOC_PERTURB_=204
PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
export PATH
. /etc/rc.d/init.d/functions
# Set the umask. For iscsi, the initrd can contain plaintext
# password (chap secret), so only allow read by owner.
umask 077

View File

@@ -95,7 +95,10 @@ root filesystem.
.B root=<path to blockdevice>
specify e.g. \fI/dev/sda1\fR or
\fI/dev/disk/by-path/pci-0000:00:1f.1-scsi-0:0:1:0-part1\fR
.B rootfstype=<filesystem type>
"auto" if not specified, e.g. \fIrootfstype=ext3\fR
.B rootflags=<mount options>
specify additional mount options for the root filesystem
.SH I18N
e.g. LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYTABLE=de-latin1-nodeadkeys
.TP

View File

@@ -8,3 +8,6 @@
# Additional kernel modules to install
#drivers=""
# build initrd only to boot current hardware
#hostonly="-h"

View File

@@ -5,14 +5,14 @@
%endif
%if %{defined gittag}
%define rdist 1.git%{gittag}%{?dist}
%define rdist .git%{gittag}%{?dist}
%define dashgittag -%{gittag}
%else
%define rdist %{?dist}
%endif
Name: dracut
Version: 0.9
Version: 001
Release: 1%{?rdist}
Summary: Initramfs generator using udev
Group: System Environment/Base
@@ -40,13 +40,11 @@ Requires: filesystem >= 2.1.0, cpio, device-mapper, initscripts >= 8.63-1
Requires: e2fsprogs >= 1.38-12, libselinux, libsepol, coreutils
Requires: mdadm, elfutils-libelf, plymouth >= 0.7.0
Requires: cryptsetup-luks
Requires: bridge-utils
Requires: file
Requires: bzip2
%ifnarch s390 s390x
Requires: policycoreutils
Requires: dmraid
Requires: kbd
%endif
%if ! 0%{?with_switch_root}
Requires: util-linux-ng >= 2.16
@@ -56,20 +54,29 @@ BuildArch: noarch
%description
dracut is a new, event-driven initramfs infrastructure based around udev.
%package generic
Summary: Metapackage to build a generic initramfs with dracut
%package network
Summary: dracut modules to build a dracut initramfs with network support
Requires: %{name} = %{version}-%{release}
Requires: rpcbind nfs-utils
Requires: iscsi-initiator-utils
Requires: nbd
Requires: net-tools iproute
Requires: plymouth-system-theme plymouth-theme-charge plymouth-theme-solar
Requires: plymouth-theme-fade-in plymouth-theme-spinfinity
Requires: bridge-utils
%description network
This package requires everything which is needed to build a generic
all purpose initramfs with network support with dracut.
%package generic
Summary: Metapackage to build a generic initramfs with dracut
Requires: %{name} = %{version}-%{release}
Requires: %{name}-network = %{version}-%{release}
%description generic
This package requires everything which is needed to build a generic
all purpose initramfs with dracut.
%package kernel
Summary: Metapackage to build generic initramfs with dracut with only kernel modules
Requires: %{name} = %{version}-%{release}
@@ -102,7 +109,8 @@ make
%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT sbindir=/sbin sysconfdir=/etc mandir=%{_mandir}
make install DESTDIR=$RPM_BUILD_ROOT sbindir=/sbin \
sysconfdir=/etc mandir=%{_mandir}
%if ! 0%{?with_switch_root}
rm -f $RPM_BUILD_ROOT/sbin/switch_root
@@ -116,28 +124,54 @@ rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,0755)
%doc README HACKING TODO COPYING AUTHORS
%doc README HACKING TODO COPYING AUTHORS NEWS
/sbin/dracut
%if 0%{?with_switch_root}
/sbin/switch_root
%endif
%dir %{_datadir}/dracut
%{_datadir}/dracut/dracut-functions
%{_datadir}/dracut/modules.d
%config(noreplace) /etc/dracut.conf
%{_mandir}/man8/dracut.8*
%{_datadir}/dracut/modules.d/00dash
%{_datadir}/dracut/modules.d/10redhat-i18n
%{_datadir}/dracut/modules.d/10rpmversion
%{_datadir}/dracut/modules.d/50plymouth
%{_datadir}/dracut/modules.d/90crypt
%{_datadir}/dracut/modules.d/90dmraid
%{_datadir}/dracut/modules.d/90dmsquash-live
%{_datadir}/dracut/modules.d/90kernel-modules
%{_datadir}/dracut/modules.d/90lvm
%{_datadir}/dracut/modules.d/90mdraid
%{_datadir}/dracut/modules.d/95debug
%{_datadir}/dracut/modules.d/95resume
%{_datadir}/dracut/modules.d/95rootfs-block
%{_datadir}/dracut/modules.d/95s390
%{_datadir}/dracut/modules.d/95terminfo
%{_datadir}/dracut/modules.d/95udev-rules
%{_datadir}/dracut/modules.d/95udev-rules.ub810
%{_datadir}/dracut/modules.d/98syslog
%{_datadir}/dracut/modules.d/99base
%files generic
%files network
%defattr(-,root,root,0755)
%doc README.generic
%{_datadir}/dracut/modules.d/40network
%{_datadir}/dracut/modules.d/95fcoe
%{_datadir}/dracut/modules.d/95iscsi
%{_datadir}/dracut/modules.d/95nbd
%{_datadir}/dracut/modules.d/95nfs
%files kernel
%defattr(-,root,root,0755)
%doc README.kernel
%files generic
%defattr(-,root,root,0755)
%doc README.generic
%files tools
%defattr(-,root,root,0755)
%doc COPYING
%doc COPYING NEWS
/sbin/dracut-gencmdline
/sbin/dracut-catimages
%dir /boot/dracut
@@ -145,33 +179,36 @@ rm -rf $RPM_BUILD_ROOT
%dir /var/lib/dracut/overlay
%changelog
* Wed Sep 02 2009 Harald Hoyer <harald@redhat.com> 001-1
- version 001
- see http://dracut.git.sourceforge.net/git/gitweb.cgi?p=dracut/dracut;a=blob_plain;f=NEWS
* Fri Aug 14 2009 Harald Hoyer <harald@redhat.com> 0.9-1
- version 0.9
- see http://dracut.git.sourceforge.net/git/gitweb.cgi?p=dracut;a=blob_plain;f=NEWS
* Thu Aug 06 2009 Harald Hoyer <harald@redhat.com> 0.8-1
- version 0.8
- see http://dracut.git.sourceforge.net/git/gitweb.cgi?p=dracut;a=blob_plain;f=NEWS
- see http://dracut.git.sourceforge.net/git/gitweb.cgi?p=dracut/dracut;a=blob_plain;f=NEWS
* Fri Jul 24 2009 Harald Hoyer <harald@redhat.com> 0.7-1
- version 0.7
- see http://dracut.git.sourceforge.net/git/gitweb.cgi?p=dracut;a=blob_plain;f=NEWS
- see http://dracut.git.sourceforge.net/git/gitweb.cgi?p=dracut/dracut;a=blob_plain;f=NEWS
* Wed Jul 22 2009 Harald Hoyer <harald@redhat.com> 0.6-1
- version 0.6
- see http://dracut.git.sourceforge.net/git/gitweb.cgi?p=dracut;a=blob_plain;f=NEWS
- see http://dracut.git.sourceforge.net/git/gitweb.cgi?p=dracut/dracut;a=blob_plain;f=NEWS
* Fri Jul 17 2009 Harald Hoyer <harald@redhat.com> 0.5-1
- version 0.5
- see http://dracut.git.sourceforge.net/git/gitweb.cgi?p=dracut;a=blob_plain;f=NEWS
- see http://dracut.git.sourceforge.net/git/gitweb.cgi?p=dracut/dracut;a=blob_plain;f=NEWS
* Sat Jul 04 2009 Harald Hoyer <harald@redhat.com> 0.4-1
- version 0.4
- see http://dracut.git.sourceforge.net/git/gitweb.cgi?p=dracut;a=blob_plain;f=NEWS
- see http://dracut.git.sourceforge.net/git/gitweb.cgi?p=dracut/dracut;a=blob_plain;f=NEWS
* Thu Jul 02 2009 Harald Hoyer <harald@redhat.com> 0.3-1
- version 0.3
- see http://dracut.git.sourceforge.net/git/gitweb.cgi?p=dracut;a=blob_plain;f=NEWS
- see http://dracut.git.sourceforge.net/git/gitweb.cgi?p=dracut/dracut;a=blob_plain;f=NEWS
* Wed Jul 01 2009 Harald Hoyer <harald@redhat.com> 0.2-1
- version 0.2

View File

@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
. $dracutfunctions

View File

@@ -1,15 +1,16 @@
#!/bin/bash
# Include wired net drivers, excluding wireless
for modname in $(find "$srcmods/kernel/drivers" -name '*.ko'); do
if nm -uPA $modname | egrep -q 'eth_type_trans|register_virtio_device' \
&& ! nm -uPA $modname | egrep -q 'iw_handler_get_spy'; then
if echo "$modname" | egrep -q '/wireless/|/isdn/|/uwb/'; then
continue
else
instmods $modname
fi
fi
done
net_module_test() {
local net_drivers='eth_type_trans|register_virtio_device'
local unwanted_drivers='/(wireless|isdn|uwb)/'
nm -uPA "$1" | egrep -q $net_drivers && \
nm -uPA "$1" | egrep -qv 'iw_handler_get_spy' && \
[[ ! $1 =~ $unwanted_drivers ]]
}
instmods $(filter_kernel_modules net_module_test)
instmods ecb arc4
# bridge modules
instmods bridge stp llc

View File

@@ -24,6 +24,7 @@ if [ -n "$LUKS" ]; then
fi
if [ $ask -gt 0 ]; then
info "luksOpen $1 $2"
# flock against other interactive activities
{ flock -s 9;
/bin/plymouth ask-for-password \
@@ -35,6 +36,8 @@ fi
# mark device as asked
>> /tmp/cryptroot-asked-$2
udevsettle
unset LUKS
unset ask
unset luks

View File

@@ -34,13 +34,13 @@ if [[ $hostonly ]]; then
inst ${LIBDIR}/plymouth/${PLYMOUTH_PLUGIN}.so
fi
else
for x in /usr/share/plymouth/themes/*/* ; do
for x in /usr/share/plymouth/themes/{text,details}/* ; do
[[ -f "$x" ]] || continue
THEME_DIR=$(dirname "$x")
mkdir -p "${initdir}/$THEME_DIR"
dracut_install "$x"
done
for x in ${LIBDIR}/plymouth/*.so ; do
for x in ${LIBDIR}/plymouth/{text,details}.so ; do
[[ -f "$x" ]] || continue
[[ "$x" != "${x%%/label.so}" ]] && continue
dracut_install "$x"

View File

@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# if cryptsetup is not installed, then we cannot support encrypted devices.
which cryptsetup >/dev/null 2>&1 || exit 1
@@ -6,8 +6,21 @@ which cryptsetup >/dev/null 2>&1 || exit 1
# hostonly checking should only return true if root is on a LUKS device
# in some way, but I am too lazy to figure out how to do that.
# Instead, fail if we do not have a LUKS device in use somewhere.
if [ "$1" = "-h" ] ; then
blkid | grep -q crypt_LUKS || exit 1
fi
. $dracutfunctions
is_crypt() { [[ $(get_fs_type /dev/block/$1) = crypto_LUKS ]]; }
[[ $1 = '-h' ]] && {
rootdev=$(find_root_block_device)
if [[ $rootdev ]]; then
# root lives on a block device, so we can be more precise about
# hostonly checking
check_block_and_slaves is_crypt "$rootdev" || exit 1
else
# root is not on a block device, use the shotgun approach
blkid | grep -q crypt_LUKS || exit 1
fi
}
exit 0

View File

@@ -0,0 +1,4 @@
# close everything which is not busy
for i in /dev/mapper/luks-*; do
cryptsetup luksClose $i >/dev/null 2>&1
done

View File

@@ -24,14 +24,17 @@ if [ -n "$LUKS" ]; then
fi
if [ $ask -gt 0 ]; then
info "luksOpen $1 $2"
# flock against other interactive activities
{ flock -s 9;
echo -n "$1 is password protected "
/sbin/cryptsetup luksOpen -T1 $1 $2
/sbin/cryptsetup luksOpen -T1 $1 $2
} 9>/.console.lock
fi
# mark device as asked
>> /tmp/cryptroot-asked-$2
udevsettle
exit 0

View File

@@ -3,3 +3,5 @@ inst cryptsetup
inst_rules "$moddir/70-luks.rules"
inst "$moddir"/cryptroot-ask.sh /sbin/cryptroot-ask
inst_hook cmdline 30 "$moddir/parse-crypt.sh"
inst_hook pre-pivot 30 "$moddir/crypt-cleanup.sh"
inst_hook pre-pivot 60 "$moddir/crypt-cleanup.sh"

View File

@@ -4,11 +4,22 @@
# in trying to support it in the initramfs.
which dmraid >/dev/null 2>&1 || exit 1
# Hostonly checking should really fail if the root device is not on a
# dmraid volume. I am lazy. Therefore, fail the hostonly check only
# if we are not using dmraid right now.
if [[ $1 = -h ]]; then
dmraid -r | grep -q ok || exit 1
fi
. $dracutfunctions
[[ $debug ]] && set -x
is_dmraid() { get_fs_type /dev/block/$1 |grep -v linux_raid_member | \
grep -q _raid_member; }
[[ $1 = '-h' ]] && {
rootdev=$(find_root_block_device)
if [[ $rootdev ]]; then
# root lives on a block device, so we can be more precise about
# hostonly checking
check_block_and_slaves is_dmraid "$rootdev" || exit 1
else
# root is not on a block device, use the shotgun approach
dmraid -r | grep -q ok || exit 1
fi
}
exit 0

View File

@@ -0,0 +1,2 @@
# close everything which is not busy
dmraid -an >/dev/null 2>&1

View File

@@ -15,12 +15,14 @@ if $UDEV_QUEUE_EMPTY >/dev/null 2>&1; then
if [ "${s##$r}" != "$s" ]; then
info "Activating $s"
dmraid -ay $s 2>&1 | vinfo
udevsettle
fi
done
done
else
# scan and activate all DM RAIDS
dmraid -ay 2>&1 | vinfo
udevsettle
fi
fi

View File

@@ -3,3 +3,5 @@ dracut_install dmraid partx
inst "$moddir/dmraid.sh" /sbin/dmraid_scan
inst_rules 64-md-raid.rules
inst_rules "$moddir/61-dmraid-imsm.rules"
inst_hook pre-pivot 30 "$moddir/dmraid-cleanup.sh"
inst_hook pre-pivot 60 "$moddir/dmraid-cleanup.sh"

View File

@@ -24,7 +24,7 @@ overlay=$(getarg overlay)
# FIXME: we need to be able to hide the plymouth splash for the check really
[ -e $livedev ] & fs=$(blkid -s TYPE -o value $livedev)
if [ "$fs" == "iso9660" -o "$fs" = "udf" ]; then
if [ "$fs" = "iso9660" -o "$fs" = "udf" ]; then
check="yes"
fi
getarg check || check=""
@@ -64,7 +64,7 @@ do_live_overlay() {
pathspec=$( echo $overlay | sed -e 's/^.*://' )
fi
if [ -z "$pathspec" -o "$pathspec" == "auto" ]; then
if [ -z "$pathspec" -o "$pathspec" = "auto" ]; then
pathspec="/${live_dir}/overlay-$l-$u"
fi
devspec=$( echo $overlay | sed -e 's/:.*$//' )

View File

@@ -1,16 +1,19 @@
#!/bin/bash
if [ -z "$drivers" ]; then
drivers="sd_mod =fs"
# Include block controller drivers
blockfuncs='ata_scsi_ioctl|scsi_add_host|blk_init_queue|register_mtd_blktrans|scsi_esp_register|register_virtio_device'
for modname in $(find "$srcmods/kernel/drivers" -name '*.ko'); do
if nm -uPA $modname | egrep -q "$blockfuncs"; then
drivers="${drivers} $modname"
if [[ -z $drivers ]]; then
block_module_test() {
local blockfuncs='ata_scsi_ioctl|scsi_add_host|blk_init_queue|register_mtd_blktrans|scsi_esp_register|register_virtio_device'
nm -uPA "$1" | egrep -q "$blockfuncs"
}
instmods sd_mod $(filter_kernel_modules block_module_test)
# if not on hostonly mode, install all known filesystems.
if [[ $hostonly = '' ]]; then
instmods '=fs'
else
instmods $(get_fs_type "/dev/block/$(find_root_block_device)")
fi
done
instmods $drivers
# hardcoded list of exceptions
rm -fr ${initdir}/lib/modules/*/kernel/fs/ocfs2
# hardcoded list of exceptions
rm -fr ${initdir}/lib/modules/*/kernel/fs/ocfs2
else
instmods $drivers
fi

View File

@@ -6,14 +6,14 @@
SUBSYSTEM!="block", GOTO="lvm_end"
ACTION!="add|change", GOTO="lvm_end"
KERNEL=="dm-[0-9]*", IMPORT{program}="vol_id --export $tempnode"
KERNEL=="md[0-9]*|md/*", IMPORT{program}="vol_id --export $tempnode"
KERNEL=="dm-[0-9]*", ACTION!="change", GOTO="lvm_end"
ENV{ID_FS_TYPE}=="LVM2_member", \
TEST!="/tmp/.lvm_scan-%k", \
RUN+="/bin/sh -c '>/tmp/.lvm_scan-%k; /bin/ln -fs /sbin/lvm_scan /initqueue/lvm_scan.sh'"
KERNEL!="dm-[0-9]*", GOTO="lvm_end"
OPTIONS="link_priority=-100"
ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}"

View File

@@ -6,17 +6,10 @@
SUBSYSTEM!="block", GOTO="lvm_end"
ACTION!="add|change", GOTO="lvm_end"
KERNEL=="dm-[0-9]*", IMPORT{program}="/sbin/blkid -o udev -p $tempnode"
KERNEL=="md[0-9]*|md/*", IMPORT{program}="/sbin/blkid -o udev -p $tempnode"
KERNEL=="dm-[0-9]*", ACTION=="add", GOTO="lvm_end"
ENV{ID_FS_TYPE}=="LVM2_member", \
TEST!="/tmp/.lvm_scan-%k", \
RUN+="/bin/sh -c '>/tmp/.lvm_scan-%k; /bin/ln -fs /sbin/lvm_scan /initqueue/lvm_scan.sh'"
OPTIONS="link_priority=-100"
ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}"
LABEL="lvm_end"

View File

@@ -1,13 +1,23 @@
#!/bin/sh
#!/bin/bash
# No point trying to support lvm if the binaries are missing
which lvm >/dev/null 2>&1 || exit 1
# We should really just check to see if root is on a logical volume
# when running in hostonly mode. I am lazy. Therefore, fail the hostonly
# check unless there is a logical volume in use somewhere.
if [ "$1" = "-H" ] || [ "$1" = "--hostonly" ]; then
blkid | grep -q lvm2pv || exit 1
fi
. $dracutfunctions
[[ $debug ]] && set -x
is_lvm() { [[ $(get_fs_type /dev/block/$1) = LVM2_member ]]; }
[[ $1 = '-h' ]] && {
rootdev=$(find_root_block_device)
if [[ $rootdev ]]; then
# root lives on a block device, so we can be more precise about
# hostonly checking
check_block_and_slaves is_lvm "$rootdev" || exit 1
else
# root is not on a block device, use the shotgun approach
blkid | grep -q LVM2_member || exit 1
fi
}
exit 0

View File

@@ -12,3 +12,5 @@ fi
inst "$moddir/lvm_scan.sh" /sbin/lvm_scan
inst_hook cmdline 30 "$moddir/parse-lvm.sh"
inst_hook pre-pivot 30 "$moddir/lvm-cleanup.sh"
inst_hook pre-pivot 60 "$moddir/lvm-cleanup.sh"

2
modules.d/90lvm/lvm-cleanup.sh Executable file
View File

@@ -0,0 +1,2 @@
# stop everything which is not busy
lvm vgchange -a n >/dev/null 2>&1

View File

@@ -23,7 +23,7 @@ if $UDEV_QUEUE_EMPTY >/dev/null 2>&1; then
printf '"a|^/dev/%s$|", ' $dev;
done;
echo '"r/.*/" ]';
echo 'types = [ "blkext", 1024 ]'
echo 'types = [ "blkext", 1024 , "cciss0", 1024 ]'
echo '}';
} > /etc/lvm/lvm.conf
lvmwritten=1
@@ -33,5 +33,6 @@ if $UDEV_QUEUE_EMPTY >/dev/null 2>&1; then
lvm vgchange -ay $VGS 2>&1 | vinfo
[ "$lvmwritten" ] && rm -f /etc/lvm/lvm.conf
unset lvmwritten
udevsettle
fi

View File

@@ -1 +0,0 @@
SUBSYSTEM=="block", ACTION=="add|change", KERNEL=="md[0-9]*|md_d[0-9]*|md/*", IMPORT{program}="vol_id --export $tempnode"

View File

@@ -2,7 +2,7 @@
# automatically cause mdadm to be run.
# See udev(8) for syntax
ACTION!="add", GOTO="md_inc_end"
ACTION!="add|change", GOTO="md_inc_end"
SUBSYSTEM!="block", GOTO="md_inc_end"
ENV{ID_FS_TYPE}!="linux_raid_member|isw_raid_member", GOTO="md_inc_end"
ENV{ID_FS_TYPE}=="isw_raid_member", ENV{rd_NO_MDIMSM}=="?*", GOTO="md_inc_end"

View File

@@ -3,11 +3,21 @@
# No mdadm? No mdraid support.
which mdadm >/dev/null 2>&1 || exit 1
# We were asked to run in hostonly mode, so pass the check only if there
# is an mdraid volume in use somewhere. This should really check to see if
# root is on an mdraid volume only, but I am lazy.
if [[ $1 = -h ]]; then
blkid | grep -q linux_raid || exit 1
fi
. $dracutfunctions
[[ $debug ]] && set -x
is_mdraid() { get_fs_type /dev/block/$1 |egrep -q '(linux|isw)_raid'; }
[[ $1 = '-h' ]] && {
rootdev=$(find_root_block_device)
if [[ $rootdev ]]; then
# root lives on a block device, so we can be more precise about
# hostonly checking
check_block_and_slaves is_mdraid "$rootdev" || exit 1
else
# root is not on a block device, use the shotgun approach
blkid | grep -q linux_raid || exit 1
fi
}
exit 0

View File

@@ -11,9 +11,7 @@ dracut_install mdadm partx
# inst /etc/passwd
# inst /etc/group
if [ -x /lib/udev/vol_id ]; then
inst_rules "$moddir/61-mdadm.rules"
else
if [ ! -x /lib/udev/vol_id ]; then
inst_rules 64-md-raid.rules
fi
@@ -35,3 +33,5 @@ fi
inst "$moddir/mdraid_start.sh" /sbin/mdraid_start
inst_hook pre-trigger 30 "$moddir/parse-md.sh"
inst_hook pre-pivot 30 "$moddir/mdraid-cleanup.sh"
inst_hook pre-pivot 60 "$moddir/mdraid-cleanup.sh"

View File

@@ -0,0 +1,4 @@
# stop everything which is not busy
for i in /dev/md*; do
mdadm --stop $i >/dev/null 2>&1
done

View File

@@ -10,9 +10,14 @@ if $UDEV_QUEUE_EMPTY >/dev/null 2>&1; then
case $md in
/dev/md*p*) ;;
*)
info "Starting MD RAID array $md"
mdadm -R $md 2>&1 | vinfo
mdadm -IR $md 2>&1 | vinfo
if mdadm --query --test --detail $md 2>&1|grep -q 'does not appear to be active'; then
info "Starting MD RAID array $md"
mdadm -R $md 2>&1 | vinfo
if mdadm --query --test --detail $md 2>&1|grep -q 'does not appear to be active'; then
mdadm -IR $md 2>&1 | vinfo
fi
udevsettle
fi
esac
done
fi

11
modules.d/95fcoe/check Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/sh
# We depend on network modules being loaded
[ "$1" = "-d" ] && echo network
# FIXME
# If hostonly was requested, fail the check if we are not actually
# booting from root.
#[ "$1" = "-h" ] && ! egrep -q '/ /dev/nbd[0-9]*' /proc/mounts && exit 1
exit 0

View File

@@ -0,0 +1,14 @@
#!/bin/sh
# We use (fcoe_interface or fcoe_mac) and fcoe_dcb as set by parse-fcoe.sh
# If neither mac nor interface are set we don't continue
[ -z "$fcoe_interface" -a -z "$fcoe_mac" ] && return
# Write udev rules
{
if [ -n "$fcoe_mac" ] ; then
printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="/sbin/fcoe-up $env{INTERFACE} %s"\n' "$fcoe_mac" "$fcoe_dcb"
else
printf 'ACTION=="add", SUBSYSTEM=="net", KERNEL=="%s", RUN+="/sbin/fcoe-up $env{INTERFACE} %s"\n' "$fcoe_interface" "$fcoe_dcb"
fi
} > /etc/udev/rules.d/60-fcoe.rules

16
modules.d/95fcoe/fcoe-up Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/sh
#
# We get called like this:
# /sbin/fcoe-up <network-device> <dcb|nodcb>
#
# Note currently only nodcb is supported, the dcb option is reserved for
# future use.
# Huh? Missing arguments ??
[ -z "$1" -o -z "$2" ] && exit 1
netif=$1
dcb=$2
/sbin/ip link set "$netif" up
echo -n "$netif" > /sys/module/fcoe/parameters/create

7
modules.d/95fcoe/install Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
dracut_install ip
inst "$moddir/fcoe-up" "/sbin/fcoe-up"
inst_hook pre-udev 60 "$moddir/fcoe-genrules.sh"
inst_hook cmdline 99 "$moddir/parse-fcoe.sh"

2
modules.d/95fcoe/installkernel Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
instmods fcoe

48
modules.d/95fcoe/parse-fcoe.sh Executable file
View File

@@ -0,0 +1,48 @@
#!/bin/sh
#
# Supported formats:
# fcoe=<networkdevice>:<dcb|nodcb>
# fcoe=<macaddress>:<dcb|nodcb>
#
# Note currently only nodcb is supported, the dcb option is reserved for
# future use.
#
# Note letters in the macaddress must be lowercase!
#
# Examples:
# fcoe=eth0:nodcb
# fcoe=4A:3F:4C:04:F8:D7:nodcb
[ -z "$fcoe" ] && fcoe=$(getarg fcoe=)
# If it's not set we don't continue
[ -z "$fcoe" ] && return
parse_fcoe_opts() {
local IFS=:
set $fcoe
case $# in
2)
fcoe_interface=$1
fcoe_dcb=$2
;;
7)
fcoe_mac=$1:$2:$3:$4:$5:$6
fcoe_dcb=$7
;;
*)
die "Invalid arguments for fcoe="
;;
esac
}
parse_fcoe_opts
# currently only nodcb is supported
if [ "$fcoe_dcb" != "nodcb" ] ; then
die "Invalid FCoE DCB option: $fcoe_dcb"
fi
# FCoE actually supported?
[ -e /sys/module/fcoe/parameters/create ] || modprobe fcoe || die "FCoE requested but kernel/initrd does not support FCoE"

View File

@@ -1,11 +1,35 @@
#!/bin/sh
#!/bin/bash
# We depend on network modules being loaded
[ "$1" = "-d" ] && echo network
# If hostonly was requested, fail the check if we are not actually
# booting from root.
#[ "$1" = "-h" ] && ! egrep -q '/ /dev/nbd[0-9]*' /proc/mounts && exit 1
# If our prerequisites are not met, fail anyways.
which iscsistart hostname iscsi-iname >/dev/null 2>&1 || exit 1
# If hostonly was requested, fail the check if we are not actually
# booting from root.
. $dracutfunctions
[[ $debug ]] && set -x
is_iscsi() (
[[ -L /sys/dev/block/$1 ]] || return
cd "$(readlink -f /sys/dev/block/$1)"
until [[ -d sys || -d iscsi_session ]]; do
cd ..
done
[[ -d iscsi_session ]]
)
case $1 in
-h) rootdev=$(find_root_block_device)
if [[ $rootdev ]]; then
# root lives on a block device, so we can be more precise about
# hostonly checking
check_block_and_slaves is_iscsi "$rootdev" || exit 1
else
exit 1
fi ;;
esac
exit 0

View File

@@ -1,7 +0,0 @@
SUBSYSTEM!="block", GOTO="nbd_end"
ACTION!="change", GOTO="nbd_end"
KERNEL=="nbd[0-9]*", IMPORT{program}="vol_id --export $tempnode"
KERNEL=="nbd[0-9]*", IMPORT{program}="/sbin/blkid -o udev -p $tempnode"
LABEL="nbd_end"

View File

@@ -1,6 +0,0 @@
SUBSYSTEM!="block", GOTO="nbd_end"
ACTION!="change", GOTO="nbd_end"
KERNEL=="nbd[0-9]*", IMPORT{program}="/sbin/blkid -o udev -p $tempnode"
LABEL="nbd_end"

View File

@@ -1,11 +1,19 @@
#!/bin/sh
#!/bin/bash
# We depend on network modules being loaded
[ "$1" = "-d" ] && echo network
# If hostonly was requested, fail the check if we are not actually
# booting from root.
[ "$1" = "-h" ] && ! egrep -q '/ /dev/nbd[0-9]*' /proc/mounts && exit 1
# If our prerequisites are not met, fail anyways.
# If our prerequisites are not met, fail.
which nbd-client >/dev/null 2>&1 || exit 1
# if an nbd device is not somewhere in the chain of devices root is mounted on,
# fail the hostonly check.
[ "$1" = "-h" ] && {
is_nbd() { [[ -b /dev/block/$1 && $1 == 43:* ]] ;}
. $dracutfunctions
rootdev=$(find_root_block_device)
[[ -b /dev/block/$rootdev ]] || exit 1
check_block_and_slaves is_nbd "$rootdev" || exit 1
}
exit 0

View File

@@ -2,10 +2,4 @@
inst nbd-client
inst_hook cmdline 90 "$moddir/parse-nbdroot.sh"
if [ -x /lib/udev/vol_id ]; then
inst_rules "$moddir/61-nbd-vol_id.rules"
else
inst_rules "$moddir/61-nbd.rules"
fi
inst "$moddir/nbdroot" "/sbin/nbdroot"

View File

@@ -0,0 +1,7 @@
SUBSYSTEM!="block", GOTO="psv_end"
ACTION!="add|change", GOTO="psv_end"
ACTION=="change", KERNEL=="dm-[0-9]*", IMPORT{program}="vol_id --export $tempnode"
KERNEL=="cciss[0-9]*", IMPORT{program}="vol_id --export $tempnode"
KERNEL=="nbd[0-9]*", IMPORT{program}="vol_id --export $tempnode"
KERNEL=="md[0-9]*|md_d[0-9]*|md/*", IMPORT{program}="vol_id --export $tempnode"
LABEL="psv_end"

View File

@@ -0,0 +1,7 @@
SUBSYSTEM!="block", GOTO="ps_end"
ACTION!="add|change", GOTO="ps_end"
ACTION=="change", KERNEL=="dm-[0-9]*", IMPORT{program}="/sbin/blkid -o udev -p $tempnode"
KERNEL=="cciss[0-9]*", IMPORT{program}="/sbin/blkid -o udev -p $tempnode"
KERNEL=="nbd[0-9]*", IMPORT{program}="/sbin/blkid -o udev -p $tempnode"
KERNEL=="md[0-9]*|md_d[0-9]*|md/*", IMPORT{program}="/sbin/blkid -o udev -p $tempnode"
LABEL="ps_end"

View File

@@ -0,0 +1,20 @@
SUBSYSTEM!="block", GOTO="pss_end"
ACTION!="add|change", GOTO="pss_end"
ACTION=="change", KERNEL=="dm-[0-9]*", GOTO="do_pss"
KERNEL=="cciss[0-9]*", GOTO="do_pss"
KERNEL=="nbd[0-9]*", GOTO="do_pss"
KERNEL=="md[0-9]*|md_d[0-9]*|md/*", GOTO="do_pss"
GOTO="pss_end"
LABEL="do_pss"
# by-path (parent device path)
ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="", DEVPATH!="*/virtual/*", IMPORT{program}="path_id %p"
ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}"
ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}-part%n"
# by-label/by-uuid links (filesystem metadata)
ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}"
LABEL="pss_end"

View File

@@ -19,8 +19,12 @@ dracut_install cat uname
if [ ! -x /lib/udev/vol_id ]; then
dracut_install blkid
inst_rules "$moddir/59-persistent-storage.rules"
else
inst_rules "$moddir/59-persistent-storage-volid.rules"
fi
inst_rules "$moddir/61-persistent-storage-volid.rules"
for i in \
ata_id \
cdrom_id \
@@ -32,6 +36,7 @@ hid2hci \
path_id \
scsi_id \
usb_id \
vol_id \
; do
[ -x /lib/udev/$i ] && dracut_install /lib/udev/$i
done

24
modules.d/98syslog/README Normal file
View File

@@ -0,0 +1,24 @@
Syslog support for dracut
This module provides syslog functionality in the initrd.
This is especially interesting when complex configuration being
used to provide access to the device the rootfs resides on.
When this module is installed into the ramfs it is triggered by
the udev event from the nic being setup (online).
Then if syslog is configured it is started and will forward all
kernel messages to the given syslog server.
The syslog implementation is detected automatically by finding the
apropriate binary with the following order:
rsyslogd
syslogd
syslog-ng
Then if detected the syslog.conf is generated and syslog is started.
Bootparameters:
syslogserver=ip Where to syslog to
sysloglevel=level What level has to be logged
syslogtype=rsyslog|syslog|syslogng
Don't auto detect syslog but set it

4
modules.d/98syslog/check Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/sh
# do not add this module by default
exit 255

21
modules.d/98syslog/install Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/sh
if which rsyslogd >/dev/null; then
installs="rsyslogd /usr/lib/rsyslog/lmnet.so /usr/lib/rsyslog/imklog.so /usr/lib/rsyslog/imuxsock.so"
elif which syslogd >/dev/null; then
installs="syslogd"
elif which syslog-ng >/dev/null; then
installs="syslog-ng"
else
dwarn "Could not find any syslog binary although the syslogmodule is selected to be installed. Please check."
fi
if [ -n "$installs" ]; then
dracut_install cat
dracut_install $installs
inst_hook cmdline 90 "$moddir/parse-syslog-opts.sh"
inst_hook pre-udev 61 "$moddir/syslog-genrules.sh"
inst_hook pre-pivot 99 "$moddir/syslog-cleanup.sh"
inst_simple "$moddir/rsyslogd-start.sh" /sbin/rsyslogd-start
inst_simple "$moddir/rsyslogd-stop.sh" /sbin/rsyslogd-stop
mkdir -p ${initdir}/etc/templates
inst_simple "${moddir}/rsyslog.conf" /etc/templates
fi

View File

@@ -0,0 +1,21 @@
#!/bin/sh
# Parses the syslog commandline options
#
#Bootparameters:
#syslogserver=ip Where to syslog to
#sysloglevel=level What level has to be logged
#syslogtype=rsyslog|syslog|syslogng
# Don't auto detect syslog but set it
if getarg rdnetdebug ; then
exec >/tmp/syslog-parse-opts.$1.$$.out
exec 2>>/tmp/syslog-parse-opts.$1.$$.out
set -x
fi
syslogserver=$(getarg syslog)
syslogfilters=$(getargs filter)
syslogtype=$(getarg syslogtype)
[ -n "$syslogserver" ] && echo $syslogserver > /tmp/syslog.server
[ -n "$syslogfilters" ] && echo "$syslogfilters" > /tmp/syslog.filters
[ -n "$syslogtype" ] && echo "$syslogtype" > /tmp/syslog.type

View File

@@ -0,0 +1,31 @@
#rsyslog v3 config file
# if you experience problems, check
# http://www.rsyslog.com/troubleshoot for assistance
#### MODULES ####
$ModLoad imuxsock.so # provides support for local system logging (e.g. via logger command)
$ModLoad imklog.so # provides kernel logging support (previously done by rklogd)
#$ModLoad immark.so # provides --MARK-- message capability
# Provides UDP syslog reception
#$ModLoad imudp.so
#$UDPServerRun 514
# Provides TCP syslog reception
#$ModLoad imtcp.so
#$InputTCPServerRun 514
#### GLOBAL DIRECTIVES ####
# Use default timestamp format
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
# File syncing capability is disabled by default. This feature is usually not required,
# not useful and an extreme performance hit
#$ActionFileEnableSync on
#### RULES ####

View File

@@ -0,0 +1,37 @@
#!/bin/sh
# Triggered by udev and starts rsyslogd with bootparameters
. /lib/dracut-lib.sh
if getarg rdnetdebug ; then
exec >/tmp/rsyslogd-start.$1.$$.out
exec 2>>/tmp/rsyslogd-start.$1.$$.out
set -x
fi
rsyslog_config() {
local server=$1
shift
local syslog_template=$1
shift
local filters=$*
local filter=
cat $syslog_template
for filter in $filters; do
echo "${filter} @${server}"
done
# echo "*.* /tmp/syslog"
}
read server < /tmp/syslog.server
read filters < /tmp/syslog.filters
[ -z "$filters" ] && filters="kern.*"
read conf < /tmp/syslog.conf
[ -z "$conf" ] && conf="/etc/rsyslog.conf" && echo "$conf" > /tmp/syslog.conf
template=/etc/templates/rsyslog.conf
if [ -n "$server" ]; then
rsyslog_config "$server" "$template" "$filters" > $conf
/sbin/rsyslogd -c3
fi

View File

@@ -0,0 +1,10 @@
#!/bin/sh
# Kills rsyslogd
if [ -f /var/run/syslogd.pid ]; then
read pid < /var/run/syslogd.pid
kill $pid
kill -0 $pid && kill -9 $pid
else
warn "rsyslogd-stop: Could not find a pid for rsyslogd. Won't kill it."
fi

View File

@@ -0,0 +1,19 @@
#!/bin/sh
# Just cleans up a previously started syslogd
. /lib/dracut-lib.sh
if getarg rdnetdebug ; then
exec >/tmp/syslog-cleanup.$1.$$.out
exec 2>>/tmp/syslog-cleanup.$1.$$.out
set -x
fi
if [ -f /tmp/syslog.server ]; then
read syslogtype < /tmp/syslog.type
if [ -e "/sbin/${syslogtype}-stop" ]; then
${syslogtype}-stop
else
warn "syslog-cleanup: Could not find script to stop syslog of type \"$syslogtype\". Syslog will not be stopped."
fi
fi

View File

@@ -0,0 +1,35 @@
#!/bin/dash
# Creates the syslog udev rules to be triggered when interface becomes online.
. /lib/dracut-lib.sh
detect_syslog() {
syslogtype=""
if [ -e /sbin/rsyslogd ]; then
syslogtype="rsyslogd"
elif [ -e /sbin/syslogd ]; then
syslogtype="syslogd"
elif [ /sbin/syslog-ng ]; then
syslogtype="syslog-ng"
else
dwarn "Could not find any syslog binary although the syslogmodule is selected to be installed. Please check."
fi
echo "$syslogtype"
[ -n "$syslogtype" ]
}
if getarg rdnetdebug ; then
exec >/tmp/syslog-genrules.$1.$$.out
exec 2>>/tmp/syslog-genrules.$1.$$.out
set -x
fi
read syslogtype < /tmp/syslog.type
if [ -z "$syslogtype" ]; then
syslogtype=$(detect_syslog)
echo $syslogtype > /tmp/syslog.type
fi
if [ -e "/sbin/${syslogtype}-start" ]; then
printf 'ACTION=="online", SUBSYSTEM=="net", RUN+="/sbin/'${syslogtype}'-start $env{INTERFACE}"\n' > /etc/udev/rules.d/70-syslog.rules
else
warn "syslog-genrules: Could not find binary to start syslog of type \"$syslogtype\". Syslog will not be started."
fi

View File

@@ -107,3 +107,13 @@ incol2() {
done < $file
return 1
}
udevsettle() {
[ -z "$UDEVVERSION" ] && UDEVVERSION=$(udevadm --version)
if [ $UDEVVERSION -ge 143 ]; then
udevadm settle --exit-if-exists=/initqueue/work --exit-if-exists=/dev/root
else
udevadm settle --timeout=30
fi
}

View File

@@ -112,11 +112,7 @@ while :; do
# check if root can be mounted
[ -e /dev/root ] && break;
if [ $UDEVVERSION -ge 143 ]; then
udevadm settle --exit-if-exists=/initqueue/work --exit-if-exists=/dev/root
else
udevadm settle --timeout=30
fi
udevsettle
# bail out, if we have mounted the root filesystem
[ -d "$NEWROOT/proc" ] && break;
@@ -217,14 +213,19 @@ for x in "$@"; do
initargs="$initargs $x"
done
# Copy state
mkdir /dev/.initramfs/
# Prepare network opts for passing
if [ -e /tmp/net.ifaces ]; then
mkdir /dev/.initramfs/
cp /tmp/net.* /dev/.initramfs/ >/dev/null 2>&1
mkdir -p /dev/.initramfs/state/etc/sysconfig/network-scripts/
cp /tmp/resolv.conf /dev/.initramfs/state/etc/ >/dev/null 2>&1
echo "files /etc/sysconfig/network-scripts" > /dev/.initramfs/rwtab
cp -a /tmp/ifcfg/* /dev/.initramfs/state/etc/sysconfig/network-scripts/ >/dev/null 2>&1
fi
# Debug: Copy state
if getarg rdcopystate; then
cp /tmp/* /dev/.initramfs/ >/dev/null 2>&1
else
cp /tmp/net.* /dev/.initramfs/ >/dev/null 2>&1
cp /tmp/resolv.conf /dev/.initramfs/ >/dev/null 2>&1
cp -a /tmp/ifcfg/ /dev/.initramfs/ >/dev/null 2>&1
fi
exec switch_root "$NEWROOT" "$INIT" $initargs || {

View File

@@ -1,11 +1,13 @@
#!/bin/sh
# FIXME: load selinux policy. this should really be done after we switchroot
if [ -x "$NEWROOT/usr/sbin/load_policy" ] && [ -e "$NEWROOT/etc/sysconfig/selinux" ]; then
chroot $NEWROOT /usr/sbin/load_policy -i
{
chroot $NEWROOT /usr/sbin/load_policy -i 2>&1
if [ $? -eq 3 ]; then
echo "Initial SELinux policy load failed and enforcing mode requested."
echo "Not continuing"
warn "Initial SELinux policy load failed and enforcing mode requested."
warn "Not continuing"
sleep 100d
exit 1
fi
} | vinfo
fi

View File

@@ -10,7 +10,7 @@ client_run() {
echo "CLIENT TEST START: $@"
$testdir/run-qemu -hda root.ext2 -m 256M -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "$@ root=/dev/dracut/root rw quiet console=ttyS0,115200n81 rdshell $DEBUGFAIL " \
-append "$@ root=/dev/dracut/root rw quiet rdinfo console=ttyS0,115200n81 rdshell $DEBUGFAIL " \
-initrd initramfs.testing
if ! grep -m 1 -q dracut-root-block-success root.ext2; then
echo "CLIENT TEST END: $@ [FAIL]"

View File

@@ -0,0 +1,10 @@
all:
@make -s --no-print-directory -C ../.. all
@basedir=../.. testdir=../ ./test.sh --all
setup:
@make --no-print-directory -C ../.. all
@basedir=../.. testdir=../ ./test.sh --setup
clean:
@basedir=../.. testdir=../ ./test.sh --clean
run:
@basedir=../.. testdir=../ ./test.sh --run

View File

@@ -0,0 +1,46 @@
#!/bin/sh
# don't let udev and this script step on eachother's toes
set -x
for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
udevadm control --reload-rules
# save a partition at the beginning for future flagging purposes
sfdisk -C 1280 -H 2 -S 32 -L /dev/sda <<EOF
,16
,400
,400
,400
EOF
echo -n test >keyfile
cryptsetup -q luksFormat /dev/sda2 /keyfile
cryptsetup -q luksFormat /dev/sda3 /keyfile
cryptsetup -q luksFormat /dev/sda4 /keyfile
cryptsetup luksOpen /dev/sda2 dracut_sda2 </keyfile
cryptsetup luksOpen /dev/sda3 dracut_sda3 </keyfile
cryptsetup luksOpen /dev/sda4 dracut_sda4 </keyfile
mdadm --create /dev/md0 --run --auto=yes --level=5 --raid-devices=3 /dev/mapper/dracut_sda2 /dev/mapper/dracut_sda3 /dev/mapper/dracut_sda4
# wait for the array to finish initailizing, otherwise this sometimes fails
# randomly.
mdadm -W /dev/md0
lvm pvcreate -ff -y /dev/md0 && \
lvm vgcreate dracut /dev/md0 && \
lvm lvcreate -l 100%FREE -n root dracut && \
lvm vgchange -ay && \
mke2fs /dev/dracut/root && \
mkdir -p /sysroot && \
mount /dev/dracut/root /sysroot && \
cp -a -t /sysroot /source/* && \
umount /sysroot && \
lvm lvchange -a n /dev/dracut/root && \
lvm vgchange -a n dracut && \
{
lvm vgdisplay && \
{ mdadm -W /dev/md0 || :;} && \
mdadm --stop /dev/md0 && \
cryptsetup luksClose /dev/mapper/dracut_sda2 && \
cryptsetup luksClose /dev/mapper/dracut_sda3 && \
cryptsetup luksClose /dev/mapper/dracut_sda4 && \
:; :;} && \
echo "dracut-root-block-created" >/dev/sda1
poweroff -f

View File

@@ -0,0 +1,6 @@
#!/bin/sh
[ -b /dev/mapper/$2 ] && exit 0
echo -n test >/keyfile
/sbin/cryptsetup luksOpen $1 $2 </keyfile

View File

@@ -0,0 +1,2 @@
#!/bin/sh
getarg rdinitdebug || poweroff -f

View File

@@ -0,0 +1,10 @@
#!/bin/sh
exec >/dev/console 2>&1
echo "dracut-root-block-success" >/dev/sda1
export TERM=linux
export PS1='initramfs-test:\w\$ '
[ -f /etc/fstab ] || ln -s /proc/mounts /etc/fstab
stty sane
echo "made it to the rootfs! Powering down."
mount -n -o remount,ro /
poweroff -f

View File

@@ -0,0 +1,77 @@
#!/bin/bash
TEST_DESCRIPTION="root filesystem on LVM on encrypted partitions of a RAID-5"
KVERSION=${KVERSION-$(uname -r)}
# Uncomment this to debug failures
#DEBUGFAIL="rdinitdebug rdnetdebug"
test_run() {
$testdir/run-qemu -hda root.ext2 -m 256M -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "root=/dev/dracut/root rw quiet rdinfo console=ttyS0,115200n81 rdshell $DEBUGFAIL" \
-initrd initramfs.testing
grep -m 1 -q dracut-root-block-success root.ext2 || return 1
}
test_setup() {
# Create the blank file to use as a root filesystem
dd if=/dev/zero of=root.ext2 bs=1M count=40
kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay
(
initdir=overlay/source
. $basedir/dracut-functions
dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \
/lib/terminfo/l/linux mount dmesg ifconfig dhclient mkdir cp ping dhclient
inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script"
inst "$basedir/modules.d/40network/ifup" "/sbin/ifup"
dracut_install grep
inst ./test-init /sbin/init
find_binary plymouth >/dev/null && dracut_install plymouth
(cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
)
# second, install the files needed to make the root filesystem
(
initdir=overlay
. $basedir/dracut-functions
dracut_install sfdisk mke2fs poweroff cp umount
inst_simple ./create-root.sh /initqueue/01create-root.sh
)
# create an initramfs that will create the target root filesystem.
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut -l -i overlay / \
-m "dash crypt lvm mdraid udev-rules base rootfs-block kernel-modules" \
-d "ata_piix ext2 sd_mod" \
-f initramfs.makeroot $KVERSION || return 1
rm -rf overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu -hda root.ext2 -m 256M -nographic -net none \
-kernel "/boot/vmlinuz-$kernel" \
-append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81" \
-initrd initramfs.makeroot || return 1
grep -m 1 -q dracut-root-block-created root.ext2 || return 1
(
initdir=overlay
. $basedir/dracut-functions
dracut_install poweroff shutdown
inst_simple ./hard-off.sh /emergency/01hard-off.sh
inst ./cryptroot-ask /sbin/cryptroot-ask
)
sudo $basedir/dracut -l -i overlay / \
-o "plymouth" \
-a "debug" \
-d "ata_piix ext2 sd_mod" \
-f initramfs.testing $KVERSION || return 1
}
test_cleanup() {
rm -fr overlay mnt
rm -f root.ext2 initramfs.makeroot initramfs.testing
}
. $testdir/test-functions