Compare commits

..

58 Commits
024 ... 025

Author SHA1 Message Date
Harald Hoyer
e5786ed1b7 version 025 2013-01-23 15:38:48 +01:00
Harald Hoyer
b47517140b dracut.spec: add drm module 2013-01-23 15:38:48 +01:00
Colin Guthrie
3de6001e1e Include crc32c module for xfs.
Just like btrfs, xfs now requires CRC module that cannot be resolved via
normal module resolving.

Move this hack into fs-lib and remove it from btrfs module.

https://bugs.mageia.org/show_bug.cgi?id=8676
2013-01-23 15:24:27 +01:00
Harald Hoyer
c8d685c9d3 dracut-functions.sh: cope with optional field #7 in mountinfo
also handle fstab entries with LABEL=, UUID= and PARTUUID=
2013-01-23 15:24:27 +01:00
Harald Hoyer
d6d3173916 network/dhclient-script.sh: also touch "/tmp/setup_net_<mac>.ok" 2013-01-23 15:24:27 +01:00
Harald Hoyer
8b6bf0ef57 romount fix 2013-01-23 15:24:27 +01:00
Dave Young
7bd8f23303 Add memory usage trace to diffrent hook points
Hi, Here is an update of this patch, fixed the local variable issue.
2013-01-23 15:24:27 +01:00
dyoung@redhat.com
a08ea34aba add function getargnum
For cmdline argument with numeric value, add a new function getargnum
It will get proper value with default value as $1, min value as $2,
max value as $3, and param name as $4. valid result will be echo to stdout.
for nul or value not valid it will just echo the default value.
Note: The values should be >=0

[v1->v2]: add arg <minval>
[v2->v3]: do not use bash string match =~

Signed-off-by: Dave Young <dyoung@redhat.com>
2013-01-23 15:24:27 +01:00
Dave Young
6cb77ea91f use linkup in dhclient-script.sh
linkup is a wrapper function for waiting interface ready and up.
change to use linkup as what we do in ifup script.

Signed-off-by: Dave Young <dyoung@redhat.com>
2013-01-23 15:24:27 +01:00
Colin Guthrie
c586b033a7 Extend 52f1b041 to allow devices to be specified in config files as well as cmdline.
This also changes the command line switch to be --add-device and the
config directive is set to add_device. This was chosen as device= in the
config file seems too generic and not quite as consistent with other
directives (i.e. drivers/add_drivers)

The --device command line is still supported but it should be considered
deprecated in favour of --add-device.
2013-01-23 15:24:27 +01:00
Jiri Pirko
a9f634f815 fix teamd exec in case config does not include devname
In case that configuration file did not include name of team device,
teamd would not start. Fix this by adding "-t" parameter.

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-01-23 15:24:27 +01:00
Harald Hoyer
551c2dd71f shutdown: kill all processes and report remaining ones 2013-01-22 15:31:45 +01:00
Harald Hoyer
ffc4f173b6 mdraid: add mdmon-offroot@.service and takeover mdmon in shutdown 2013-01-22 15:31:41 +01:00
Harald Hoyer
ebd1d65a1b shutdown: source pre-shutdown hook and force quit plymouth before umount 2013-01-22 15:31:22 +01:00
Harald Hoyer
5b68300899 dracut-lib.sh: force hide plymouth in shutdown emergency shell 2013-01-22 15:31:19 +01:00
Harald Hoyer
2b6dd6a1fc dracut-functions.sh: add pre-shutdown hook 2013-01-22 15:31:16 +01:00
Harald Hoyer
1d22c670b0 dracut.asc: document shutdown procedure 2013-01-18 10:13:14 +01:00
Harald Hoyer
0ae480dcbf dracut.asc: s/rd.ip/ip/g 2013-01-07 18:00:06 +01:00
Harald Hoyer
256cba18c3 dracut-functions.sh: fixed inst_rules search path 2013-01-03 09:29:05 +01:00
Harald Hoyer
e6fcec9173 usrmount/mount-usr.sh: filter "subvol=" from root rflags
https://bugzilla.redhat.com/show_bug.cgi?id=890577
2013-01-02 14:06:44 +01:00
Harald Hoyer
1db3d2615d kernel-modules: create /etc/modprobe.d if it does not yet exist
https://bugzilla.redhat.com/show_bug.cgi?id=873220
2013-01-02 13:57:40 +01:00
Harald Hoyer
5204d1d36d dmsquash-live: fixed checkisomd5 service call 2013-01-02 13:56:27 +01:00
dyoung@redhat.com
3fa59d171d Wait for interface up at the early stage
In case long delay of network driver initqueue will exit before net dev is
ready. We have no chance to setup it then.
For dhcp, when we finish the setup there will be a setup_net_<dev>.ok. Doing
same for static ip case. Also add a check to initqueue when we generate udev
rules to ensure it's early enough.

[v1->v2]: only wait for bootdev or it's possible to cause boot fail for
waiting for non-bootdev. For example bond0->eth0, set bond0 as bootdev and
dhcp, we only need to wait bond0 setup ok.

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-12-14 09:09:00 +01:00
dyoung@redhat.com
d7264a3cc0 Get ifaces for udev rule use
In case BOOTIF is not set and IFACES are not set in bonding/vlan/bridge code,
net-genrule.sh will fall to bring up all net interfaces.

Here add a failsafe option to read IFACES from /tmp/net.ifaces

[v1->v2]: move IFACES reading from net.ifaces after bonding/vlan/bridge info
code chunks.
[v2->v3]: [ -n "$IFACES" ] should be  [ -z "$IFACES" ]

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-12-14 09:08:59 +01:00
dyoung@redhat.com
9078167927 Wait for link ready before use the interface
Some network driver will take long time to initialize. We have an example
in a HP machine which take about one minute for this. The callback such as
"ip link set <dev> up" will fail, afterwards setup for network will also
fail.

Fix this by add a new function wait_for_if_link, wait the link ready before
use it.

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-12-14 09:08:59 +01:00
dyoung@redhat.com
3bd7fba7af Change to use linkup function in network scripts
Update ifup.sh and fcoe-up.sh, use linkup function instead of directly
call ip command.

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-12-14 09:08:59 +01:00
dyoung@redhat.com
b455451f49 Add function linkup
set link up usually include two steps, ip link set <dev> up and
wait_for_if_up <dev>. Now do these two steps in one function linkup.
Later patch will add other code into it.

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-12-14 09:08:59 +01:00
dyoung@redhat.com
efa5eb424d Move wait for if functions to net lib
net-lib.sh are created for net related functions, move the wait_for_if* to
net-lib.sh naturally.

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-12-14 09:08:59 +01:00
Cong Wang
3baa150bd4 dracut: add team device support
V2: merge patch 2/2
    fix active-backup mode by adding slaves one by one
    sync with the latest teamd
    improve the comments
    wait for team ports to come up
    install /etc/libnl/classid too

This patch adds the initial support for team device [1].
A new cmdline team= is introduced for it.

Note, currently we don't support stacked devices
on/under team, it is tricky and can be added on request.

1. http://www.libteam.org/

Cc: Harald Hoyer <harald@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Cong Wang <amwang@redhat.com>
2012-12-14 09:06:51 +01:00
Harald Hoyer
43cc4d84bc change for "udevadm control": s/--reload-rules/--reload/g 2012-12-14 09:04:56 +01:00
Harald Hoyer
6b84015e67 iscsi/iscsiroot.sh: reload rules after adding 99-iscsi-root.rules 2012-12-14 09:04:56 +01:00
Harald Hoyer
60bbb8fcc9 cms/cms-write-ifcfg.sh: also fill in /etc/hostname 2012-12-14 09:04:56 +01:00
Harald Hoyer
16c84f2873 udev-rules/udev-rules-prepare.sh: get UDEVVERSION, if unset 2012-12-14 09:04:56 +01:00
Amadeusz Żołnowski
579238a3ac Fallback to external blkid and path_id in udev rules for <udev-176.
Starting with commit 24a38bc1cb dracut
uses udev builtins but still depends on >=udev-166 in dracut.spec.  This
patch makes dracut work with older udev again.

All credits go to Alexander Tsoy <alexander@tsoy.me>; see

  https://bugs.gentoo.org/show_bug.cgi?id=437700
2012-12-14 09:04:56 +01:00
Harald Hoyer
2b5cd3dbf8 nfs/nfsroot-cleanup.sh: mount --bind instead of --move 2012-12-14 09:04:55 +01:00
Harald Hoyer
3d8a164d0e dracut.spec: add iputils and iproute requirement for dracut-network 2012-12-14 09:04:55 +01:00
Nicolas Chauvet
00ae54f00a Fix rd.blacklist.driver when no /etc/modprobe.d exists
This bug was reported as http://bugzilla.redhat.com/873220#c2

As the /etc/modprobe.d isn't created in the boot process
nor bundled within the initramfs, the initramfsblacklist.conf
cannot be created.

Instead, the /usr/lib/modprobe.d directory is available and using it
will restore the blacklist behavior.
2012-12-14 09:04:55 +01:00
Will Woods
488d55c546 add 'swapoff' to initramfs to fix shutdown/reboot
systemd shutdown/reboot won't work unless 'swapoff' is available.
2012-12-14 09:04:55 +01:00
Will Woods
9d6165f235 drop NEWROOT from module-setup.sh
This was almost certainly copy-pasted from mount-root.sh, but it's not
valid here - dracut doesn't use NEWROOT outside of the initramfs.
2012-12-14 09:04:55 +01:00
Dave Young
2258f00e91 split plymouth module
Kdump module will need the drm and kms kernel modules so user can see the
emergency shell at least.

Fix this by split 50plymouth module to 50drm and 50plymouth. Moving the
installkernel part to 50drm so user can use drm directly without adding
extra plymouth utils.

Signed-off-by: Dave Young <dyoung@redhat.com>
Tested-by: Chao Wang <chaowang@redhat.com>
2012-12-14 09:04:55 +01:00
Harald Hoyer
2bac2d6d76 systemd/dracut-cmdline.service: run before systemd-vconsole-setup
cmdline does generate vconsole.conf, which is needed by vconsole-setup
2012-12-14 09:04:55 +01:00
Harald Hoyer
b6b895bab5 systemd/service-to-run.sh: silence "cp" errors 2012-12-14 09:04:55 +01:00
Harald Hoyer
fdeae2a3ac crypt/crypt-run-generator.sh: do not timeout for LUKS passwords with systemd 2012-12-14 09:04:55 +01:00
Harald Hoyer
040f388331 dmsquash-live: add systemd checkisomd5 service 2012-12-14 09:04:55 +01:00
Harald Hoyer
7990578443 network: fixed MAC address assignment 2012-11-26 13:49:38 +01:00
Harald Hoyer
528ae4f46c systemd/module-setup.sh: turn off RateLimit for the journal 2012-11-26 13:49:19 +01:00
Harald Hoyer
0fb7b847c5 cms/cmssetup.sh: sync udev rules names with network/net-genrules.sh
https://bugzilla.redhat.com/show_bug.cgi?id=825199
2012-11-22 12:32:19 +01:00
Harald Hoyer
a67a6f957d nfs/nfs-start-rpc.sh: prevent mount error, if sunrpc kernel module is not in the initramfs
https://bugzilla.redhat.com/show_bug.cgi?id=870632
2012-11-22 12:29:43 +01:00
Harald Hoyer
965edeb63b i18n/parse-i18n.sh: fix locale.conf caused by 4dbc1d1bb3
https://bugzilla.redhat.com/show_bug.cgi?id=870632
2012-11-22 11:59:10 +01:00
Harald Hoyer
329bbd797f crypt/crypt-run-generator.sh: fixup last commit 065fc56ab2 2012-11-21 16:36:37 +01:00
Robert Buchholz
065fc56ab2 Make short uuid specification for allow-discards work
1) strstr " $discarduuids " did not remove the optional
'luks-' prefix from the argument as the documentation says.

2) The lookup seems backwards. $luksdev ($luks in the other code copy)
is the full uuid and thus one should check whether the user-supplied
argument (short form) is contained therein, not the other way around.

Before this commit, the only way to trigger allow-discards was to
specify the full uuid without the 'luks-' prefix.
2012-11-21 16:01:45 +01:00
Harald Hoyer
64d144aece Add sosreport script and generate /run/initramfs/sosreport.txt 2012-11-21 14:17:43 +01:00
Harald Hoyer
2d9b156e9e dracut.sh: do not strip signed kernel modules
https://bugzilla.redhat.com/show_bug.cgi?id=873796
2012-11-21 14:07:32 +01:00
Harald Hoyer
2b9be6f707 [nfs|cifs]root.sh: make "/dev/root" a symlink, so it gets cleaned up later on 2012-11-19 17:03:55 +01:00
Harald Hoyer
b26897fb60 dracut.sh: only 'warn' not 'error', if we don't strip 2012-10-19 11:20:30 +02:00
WANG Chao
8bf25df640 40network/ifup.sh: do_static() and do_ipv6auto return 0 if no errors.
Commit a0be1ed removes some lines from do_static() and do_ipv6auto().

When $hostname is empty, do_static() and do_ipv6auto() will return 1
and fails to run setup_net at the last of ifup.sh

Signed-off-by: WANG Chao <chaowang@redhat.com>
2012-10-19 11:10:52 +02:00
Harald Hoyer
e743cfdd4b dracut.conf.d/fedora.conf.example: s/kernelcmdline/kernel_cmdline 2012-10-19 11:10:03 +02:00
Harald Hoyer
636e5cd2d5 dracut.sh: only save $kernel_cmdline, if set 2012-10-19 11:09:38 +02:00
69 changed files with 821 additions and 189 deletions

View File

@@ -1,4 +1,4 @@
VERSION=024
VERSION=025
GITVERSION=$(shell [ -d .git ] && git rev-list --abbrev-commit -n 1 HEAD |cut -b 1-8)
-include Makefile.inc

View File

@@ -106,7 +106,7 @@ fi
hookdirs="cmdline pre-udev pre-trigger netroot "
hookdirs+="initqueue initqueue/settled initqueue/online initqueue/finished initqueue/timeout "
hookdirs+="pre-mount pre-pivot cleanup mount "
hookdirs+="emergency shutdown-emergency shutdown "
hookdirs+="emergency shutdown-emergency pre-shutdown shutdown "
export hookdirs
}
@@ -311,10 +311,17 @@ get_maj_min() {
# $ find_block_device /usr
# 8:4
find_block_device() {
local _x _mpt _majmin _dev _fs _maj _min
local _x _mpt _majmin _dev _fs _maj _min _find_mpt
_find_mpt="$1"
if [[ $use_fstab != yes ]]; then
while read _x _x _majmin _x _mpt _x _x _fs _dev _x; do
[[ $_mpt = $1 ]] || continue
while read _x; do
set -- $_x
_majmin="$3"
_mpt="$5"
[[ $8 = "-" ]] && shift
_fs="$8"
_dev="$9"
[[ $_mpt = $_find_mpt ]] || continue
[[ $_fs = nfs ]] && { echo $_dev; return 0;}
[[ $_fs = nfs3 ]] && { echo $_dev; return 0;}
[[ $_fs = nfs4 ]] && { echo $_dev; return 0;}
@@ -332,7 +339,7 @@ find_block_device() {
while read _dev _mpt _fs _x; do
[ "${_dev%%#*}" != "$_dev" ] && continue
if [[ $_mpt = $1 ]]; then
if [[ $_mpt = $_find_mpt ]]; then
[[ $_fs = nfs ]] && { echo $_dev; return 0;}
[[ $_fs = nfs3 ]] && { echo $_dev; return 0;}
[[ $_fs = nfs4 ]] && { echo $_dev; return 0;}
@@ -355,16 +362,40 @@ find_block_device() {
# $ find_dev_fstype /dev/sda2;echo
# ext4
find_dev_fstype() {
local _x _mpt _majmin _dev _fs _maj _min
while read _x _x _majmin _x _mpt _x _x _fs _dev _x; do
[[ $_dev = $1 ]] || continue
local _x _mpt _majmin _dev _fs _maj _min _find_dev
_find_dev="$1"
strstr "$_find_dev" "/dev" || _find_dev="/dev/block/$_find_dev"
while read _x; do
set -- $_x
_majmin="$3"
_mpt="$5"
[[ $8 = "-" ]] && shift
_fs="$8"
_dev="$9"
strstr "$_dev" "/dev" || continue
[[ $_dev -ef $_find_dev ]] || continue
[[ $_fs = "autofs" ]] && continue
echo -n $_fs;
return 0;
done < /proc/self/mountinfo
# fall back to /etc/fstab
while read _dev _mpt _fs _x; do
[[ $_dev = $1 ]] || continue
[ "${_dev%%#*}" != "$_dev" ] && continue
case "$_dev" in
LABEL=*)
_dev="$(echo $_dev | sed 's,/,\\x2f,g')"
_dev="/dev/disk/by-label/${_dev#LABEL=}"
;;
UUID=*)
_dev="/dev/disk/by-uuid/${_dev#UUID=}"
;;
PARTUUID=*)
_dev="/dev/disk/by-partuuid/${_dev#PARTUUID=}"
;;
esac
[[ $_dev -ef $_find_dev ]] || continue
echo -n $_fs;
return 0;
done < /etc/fstab
@@ -381,16 +412,25 @@ find_dev_fstype() {
# $ find_mp_fstype /;echo
# ext4
find_mp_fstype() {
local _x _mpt _majmin _dev _fs _maj _min
while read _x _x _majmin _x _mpt _x _x _fs _dev _x; do
[[ $_mpt = $1 ]] || continue
local _x _mpt _majmin _dev _fs _maj _min _find_mpt
_find_mpt="$1"
while read _x; do
set -- $_x
_majmin="$3"
_mpt="$5"
[[ $8 = "-" ]] && shift
_fs="$8"
_dev="$9"
[[ $_mpt = $_find_mpt ]] || continue
[[ $_fs = "autofs" ]] && continue
echo -n $_fs;
return 0;
done < /proc/self/mountinfo
# fall back to /etc/fstab
while read _dev _mpt _fs _x; do
[[ $_mpt = $1 ]] || continue
[ "${_dev%%#*}" != "$_dev" ] && continue
[[ $_mpt = $_find_mpt ]] || continue
echo -n $_fs;
return 0;
done < /etc/fstab
@@ -900,7 +940,7 @@ inst_rules() {
inst_dir "${udevdir}/rules.d"
inst_dir "$_target"
for _rule in "$@"; do
if [ "${rule#/}" = "$rule" ]; then
if [ "${_rule#/}" = "$_rule" ]; then
for r in ${udevdir}/rules.d /etc/udev/rules.d; do
if [[ -f $r/$_rule ]]; then
_found="$r/$_rule"

View File

@@ -30,6 +30,13 @@ early userspace.
For a complete list of kernel command line options see *dracut.cmdline*(7).
If you are dropped to an emergency shell, while booting your initramfs,
the file _/run/initramfs/sosreport.txt_ is created, which can be safed to a
(to be mounted by hand) partition (usually /boot) or a USB stick.
Additional debugging info can be produced by adding **rd.debug** to the kernel command line.
_/run/initramfs/sosreport.txt_ contains all logs and the output of some tools.
It should be attached to any report about dracut problems.
EXAMPLE
-------
@@ -325,8 +332,11 @@ provide a valid _/etc/fstab_.
Mount _<device>_ on _<mountpoint>_ with _<filesystem type>_ and _<filesystem
options>_ in the initramfs
**--device** _<device>_ ::
Bring up _<device>_ in initramfs, _<device>_ should be the device name
**--add-device** _<device>_ ::
Bring up _<device>_ in initramfs, _<device>_ should be the device name.
This can be useful in hostonly mode for resume support when your swap is on
LVM or an encrypted partition.
[NB --device can be used for compatibility with earlier releases]
**-i, --include** _<SOURCE>_ _<TARGET>_::
include the files in the SOURCE directory into the

View File

@@ -79,7 +79,7 @@ udev pulls in modules matching the computer's detected hardware.
initialized and a user-space helper started to paint animations onto the display
in lockstep with the boot process.
* If the root file system is on NFS, dracut does then:
* If the root file system is on NFS, dracut does then:
** Bring up the primary network interface.
** Invoke a DHCP client, with which it can obtain a DHCP lease.
** Extract the name of the NFS share and the address of the NFS server from the
@@ -120,6 +120,26 @@ final cleanup tasks. On an initramfs, the initial root file system cannot be
rotated away. Instead, it is simply emptied and the final root file system
mounted over the top.
== Dracut on shutdown
On a systemd driven system, the dracut initramfs is also used for the shutdown procedure.
The following steps are executed during a shutdown:
* systemd switches to the shutdown.target
* systemd starts /lib/systemd/system/shutdown.target.wants/dracut-shutdown.service
* dracut-shutdown.service executes /usr/lib/dracut/dracut-initramfs-restore
which unpacks the initramfs to /run/initramfs
* systemd finishes shutdown.target
* systemd kills all processes
* systemd tries to unmount everything and mounts the remaining read-only
* systemd checks, if there is a /run/initramfs/shutdown executable
* if yes, it does a pivot_root to /run/initramfs and executes ./shutdown.
The old root is then mounted on /oldroot. /usr/lib/dracut/modules.d/99shutdown/shutdown.sh is the shutdown executable.
* shutdown will try to umount every /oldroot mount and calls the various shutdown hooks from the dracut modules
This ensures, that all devices are disassembled and unmounted cleanly.
= User Manual
== Creating an initramfs Image
@@ -391,7 +411,7 @@ How to setup your PXE/TFTP server can be found in the
http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/[Red
Hat Enterprise Linux Storage Administration Guide].
If you specify rd.ip=auto on the kernel command line, then dracut asks a dhcp
If you specify ip=auto on the kernel command line, then dracut asks a dhcp
server about the ip adress for the machine. The dhcp server can also serve an
additional root-path, which will set the root device for dracut. With this
mechanism, you have static configuration on your client machine and a
@@ -466,6 +486,7 @@ dracut shell commands are printed as they are executed
----
# journalctl -ab
----
. With dracut >= 025 the file /run/initramfs/sosreport.txt is generated, which contains all the logs and the output of all significant tools, which are mentioned later.
If you want to save that output, simply mount /boot by hand or insert an USB stick and mount that.
Then you can store the output for later inspection.

View File

@@ -124,6 +124,12 @@ Misc
[[dracutkerneldebug]]
Debug
~~~~~
If you are dropped to an emergency shell, the file _/run/initramfs/sosreport.txt_ is created,
which can be safed to a (to be mounted by hand) partition (usually /boot) or a USB stick.
Additional debugging info can be produced by adding **rd.debug** to the kernel command line.
_/run/initramfs/sosreport.txt_ contains all logs and the output of some tools.
It should be attached to any report about dracut problems.
**rd.info**::
print informational output though "quiet" is set
@@ -131,8 +137,15 @@ Debug
allow dropping to a shell, if root mounting fails
**rd.debug**::
set -x for the dracut shell and logs to dmesg, console and
_/run/initramfs/init.log_
set -x for the dracut shell.
If systemd is active in the initramfs, all output is logged to the systemd journal,
which you can inspect with "journalctl -ab".
If systemd is not active, the logs are written to dmesg and _/run/initramfs/init.log_.
If "quiet" is set, it also logs to the console.
**rd.memdebug=[0-3]**::
print memory usage debug info, set the verbose level from 1 to 3
print nothing when set rd.memdebug=0
**rd.break**::
drop to a shell at the end
@@ -411,6 +424,10 @@ interface name. Better name it "bootnet" or "bluesocket".
then its values should be separated by semicolon.
Bond without parameters assumes bond=bond0:eth0,eth1:mode=balance-rr
**team =_<teammaster>_:_<teamslaves>_**::
Setup team device <teammaster> on top of <teamslaves>.
<teamslaves> is a comma-separated list of physical (ethernet) interfaces.
**bridge=_<bridgename>_:_<ethnames>_**::
Setup bridge <bridgename> with <ethnames>. <ethnames> is a comma-separated
list of physical (ethernet) interfaces. Bridge without parameters assumes bridge=br0:eth0

View File

@@ -82,6 +82,11 @@ If chrooted to another root other than the real root device, use --fstab and pro
*add_fstab+=*" __<filename>__ "::
Add entries of __<filename>__ to the initramfs /etc/fstab.
*add_device+=*" __<device>__ "::
Bring up _<device>_ in initramfs, _<device>_ should be the device name.
This can be useful in hostonly mode for resume support when your swap is on
LVM an encrypted partition.
*mdadmconf=*"__{yes|no}__"::
Include local _/etc/mdadm.conf_ (default=yes)

View File

@@ -11,4 +11,5 @@ systemdsystemunitdir=/usr/lib/systemd/system
udevdir=/usr/lib/udev
add_dracutmodules+=" systemd "
realinitpath="/usr/lib/systemd/systemd"
kernelcmdline+=" rd.auto=1 "
kernel_cmdline+=" rd.auto=1 "

View File

@@ -134,7 +134,7 @@ Creates initial ramdisk images for preloading modules
--mount "[DEV] [MP] [FSTYPE] [FSOPTS]"
Mount device [DEV] on mountpoint [MP] with filesystem
[FSTYPE] and options [FSOPTS] in the initramfs
--device "[DEV]" Bring up [DEV] in initramfs
--add-device "[DEV]" Bring up [DEV] in initramfs
-i, --include [SOURCE] [TARGET]
Include the files in the SOURCE directory into the
Target directory in the final initramfs.
@@ -331,7 +331,8 @@ while :; do
--fscks) push fscks_l "$2"; shift;;
--add-fstab) push add_fstab_l "$2"; shift;;
--mount) push fstab_lines "$2"; shift;;
--device) push host_devs "$2"; shift;;
--add-device|--device)
push add_device_l "$2"; shift;;
--kernel-cmdline) push kernel_cmdline_l "$2"; shift;;
--nofscks) nofscks_l="yes";;
--ro-mnt) ro_mnt_l="yes";;
@@ -734,6 +735,16 @@ for f in $add_fstab; do
done < $f
done
if (( ${#add_device_l[@]} )); then
while pop add_device_l val; do
add_device+=" $val "
done
fi
for dev in $add_device; do
push host_devs $dev
done
if [[ $hostonly ]]; then
# in hostonly mode, determine all devices, which have to be accessed
# and examine them for filesystem types
@@ -755,18 +766,18 @@ if [[ $hostonly ]]; then
fi
_get_fs_type() (
[[ $1 ]] || return
[[ $1 ]] || return 1
if [[ -b $1 ]] && get_fs_env $1; then
echo "$(readlink -f $1)|$ID_FS_TYPE"
return 1
return 0
fi
if [[ -b /dev/block/$1 ]] && get_fs_env /dev/block/$1; then
echo "$(readlink -f /dev/block/$1)|$ID_FS_TYPE"
return 1
return 0
fi
if fstype=$(find_dev_fstype $1); then
echo "$1|$fstype"
return 1
return 0
fi
return 1
)
@@ -937,7 +948,7 @@ fi
if [[ $kernel_only != yes ]]; then
(( ${#install_items[@]} > 0 )) && dracut_install ${install_items[@]}
echo "$kernel_cmdline" >> "${initdir}/etc/cmdline.d/01-default.conf"
[[ $kernel_cmdline ]] && echo "$kernel_cmdline" >> "${initdir}/etc/cmdline.d/01-default.conf"
while pop fstab_lines line; do
echo "$line 0 0" >> "${initdir}/etc/fstab"
@@ -1031,7 +1042,7 @@ fi
if [[ $do_strip = yes ]] ; then
for p in strip xargs find; do
if ! type -P $p >/dev/null; then
derror "Could not find '$p'. You should run $0 with '--nostrip'."
dwarn "Could not find '$p'. Not stripping the initramfs."
do_strip=no
fi
done
@@ -1041,21 +1052,27 @@ if [[ $do_strip = yes ]] ; then
dinfo "*** Stripping files ***"
if [[ $DRACUT_FIPS_MODE ]]; then
find "$initdir" -type f \
'(' -perm -0100 -or -perm -0010 -or -perm -0001 \
-or -path '*/lib/modules/*.ko' ')' -print0 \
-executable -not -path '*/lib/modules/*.ko' -print0 \
| while read -r -d $'\0' f; do
if ! [[ -e "${f%/*}/.${f##*/}.hmac" ]] \
&& ! [[ -e "/lib/fipscheck/${f##*/}.hmac" ]] \
&& ! [[ -e "/lib64/fipscheck/${f##*/}.hmac" ]]; then
echo -n "$f"; echo -n -e "\000"
fi
done |xargs -r -0 strip -g 2>/dev/null
done | xargs -r -0 strip -g 2>/dev/null
else
find "$initdir" -type f \
'(' -perm -0100 -or -perm -0010 -or -perm -0001 \
-or -path '*/lib/modules/*.ko' ')' -print0 \
-executable -not -path '*/lib/modules/*.ko' -print0 \
| xargs -r -0 strip -g 2>/dev/null
fi
# strip kernel modules, but do not touch signed modules
find "$initdir" -type f -path '*/lib/modules/*.ko' -print0 \
| while read -r -d $'\0' f; do
SIG=$(tail -c 28 "$f")
[[ $SIG == '~Module signature appended~' ]] || { echo -n "$f"; echo -n -e "\000"; }
done | xargs -r -0 strip -g
dinfo "*** Stripping files done ***"
fi

View File

@@ -106,6 +106,8 @@ NFS, iSCSI, NBD, FCoE with the dracut-network package.
%package network
Summary: dracut modules to build a dracut initramfs with network support
Requires: %{name} = %{version}-%{release}
Requires: iputils
Requires: iproute
Obsoletes: dracut-generic < 008
Provides: dracut-generic = %{version}-%{release}
@@ -274,6 +276,7 @@ rm -rf $RPM_BUILD_ROOT
%{dracutlibdir}/modules.d/10i18n
%{dracutlibdir}/modules.d/30convertfs
%{dracutlibdir}/modules.d/45url-lib
%{dracutlibdir}/modules.d/50drm
%{dracutlibdir}/modules.d/50plymouth
%{dracutlibdir}/modules.d/80cms
%{dracutlibdir}/modules.d/90btrfs

View File

@@ -26,8 +26,8 @@ inst_key_val '' /etc/vconsole.conf vconsole.font.unimap FONT_UNIMAP -d UNIMAP
inst_key_val 1 /etc/vconsole.conf vconsole.font.unicode UNICODE vconsole.unicode
inst_key_val '' /etc/vconsole.conf vconsole.keymap.ext EXT_KEYMAP
inst_key_val '' /etc/locale.conf LANG locale.LANG
inst_key_val '' /etc/locale.conf LC_ALL locale.LC_ALL
inst_key_val '' /etc/locale.conf locale.LANG LANG
inst_key_val '' /etc/locale.conf locale.LC_ALL LC_ALL
if [ -f /etc/locale.conf ]; then
. /etc/locale.conf

View File

@@ -25,8 +25,7 @@ setup_interface() {
if ! ip link set $netif mtu $mtu ; then
ip link set $netif down
ip link set $netif mtu $mtu
ip link set $netif up
wait_for_if_up $netif
linkup $netif
fi
fi
@@ -51,6 +50,7 @@ PATH=/usr/sbin:/usr/bin:/sbin:/bin
export PS4="dhclient.$interface.$$ + "
exec >>/run/initramfs/loginit.pipe 2>>/run/initramfs/loginit.pipe
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
type ip_to_var >/dev/null 2>&1 || . /lib/net-lib.sh
# We already need a set netif here
netif=$interface
@@ -61,8 +61,7 @@ netif=$interface
case $reason in
PREINIT)
echo "dhcp: PREINIT $netif up"
ip link set $netif up
wait_for_if_up $netif
linkup $netif
;;
BOUND)
echo "dhcp: BOND setting $netif"
@@ -89,6 +88,7 @@ case $reason in
echo "source_hook initqueue/online $netif"
[ -e /tmp/net.$netif.manualup ] || echo "/sbin/netroot $netif"
echo "> /tmp/setup_net_$netif.ok"
echo "> /tmp/setup_net_\$(cat /sys/class/net/$netif/address).ok"
echo "rm -f $hookdir/initqueue/setup_net_$netif.sh"
} > $hookdir/initqueue/setup_net_$netif.sh

View File

@@ -28,6 +28,15 @@ if [ -e /tmp/bond.info ]; then
done
fi
if [ -e /tmp/team.info ]; then
. /tmp/team.info
for slave in $teamslaves ; do
if [ "$netif" = "$slave" ] ; then
netif=$teammaster
fi
done
fi
# bridge this interface?
if [ -e /tmp/bridge.info ]; then
. /tmp/bridge.info
@@ -84,20 +93,20 @@ do_ipv6auto() {
echo 0 > /proc/sys/net/ipv6/conf/$netif/forwarding
echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_ra
echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_redirects
ip link set $netif up
wait_for_if_up $netif
linkup $netif
[ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
return 0
}
# Handle static ip configuration
do_static() {
strstr $ip '*:*:*' && load_ipv6
ip link set $netif up
wait_for_if_up $netif
[ -n "$macaddr" ] && ip link set address $macaddr
[ -n "$mtu" ] && ip link set mtu $mtu
linkup $netif
[ -n "$macaddr" ] && ip link set address $macaddr dev $netif
[ -n "$mtu" ] && ip link set mtu $mtu dev $netif
if strstr $ip '*:*:*'; then
# note no ip addr flush for ipv6
ip addr add $ip/$mask dev $netif
@@ -108,6 +117,9 @@ do_static() {
[ -n "$gw" ] && echo ip route add default via $gw dev $netif > /tmp/net.$netif.gw
[ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
> /tmp/setup_net_${netif}.ok
return 0
}
# loopback is always handled the same way
@@ -143,13 +155,12 @@ if [ -e /tmp/bond.info ]; then
fi
done
ip link set $netif up
linkup $netif
for slave in $bondslaves ; do
ip link set $slave down
echo "+$slave" > /sys/class/net/$bondname/bonding/slaves
ip link set $slave up
wait_for_if_up $slave
linkup $slave
done
# add the bits to setup the needed post enslavement parameters
@@ -163,6 +174,28 @@ if [ -e /tmp/bond.info ]; then
fi
fi
if [ -e /tmp/team.info ]; then
. /tmp/team.info
if [ "$netif" = "$teammaster" ] && [ ! -e /tmp/net.$teammaster.up ] ; then
# We shall only bring up those _can_ come up
# in case of some slave is gone in active-backup mode
working_slaves=""
for slave in $teamslaves ; do
ip link set $slave up 2>/dev/null
if wait_for_if_up $slave; then
working_slaves+="$slave "
fi
done
# Do not add slaves now
teamd -d -U -n -t $teammaster -f /etc/teamd/$teammaster.conf
for slave in $working_slaves; do
# team requires the slaves to be down before joining team
ip link set $slave down
teamdctl $teammaster port add $slave
done
ip link set $teammaster up
fi
fi
# XXX need error handling like dhclient-script
@@ -176,9 +209,8 @@ if [ -e /tmp/bridge.info ]; then
if [ "$ethname" = "$bondname" ] ; then
DO_BOND_SETUP=yes ifup $bondname -m
else
ip link set $ethname up
linkup $ethname
fi
wait_for_if_up $ethname
brctl addif $bridgename $ethname
done
fi
@@ -200,9 +232,8 @@ if [ "$netif" = "$vlanname" ] && [ ! -e /tmp/net.$vlanname.up ]; then
if [ "$phydevice" = "$bondname" ] ; then
DO_BOND_SETUP=yes ifup $phydevice -m
else
ip link set "$phydevice" up
linkup "$phydevice"
fi
wait_for_if_up "$phydevice"
ip link add dev "$vlanname" link "$phydevice" type vlan id "$(get_vid $vlanname; echo $?)"
fi

View File

@@ -64,7 +64,8 @@ installkernel() {
{ find_kernel_modules_by_path drivers/net; if [ "$_arch" = "s390" -o "$_arch" = "s390x" ]; then find_kernel_modules_by_path drivers/s390/net; fi; } \
| net_module_filter | instmods
instmods =drivers/net/phy ecb arc4 bridge stp llc ipv6 bonding 8021q af_packet virtio_net
#instmods() will take care of hostonly
instmods =drivers/net/phy ecb arc4 bridge stp llc ipv6 bonding 8021q af_packet virtio_net =drivers/net/team
}
install() {
@@ -72,6 +73,8 @@ install() {
dracut_install ip arping dhclient sed
dracut_install -o ping ping6
dracut_install -o brctl
dracut_install -o teamd teamdctl teamnl
inst_simple /etc/libnl/classid
inst_script "$moddir/ifup.sh" "/sbin/ifup"
inst_script "$moddir/netroot.sh" "/sbin/netroot"
inst_script "$moddir/dhclient-script.sh" "/sbin/dhclient-script"
@@ -82,6 +85,7 @@ install() {
inst_hook cmdline 91 "$moddir/dhcp-root.sh"
inst_hook cmdline 95 "$moddir/parse-vlan.sh"
inst_hook cmdline 96 "$moddir/parse-bond.sh"
inst_hook cmdline 96 "$moddir/parse-team.sh"
inst_hook cmdline 97 "$moddir/parse-bridge.sh"
inst_hook cmdline 98 "$moddir/parse-ip-opts.sh"
inst_hook cmdline 99 "$moddir/parse-ifname.sh"

View File

@@ -34,11 +34,24 @@ fi
IFACES+=" ${bondslaves%% *}"
fi
if [ -e /tmp/team.info ]; then
. /tmp/team.info
IFACES+=" ${teamslaves}"
fi
if [ -e /tmp/vlan.info ]; then
. /tmp/vlan.info
IFACES+=" $phydevice"
fi
if [ -z "$IFACES" ]; then
[ -e /tmp/net.ifaces ] && read IFACES < /tmp/net.ifaces
fi
if [ -e /tmp/net.bootdev ]; then
bootdev=$(cat /tmp/net.bootdev)
fi
ifup='/sbin/ifup $env{INTERFACE}'
[ -z "$netroot" ] && ifup="$ifup -m"
@@ -47,16 +60,23 @@ fi
if [ -n "$BOOTIF" ] ; then
BOOTIF=$(fix_bootif "$BOOTIF")
printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="%s"\n' "$BOOTIF" "/sbin/initqueue --onetime $ifup"
echo "[ -f /tmp/setup_net_${BOOTIF}.ok ]" >$hookdir/initqueue/finished/wait-${BOOTIF}.sh
# If we have to handle multiple interfaces, handle only them.
elif [ -n "$IFACES" ] ; then
for iface in $IFACES ; do
printf 'SUBSYSTEM=="net", ENV{INTERFACE}=="%s", RUN+="%s"\n' "$iface" "/sbin/initqueue --onetime $ifup"
if [ "$bootdev" = "$iface" ]; then
echo "[ -f /tmp/setup_net_${iface}.ok ]" >$hookdir/initqueue/finished/wait-$iface.sh
fi
done
# Default: We don't know the interface to use, handle all
# Fixme: waiting for the interface as well.
else
# if you change the name of "91-default-net.rules", also change modules.d/80cms/cmssetup.sh
printf 'SUBSYSTEM=="net", RUN+="%s"\n' "/sbin/initqueue --onetime $ifup" > /etc/udev/rules.d/91-default-net.rules
fi
# if you change the name of "90-net.rules", also change modules.d/80cms/cmssetup.sh
} > /etc/udev/rules.d/90-net.rules

View File

@@ -1,4 +1,6 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
get_ip() {
local iface="$1" ip=""
@@ -272,7 +274,12 @@ ip_to_var() {
2) dev=$1; autoconf=$2 ;;
3) dev=$1; autoconf=$2; mtu=$3 ;;
4) dev=$1; autoconf=$2; mtu=$3; macaddr=$4 ;;
*) ip=$1; srv=$2; gw=$3; mask=$4; hostname=$5; dev=$6; autoconf=$7; mtu=$8; macaddr=$9 ;;
*) ip=$1; srv=$2; gw=$3; mask=$4;
hostname=$5; dev=$6; autoconf=$7; mtu=$8;
if [ -n "${9}" -a -n "${10}" -a -n "${11}" -a -n "${12}" -a -n "${13}" -a -n "${14}" ]; then
macaddr="${9}:${10}:${11}:${12}:${13}:${14}"
fi
;;
esac
# anaconda-style argument cluster
if strstr "$autoconf" "*.*.*.*"; then
@@ -315,3 +322,46 @@ parse_ifname_opts() {
esac
}
# some network driver need long time to initialize, wait before it's ready.
wait_for_if_link() {
local cnt=0
local li
while [ $cnt -lt 600 ]; do
li=$(ip -o link show dev $1 2>/dev/null)
[ -n "$li" ] && return 0
sleep 0.1
cnt=$(($cnt+1))
done
return 1
}
wait_for_if_up() {
local cnt=0
local li
while [ $cnt -lt 200 ]; do
li=$(ip -o link show up dev $1)
[ -n "$li" ] && return 0
sleep 0.1
cnt=$(($cnt+1))
done
return 1
}
wait_for_route_ok() {
local cnt=0
while [ $cnt -lt 200 ]; do
li=$(ip route show)
[ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
sleep 0.1
cnt=$(($cnt+1))
done
return 1
}
linkup() {
wait_for_if_link $1 2>/dev/null\
&& ip link set $1 up 2>/dev/null\
&& wait_for_if_up $1 2>/dev/null
}

View File

@@ -0,0 +1,44 @@
#!/bin/sh
#
# Format:
# team=<teammaster>:<teamslaves>
#
# teamslaves is a comma-separated list of physical (ethernet) interfaces
#
# return if team already parsed
[ -n "$teammaster" ] && return
# Check if team parameter is valid
if getarg team= >/dev/null ; then
:
fi
parseteam() {
local v=${1}:
set --
while [ -n "$v" ]; do
set -- "$@" "${v%%:*}"
v=${v#*:}
done
unset teammaster teamslaves
case $# in
2) teammaster=$1; teamslaves=$(str_replace "$2" "," " ") ;;
*) die "team= requires two parameters" ;;
esac
}
unset teammaster teamslaves
if getarg team>/dev/null; then
# Read team= parameters if they exist
team="$(getarg team=)"
if [ ! "$team" = "team" ]; then
parseteam "$(getarg team=)"
fi
echo "teammaster=$teammaster" > /tmp/team.info
echo "teamslaves=\"$teamslaves\"" >> /tmp/team.info
return
fi

View File

@@ -0,0 +1,63 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
return 0
}
depends() {
return 0
}
installkernel() {
local _modname
# Include KMS capable drm drivers
drm_module_filter() {
local _drm_drivers='drm_crtc_init'
local _ret
# subfunctions inherit following FDs
local _merge=8 _side2=9
function nmf1() {
local _fname _fcont
while read _fname; do
case "$_fname" in
*.ko) _fcont="$(< $_fname)" ;;
*.ko.gz) _fcont="$(gzip -dc $_fname)" ;;
*.ko.xz) _fcont="$(xz -dc $_fname)" ;;
esac
[[ $_fcont =~ $_drm_drivers
&& ! $_fcont =~ iw_handler_get_spy ]] \
&& echo "$_fname"
done
}
function rotor() {
local _f1 _f2
while read _f1; do
echo "$_f1"
if read _f2; then
echo "$_f2" 1>&${_side2}
fi
done | nmf1 1>&${_merge}
}
# Use two parallel streams to filter alternating modules.
set +x
eval "( ( rotor ) ${_side2}>&1 | nmf1 ) ${_merge}>&1"
[[ $debug ]] && set -x
return 0
}
for _modname in $(find_kernel_modules_by_path drivers/gpu/drm \
| drm_module_filter) ; do
# if the hardware is present, include module even if it is not currently loaded,
# as we could e.g. be in the installer; nokmsboot boot parameter will disable
# loading of the driver if needed
if [[ $hostonly ]] && modinfo -F alias $_modname | sed -e 's,\?,\.,g' -e 's,\*,\.\*,g' \
| grep -qxf - /sys/bus/pci/devices/*/modalias; then
hostonly='' instmods $_modname
continue
fi
instmods $_modname
done
}

View File

@@ -8,59 +8,7 @@ check() {
}
depends() {
return 0
}
installkernel() {
local _modname
# Include KMS capable drm drivers
drm_module_filter() {
local _drm_drivers='drm_crtc_init'
local _ret
# subfunctions inherit following FDs
local _merge=8 _side2=9
function nmf1() {
local _fname _fcont
while read _fname; do
case "$_fname" in
*.ko) _fcont="$(< $_fname)" ;;
*.ko.gz) _fcont="$(gzip -dc $_fname)" ;;
*.ko.xz) _fcont="$(xz -dc $_fname)" ;;
esac
[[ $_fcont =~ $_drm_drivers
&& ! $_fcont =~ iw_handler_get_spy ]] \
&& echo "$_fname"
done
}
function rotor() {
local _f1 _f2
while read _f1; do
echo "$_f1"
if read _f2; then
echo "$_f2" 1>&${_side2}
fi
done | nmf1 1>&${_merge}
}
# Use two parallel streams to filter alternating modules.
set +x
eval "( ( rotor ) ${_side2}>&1 | nmf1 ) ${_merge}>&1"
[[ $debug ]] && set -x
return 0
}
for _modname in $(find_kernel_modules_by_path drivers/gpu/drm \
| drm_module_filter) ; do
# if the hardware is present, include module even if it is not currently loaded,
# as we could e.g. be in the installer; nokmsboot boot parameter will disable
# loading of the driver if needed
if [[ $hostonly ]] && modinfo -F alias $_modname | sed -e 's,\?,\.,g' -e 's,\*,\.\*,g' \
| grep -qxf - /sys/bus/pci/devices/*/modalias; then
hostonly='' instmods $_modname
continue
fi
instmods $_modname
done
echo drm
}
install() {

View File

@@ -32,6 +32,7 @@ function cms_write_config()
cat > /etc/sysconfig/network << EOF
HOSTNAME=$HOSTNAME
EOF
echo "$HOSTNAME" > /etc/hostname
if [ "$ipv6" ]; then
echo "NETWORKING_IPV6=yes" >> /etc/sysconfig/network
else

View File

@@ -167,8 +167,8 @@ processcmsfile()
printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="%s", KERNELS=="%s", ENV{INTERFACE}=="?*", RUN+="/sbin/initqueue --onetime --unique --name cmsifup-$env{INTERFACE} /sbin/cmsifup $env{INTERFACE}"\n' "$driver" "$devbusid" > /etc/udev/rules.d/99-cms.rules
# remove the default net rules
rm -f /etc/udev/rules.d/61-default-net.rules
[[ -f /etc/udev/rules.d/60-net.rules ]] \
rm -f /etc/udev/rules.d/91-default-net.rules
[[ -f /etc/udev/rules.d/90-net.rules ]] \
|| printf 'SUBSYSTEM=="net", ACTION=="online", RUN+="/sbin/initqueue --onetime --env netif=$env{INTERFACE} source_hook initqueue/online"\n' >> /etc/udev/rules.d/99-cms.rules
znet_cio_free

View File

@@ -26,7 +26,7 @@ depends() {
}
installkernel() {
instmods btrfs crc32c
instmods btrfs
}
install() {

View File

@@ -1,4 +1,6 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
. /lib/dracut-lib.sh
@@ -11,18 +13,21 @@ if [ -f /etc/crypttab ]; then
done < /etc/crypttab
fi
allowdiscards="-"
# parse for allow-discards
if strstr "$(cryptsetup --help)" "allow-discards"; then
if discarduuids=$(getargs "rd.luks.allow-discards"); then
discarduuids=$(str_replace "$discarduuids" 'luks-' '')
if strstr " $discarduuids " " ${luks##luks-}"; then
allowdiscards="allow-discards"
fi
elif getargbool rd.luks.allow-discards; then
allowdiscards="allow-discards"
allowdiscards="allow-discards"
fi
elif getargbool 0 rd.luks.allow-discards; then
allowdiscards="allow-discards"
fi
fi
echo "$luks $dev none $allowdiscards" >> /etc/crypttab
echo "$luks $dev - timeout=0,$allowdiscards" >> /etc/crypttab
if command -v systemctl >/dev/null; then
systemctl daemon-reload

View File

@@ -97,10 +97,11 @@ done
# parse for allow-discards
if strstr "$(cryptsetup --help)" "allow-discards"; then
if discarduuids=$(getargs "rd.luks.allow-discards"); then
discarduuids=$(str_replace "$discarduuids" 'luks-' '')
if strstr " $discarduuids " " ${luksdev##luks-}"; then
allowdiscards="--allow-discards"
fi
elif getargbool rd.luks.allow-discards; then
elif getargbool 0 rd.luks.allow-discards; then
allowdiscards="--allow-discards"
fi
fi

View File

@@ -0,0 +1,13 @@
[Unit]
Description=Media check on %f
DefaultDependencies=no
Before=shutdown.target
[Service]
Type=oneshot
RemainAfterExit=no
ExecStart=/bin/checkisomd5 --verbose %f
StandardInput=tty-force
StandardOutput=inherit
StandardError=inherit
TimeoutSec=0

View File

@@ -32,7 +32,12 @@ fi
getarg rd.live.check -d check || check=""
if [ -n "$check" ]; then
[ -x /bin/plymouth ] && /bin/plymouth --hide-splash
checkisomd5 --verbose $livedev
if [ -n "$DRACUT_SYSTEMD" ]; then
p=$(str_replace "$livedev" "-" '\x2d')
systemctl start checkisomd5@${p}.service
else
checkisomd5 --verbose $livedev
fi
if [ $? -ne 0 ]; then
die "CD check failed!"
exit 1

View File

@@ -29,5 +29,6 @@ install() {
inst_script "$moddir/dmsquash-live-root.sh" "/sbin/dmsquash-live-root"
# should probably just be generally included
inst_rules 60-cdrom_id.rules
inst_simple "$moddir/checkisomd5@.service" "/etc/systemd/system/checkisomd5@.service"
}

View File

@@ -2,6 +2,15 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
_modprobe_d=/etc/modprobe.d
if [ -d /usr/lib/modprobe.d ] ; then
_modprobe_d=/usr/lib/modprobe.d
elif [ -d /lib/modprobe.d ] ; then
_modprobe_d=/lib/modprobe.d
elif [ ! -d $_modprobe_d ] ; then
mkdir -p $_modprobe_d
fi
for i in $(getargs rd.driver.pre -d rdloaddriver=); do
(
IFS=,
@@ -11,19 +20,22 @@ for i in $(getargs rd.driver.pre -d rdloaddriver=); do
)
done
[ -d /etc/modprobe.d ] || mkdir -p /etc/modprobe.d
for i in $(getargs rd.driver.blacklist -d rdblacklist=); do
(
IFS=,
for p in $i; do
echo "blacklist $p" >> /etc/modprobe.d/initramfsblacklist.conf
echo "blacklist $p" >> $_modprobe_d/initramfsblacklist.conf
done
)
done
for p in $(getargs rd.driver.post -d rdinsmodpost=); do
echo "blacklist $p" >> /etc/modprobe.d/initramfsblacklist.conf
echo "blacklist $p" >> $_modprobe_d/initramfsblacklist.conf
_do_insmodpost=1
done
[ -n "$_do_insmodpost" ] && initqueue --settled --unique --onetime insmodpost.sh
unset _do_insmodpost
unset _do_insmodpost _modprobe_d

View File

@@ -0,0 +1,16 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
_do_mdmon_takeover() {
local ret
mdmon --takeover --all
ret=$?
[ $ret -eq 0 ] && info "Taking over mdmon processes."
return $ret
}
if command -v mdmon >/dev/null; then
_do_mdmon_takeover $1
else
:
fi

View File

@@ -88,5 +88,8 @@ install() {
inst_hook shutdown 30 "$moddir/md-shutdown.sh"
inst_script "$moddir/mdraid-cleanup.sh" /sbin/mdraid-cleanup
inst_script "$moddir/mdraid_start.sh" /sbin/mdraid_start
if [ -e /lib/systemd/system/mdmon-offroot@.service ]; then
inst_simple /lib/systemd/system/mdmon-offroot@.service
fi
inst_hook pre-shutdown 30 "$moddir/mdmon-pre-shutdown.sh"
}

View File

@@ -18,7 +18,7 @@ echo server: $server
echo path: $path
echo options: $options
mount.cifs //$server/$path $NEWROOT -o $options && { [ -e /dev/root ] || >/dev/root ; }
mount.cifs //$server/$path $NEWROOT -o $options && { [ -e /dev/root ] || ln -s null /dev/root ; }
# inject new exit_if_exists
echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm "$job"' > $hookdir/initqueue/cifs.sh

View File

@@ -16,12 +16,12 @@ PATH=/usr/sbin:/usr/bin:/sbin:/bin
export PS4="fcoe-up.$1.$$ + "
exec >>/run/initramfs/loginit.pipe 2>>/run/initramfs/loginit.pipe
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
type ip_to_var >/dev/null 2>&1 || . /lib/net-lib.sh
netif=$1
dcb=$2
ip link set "$netif" up
wait_for_if_up "$netif"
linkup "$netif"
netdriver=$(readlink -f /sys/class/net/$netif/device/driver)
netdriver=${netdriver##*/}

View File

@@ -135,6 +135,7 @@ handle_netroot()
if [ -z "$root" -o -n "${root%%block:*}" ]; then
# if root is not specified try to mount the whole iSCSI LUN
printf 'SYMLINK=="disk/by-path/*-iscsi-*-%s", SYMLINK+="root"\n' $iscsi_lun >> /etc/udev/rules.d/99-iscsi-root.rules
udevadm control --reload
# install mount script
echo "iscsi_lun=$iscsi_lun . /bin/mount-lun.sh " > $hookdir/mount/01-$$-iscsi.sh

View File

@@ -2,16 +2,22 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
# Start rpcbind or rpcbind
# FIXME occasionally saw 'rpcbind: fork failed: No such device' -- why?
command -v portmap >/dev/null && [ -z "$(pidof portmap)" ] && portmap
command -v rpcbind >/dev/null && [ -z "$(pidof rpcbind)" ] && rpcbind
[ ! -d /var/lib/nfs/rpc_pipefs/nfs ] && \
mount -t rpc_pipefs rpc_pipefs /var/lib/nfs/rpc_pipefs
if modprobe sunrpc || strstr "$(cat /proc/filesystems)" rpc_pipefs; then
# Start rpc.statd as mount won't let us use locks on a NFSv4
# filesystem without talking to it. NFSv4 does locks internally,
# rpc.lockd isn't needed
[ -z "$(pidof rpc.statd)" ] && rpc.statd
[ -z "$(pidof rpc.idmapd)" ] && rpc.idmapd
[ ! -d /var/lib/nfs/rpc_pipefs/nfs ] && \
mount -t rpc_pipefs rpc_pipefs /var/lib/nfs/rpc_pipefs
# Start rpcbind or rpcbind
# FIXME occasionally saw 'rpcbind: fork failed: No such device' -- why?
command -v portmap >/dev/null && [ -z "$(pidof portmap)" ] && portmap
command -v rpcbind >/dev/null && [ -z "$(pidof rpcbind)" ] && rpcbind
# Start rpc.statd as mount won't let us use locks on a NFSv4
# filesystem without talking to it. NFSv4 does locks internally,
# rpc.lockd isn't needed
[ -z "$(pidof rpc.statd)" ] && rpc.statd
[ -z "$(pidof rpc.idmapd)" ] && rpc.idmapd
else
warn 'Kernel module "sunrpc" not in the initramfs, or support for filesystem "rpc_pipefs" missing!'
fi

View File

@@ -22,7 +22,9 @@ if incol2 /proc/mounts /var/lib/nfs/rpc_pipefs; then
mkdir -m 0755 -p $NEWROOT/$rpcpipefspath 2>/dev/null
if [ -d $NEWROOT/$rpcpipefspath ]; then
mount --move /var/lib/nfs/rpc_pipefs $NEWROOT/$rpcpipefspath
# mount --move does not seem to work???
mount --bind /var/lib/nfs/rpc_pipefs $NEWROOT/$rpcpipefspath
umount /var/lib/nfs/rpc_pipefs
else
umount /var/lib/nfs/rpc_pipefs
fi

View File

@@ -16,7 +16,7 @@ NEWROOT="$3"
nfs_to_var $root $netif
[ -z "$server" ] && die "Required parameter 'server' is missing"
mount_nfs $root $NEWROOT $netif && { [ -e /dev/root ] || >/dev/root ; }
mount_nfs $root $NEWROOT $netif && { [ -e /dev/root ] || ln -s null /dev/root ; }
# inject new exit_if_exists
echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm "$job"' > $hookdir/initqueue/nfs.sh

View File

@@ -15,7 +15,7 @@ check() {
rootopts=$opts
break
fi
done < "$NEWROOT/etc/fstab"
done < /etc/fstab
[ "$rootfs" = "reiserfs" ] && journaldev=$(fs_get_option $rootopts "jdev")
[ "$rootfs" = "xfs" ] && journaldev=$(fs_get_option $rootopts "logdev")

View File

@@ -28,7 +28,7 @@ mount_root() {
_rflags_ro="$rflags,ro"
while ! mount -t ${rootfs} -o "$_rflags_ro" "${root#block:}" "$NEWROOT"; do
warn "Failed to mount -t ${rootfs} -o $_rflags_ro ${root#block:} $NEWROOT"
warn "Failed to mount -t ${rootfs} -o ${_rflags_ro##,} ${root#block:} $NEWROOT"
fsck_ask_err
done

View File

@@ -3,8 +3,8 @@ ACTION!="add|change", GOTO="ps_end"
# Also don't process disks that are slated to be a multipath device
ENV{DM_MULTIPATH_DEVICE_PATH}=="?*", GOTO="ps_end"
KERNEL=="cciss[0-9]*", IMPORT{builtin}="blkid"
KERNEL=="nbd[0-9]*", IMPORT{builtin}="blkid"
KERNEL=="cciss[0-9]*", IMPORT BLKID
KERNEL=="nbd[0-9]*", IMPORT BLKID
KERNEL!="md[0-9]*|md_d[0-9]*|md/*", KERNEL!="md*", GOTO="md_end"
@@ -21,7 +21,7 @@ ATTR{md/array_state}=="|clear|inactive", GOTO="md_end"
LABEL="md_ignore_state"
IMPORT{program}="/sbin/mdadm --detail --export $tempnode"
IMPORT{builtin}="blkid"
IMPORT BLKID
OPTIONS+="link_priority=100"
OPTIONS+="watch"
LABEL="md_end"
@@ -34,7 +34,7 @@ ENV{DM_NAME}!="?*", GOTO="ps_end"
ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=="1", GOTO="ps_end"
ENV{DM_UUID}=="CRYPT-TEMP-?*", GOTO="ps_end"
ENV{DM_UUID}!="?*", ENV{DM_NAME}=="temporary-cryptsetup-?*", GOTO="ps_end"
IMPORT{builtin}="blkid"
IMPORT BLKID
LABEL="ps_end"

View File

@@ -12,7 +12,7 @@ GOTO="pss_end"
LABEL="do_pss"
# by-path (parent device path)
ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="", DEVPATH!="*/virtual/*", IMPORT{builtin}="path_id"
ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="", DEVPATH!="*/virtual/*", IMPORT PATH_ID
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"

View File

@@ -74,5 +74,7 @@ install() {
inst_script "$moddir/load-modules.sh" /lib/udev/load-modules.sh
inst_libdir_file "libnss_files*"
inst_hook pre-udev 10 "$moddir/udev-rules-prepare.sh"
}

View File

@@ -0,0 +1,27 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
[ -z "$UDEVVERSION" ] && export UDEVVERSION=$(udevadm --version)
for f in /etc/udev/rules.d/*-persistent-storage.rules; do
[ -e "$f" ] || continue
while read line; do
if [ "${line%%IMPORT PATH_ID}" != "$line" ]; then
if [ $UDEVVERSION -ge 174 ]; then
printf '%sIMPORT{builtin}="path_id"\n' "${line%%IMPORT PATH_ID}"
else
printf '%sIMPORT{program}="path_id %%p"\n' "${line%%IMPORT PATH_ID}"
fi
elif [ "${line%%IMPORT BLKID}" != "$line" ]; then
if [ $UDEVVERSION -ge 176 ]; then
printf '%sIMPORT{builtin}="blkid"\n' "${line%%IMPORT BLKID}"
else
printf '%sIMPORT{program}="/sbin/blkid -o udev -p $tempnode"\n' "${line%%IMPORT BLKID}"
fi
else
echo "$line"
fi
done < "${f}" > "${f}.new"
mv "${f}.new" "$f"
done

View File

@@ -12,6 +12,7 @@ Description=dracut cmdline hook
Documentation=man:dracut-cmdline.service(8)
DefaultDependencies=no
Before=dracut-pre-udev.service
Before=systemd-vconsole-setup.service
After=systemd-journald.socket
Wants=systemd-journald.socket
ConditionPathExists=/etc/initrd-release

View File

@@ -18,6 +18,7 @@ type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
source_conf /etc/conf.d
make_trace_mem "hook cmdline" '1+:mem' '1+:iomem' '3+:slab'
# run scriptlets to parse the command line
getarg 'rd.break=cmdline' -d 'rdbreak=cmdline' && emergency_shell -n cmdline "Break before cmdline"
source_hook cmdline

View File

@@ -15,7 +15,8 @@ DefaultDependencies=no
Environment=HOME=/
WorkingDirectory=/
ExecStartPre=-/bin/plymouth quit
ExecStartPre=-/bin/echo -e '\n\nEntering emergency mode. Exit the shell to continue.\nType "journalctl" to view system logs.\n'
ExecStartPre=-/sbin/sosreport
ExecStartPre=-/bin/echo -e '\n\nEntering emergency mode. Exit the shell to continue.\nType "journalctl" to view system logs.\nYou might want to save "/run/initramfs/sosreport.txt" to a USB stick or /boot\nafter mounting them and attach it to a bug report.\n\n'
ExecStart=-/bin/sh -i -l
ExecStopPost=-/bin/rm -f /.console_lock
Type=oneshot

View File

@@ -10,6 +10,7 @@ type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
source_conf /etc/conf.d
make_trace_mem "hook initqueue" '1:shortmem' '2+:mem' '3+:slab'
getarg 'rd.break=initqueue' -d 'rdbreak=initqueue' && emergency_shell -n initqueue "Break before initqueue"
RDRETRY=$(getarg rd.retry -d 'rd_retry=')

View File

@@ -10,6 +10,7 @@ type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
source_conf /etc/conf.d
make_trace_mem "hook pre-pivot" '1:shortmem' '2+:mem' '3+:slab'
# pre pivot scripts are sourced just before we doing cleanup and switch over
# to the new root.
getarg 'rd.break=pre-pivot' 'rdbreak=pre-pivot' && emergency_shell -n pre-pivot "Break pre-pivot"

View File

@@ -10,6 +10,7 @@ type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
source_conf /etc/conf.d
make_trace_mem "hook pre-trigger" "1:shortmem" "2+:mem" "3+:slab"
getargbool 0 rd.udev.info -n -y rdudevinfo && udevadm control --log-priority=info
getargbool 0 rd.udev.debug -n -y rdudevdebug && udevadm control --log-priority=debug
udevproperty "hookdir=$hookdir"

View File

@@ -9,6 +9,7 @@ type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
source_conf /etc/conf.d
make_trace_mem "hook pre-udev" '1:shortmem' '2+:mem' '3+:slab'
# pre pivot scripts are sourced just before we doing cleanup and switch over
# to the new root.
getarg 'rd.break=pre-udev' 'rdbreak=pre-udev' && emergency_shell -n pre-udev "Break pre-udev"

View File

@@ -85,7 +85,7 @@ install() {
$systemdsystemunitdir/initrd-switch-root.target \
$systemdsystemunitdir/initrd-switch-root.service \
$systemdsystemunitdir/umount.target \
journalctl systemctl echo
journalctl systemctl echo swapoff
if [[ $hostonly ]]; then
dracut_install -o /etc/systemd/journald.conf \
@@ -145,5 +145,14 @@ install() {
inst_script "$moddir/service-to-run.sh" "${systemdutildir}/system-generators/service-to-run"
inst_rules 99-systemd.rules
# turn off RateLimit for journal
{
echo "[Journal]"
echo "RateLimitInterval=0"
echo "RateLimitBurst=0"
} >> "$initdir/etc/systemd/journald.conf"
}

View File

@@ -1,5 +1,5 @@
#!/bin/sh
mkdir -p /run/systemd/system/
cp -d -t /run/systemd/system/ /etc/systemd/system/*
cp -d -t /run/systemd/system/ /etc/systemd/system/* 2>/dev/null
exit 0

View File

@@ -5,6 +5,21 @@
type info >/dev/null 2>&1 || . /lib/dracut-lib.sh
type fsck_single >/dev/null 2>&1 || . /lib/fs-lib.sh
filtersubvol() {
local _oldifs
_oldifs="$IFS"
IFS=","
set $*
IFS="$_oldifs"
while [ $# -gt 0 ]; do
case $1 in
subvol\=*) :;;
*) echo -n "${1}," ;;
esac
shift
done
}
fsck_usr()
{
local _dev=$1
@@ -56,6 +71,8 @@ mount_usr()
[ "${root#block:}" -ef $_dev ]
[ -n "$rflags" ]; then
# for btrfs subvolumes we have to mount /usr with the same rflags
rflags=$(filtersubvol "$rflags")
rflags=${rflags%%,}
_opts="${_opts:+${_opts},}${rflags}"
elif getargbool 0 ro; then
# if "ro" is specified, we want /usr to be mounted read-only

View File

@@ -43,6 +43,20 @@ str_replace() {
echo "${out}${in}"
}
killall_proc_mountpoint() {
local _pid
local _t
for _pid in /proc/*; do
_pid=${_pid##/proc/}
case $_pid in
*[!0-9]*) continue;;
esac
[ -e /proc/$_pid/exe ] || continue
[ -e /proc/$_pid/root ] || continue
strstr "$(ls -l /proc/$_pid /proc/$_pid/fd 2>/dev/null)" "$1" && kill -9 $_pid
done
}
_getcmdline() {
local _line
local _i
@@ -167,6 +181,35 @@ getargbool() {
return 0
}
isdigit() {
case "$1" in
*[!0-9]*|"") return 1;;
esac
return 0
}
# getargnum <defaultval> <minval> <maxval> <arg>
# Will echo the arg if it's in range [minval - maxval].
# If it's not set or it's not valid, will set it <defaultval>.
# Note all values are required to be >= 0 here.
# <defaultval> should be with [minval -maxval].
getargnum() {
local _b
unset _b
local _default _min _max
_default=$1; shift
_min=$1; shift
_max=$1; shift
_b=$(getarg "$1")
[ $? -ne 0 -a -z "$_b" ] && _b=$_default
if [ -n "$_b" ]; then
isdigit "$_b" && _b=$(($_b)) && \
[ $_b -ge $_min ] && [ $_b -le $_max ] && echo $_b && return
fi
echo $_default
}
_dogetargs() {
debug_off
local _o _found _key
@@ -481,29 +524,6 @@ else
}
fi
wait_for_if_up() {
local cnt=0
local li
while [ $cnt -lt 200 ]; do
li=$(ip -o link show up dev $1)
[ -n "$li" ] && return 0
sleep 0.1
cnt=$(($cnt+1))
done
return 1
}
wait_for_route_ok() {
local cnt=0
while [ $cnt -lt 200 ]; do
li=$(ip route show)
[ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
sleep 0.1
cnt=$(($cnt+1))
done
return 1
}
# root=nfs:[<server-ip>:]<root-dir>[:<nfs-options>]
# root=nfs4:[<server-ip>:]<root-dir>[:<nfs-options>]
nfsroot_to_var() {
@@ -879,12 +899,23 @@ _emergency_shell()
systemctl start dracut-emergency.service
rm -f /.console_lock
else
echo "Dropping to debug shell."
debug_off
echo
/sbin/sosreport
echo 'You might want to save "/run/initramfs/sosreport.txt" to a USB stick or /boot'
echo 'after mounting them and attach it to a bug report.'
if ! RD_DEBUG= getargbool 0 rd.debug -d -y rdinitdebug -d -y rdnetdebug; then
echo
echo 'To get more debug information in the report,'
echo 'reboot with "rd.debug" added to the kernel command line.'
fi
echo
echo 'Dropping to debug shell.'
echo
export PS1="$_name:\${PWD}# "
[ -e /.profile ] || >/.profile
_ctty="$(getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
_ctty="$(RD_DEBUG= getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
if [ -z "$_ctty" ]; then
_ctty=console
while [ -f /sys/class/tty/$_ctty/active ]; do
@@ -909,6 +940,11 @@ emergency_shell()
shift 2
elif [ "$1" = "--shutdown" ]; then
_rdshell_name=$2; action="Shutdown"; hook="shutdown-emergency"
if [ -x /bin/plymouth ]; then
/bin/plymouth --hide-splash
elif [ -x /oldroot/bin/plymouth ]; then
/oldroot/bin/plymouth --hide-splash
fi
shift 2
fi
@@ -920,7 +956,7 @@ emergency_shell()
if getargbool 1 rd.shell -d -y rdshell || getarg rd.break -d rdbreak; then
_emergency_shell $_rdshell_name
else
warn "$action has failed. To debug this issue add \"rd.shell\" to the kernel command line."
warn "$action has failed. To debug this issue add \"rd.shell rd.debug\" to the kernel command line."
# cause a kernel panic
exit 1
fi
@@ -977,3 +1013,98 @@ listlist() {
are_lists_eq() {
listlist "$1" "$2" "$3" "$4" && listlist "$1" "$3" "$2" "$4"
}
setmemdebug() {
if [ -z "$DEBUG_MEM_LEVEL" ]; then
export DEBUG_MEM_LEVEL=$(getargnum 0 0 3 rd.memdebug)
fi
}
setmemdebug
# parameters: msg [trace_level:trace]...
make_trace_mem()
{
local msg
msg="$1"
shift
if [ -n "$DEBUG_MEM_LEVEL" ] && [ "$DEBUG_MEM_LEVEL" -gt 0 ]; then
make_trace show_memstats $DEBUG_MEM_LEVEL "[debug_mem]" "$msg" "$@"
fi
}
# parameters: func log_level prefix msg [trace_level:trace]...
make_trace()
{
local func log_level prefix msg msg_printed
local trace trace_level trace_in_higher_levels insert_trace
func=$1
shift
log_level=$1
shift
prefix=$1
shift
msg=$1
shift
if [ -z "$log_level" ]; then
return
fi
msg=$(echo $msg)
msg_printed=0
while [ $# -gt 0 ]; do
trace=${1%%:*}
trace_level=${trace%%+}
[ "$trace" != "$trace_level" ] && trace_in_higher_levels="yes"
trace=${1##*:}
if [ -z "$trace_level" ]; then
trace_level=0
fi
insert_trace=0
if [ -n "$trace_in_higher_levels" ]; then
if [ "$log_level" -ge "$trace_level" ]; then
insert_trace=1
fi
else
if [ "$log_level" -eq "$trace_level" ]; then
insert_trace=1
fi
fi
if [ $insert_trace -eq 1 ]; then
if [ $msg_printed -eq 0 ]; then
echo "$prefix $msg"
msg_printed=1
fi
$func $trace
fi
shift
done
}
# parameters: type
show_memstats()
{
case $1 in
shortmem)
cat /proc/meminfo | grep -e "^MemFree" -e "^Cached" -e "^Slab"
;;
mem)
cat /proc/meminfo
;;
slab)
cat /proc/slabinfo
;;
iomem)
cat /proc/iomem
;;
esac
}

View File

@@ -83,7 +83,7 @@ trap "emergency_shell Signal caught!" 0
[ -d /run/initramfs ] || mkdir -p -m 0755 /run/initramfs
UDEVVERSION=$(udevadm --version)
export UDEVVERSION=$(udevadm --version)
if [ $UDEVVERSION -gt 166 ]; then
# newer versions of udev use /run/udev/rules.d
export UDEVRULESD=/run/udev/rules.d

View File

@@ -32,6 +32,7 @@ install() {
inst_script "$moddir/init.sh" "/init"
inst_script "$moddir/initqueue.sh" "/sbin/initqueue"
inst_script "$moddir/loginit.sh" "/sbin/loginit"
inst_script "$moddir/sosreport.sh" "/sbin/sosreport"
[ -e "${initdir}/lib" ] || mkdir -m 0755 -p ${initdir}/lib
mkdir -m 0755 -p ${initdir}/lib/dracut

49
modules.d/99base/sosreport.sh Executable file
View File

@@ -0,0 +1,49 @@
#!/bin/sh
echo 'Generating "/run/initramfs/sosreport.txt"'
exec >/run/initramfs/sosreport.txt 2>&1
set -x
cat /proc/self/mountinfo
cat /proc/mounts
blkid
blkid -o udev
ls -l /dev/disk/by*
cat /proc/cmdline
[ -f /etc/cmdline ] && cat /etc/cmdline
for _i in /etc/cmdline.d/*.conf; do
[ -f "$_i" ] || break
echo $_i
cat $_i
done
for _i in /etc/conf.d/*.conf; do
[ -f "$_i" ] || break
echo $_i
cat $_i
done
if command -v lvm >/dev/null 2>/dev/null; then
lvm pvdisplay
lvm vgdisplay
lvm lvdisplay
fi
command -v dmsetup >/dev/null 2>/dev/null && dmsetup ls --tree
cat /proc/mdstat
if command -v journalctl >/dev/null 2>/dev/null; then
journalctl -ab --no-pager
else
dmesg
[ -f /run/initramfs/init.log ] && cat /run/initramfs/init.log
fi

View File

@@ -35,6 +35,24 @@ echo_fs_helper() {
esac
}
include_fs_helper_modules() {
local dev=$1 fs=$2
case "$fs" in
xfs|btrfs)
instmods crc32c
;;
esac
}
installkernel() {
# xfs and btrfs needs crc32c...
if [[ $hostonly ]]; then
for_each_host_dev_fs include_fs_helper_modules
:
else
instmods crc32c
fi
}
install() {
local _helpers

View File

@@ -8,6 +8,8 @@
# Harald Hoyer <harald@redhat.com>
ACTION="$1"
exec </dev/console >>/dev/console 2>>/dev/console
export TERM=linux
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
. /lib/dracut-lib.sh
@@ -24,13 +26,23 @@ fi
trap "emergency_shell --shutdown shutdown Signal caught!" 0
getarg 'rd.break=pre-shutdown' && emergency_shell --shutdown pre-shutdown "Break before pre-shutdown"
source_hook pre-shutdown
if ! ( [ -x /bin/plymouth ] && /bin/plymouth --quit ); then
[ -x /oldroot/bin/plymouth ] && /oldroot/bin/plymouth --quit
fi
warn "Killing all remaining processes"
killall_proc_mountpoint /oldroot
umount_a() {
local _did_umount="n"
while read a mp a; do
if strstr "$mp" oldroot; then
if umount "$mp"; then
_did_umount="y"
echo "Unmounted $mp."
warn "Unmounted $mp."
fi
fi
done </proc/mounts
@@ -43,8 +55,27 @@ while [ $_cnt -le 40 ]; do
umount_a 2>/dev/null || break
_cnt=$(($_cnt+1))
done
[ $_cnt -ge 40 ] && umount_a
if strstr "$(cat /proc/mounts)" "/oldroot"; then
warn "Cannot umount /oldroot"
for _pid in /proc/*; do
_pid=${_pid##/proc/}
case $_pid in
*[!0-9]*) continue;;
esac
[ -e /proc/$_pid/exe ] || continue
[ -e /proc/$_pid/root ] || continue
if strstr "$(ls -l /proc/$_pid /proc/$_pid/fd 2>/dev/null)" "oldroot"; then
warn "Blocking umount of /oldroot [$_pid] $(cat /proc/$_pid/cmdline)"
elif [ $_pid -ne $$ ]; then
warn "Still running [$_pid] $(cat /proc/$_pid/cmdline)"
fi
ls -l /proc/$_pid/fd 2>&1 | vwarn
done
fi
_check_shutdown() {
local __f
local __s=1

View File

@@ -4,7 +4,7 @@ for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
rm /etc/lvm/lvm.conf
udevadm control --reload-rules
udevadm control --reload
set -e
# save a partition at the beginning for future flagging purposes
sfdisk -C 2560 -H 2 -S 32 -L /dev/sda <<EOF

View File

@@ -4,7 +4,7 @@ for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
rm /etc/lvm/lvm.conf
udevadm control --reload-rules
udevadm control --reload
set -e
# save a partition at the beginning for future flagging purposes
sfdisk -C 2560 -H 2 -S 32 -L /dev/sda <<EOF

View File

@@ -4,7 +4,7 @@ for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
rm /etc/lvm/lvm.conf
udevadm control --reload-rules
udevadm control --reload
set -e
# save a partition at the beginning for future flagging purposes
sfdisk -C 5120 -H 2 -S 32 -L /dev/sda <<EOF

View File

@@ -4,7 +4,7 @@ for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
rm /etc/lvm/lvm.conf
udevadm control --reload-rules
udevadm control --reload
set -e
# save a partition at the beginning for future flagging purposes
sfdisk -C 10240 -H 2 -S 32 -L /dev/sda <<EOF

View File

@@ -4,7 +4,7 @@ for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
rm /etc/lvm/lvm.conf
udevadm control --reload-rules
udevadm control --reload
# save a partition at the beginning for future flagging purposes
sfdisk -C 1280 -H 2 -S 32 -L /dev/sda <<EOF
,16

View File

@@ -4,7 +4,7 @@ for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
rm /etc/lvm/lvm.conf
udevadm control --reload-rules
udevadm control --reload
# save a partition at the beginning for future flagging purposes
sfdisk -C 1280 -H 2 -S 32 -L /dev/sda <<EOF
,1

View File

@@ -7,7 +7,7 @@ for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
rm /etc/lvm/lvm.conf
udevadm control --reload-rules
udevadm control --reload
# save a partition at the beginning for future flagging purposes
sfdisk -C 1280 -H 2 -S 32 -L /dev/sda <<EOF
,16

View File

@@ -5,7 +5,7 @@ for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
rm /etc/lvm/lvm.conf
udevadm control --reload-rules
udevadm control --reload
# save a partition at the beginning for future flagging purposes
sfdisk -C 2560 -H 2 -S 32 -L /dev/sda <<EOF
,16

View File

@@ -3,7 +3,7 @@
for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
udevadm control --reload-rules
udevadm control --reload
# save a partition at the beginning for future flagging purposes
sfdisk -C 655600 -H 2 -S 32 -L /dev/sda <<EOF
,16

View File

@@ -4,7 +4,7 @@ for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
rm /etc/lvm/lvm.conf
udevadm control --reload-rules
udevadm control --reload
mkfs.ext3 -j -F /dev/sda && \
mkdir -p /sysroot && \
mount /dev/sda /sysroot && \

View File

@@ -4,7 +4,7 @@ for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
rm /etc/lvm/lvm.conf
udevadm control --reload-rules
udevadm control --reload
echo -n test >keyfile
cryptsetup -q luksFormat /dev/sdb /keyfile
echo "The passphrase is test"

View File

@@ -5,7 +5,7 @@ for x in 61-dmraid-imsm.rules 64-md-raid.rules 65-md-incremental-imsm.rules 65-m
done
rm /etc/lvm/lvm.conf
udevadm control --reload-rules
udevadm control --reload
# dmraid does not want symlinks in --disk "..."
if [ -e /dev/hda ] ; then
echo y|dmraid -f isw -C Test0 --type 1 --disk "/dev/hdb /dev/hdc"