Compare commits

..

144 Commits

Author SHA1 Message Date
Lukas Nykryn
7b9bbc2a82 01fips: add authenec module
Resolves: #1465946
2017-06-28 16:10:48 +02:00
Lukas Nykryn
994a6cdd88 95iscsi: run iscsistart with DefaultDependencies=no
In upstream part of 7e51a94f5b

Resolves: #1461234
2017-06-15 14:01:13 +02:00
Lukas Nykryn
3674e2e16f fips: add cmac kernel module
cmac is now marked as fips_allowed

Resolves: rhbz#1460865
2017-06-13 16:40:47 +02:00
Peter Robinson
436052a84b Add check for aarch64 to the arm kernel module list
This adds the same list of drivers we use for arm platforms for
aarch64 too, also add the DMA drivers there too as they can add
sigficant performance for some storage/usb and often need to be
present when the storage drivers load.

Signed-off-by: Peter Robinson <pbrobinson@gmail.com>

Cherry-picked from: 917e1b6b5b
Resolves: #1459277
2017-06-12 16:09:01 +02:00
Prarit Bhargava
784c92876b module-setup.sh: Add ARM specific driver to initramfs image
If a hisi_sas storage device is used as / during system install, the
resulting installation will not boot because the hisi_sas driver is not
included in the initramfs.

The Hisilicon storage driver needs to be added to the initramfs image for
aarch64 kernels.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Cc: dzickus@redhat.com
Cc: dmarlin@redhat.com
Cc: wefu@redhat.com
Cc: harald@redhat.com

Resolves: #1459277
2017-06-12 16:09:01 +02:00
Lukas Nykryn
fb008ce665 Revert "systemd/dracut-initqueue.sh: don't go into emergency"
This reverts commit 4c5f1b3b4a.

Resolves: #1396865
2017-06-12 16:09:01 +02:00
Michal Sekletar
02d0d0a208 udev-rules: pull in 40-redhat-cpu-hotplug.rules
Cpu hotplug policy was split off to separate file. Let's pull in the new
rules file by default.

See: https://bugzilla.redhat.com/show_bug.cgi?id=1266322

Resolves: #1460707
2017-06-12 15:55:30 +02:00
Tong Li
5ae8333947 95ssh-client: attempt to copy UserKnownHostsFile to kdump's initramfs
Bug related to this issue: https://bugzilla.redhat.com/show_bug.cgi?id=1360131
Now dracut only attempts to copy GlobalKnownHostsFile while generating kdump's
initramfs. This method will cause kdump's failure if users set customized
UserKnownHostsFile in /etc/ssh/ssh_config. This patch simply attempts to copy
those files too while going through /etc/ssh/ssh_config. Note that we need to
make sure ~/foo will be copied as /root/foo in kdump's initramfs.

Cherry-picked from: 32f5af2f5e
Resolves: #1360131
2017-04-20 10:08:06 +02:00
Lukas Nykryn
ea8bef9893 ifup: don't ifup team master indefinitely
https://bugzilla.redhat.com/show_bug.cgi?id=1416958
Thanks to martin.moore@hpe.com for the patch
2017-04-06 16:27:01 +02:00
Lukas Nykryn
3186abd76e write-ifcfg: do't write MTU twice for regular eth devices
If MTU is specified, we write it for every type of device in the
beginning. There is not point writing it again for Type=ethernet
devices.
2017-04-06 16:27:01 +02:00
Lukas Nykryn
a603e1f3a6 network/ifup: write override file before dhcp_do
Commit cf376023e6 moved writing .resolv.conf and .override
after dhcp_do, because dhcp_do was overwriting .resolv.conf. But .override does not have
such problem and on the contrary dhcp_do reads .override file if it is present. So let\'s
move it back.

https://bugzilla.redhat.com/show_bug.cgi?id=1415004
2017-03-24 10:34:27 +01:00
Lidong Zhong
2877acadc0 dracut-functions.sh: remove duplicate declaratio of local variable 2017-03-16 12:22:13 +01:00
Xunlei Pang
414834306b testsuite: add "rd.memdebug=4" in TEST-01-BASIC to test rd.memdebug
"rd.memdebug=4" includes all the test level, so add it to test
rd.memdebug function.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
2017-03-14 12:36:16 +01:00
Xunlei Pang
01e66d43d8 dracut.cmdline.7.asc: update document for rd.memdebug=4
"rd.memdebug=4" is for kernel module memory consumption debugging.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
2017-03-14 12:33:18 +01:00
Xunlei Pang
e186d99780 99base: apply kernel module memory debug support
Extend "rd.memdebug" to "4", and "make_trace_mem" to "4+:komem".
Add new "cleanup_trace_mem" to cleanup the trace if active.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
2017-03-14 12:33:13 +01:00
Xunlei Pang
3ce2235abb 99base: add memtrace-ko.sh to debug kernel module large memory consumption
The current method for memory debug is to use "rd.memdebug=[0-3]",
it is not enough for debugging kernel modules. For example, when we
want to find out which kernel module consumes a large amount of memory,
"rd.memdebug=[0-3]" won't help too much.

A better way is needed to achieve this requirement, this is useful for
kdump OOM debugging.

The principle of this patch is to use kernel trace to track slab and
buddy allocation calls during kernel module loading(module_init), thus
we can analyze all the trace data and get the total memory consumption.
As for large slab allocation, it will probably fall into buddy allocation,
thus tracing "mm_page_alloc" alone should be enough for the purpose(this
saves quite some trace buffer memory, also large free is quite unlikey
during module loading, we neglect those memory free events).

The trace events include memory calls under "tracing/events/":
  kmem/mm_page_alloc

We also inpect the following events to detect the module loading:
  module/module_load
  module/module_put

Since we use filters to trace events, the final trace data size won't
be too big. Users can adjust the trace buffer size via "trace_buf_size"
kernel boot command line as needed.

We can get the module name and task pid from "module_load" event which
also mark the beginning of the loading, and module_put called by the
same task pid implies the end of the loading. So the memory events
recorded in between by the same task pid are consumed by this module
during loading(i.e. modprobe or module_init()).

With these information, we can record the rough total memory(the larger,
the more precise the result will be) consumption involved by each kernel
module loading.

Thus we introduce this shell script to find out which kernel module
consumes a large amount of memory during loading. Use "rd.memdebug=4"
as the tigger.

After applying this patch and specifying "rd.memdebug=4", during booting
it will print out something extra like below:
0 pages consumed by "pata_acpi"
0 pages consumed by "ata_generic"
1 pages consumed by "drm"
0 pages consumed by "ttm"
0 pages consumed by "drm_kms_helper"
835 pages consumed by "qxl"
0 pages consumed by "mii"
6 pages consumed by "8139cp"
0 pages consumed by "virtio"
0 pages consumed by "virtio_ring"
9 pages consumed by "virtio_pci"
1 pages consumed by "8139too"
0 pages consumed by "serio_raw"
0 pages consumed by "crc32c_intel"
199 pages consumed by "virtio_console"
0 pages consumed by "libcrc32c"
9 pages consumed by "xfs"

From the print, we see clearly that "qxl" consumed the most memory.

This file will be installed as a separate executable named "tracekomem"
in the following patch.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
2017-03-14 12:33:07 +01:00
Harald Hoyer
9301650e17 dracut.sh: fail hard, if we find modules and modules.dep is missing
If modules are present in /lib/modules/<kernelversion> and modules.dep
is empty, depmod was not run most likely.
2017-03-10 15:39:36 +01:00
Harald Hoyer
d971a570d0 add dracut.pc pkg-config file 2017-03-10 15:39:36 +01:00
Harald Hoyer
72ae0fd418 systemd/dracut-cmdline.sh: unset "UNSET" $root
https://bugzilla.redhat.com/show_bug.cgi?id=1365667
caused by commit 9aa224cc
2017-01-18 13:13:44 +01:00
Harald Hoyer
fa861e2cbf dracut.conf.5.asc: add Warning about leading and trailing spaces in lists 2017-01-11 13:47:24 +01:00
Harald Hoyer
b120b0c116 dracut.sh: skip empty lines in /proc/modules
https://bugzilla.redhat.com/show_bug.cgi?id=1405025
2017-01-11 13:40:13 +01:00
Harald Hoyer
1bb76cea72 fips/module-setup.sh: make tcrypt non-optional 2016-11-30 15:02:16 +01:00
Harald Hoyer
5fd8d27383 README.md: correct CentOS build job link 2016-11-30 14:15:37 +01:00
Harald Hoyer
d381343caa README.md: correct CentOS build job link 2016-11-30 14:06:58 +01:00
Harald Hoyer
11366030aa README.md: correct CentOS build job link 2016-11-30 14:01:03 +01:00
Harald Hoyer
455f87f41f fips/fips.sh: also check for crypto-$mod in /proc/crypto
if the module name is the alias crypto-<algo>, check if <algo> is in
/proc/crypto as "name : <algo>" or "driver: <algo>"
2016-11-30 13:56:23 +01:00
Harald Hoyer
73cf135d80 fips/module-setup.sh: also blacklist the alias resolved modules 2016-11-30 13:54:20 +01:00
Harald Hoyer
0ee8c37f39 Merge pull request #172 from haraldh/RHEL-7
RHEL-7: prepare testsuite for jenkins
2016-11-11 15:27:30 +01:00
Harald Hoyer
968eb46fce TEST-99-RPM: speedup test 2016-11-11 15:10:08 +01:00
Harald Hoyer
904c466cdb testsuite: guard against kernel panic
call qemu with --no-reboot and append "panic=1" to the kernel cmdline
2016-11-11 13:45:24 +01:00
Harald Hoyer
ba5efdcffa TEST-70-BONDBRIDGETEAMVLAN: fix server ip setup 2016-11-11 13:45:00 +01:00
Harald Hoyer
afeb39aa85 TEST-30-ISCSI/test.sh: set device timeout 2016-11-11 13:11:36 +01:00
Harald Hoyer
a081e072d8 test-rpms.txt: add dhcp 2016-11-11 12:34:00 +01:00
Harald Hoyer
aa40b82145 test/Makefile: proper return code for "make check" 2016-11-11 12:18:06 +01:00
Harald Hoyer
81bb61b525 TEST-99-RPM: ignore openldap leftovers 2016-11-11 11:42:54 +01:00
Harald Hoyer
7b4173d698 test/test-rpms.txt: add gzip 2016-11-11 11:40:58 +01:00
Harald Hoyer
13a61f82ba TEST-ISCSI: fix command check 2016-11-11 11:34:33 +01:00
Harald Hoyer
d2fd423a8d test: remove sudo calls
rather run:

$ sudo make check
2016-11-10 14:57:05 +01:00
Harald Hoyer
f432d367fc test/test-rpms.txt: add list of rpms to install 2016-11-10 14:42:01 +01:00
Harald Hoyer
6dcb4867ae README.md: update 2016-10-20 15:27:53 +02:00
Harald Hoyer
05a38caaf2 add README.md 2016-10-20 14:59:26 +02:00
Lukas Nykryn
443d167a95 network: do not check "firmware boot selected flag"
Apparently it is not set correctly on some setups
https://bugzilla.redhat.com/show_bug.cgi?id=1380581
2016-10-05 17:46:36 +02:00
Harald Hoyer
33710dfbfc network: fix dhcp classless_static_routes
removed copy&paste artifact "modify_routes add"

there is no modify_routes() function, and we simply want the output
of the parse function.
2016-09-07 10:20:20 +02:00
Harald Hoyer
c87d489ca6 network/parse-ip-opts: be more liberal to multiple ip= options
Do not bail out early.

https://bugzilla.redhat.com/show_bug.cgi?id=1304069
2016-09-07 10:20:20 +02:00
Harald Hoyer
99e72a4b1c fcoe: only install /etc/hba.conf, it it exists
https://bugzilla.redhat.com/show_bug.cgi?id=1369342
2016-09-07 10:17:43 +02:00
Harald Hoyer
39c4892772 TEST-16-DMSQUASH: add sr_mod
otherwise no cdrom can be accessed on RHEL-7
2016-08-26 11:24:42 +02:00
Harald Hoyer
8c67fb9123 nfs: install more kernel modules
adds support for rpcrdma to support NFSROOT over NFSoRDMA

https://bugzilla.redhat.com/show_bug.cgi?id=1367374
2016-08-19 15:56:47 +02:00
Harald Hoyer
1d267fb82c dracut.cmdline.7.asc: document rd.shell=0 for rd.emergency 2016-08-17 16:49:00 +02:00
Harald Hoyer
91896ab68e dracut.sh: document --hostonly-i18n and --no-hostonly-i18n
show description in --help

https://bugzilla.redhat.com/show_bug.cgi?id=1266448
2016-08-17 16:48:07 +02:00
Harald Hoyer
1b23c6c65c url-lib: ca-bundle.crt changed to a symlink
use inst() instead of inst_simple()

/etc/pki/tls/certs/ca-bundle.crt is a symlink to
../../ca-trust/extracted/pem/tls-ca-bundle.pem

with inst() we install the original file also.

https://bugzilla.redhat.com/show_bug.cgi?id=1341280
2016-08-17 16:41:21 +02:00
Harald Hoyer
b8e6c051c6 network:ibft put IPv6 IP in brackets
ip=2620:0052:0000:2220:0226:b9ff:fe81:cde4::[2620:0052:0000:2220:0000:0000:0000:03fe]:64::ibft0:none

should be

ip=[2620:0052:0000:2220:0226:b9ff:fe81:cde4]::[2620:0052:0000:2220:0000:0000:0000:03fe]:64::ibft0:none

https://bugzilla.redhat.com/show_bug.cgi?id=1322592#c19
2016-08-17 16:26:13 +02:00
Harald Hoyer
fc77aca7dd systemd/dracut-cmdline.sh: unset "UNSET" $root
https://bugzilla.redhat.com/show_bug.cgi?id=1365667
caused by commit 9aa224cc
2016-08-12 13:29:31 +02:00
Harald Hoyer
7a7b8c1740 dracut-functions.sh: catch all lvm slaves
add check_vol_slaves_all to be used in check_block_and_slaves_all

otherwise only the first lvm VG member would be processed
2016-08-12 12:33:10 +02:00
Harald Hoyer
8dd6ff8d6a fips: remove sha1-mb
This module should be loaded automatically, if the HW supports it.
2016-08-12 12:33:10 +02:00
Lukas Nykryn
10e6bf0e43 fips-module: add missing spaces
https://bugzilla.redhat.com/show_bug.cgi?id=1359677
2016-07-28 12:27:10 +02:00
Harald Hoyer
cd6679c716 add rd.emergency=[reboot|poweroff|halt]
specifies what action to execute in case of a critical failure

(cherry picked from commit c45e856a65)

https://bugzilla.redhat.com/show_bug.cgi?id=1359144
2016-07-22 15:26:32 +02:00
Harald Hoyer
20171c7519 lvm: include /etc/lvm/lvm_<host_tag>.conf
https://bugzilla.redhat.com/show_bug.cgi?id=1328778
2016-07-22 13:26:10 +02:00
Harald Hoyer
b7c7b16d4e dracut.sh: extend host_fs_types with $filesystems
Additional filesystems specified on the kernel command line or in the
configuration files, should trigger the inclusion of the corresponding
dracut modules, therefore host_fs_types is extended with these
filesystems.
2016-07-22 08:39:38 +02:00
Harald Hoyer
b077d18963 nfs: install all nfs modules non-hostonly
If nfs is used, we should include all nfs modules, in the case, where
$host_fs_types contains nfs.
2016-07-22 08:30:36 +02:00
Harald Hoyer
2f42cfcbeb fips: add "sha1-mb" to fips modules
https://bugzilla.redhat.com/show_bug.cgi?id=1357080
2016-07-21 15:08:59 +02:00
Harald Hoyer
0eb1afa9ea fips: use /lib/modules/$(uname -r)/modules.fips
if /lib/modules/$(uname -r)/modules.fips exists, use that list instead
of the dracut module list.
2016-07-21 15:07:52 +02:00
Harald Hoyer
2c9f267268 Merge pull request #141 from pratyushanand/for-RHEL-7
RHEL7: Install module for active watchdog
2016-07-21 11:12:01 +02:00
Harald Hoyer
038f142ef9 dracut.spec: remove trailing space 2016-07-06 09:17:36 +02:00
Harald Hoyer
1492490070 watchdog: start traversing the device tree from the right directory
start with the device subtree, not with the parent of it
2016-07-05 12:52:16 +05:30
Harald Hoyer
0eb1ee3db2 watchdog: clean return of installkernel()
return 0, otherwise if _alldrivers is empty, the return code is fail
2016-07-05 12:52:16 +05:30
Harald Hoyer
4c83fd10ab watchdog/module-setup.sh: rewrite
- use local variables with _
- use associative array for the kernel modules
- install emergency hook even in the systemd case
- follow device path until /sys is reached
- set kernel version for modprobe checking
2016-07-05 12:52:16 +05:30
Pratyush Anand
f69cd051ab watchdog: ensure that module is loaded as early as possible
It is expected that a watchdog module will disable an active watchdog when
its probe is called ie, when it is loaded. So an early load of the module
will help to disable it earlier.
This can be helpful in some corner cases where kdump and watchdog daemon
both are active.

Testing:
    -- When watchdog kernel modules were added
	# dracut --no-hostonly initramfs-test.img -a watchdog
	# lsinitrd initramfs-test.img -f etc/cmdline.d/00-watchdog.conf
 	rd.driver.pre=iTCO_wdt,lpc_ich,

Signed-off-by: Pratyush Anand <panand@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Harald Hoyer <harald@redhat.com>
2016-07-05 12:52:16 +05:30
Pratyush Anand
0be17528e5 watchdog: install module for active watchdog
Recently following patches have been added in upstream Linux kernel, which
(1) fixes parent of watchdog_device so that
/sys/class/watchdog/watchdogn/device is populated. (2) adds some sysfs
device attributes so that different watchdog status can be read.

http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=6551881c86c791237a3bebf11eb3bd70b60ea782
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=906d7a5cfeda508e7361f021605579a00cd82815
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=33b711269ade3f6bc9d9d15e4343e6fa922d999b

With the above support, now we can find out whether a watchdog is active or
not. We can also find out the driver/module responsible for that watchdog
device.

Proposed patch uses above support and then adds module of active watchdog
in initramfs generated by dracut for hostonly mode. Kernel module for
inactive watchdog will be added as well for none hostonly mode.

When an user does not want to add kernel module, then one should exclude
complete dracut watchdog module with --omit.

Testing:
-- When watchdog is active watchdog modules were added
	# cat /sys/class/watchdog/watchdog0/identity
	iTCO_wdt
	# cat /sys/class/watchdog/watchdog0/state
	active
	# dracut --hostonly initramfs-test.img -a watchdog
	# lsinitrd initramfs-test.img | grep iTCO
	-rw-r--r--   1 root     root         9100 Feb 24 09:19 usr/lib/modules/.../kernel/drivers/watchdog/iTCO_vendor_support.ko
	-rw-r--r--   1 root     root        19252 Feb 24 09:19 usr/lib/modules/.../kernel/drivers/watchdog/iTCO_wdt.ko

-- When watchdog is inactive then watchdog modules were not added
	# cat /sys/class/watchdog/watchdog0/state
	inactive
	# dracut --hostonly initramfs-test.img -a watchdog
	# lsinitrd initramfs-test.img | grep iTCO

-- When watchdog is inactive, but no hostonly mode, watchdog modules were added
	# cat /sys/class/watchdog/watchdog0/state
	inactive
	# dracut --no-hostonly initramfs-test.img -a watchdog
	# lsinitrd initramfs-test.img | grep iTCO
	-rw-r--r--   1 root     root         9100 Feb 24 09:19 usr/lib/modules/.../kernel/drivers/watchdog/iTCO_vendor_support.ko
	-rw-r--r--   1 root     root        19252 Feb 24 09:19 usr/lib/modules/.../kernel/drivers/watchdog/iTCO_wdt.ko

Signed-off-by: Pratyush Anand <panand@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Harald Hoyer <harald@redhat.com>
2016-07-05 12:52:16 +05:30
Pratyush Anand
e5439c9b37 watchdog: Do not add hooks if systemd module is included
When systemd is present, let it manage watchdog feed.

Signed-off-by: Pratyush Anand <panand@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Harald Hoyer <harald@redhat.com>
2016-07-05 12:52:16 +05:30
Harald Hoyer
573e508554 dracut.spec: remove dd
dd is part of coreutils
2016-07-04 16:30:47 +02:00
Harald Hoyer
7b0ce59233 TEST-70-BONDBRIDGETEAMVLAN: add testcase for testsuite
multiple bonds
multiple bridges
multiple vlans
2016-07-04 16:28:08 +02:00
Harald Hoyer
7a90c8b343 network: support multiple vlan, team, bridge and bond 2016-07-04 16:28:08 +02:00
HATAYAMA Daisuke
84d845fc7d lsinitrd: Suppress "cat: write error: Broken pipe"
On systemd, SIGPIPE is ignored by default; see man 5 systemd.exec for
IgnoreSIGPIPE=. As a result, lsinitrd.sh under a systemd service
outputs "cat: write error: Broken pipe" in the processing of
determining a compression format of a given initramfs file using cat
command in the write part of a pipeline processing.

For example, this is a log message of kdump.service in RHEL7.1,

    -- Logs begin at Wed 2015-11-04 09:57:33 JST, end at Wed 2015-11-04 09:58:28 JST. --
    Nov 04 09:57:33 localhost systemd[1]: Stopping Crash recovery kernel arming...
    Nov 04 09:57:33 localhost kdumpctl[22545]: kexec: unloaded kdump kernel
    Nov 04 09:57:33 localhost kdumpctl[22545]: Stopping kdump: [OK]
    Nov 04 09:57:33 localhost systemd[1]: Starting Crash recovery kernel arming...
    Nov 04 09:57:36 localhost kdumpctl[22553]: Detected change(s) in the following file(s):
    Nov 04 09:57:36 localhost kdumpctl[22553]: /etc/kdump.conf
    Nov 04 09:57:36 localhost kdumpctl[22553]: Rebuilding /boot/initramfs-3.10.0-229.el7.x86_64kdump.img
    Nov 04 09:57:40 localhost dracut[24914]: Executing: /usr/sbin/dracut --hostonly --hostonly-cmdline -o "plymouth dash resume" -f /boot/initramfs-3.10.0-229.el7.x86_64kdump.img 3.10.0-229.el7.x86_64
    ...<cut>...
    Nov 04 09:58:12 localhost dracut[24914]: *** Creating image file done ***
    Nov 04 09:58:12 localhost dracut[24914]: Image: /boot/initramfs-3.10.0-229.el7.x86_64kdump.img: 18M
    Nov 04 09:58:12 localhost kdumpctl[22553]: cat: write error: Broken pipe
    Nov 04 09:58:12 localhost dracut[24914]: ========================================================================
    Nov 04 09:58:12 localhost dracut[24914]: Version: dracut-033-240.el7
    Nov 04 09:58:12 localhost dracut[24914]:
    Nov 04 09:58:12 localhost dracut[24914]: Arguments: --hostonly --hostonly-cmdline -o 'plymouth dash resume' -f
    Nov 04 09:58:13 localhost dracut[24914]:
    Nov 04 09:58:13 localhost dracut[24914]: dracut modules:
    Nov 04 09:58:13 localhost dracut[24914]: bash

kdump.service builds and loads an initramfs for kdump kernel using
kdumpctl command which uses dracut command and so lsinitrd command,
too.

Although there's no actual harm except for the error message, there
has been several inquiries from customers about this message so
far. We should suppress this message to reduce needless
communications.

To suppress the message, this commit cleans up the processing of
reading the first 6 bytes of a given initramfs file without cat
command.

(cherry picked from commit 3ce142861d)

Conflicts:
	lsinitrd.sh
2016-07-01 13:17:18 +02:00
Harald Hoyer
aea64fe178 TEST-14-IMSM: add rd.device.timeout 2016-07-01 13:17:18 +02:00
Harald Hoyer
271a64bfd1 TEST-13-ENC-RAID-LVM: add rd.device.timeout=40 2016-07-01 12:29:16 +02:00
Harald Hoyer
fd8506b5da systemd: let booting work after exiting emergency
If the user managed to mount /sysroot, let it work
2016-07-01 12:29:16 +02:00
Harald Hoyer
4c5f1b3b4a systemd/dracut-initqueue.sh: don't go into emergency
let systemd go into emergency.target later on
2016-07-01 12:29:15 +02:00
Harald Hoyer
a95fe14581 99base/init.sh: break the initqueue, if emergency shell was successful 2016-07-01 12:29:15 +02:00
Harald Hoyer
6efee60f93 test/TEST-12-RAID-DEG: add rd.device.timeout 2016-07-01 12:29:15 +02:00
Harald Hoyer
22a907b383 test/TEST-04-systemd: fixup test
- fix find -perm
- add failme test cases
- remove journal output
2016-07-01 12:29:15 +02:00
Harald Hoyer
ca46c751d1 add rd.device.timeout=<seconds> parameter 2016-07-01 12:29:15 +02:00
Harald Hoyer
ca64eeec79 virtfs: use systemd generator
use a systemd generator, instead of a dracut hook to mount
2016-07-01 12:29:15 +02:00
Alexander Kurtz
9aa224cc19 dracut-systemd/dracut-cmdline.sh: Don't error out if there is no root= argument.
Thanks to systemd's gpt-auto-generator [0] (which implements the Discoverable
Partitions Specification [1]), it is no longer necessary to always specify the
root= argument.

However, dracut would still refuse to boot if there was no root= argument (or
if it was set to the special value "gpt-auto" [2]). This commit stops dracut
from aborting the boot process in these cases and simply lets systemd do its
magic.

[0] https://github.com/systemd/systemd/blob/v229/src/gpt-auto-generator
[1] https://www.freedesktop.org/wiki/Specifications/DiscoverablePartitionsSpec/
[2] https://github.com/systemd/systemd/blob/v229/src/gpt-auto-generator/gpt-auto-generator.c#L928

(cherry picked from commit 016613c774)
2016-07-01 12:29:15 +02:00
Harald Hoyer
13264563a9 network:wait_for_ipv6_auto() wait for all tentative addresses 2016-07-01 12:29:15 +02:00
Harald Hoyer
cc3f588071 network: flush only IPv4 addresses on configuration
also flush on dhcp
2016-07-01 12:29:15 +02:00
Harald Hoyer
42dd8928a8 network: differ between ipv6 local and global tentative
For dhcpv6, only a non-tentative scope local address is needed.
2016-06-30 11:10:35 +02:00
Harald Hoyer
6d22a6860e network/net-lib.sh: auto6 wait for route ra
Wait for a router advertised route
2016-06-30 08:52:09 +02:00
Hannes Reinecke
bac74f05e3 40network: Update iBFT scanning code to handle IPv6
IPv6 addresses should be specified in brackets so that the
ip= scanning code doesn't get confused.

References: bnc#887542

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Thomas Renninger <trenn@suse.com>
(cherry picked from commit c98d1756f7)
2016-06-29 18:26:58 +02:00
Xunlei Pang
a320422588 network/net-lib.sh: delete duplicated DNS items from "/etc/resolv.conf"
Users can pass the DNS information throught "nameserver=" cmdline,
there maybe duplicated inputs.

"/etc/resolv.conf" have some restrictions on the number of DNS items
effective, so make sure that this file contains no duplicated items.

We achieve this by simply making the file have no duplicated lines.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
(cherry picked from commit 4fa5c235a7)
2016-06-29 17:27:36 +02:00
Harald Hoyer
5bc318633f network: dhcp before parsing specified dns through cmdline
I met a problem when passing kdump dns to dracut via "nameserver=x.x.x.x",
the dns I provided didn't appear in the "/etc/resolv.conf".

After some debugging, found that when setup dhcp DNS, in setup_interface()
and setup_interface6(), it has:
    echo "search $search $domain" > /tmp/net.$netif.resolv.conf

So if "$search $domain" isn't NULL(this is ture in my kdump environment),
the dns contents(that is, dns1, dns2, nameserver) in "ifup" before dhcp
will be discarded.

This patch addresses it by handling dhcp first. In fact this is also the
way the NetworkManager in 1st kernel works.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>

cherry-pick of commit cf376023e6
2016-06-29 17:26:17 +02:00
Michael Chapman
53310e44c9 systemd: ensure journal is volatile
If journald.conf already contains Storage=persistent, journald will
write to /var/log/journal/, which ends up at /run/initramfs/log/journal/
after switching root. We want to make sure early boot logs are written
to /run/log/journal/ so they can be flushed to /var/log/journal/ after
switching root.

(cherry picked from commit 5dea430e08)
2016-06-29 17:21:56 +02:00
Harald Hoyer
a7805d1297 network/net-lib.sh(wait_for_ipv6_dad): simplify ip call
taken from initscripts
2016-06-29 17:19:06 +02:00
Harald Hoyer
435af39a00 network/net-lib.sh(parse_ifname_opts): support 21 byte MAC addrs
infiniband MAC addrs are 20 bytes long not 6

https://bugzilla.redhat.com/show_bug.cgi?id=1319270
2016-06-29 16:37:40 +02:00
Harald Hoyer
323093b621 test: add TEST-60-MTUMAC
test MTU and MACADDR setting
2016-06-29 15:51:42 +02:00
Harald Hoyer
61b5ee6d1d network: set MTU and MACADDR for dhcp and auto6 2016-06-29 15:13:35 +02:00
Harald Hoyer
55712f46c0 test: don't call ldconfig with -- path separator 2016-06-29 15:11:39 +02:00
Harald Hoyer
53e4ab7174 network: support macaddr in brackets []
ip=ens3:dhcp:1000
ip=ens3:dhcp::54:52:00:ab💿ef
ip=ens3:dhcp::[54:52:00🆎cd:ef]
ip=ens3:dhcp:1000:54:52:00:ab💿ef
ip=ens3:dhcp:1000:[54:52:00🆎cd:ef]

ip=192.168.122.20::192.168.122.1:24:test:ens3:none:1000
ip=192.168.122.20::192.168.122.1:24:test:ens3:none::54:52:00:ab💿ef
ip=192.168.122.20::192.168.122.1:24:test:ens3:none::[54:52:00🆎cd:ef]
ip=192.168.122.20::192.168.122.1:24:test:ens3:none:1000:54:52:00🆎cd:ef
ip=192.168.122.20::192.168.122.1:24:test:ens3:none:1000:[54:52:00🆎cd:ef]

ip=::::test:ens3:dhcp:1000
ip=::::test:ens3:dhcp::54:52:00:ab💿ef
ip=::::test:ens3:dhcp::[54:52:00🆎cd:ef]
ip=::::test:ens3:dhcp:1000:54:52:00:ab💿ef
ip=::::test:ens3:dhcp:1000:[54:52:00🆎cd:ef]
2016-06-29 12:44:49 +02:00
Harald Hoyer
b7f5e42c57 network/net-lib.sh: correctly set mac address for ip=...:<mtu>:<mac>
if ip=...:<mtu>:<mac> was specified, macadress was not set

(cherry picked from commit efbc47b8e4)
2016-06-29 12:15:12 +02:00
Harald Hoyer
603a0fe0a3 fcoe-up: remove initlog logic
(cherry picked from commit f60b7d8655)
2016-06-29 12:06:20 +02:00
Hannes Reinecke
f105eaebb8 95fcoe: update fcoe interface check 2016-06-29 11:57:56 +02:00
Hannes Reinecke
f501c955e8 95fcoe: Store current configuration in dracut cmdline
When running with --hostonly-cmdline we should be storing
the current configuration in /etc/cmdline.d so that dracut
will be configure the system automatically.

References: bnc#877288

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Thomas Renninger <trenn@suse.de>
(cherry picked from commit 8b257fcc86)
2016-06-29 11:54:19 +02:00
Hannes Reinecke
b9668f8f00 95fcoe: skip VLAN devices in fcoe-up
DCB & fipvlan can only be called on real devices, not VLAN
ones. So skip any VLAN devices which might been added to the
list of network interfaces.

References: bnc#878583

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Thomas Renninger <trenn@suse.de>
(cherry picked from commit 0a68a26cff)
2016-06-29 11:51:05 +02:00
Hannes Reinecke
a4cbfd719b 95fcoe: start lldpad separately
lldpad is a system-wide process, which must be started only once.
So we should be separate it from fcoe-up, as it might be called
several times.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Thomas Renninger <trenn@suse.de>
(cherry picked from commit 22e837b645)
2016-06-29 11:50:56 +02:00
Harald Hoyer
7335bd1e23 Defer modprobe of HW modules, until udev is running
Also honor blacklisting

(cherry picked from commit 437dad70e9)
2016-06-29 11:50:13 +02:00
Hannes Reinecke
26eeb4af8d Reset IFS variable
Setting and unsetting the IFS variable is tricky. To be on the
safe side we should always reset the IFS variable to its original
value after parsing.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Thomas Renninger <trenn@suse.de>
(cherry picked from commit b8efaa0017)
2016-06-29 11:41:21 +02:00
Mike Gilbert
d6b9aac6d0 Replace echo -n with printf in code with a /bin/sh shebang
POSIX does not mandate that echo support the -n parameter.
printf has more well-defined behavior.

(cherry picked from commit 5899f2f516)
2016-06-29 11:40:14 +02:00
Thomas Renninger
3186a0aa15 dracut: nbd: Only complain of missing binary in hostonly mode if
rootfs is on nbd

In not hostonly mode, require_binaries will still complain.
If in hostonly mode and the module is explicitly added via -a nbd, then
install() section will still complain later:
dracut-install: ERROR: installing 'nbd-client'

Signed-off-by: Thomas Renninger <trenn@suse.de>
(cherry picked from commit e683985d10)
2016-06-29 11:34:26 +02:00
Harald Hoyer
cc7d2eeb36 add "--install-optional" and install_optional_items
(cherry picked from commit 54b68829b6)
2016-06-29 11:28:23 +02:00
Harald Hoyer
b4ad021d34 dracut: only use one tmpdir
also remove any partial written initramfs images
2016-06-29 11:25:12 +02:00
Harald Hoyer
f45726652f fcoe: check if needed for hostonly 2016-06-29 10:50:58 +02:00
Harald Hoyer
ced0638e2c Disable early microcode for non-x86 architecures 2016-06-29 10:45:58 +02:00
Harald Hoyer
8175f5eb82 test/TEST-02-systemd: use marker disk for successfull boot marker 2016-06-27 10:28:09 +02:00
Harald Hoyer
017c16b97a systemd: add -.slice and make reboot work
-.slice and conflicting with emergency.target and shutdown.target
makes reboot work
2016-06-27 10:27:05 +02:00
Harald Hoyer
320b8d5c0c network/dhclient.conf: add missing commata
options need to be seperated by ,

(cherry picked from commit 7e51abc81f)
2016-06-24 11:10:19 +02:00
Harald Hoyer
0b7c2400c3 TEST-50-MULTINIC: add multiple bond tests 2016-06-22 14:03:12 +02:00
Harald Hoyer
fefb96f43f network/parse-bond.sh: handle multiple bond interfaces 2016-06-22 13:32:11 +02:00
Harald Hoyer
1472b5486b ifup: setup bridge, bonding and teaming only once
if those assembled interfaces use dhcp "$iface.up" is created too late
2016-06-10 16:24:24 +02:00
Harald Hoyer
e6ae0c6128 network/net-genrules.sh: generate rules for all interfaces
previously, if "rd.neednet" and bond was specified, only the bond
interface was configured.

https://bugzilla.redhat.com/show_bug.cgi?id=1282680
2016-06-10 16:24:24 +02:00
Harald Hoyer
ac422d577c base/dracut-lib.sh: add trim()
trim() to remove leading and trailing whitespace
2016-06-10 16:24:24 +02:00
Harald Hoyer
484aba4298 network: add 73-idrac.rules udev rules
idrac USB devices want a special network name
2016-06-08 16:19:12 +02:00
Harald Hoyer
b14e0fb826 more dash removal 2016-05-27 11:22:38 +02:00
Harald Hoyer
863105bce1 dracut.spec: add a tag with the current version 2016-05-27 11:22:38 +02:00
Harald Hoyer
15ec719501 test/NBD: add checks for needed binaries 2016-05-27 11:22:38 +02:00
Harald Hoyer
249a94ab04 test: remove dash module, as it is not available in RHEL 2016-05-27 11:22:38 +02:00
Harald Hoyer
6656e1547f dracut-functions.sh: add str_starts() and str_ends() 2016-05-25 14:49:34 +02:00
Daniel Drake
688afe0fc3 kernel-modules: increase SDHCI driver inclusion
The sdhci-pci module is currently not being included in the initramfs,
even though other sdhci modules are. This breaks boot on systems that
rely on this driver to access the root filesystem.

Instead of looking for modules that use sdhci_pltfm_init, look for
sdhci_add_host. I checked 3.18 kernel sources, and this change
does not remove any of the previously-matched SDHCI drivers.
It should result in the addition of sdhci-pci, sdhci-s3c, sdhci-spear
and sdhci-acpi.

(cherry picked from commit 6dcc5e1158)
2016-05-25 14:40:40 +02:00
Harald Hoyer
8fb06a0562 shutdown: guard against read-only /run
remount the switch rooted /run writeable again.

(cherry picked from commit 54e09dfb72)
2016-05-23 12:49:32 +02:00
Hannes Reinecke
68021e85c9 95iscsi: parse output from iscsiadm correctly
Due to some obsure reason the IFS parameter is not set correctly
when evaluating get_ibft_mod(). So change the parsing to not rely
on IFS altogether.

References: bnc#886199

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Thomas Renninger <trenn@suse.de>
2016-05-18 14:44:16 +02:00
Hannes Reinecke
12aa314819 95iscsi: More empty cmdline fixes
This fixes up some 95iscsi/module-setup.sh which might print out empty
commandline files.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Thomas Renninger <trenn@suse.de>
2016-05-18 14:44:16 +02:00
Hannes Reinecke
bff5416520 95iscsi: Fixup bnx2i offload booting
bnx2i is using a separate iSCSI offload engine with a separate
MAC address. As a result, the iBFT information is displaying
a MAC address which does not relate to any MAC address from
the network interfaces.
In addition, the iSCSI offload engine works independently on
the NIC, so we do not need to enable the NIC for iSCSI offload
to work.
This patch modifies the automatic iBFT detection to not set
the 'ip=ibft' flag when bnx2i offload is detected.

References: bnc#855747

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Thomas Renninger <trenn@suse.de>
2016-05-18 14:44:16 +02:00
Hannes Reinecke
9eab750787 95iscsi: Install libgcc_s library
iscsiuio is using pthread, which requires libgcc_s for
pthread_cancel to work.
Without this library iscsiuio will crash with SIGABRT.

References: bnc#881692

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Thomas Renninger <trenn@suse.de>
2016-05-18 14:44:16 +02:00
Hannes Reinecke
f31220ec88 95iscsi: Autodetect iSCSI firmware
Some iSCSI initiator present firmware information in
/sys/firmware/ibft or /sys/firmware/iscsi_bootX

Whenever we detect one of those directories we should assume
that the iSCSI devices should be activated.

Also incorporates SUSE patches:
0049:
95iscsi: Use 'ip=ibft' for ibft autoconfiguration

For iBFT autoconfiguration we should be setting 'ip=ibft'
instead of rd.neednet. This should instruct dracut to only
enable the iBFT interfaces and leave the rest alone.

References: bnc#879038

0054:
95iscsi: update commandline printing

dracut has a separate callout 'cmdline' which should be used
for printing out the generated commandline.

Signed-off-by: Pavel Wieczorkiewicz <pwieczorkiewicz@suse.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Thomas Renninger <trenn@suse.de>
2016-05-18 14:44:16 +02:00
Harald Hoyer
043d61b542 url-lib/url-lib.sh:nfs_fetch_url(): pass file directory to query if nfs is already mounted
Otherwise the returned mount path includes the file with the directory

https://bugzilla.redhat.com/show_bug.cgi?id=1302764
2016-03-14 15:55:03 +01:00
Harald Hoyer
0d7b00a230 network: if rd.neednet=0 we don't need a bootdev
otherwise dracut would wait for the bootdev interface to appear and be
setup

(cherry picked from commit f4f8fb5c10)
2016-02-29 15:07:59 +01:00
Harald Hoyer
a48ea27deb network/dhclient-script.sh: add classless-static-routes support
https://bugzilla.redhat.com/show_bug.cgi?id=1260955
2016-02-29 15:00:46 +01:00
Harald Hoyer
9d030e4ef1 documentation: "--hostonly-i18n" "--no-hostonly-i18n" "i18n_install_all"
(cherry picked from commit fe6455a6e8)
2016-02-29 13:13:02 +01:00
Harald Hoyer
3a39dd027f dracut.sh: for microcode generation, skip gpg files
skip all ".asc" files for the AMD microcode generation

(cherry picked from commit c44d2252bb)
2016-02-29 11:56:05 +01:00
Harald Hoyer
de8cc25d70 dracut: add "tar" and "dd" requirement
https://bugzilla.redhat.com/show_bug.cgi?id=1285810
2016-02-29 11:55:25 +01:00
Harald Hoyer
ba977abe63 systemd: add "wheel" and "adm" to passwd and group
# LANG=C journalctl -b -u systemd-tmpfiles-setup-dev.service | grep
     # ACL
     Dec 01 13:56:59 localhost.localdomain systemd-tmpfiles[112]: Failed
to parse ACL "d:group:adm:r-x,d:group:wheel:r-x": Invalid argument.
Ignoring
     Dec 01 13:56:59 localhost.localdomain systemd-tmpfiles[112]: Failed
to parse ACL "group:adm:r-x,group🛞r-x": Invalid argument. Ignoring
     Dec 01 13:56:59 localhost.localdomain systemd-tmpfiles[112]: Failed
to parse ACL "d:group:adm:r-x,d:group:wheel:r-x": Invalid argument.
Ignoring
     Dec 01 13:56:59 localhost.localdomain systemd-tmpfiles[112]: Failed
to parse ACL "group:adm:r-x,group🛞r-x": Invalid argument. Ignoring

     # grep ^[aA] /usr/lib/tmpfiles.d/systemd.conf
     a+ /run/log/journal/%m - - - - d:group:adm:r-x,d:group:wheel:r-x
     A+ /run/log/journal/%m - - - - group:adm:r-x,group🛞r-x
     a+ /var/log/journal/%m - - - - d:group:adm:r-x,d:group:wheel:r-x
     A+ /var/log/journal/%m - - - - group:adm:r-x,group🛞r-x

https://bugzilla.redhat.com/show_bug.cgi?id=1287537
2016-02-29 11:52:37 +01:00
Thomas Renninger
69762959ae 90lvm: Install dm-snapshot module
bnc#888530

Signed-off-by: Thomas Renninger <trenn@suse.de>
(cherry picked from commit 5c84d51b3f)
2016-02-29 11:47:43 +01:00
Pekka Wallendahl
851946468a multipath: fix majmin_to_mpath_dev()
* Multipath device names only start with the mpath-prefix if the option
  use_userfriendly_names is set true in /etc/multipath.conf and if user
  has not set any aliases in the said file. Thus the for-loop should go
  through all files in /dev/mapper/, not just ones starting with 'mpath'

* Bash is perfectly capable to extend `/dev/mapper/*` notation without a
  need to pass it to an external ls

* Changed the function to use a local variable $_dev instead of the
  global $dev, which seemed to be the original intention as the local
  _dev was defined but not used

(cherry picked from commit 28058a2e37)
2016-02-29 11:43:18 +01:00
Harald Hoyer
28665b4fa5 dracut-functions.sh:fix check_vol_slaves() volume group name stripping
commit 466a59984a removed whitespace
stripping from lvm volume group names.

(cherry picked from commit 2fd8588da5)
2016-02-29 11:41:42 +01:00
Harald Hoyer
17985b2575 network: fix carrier detection
rename iface_has_link() to iface_has_carrier() to clarify usage

Only assign static "wildcard interface" settings, if the interface has a
carrier.

If the interface name was specified with a name, do not do carrier
checking for static configurations.

(cherry picked from commit df95b1003c)
2015-12-14 16:16:00 +01:00
Harald Hoyer
2f20797a40 iscsi/iscsiroot.sh: better put variables in quotes
first rule for a bash programmer
2015-11-26 10:10:40 +01:00
125 changed files with 2630 additions and 819 deletions

View File

@@ -15,6 +15,7 @@ mandir ?= ${prefix}/share/man
CFLAGS ?= -O2 -g -Wall
CFLAGS += -std=gnu99 -D_FILE_OFFSET_BITS=64
bashcompletiondir ?= ${datadir}/bash-completion/completions
pkgconfigdatadir ?= $(datadir)/pkgconfig
man1pages = lsinitrd.1
@@ -40,7 +41,7 @@ manpages = $(man1pages) $(man5pages) $(man7pages) $(man8pages)
.PHONY: install clean archive rpm testimage test all check AUTHORS doc dracut-version.sh
all: dracut-version.sh dracut-install skipcpio/skipcpio
all: dracut-version.sh dracut.pc dracut-install skipcpio/skipcpio
DRACUT_INSTALL_OBJECTS = \
install/dracut-install.o \
@@ -93,7 +94,15 @@ dracut.html: dracut.asc $(manpages) dracut.css dracut.usage.asc
http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl dracut.xml
rm -f -- dracut.xml
install: dracut-version.sh
dracut.pc: Makefile.inc Makefile
@echo "Name: dracut" > dracut.pc
@echo "Description: dracut" >> dracut.pc
@echo "Version: $(VERSION)$(GITVERSION)" >> dracut.pc
@echo "dracutdir=$(pkglibdir)" >> dracut.pc
@echo "dracutmodulesdir=$(pkglibdir)/modules.d" >> dracut.pc
@echo "dracutconfdir=$(pkglibdir)/dracut.conf.d" >> dracut.pc
install: all
mkdir -p $(DESTDIR)$(pkglibdir)
mkdir -p $(DESTDIR)$(bindir)
mkdir -p $(DESTDIR)$(sysconfdir)
@@ -153,6 +162,8 @@ endif
mkdir -p $(DESTDIR)${bashcompletiondir}
install -m 0644 dracut-bash-completion.sh $(DESTDIR)${bashcompletiondir}/dracut
install -m 0644 lsinitrd-bash-completion.sh $(DESTDIR)${bashcompletiondir}/lsinitrd
mkdir -p $(DESTDIR)${pkgconfigdatadir}
install -m 0644 dracut.pc $(DESTDIR)${pkgconfigdatadir}/dracut.pc
dracut-version.sh:
@echo "DRACUT_VERSION=$(VERSION)$(GITVERSION)" > dracut-version.sh
@@ -189,7 +200,7 @@ rpm: dracut-$(VERSION).tar.bz2 syncheck
(cd "$$rpmbuild"; rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" \
--define "_specdir $$PWD" --define "_srcrpmdir $$PWD" \
--define "_rpmdir $$PWD" -ba dracut.spec; ) && \
( mv "$$rpmbuild"/$$(arch)/*.rpm .; mv "$$rpmbuild"/*.src.rpm .;rm -fr -- "$$rpmbuild"; ls *.rpm )
( mv "$$rpmbuild"/$$(arch)/*.rpm $(DESTDIR).; mv "$$rpmbuild"/*.src.rpm $(DESTDIR).;rm -fr -- "$$rpmbuild"; ls $(DESTDIR)*.rpm )
syncheck:
@ret=0;for i in dracut-initramfs-restore.sh modules.d/*/*.sh; do \

5
README.md Normal file
View File

@@ -0,0 +1,5 @@
# dracut RHEL-7 branch
dracut is an initramfs infrastructure.
CentOS CI Status: [![Build Status](https://ci.centos.org/buildStatus/icon?job=dracut-push-rhel-7)](https://ci.centos.org/job/dracut-push-rhel-7/)

View File

@@ -40,7 +40,7 @@ _dracut() {
--omit-drivers --modules --omit --drivers --filesystems --install
--fwdir --libdirs --fscks --add-fstab --mount --device --nofscks
--kmoddir --conf --confdir --tmpdir --stdlog --compress --prefix
--kernel-cmdline --sshkey --persistent-policy'
--kernel-cmdline --sshkey --persistent-policy --install-optional'
)
if __contains_word "$prev" ${OPTS[ARG]}; then
@@ -49,7 +49,7 @@ _dracut() {
comps=$(compgen -d -- "$cur")
compopt -o filenames
;;
-c|--conf|--sshkey|--add-fstab|--add-device|-I|--install)
-c|--conf|--sshkey|--add-fstab|--add-device|-I|--install|--install-optional)
comps=$(compgen -f -- "$cur")
compopt -o filenames
;;

View File

@@ -29,6 +29,10 @@ fi
# Generic substring function. If $2 is in $1, return 0.
strstr() { [[ $1 = *$2* ]]; }
# returns OK if $1 contains literal string $2 at the beginning, and isn't empty
str_starts() { [ "${1#"$2"*}" != "$1" ]; }
# returns OK if $1 contains literal string $2 at the end, and isn't empty
str_ends() { [ "${1%*"$2"}" != "$1" ]; }
# helper function for check() in module-setup.sh
# to check for required installed binaries
@@ -422,7 +426,7 @@ shorten_persistent_dev() {
# $ find_block_device /usr
# 8:4
find_block_device() {
local _majmin _dev _majmin _find_mpt
local _dev _majmin _find_mpt
_find_mpt="$1"
if [[ $use_fstab != yes ]]; then
[[ -d $_find_mpt/. ]]
@@ -628,7 +632,7 @@ check_block_and_slaves_all() {
if ! lvm_internal_dev $2 && "$1" $2; then
_ret=0
fi
check_vol_slaves "$@" && return 0
check_vol_slaves_all "$@" && return 0
if [[ -f /sys/dev/block/$2/../dev ]]; then
check_block_and_slaves_all $1 $(<"/sys/dev/block/$2/../dev") && _ret=0
fi
@@ -687,7 +691,7 @@ check_vol_slaves() {
if [[ $_lv = $2 ]]; then
_vg=$(lvm lvs --noheadings -o vg_name $i 2>/dev/null)
# strip space
_vg=$(printf "%s\n" "$_vg")
_vg="${_vg//[[:space:]]/}"
if [[ $_vg ]]; then
for _pv in $(lvm vgs --noheadings -o pv_name "$_vg" 2>/dev/null)
do
@@ -699,6 +703,29 @@ check_vol_slaves() {
return 1
}
check_vol_slaves_all() {
local _lv _vg _pv
for i in /dev/mapper/*; do
[[ $i == /dev/mapper/control ]] && continue
_lv=$(get_maj_min $i)
if [[ $_lv = $2 ]]; then
_vg=$(lvm lvs --noheadings -o vg_name $i 2>/dev/null)
# strip space
_vg="${_vg//[[:space:]]/}"
if [[ $_vg ]]; then
for _pv in $(lvm vgs --noheadings -o pv_name "$_vg" 2>/dev/null)
do
check_block_and_slaves_all $1 $(get_maj_min $_pv)
done
return 0
fi
fi
done
return 1
}
# fs_get_option <filesystem options> <search for option>
# search for a specific option in a bunch of filesystem options
# and return the value

View File

@@ -150,8 +150,7 @@ dlog_init() {
&& type -P systemd-cat &>/dev/null \
&& systemctl --quiet is-active systemd-journald.socket &>/dev/null \
&& { echo "dracut-$DRACUT_VERSION" | systemd-cat -t 'dracut' &>/dev/null; } ; then
readonly _dlogdir="$(mktemp --tmpdir="$TMPDIR/" -d -t dracut-log.XXXXXX)"
readonly _systemdcatfile="$_dlogdir/systemd-cat"
readonly _systemdcatfile="$DRACUT_TMPDIR/systemd-cat"
mkfifo "$_systemdcatfile"
readonly _dlogfd=15
systemd-cat -t 'dracut' --level-prefix=true <"$_systemdcatfile" &

View File

@@ -306,6 +306,12 @@ provide a valid _/etc/fstab_.
**--no-hostonly-cmdline**:
Do not store kernel command line arguments needed in the initramfs
**--hostonly-i18n**:
Install only needed keyboard and font files according to the host configuration (default).
**--no-hostonly-i18n**:
Install all keyboard and font files available.
**--persistent-policy** _<policy>_::
Use _<policy>_ to address disks and partitions.
_<policy>_ can be any directory name found in /dev/disk.
@@ -349,6 +355,9 @@ example:
----
===============================
**--install-optional** _<file list>_::
install the space separated list of files into the initramfs, if they exist.
**--gzip**::
Compress the generated initramfs using gzip. This will be done by default,
unless another compression option or --no-compress is passed. Equivalent to

View File

@@ -108,6 +108,10 @@ resume=UUID=3f5ad593-4546-4a94-a374-bcfb68aa11f7
Misc
~~~~
**rd.emergency=**__[reboot|poweroff|halt]__::
specify, what action to execute in case of a critical failure. rd.shell=0 also
be specified.
**rd.driver.blacklist=**__<drivername>__[,__<drivername>__,...]::
do not load kernel module <drivername>. This parameter can be specified
multiple times.
@@ -157,8 +161,8 @@ It should be attached to any report about dracut problems.
_/run/initramfs/init.log_.
If "quiet" is set, it also logs to the console.
**rd.memdebug=[0-3]**::
Print memory usage info at various points, set the verbose level from 0 to 3.
**rd.memdebug=[0-4]**::
Print memory usage info at various points, set the verbose level from 0 to 4.
+
Higher level means more debugging output:
+
@@ -167,6 +171,10 @@ It should be attached to any report about dracut problems.
1 - partial /proc/meminfo
2 - /proc/meminfo
3 - /proc/meminfo + /proc/slabinfo
4 - /proc/meminfo + /proc/slabinfo + tracekomem
NOTE: tracekomem is a shell script utilizing kernel trace to track
the rough total memory consumption of kernel modules during
loading. It may override other trace configurations.
----
**rd.break**::

View File

@@ -30,6 +30,11 @@ dracut command line options will overwrite any values set here.
Configuration files must have the extension .conf; other extensions are ignored.
[WARNING]
====
Space-separated lists have to have a leading and trailing space!
====
*dracutmodules+=*" __<dracut modules>__ "::
Specify a space-separated list of dracut modules to call when building the
initramfs. Modules are located in _/usr/lib/dracut/modules.d_.
@@ -66,6 +71,10 @@ Configuration files must have the extension .conf; other extensions are ignored.
*install_items+=*" __<file>__[ __<file>__ ...] "::
Specify additional files to include in the initramfs, separated by spaces.
*install_optional_items+=*" __<file>__[ __<file>__ ...] "::
Specify additional files to include in the initramfs, separated by spaces,
if they exist.
*do_strip=*"__{yes|no}__"::
Strip binaries in the initramfs (default=yes)
@@ -79,6 +88,9 @@ Configuration files must have the extension .conf; other extensions are ignored.
*hostonly_cmdline*"__{yes|no}__"::
If set, store the kernel command line arguments needed in the initramfs
*i18n_install_all=*"__{yes|no}__"::
If set to yes, install all available fonts and keyboard files.
*persistent_policy=*"__<policy>__"::
Use _<policy>_ to address disks and partitions.
_<policy>_ can be any directory name found in /dev/disk.

View File

@@ -6,7 +6,7 @@ i18n_default_font="latarcyrheb-sun16"
i18n_install_all="yes"
stdloglvl=3
sysloglvl=5
install_items+=" vi /etc/virc ps grep cat rm "
install_optional_items+=" vi /etc/virc ps grep cat rm "
prefix="/"
systemdutildir=/usr/lib/systemd
systemdsystemunitdir=/usr/lib/systemd/system

119
dracut.sh
View File

@@ -141,6 +141,9 @@ Creates initial ramdisk images for preloading modules
in the initramfs
--no-hostonly-cmdline Do not store kernel command line arguments needed
in the initramfs
--hostonly-i18n Install only needed keyboard and font files according
to the host configuration (default).
--no-hostonly-i18n Install all keyboard and font files available.
--persistent-policy [POLICY]
Use [POLICY] to address disks and partitions.
POLICY can be any directory name found in /dev/disk.
@@ -158,6 +161,8 @@ Creates initial ramdisk images for preloading modules
in the final initramfs.
-I, --install [LIST] Install the space separated list of files into the
initramfs.
--install-optional [LIST] Install the space separated list of files into the
initramfs, if they exist.
--gzip Compress the generated initramfs using gzip.
This will be done by default, unless another
compression option or --no-compress is passed.
@@ -305,6 +310,7 @@ rearrange_params()
--long drivers: \
--long filesystems: \
--long install: \
--long install-optional: \
--long fwdir: \
--long libdirs: \
--long fscks: \
@@ -471,6 +477,9 @@ while :; do
-d|--drivers) push drivers_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
--filesystems) push filesystems_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
-I|--install) push install_items_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
--install-optional)
push install_optional_items_l \
"$2"; PARMS_TO_STORE+=" '$2'"; shift;;
--fwdir) push fw_dir_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
--libdirs) push libdirs_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
--fscks) push fscks_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
@@ -722,6 +731,12 @@ if (( ${#install_items_l[@]} )); then
done
fi
if (( ${#install_optional_items_l[@]} )); then
while pop install_optional_items_l val; do
install_optional_items+=" $val "
done
fi
# these options override the stuff in the config file
if (( ${#dracutmodules_l[@]} )); then
dracutmodules=''
@@ -813,31 +828,25 @@ fi
[[ $hostonly != "-h" ]] && unset hostonly
readonly TMPDIR="$tmpdir"
readonly initdir="$(mktemp --tmpdir="$TMPDIR/" -d -t initramfs.XXXXXX)"
[ -d "$initdir" ] || {
printf "%s\n" "dracut: mktemp --tmpdir=\"$TMPDIR/\" -d -t initramfs.XXXXXX failed." >&2
readonly DRACUT_TMPDIR="$(mktemp -p "$TMPDIR/" -d -t dracut.XXXXXX)"
[ -d "$DRACUT_TMPDIR" ] || {
printf "%s\n" "dracut: mktemp -p '$TMPDIR/' -d -t dracut.XXXXXX failed." >&2
exit 1
}
if [[ $early_microcode = yes ]] || ( [[ $acpi_override = yes ]] && [[ -d $acpi_table_dir ]] ); then
readonly early_cpio_dir="$(mktemp --tmpdir="$TMPDIR/" -d -t early_cpio.XXXXXX)"
[ -d "$early_cpio_dir" ] || {
printf "%s\n" "dracut: mktemp --tmpdir=\"$TMPDIR/\" -d -t early_cpio.XXXXXX failed." >&2
exit 1
}
fi
# clean up after ourselves no matter how we die.
trap '
ret=$?;
[[ $keep ]] && echo "Not removing $initdir." >&2 || { [[ $initdir ]] && rm -rf -- "$initdir"; };
[[ $keep ]] && echo "Not removing $early_cpio_dir." >&2 || { [[ $early_cpio_dir ]] && rm -Rf -- "$early_cpio_dir"; };
[[ $_dlogdir ]] && rm -Rf -- "$_dlogdir";
[[ $keep ]] && echo "Not removing $DRACUT_TMPDIR." >&2 || { [[ $DRACUT_TMPDIR ]] && rm -rf -- "$DRACUT_TMPDIR"; };
exit $ret;
' EXIT
# clean up after ourselves no matter how we die.
trap 'exit 1;' SIGINT
readonly initdir="${DRACUT_TMPDIR}/initramfs"
mkdir "$initdir"
export DRACUT_KERNEL_LAZY="1"
export DRACUT_RESOLVE_LAZY="1"
@@ -879,6 +888,24 @@ fi
dracutfunctions=$dracutbasedir/dracut-functions.sh
export dracutfunctions
case "$(arch)" in
i686|x86_64)
;;
*)
if [[ $early_microcode = yes ]]; then
early_microcode=no
dinfo "Disabling early microcode for $(arch)"
fi
;;
esac
if [[ $early_microcode = yes ]] || ( [[ $acpi_override = yes ]] && [[ -d $acpi_table_dir ]] ); then
readonly early_cpio_dir="${DRACUT_TMPDIR}/earlycpio"
mkdir "$early_cpio_dir"
fi
if (( ${#drivers_l[@]} )); then
drivers=''
while pop drivers_l val; do
@@ -942,9 +969,14 @@ esac
abs_outfile=$(readlink -f "$outfile") && outfile="$abs_outfile"
if [[ -d $srcmods ]]; then
[[ -f $srcmods/modules.dep ]] || {
dwarn "$srcmods/modules.dep is missing. Did you run depmod?"
}
if ! [[ -f $srcmods/modules.dep ]]; then
if [[ -n "$(find "$srcmods" -name '*.ko*')" ]]; then
dfatal "$srcmods/modules.dep is missing. Did you run depmod?"
exit 1
else
dwarn "$srcmods/modules.dep is missing. Did you run depmod?"
fi
fi
fi
if [[ ! $print_cmdline ]]; then
@@ -1105,6 +1137,7 @@ if [[ $hostonly ]]; then
# check /proc/modules
declare -A host_modules
while read m rest; do
[ -z "$m" ] && continue
host_modules["$m"]=1
done </proc/modules
fi
@@ -1150,6 +1183,12 @@ for dev in "${!host_fs_types[@]}"; do
fi
done
# also put the additional filesystems in host_fs_types
# so that the according modules are installed.
for fs in $filesystems; do
host_fs_types[$fs]="$fs"
done
[[ -d $udevdir ]] \
|| udevdir="$(pkg-config udev --variable=udevdir 2>/dev/null)"
if ! [[ -d "$udevdir" ]]; then
@@ -1349,6 +1388,7 @@ fi
if [[ $kernel_only != yes ]]; then
(( ${#install_items[@]} > 0 )) && inst_multiple ${install_items[@]}
(( ${#install_optional_items[@]} > 0 )) && inst_multiple -o ${install_optional_items[@]}
[[ $kernel_cmdline ]] && printf "%s\n" "$kernel_cmdline" >> "${initdir}/etc/cmdline.d/01-default.conf"
@@ -1470,8 +1510,9 @@ if [[ $do_strip = yes ]] && ! [[ $DRACUT_FIPS_MODE ]]; then
dinfo "*** Stripping files done ***"
fi
if [[ $early_microcode = yes ]]; then
dinfo "*** Generating early-microcode cpio image ***"
dinfo "*** Generating early-microcode cpio image contents ***"
ucode_dir=(amd-ucode intel-ucode)
ucode_dest=(AuthenticAMD.bin GenuineIntel.bin)
_dest_dir="$early_cpio_dir/d/kernel/x86/microcode"
@@ -1497,11 +1538,19 @@ if [[ $early_microcode = yes ]]; then
[ -e "$i" ] && break
break 2
done
cat $_fwdir/$_fw/$_src > $_dest_dir/${ucode_dest[$idx]}
for i in $_fwdir/$_fw/$_src; do
[[ -e "$i" ]] || continue
# skip gpg files
str_ends "$i" ".asc" && continue
cat "$i" >> $_dest_dir/${ucode_dest[$idx]}
done
create_early_cpio="yes"
fi
done
done
if ! [[ $create_early_cpio = yes ]]; then
dinfo "*** No early-microcode cpio image needed ***"
fi
fi
if [[ $acpi_override = yes ]] && [[ -d $acpi_table_dir ]]; then
@@ -1527,23 +1576,47 @@ dinfo "*** Creating image file ***"
[[ "$UID" != 0 ]] && cpio_owner_root="-R 0:0"
if [[ $create_early_cpio = yes ]]; then
dinfo "*** Creating microcode section ***"
echo 1 > "$early_cpio_dir/d/early_cpio"
# The microcode blob is _before_ the initramfs blob, not after
(cd "$early_cpio_dir/d"; find . -print0 | cpio --null $cpio_owner_root -H newc -o --quiet > $outfile)
if ! (
umask 077
cd "$early_cpio_dir/d"
find . -print0 | cpio --null $cpio_owner_root -H newc -o --quiet > "${DRACUT_TMPDIR}/initramfs.img"
); then
dfatal "dracut: creation of $outfile failed"
exit 1
else
dinfo "*** Created microcode section ***"
fi
fi
if ! ( umask 077; cd "$initdir"; find . -print0 | cpio --null $cpio_owner_root -H newc -o --quiet | \
$compress >> "$outfile"; ); then
if ! (
umask 077
cd "$initdir"
find . -print0 | cpio --null $cpio_owner_root -H newc -o --quiet | \
$compress >> "${DRACUT_TMPDIR}/initramfs.img";
); then
dfatal "dracut: creation of $outfile failed"
exit 1
fi
dinfo "*** Creating image file done ***"
if (( maxloglvl >= 5 )); then
if [[ $allowlocal ]]; then
"$dracutbasedir/lsinitrd.sh" "$outfile"| ddebug
"$dracutbasedir/lsinitrd.sh" "${DRACUT_TMPDIR}/initramfs.img" | ddebug
else
lsinitrd "$outfile"| ddebug
lsinitrd "${DRACUT_TMPDIR}/initramfs.img" | ddebug
fi
fi
if cp --reflink=auto "${DRACUT_TMPDIR}/initramfs.img" "$outfile" |& derror ; then
dinfo "*** Creating initramfs image file '$outfile' done ***"
else
rm -f -- "$outfile"
dfatal "dracut: creation of $outfile failed"
exit 1
fi
exit 0

View File

@@ -91,6 +91,7 @@ Requires: gzip xz
Requires: kmod
Requires: sed
Requires: kpartx
Requires: tar
%if 0%{?fedora} || 0%{?rhel} > 6
Requires: util-linux >= 2.21
@@ -202,6 +203,7 @@ git commit -a -q -m "%{version} baseline."
# Apply all the patches.
git am -p1 %{patches}
git tag %{version}
%endif
%build
@@ -310,6 +312,7 @@ rm -rf -- $RPM_BUILD_ROOT
%endif
%dir %{_sysconfdir}/dracut.conf.d
%dir %{dracutlibdir}/dracut.conf.d
%{_datadir}/pkgconfig/dracut.pc
%{_mandir}/man8/dracut.8*
%{_mandir}/man8/*service.8*
%if 0%{?fedora} > 12 || 0%{?rhel} >= 6 || 0%{?suse_version} > 9999

View File

@@ -171,39 +171,35 @@ case $bin in
;;
esac
CAT=$({
if [[ $SKIP ]]; then
$SKIP "$image"
if [[ $SKIP ]] ; then
bin="$($SKIP "$image" | { read -N 6 bin && echo "$bin" ; })"
else
read -N 6 bin < "$image"
fi
case $bin in
$'\x1f\x8b'*)
CAT="zcat --"
;;
BZh*)
CAT="bzcat --"
;;
$'\x71\xc7'*|070701)
CAT="cat --"
;;
$'\x02\x21'*)
CAT="lz4 -d -c"
;;
$'\x89'LZO$'\0'*)
CAT="lzop -d -c"
;;
*)
if echo "test"|xz|xzcat --single-stream >/dev/null 2>&1; then
CAT="xzcat --single-stream --"
else
cat "$image"
fi } | {
read -N 6 bin
case $bin in
$'\x1f\x8b'*)
echo "zcat --"
;;
BZh*)
echo "bzcat --"
;;
$'\x71\xc7'*|070701)
echo "cat --"
;;
$'\x02\x21'*)
echo "lz4 -d -c"
;;
$'\x89'LZO$'\0'*)
echo "lzop -d -c"
;;
*)
if echo "test"|xz|xzcat --single-stream >/dev/null 2>&1; then
echo "xzcat --single-stream --"
else
echo "xzcat --"
fi
;;
esac
})
CAT="xzcat --"
fi
;;
esac
skipcpio()
{

View File

@@ -96,7 +96,7 @@ do_fips()
_found=0
while read _k _s _v; do
[ "$_k" != "name" -a "$_k" != "driver" ] && continue
[ "$_v" != "$_module" ] && continue
[ "$_v" != "$_module" ] && [ "crypto-$_v" != "$_module" ] && continue
_found=1
break
done </proc/crypto

View File

@@ -11,20 +11,29 @@ depends() {
}
installkernel() {
local _fipsmodules _mod
_fipsmodules="aead aes_generic aes-x86_64 ansi_cprng arc4 blowfish camellia cast6 cbc ccm "
_fipsmodules+="chainiv crc32c crct10dif_generic cryptomgr crypto_null ctr cts deflate des des3_ede dm-crypt dm-mod drbg "
_fipsmodules+="ecb eseqiv fcrypt gcm ghash_generic hmac khazad lzo md4 md5 michael_mic rmd128 "
_fipsmodules+="rmd160 rmd256 rmd320 rot13 salsa20 seed seqiv serpent sha1 sha224 sha256 sha256_generic "
_fipsmodules+="aes_s390 des_s390 prng sha256_s390 sha_common des_check_key sha1_s390 sha512_s390"
_fipsmodules+="sha384 sha512 sha512_generic tcrypt tea tnepres twofish wp256 wp384 wp512 xeta xtea xts zlib"
local _fipsmodules _mod i
if [[ -f "${srcmods}/modules.fips" ]]; then
_fipsmodules="$(cat "${srcmods}/modules.fips")"
else
_fipsmodules="aead aes_generic aes-x86_64 ansi_cprng arc4 blowfish camellia cast6 cbc ccm "
_fipsmodules+="chainiv crc32c crct10dif_generic cryptomgr crypto_null ctr cts deflate des des3_ede dm-crypt dm-mod drbg "
_fipsmodules+="ecb eseqiv fcrypt gcm ghash_generic hmac khazad lzo md4 md5 michael_mic rmd128 "
_fipsmodules+="rmd160 rmd256 rmd320 rot13 salsa20 seed seqiv serpent sha1 sha224 sha256 sha256_generic "
_fipsmodules+="aes_s390 des_s390 prng sha256_s390 sha_common des_check_key sha1_s390 sha512_s390 "
_fipsmodules+="sha384 sha512 sha512_generic tea tnepres twofish wp256 wp384 wp512 xeta xtea xts zlib cmac authenc "
fi
mkdir -m 0755 -p "${initdir}/etc/modprobe.d"
for _mod in $_fipsmodules; do
for _mod in $_fipsmodules tcrypt; do
if hostonly='' instmods -c -s $_mod; then
echo $_mod >> "${initdir}/etc/fipsmodules"
echo "blacklist $_mod" >> "${initdir}/etc/modprobe.d/fips.conf"
for i in $(modprobe --resolve-alias $_mod 2>/dev/null); do
[[ $i == $_mod ]] && continue
echo "blacklist $i" >> "${initdir}/etc/modprobe.d/fips.conf"
done
fi
done
}

View File

@@ -11,18 +11,68 @@ depends() {
}
install() {
inst_hook cmdline 00 "$moddir/watchdog.sh"
inst_hook cmdline 50 "$moddir/watchdog.sh"
inst_hook pre-trigger 00 "$moddir/watchdog.sh"
inst_hook initqueue 00 "$moddir/watchdog.sh"
inst_hook mount 00 "$moddir/watchdog.sh"
inst_hook mount 50 "$moddir/watchdog.sh"
inst_hook mount 99 "$moddir/watchdog.sh"
inst_hook pre-pivot 00 "$moddir/watchdog.sh"
inst_hook pre-pivot 99 "$moddir/watchdog.sh"
inst_hook cleanup 00 "$moddir/watchdog.sh"
inst_hook cleanup 99 "$moddir/watchdog.sh"
# Do not add watchdog hooks if systemd module is included
# In that case, systemd will manage watchdog kick
if ! dracut_module_included "systemd"; then
inst_hook cmdline 00 "$moddir/watchdog.sh"
inst_hook cmdline 50 "$moddir/watchdog.sh"
inst_hook pre-trigger 00 "$moddir/watchdog.sh"
inst_hook initqueue 00 "$moddir/watchdog.sh"
inst_hook mount 00 "$moddir/watchdog.sh"
inst_hook mount 50 "$moddir/watchdog.sh"
inst_hook mount 99 "$moddir/watchdog.sh"
inst_hook pre-pivot 00 "$moddir/watchdog.sh"
inst_hook pre-pivot 99 "$moddir/watchdog.sh"
inst_hook cleanup 00 "$moddir/watchdog.sh"
inst_hook cleanup 99 "$moddir/watchdog.sh"
fi
inst_hook emergency 02 "$moddir/watchdog-stop.sh"
inst_multiple -o wdctl
}
installkernel() {
local -A _drivers
local _alldrivers _active _wdtdrv _wdtppath _dir
[[ -d /sys/class/watchdog/ ]] || return
for _dir in /sys/class/watchdog/*; do
[[ -d "$_dir" ]] || continue
[[ -f "$_dir/state" ]] || continue
_active=$(< "$_dir/state")
! [[ $hostonly ]] || [[ "$_active" = "active" ]] || continue
# device/modalias will return driver of this device
_wdtdrv=$(< "$_dir/device/modalias")
# There can be more than one module represented by same
# modalias. Currently load all of them.
# TODO: Need to find a way to avoid any unwanted module
# represented by modalias
_wdtdrv=$(modprobe --set-version "$kernel" -R $_wdtdrv 2>/dev/null)
if [[ $_wdtdrv ]]; then
instmods $_wdtdrv
for i in $_wdtdrv; do
_drivers[$i]=1
done
fi
# however in some cases, we also need to check that if there is
# a specific driver for the parent bus/device. In such cases
# we also need to enable driver for parent bus/device.
_wdtppath=$(readlink -f "$_dir/device")
while [[ -d "$_wdtppath" ]] && [[ "$_wdtppath" != "/sys" ]]; do
_wdtppath=$(readlink -f "$_wdtppath/..")
[[ -f "$_wdtppath/modalias" ]] || continue
_wdtdrv=$(< "$_wdtppath/modalias")
_wdtdrv=$(modprobe --set-version "$kernel" -R $_wdtdrv 2>/dev/null)
if [[ $_wdtdrv ]]; then
instmods $_wdtdrv
for i in $_wdtdrv; do
_drivers[$i]=1
done
fi
done
done
# ensure that watchdog module is loaded as early as possible
_alldrivers="${!_drivers[*]}"
[[ $_alldrivers ]] && echo "rd.driver.pre=${_alldrivers// /,}" > ${initdir}/etc/cmdline.d/00-watchdog.conf
return 0
}

View File

@@ -1,2 +1,2 @@
#!/bin/sh
[ -c /dev/watchdog ] && echo -n 'V' > /dev/watchdog
[ -c /dev/watchdog ] && printf 'V' > /dev/watchdog

View File

@@ -95,6 +95,51 @@ setup_interface6() {
[ -n "$hostname" ] && echo "echo ${hostname%.$domain}${domain:+.$domain} > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
}
function parse_option_121() {
while [ $# -ne 0 ]; do
mask="$1"
shift
# Is the destination a multicast group?
if [ $1 -ge 224 -a $1 -lt 240 ]; then
multicast=1
else
multicast=0
fi
# Parse the arguments into a CIDR net/mask string
if [ $mask -gt 24 ]; then
destination="$1.$2.$3.$4/$mask"
shift; shift; shift; shift
elif [ $mask -gt 16 ]; then
destination="$1.$2.$3.0/$mask"
shift; shift; shift
elif [ $mask -gt 8 ]; then
destination="$1.$2.0.0/$mask"
shift; shift
else
destination="$1.0.0.0/$mask"
shift
fi
# Read the gateway
gateway="$1.$2.$3.$4"
shift; shift; shift; shift
# Multicast routing on Linux
# - If you set a next-hop address for a multicast group, this breaks with Cisco switches
# - If you simply leave it link-local and attach it to an interface, it works fine.
if [ $multicast -eq 1 ]; then
temp_result="$destination dev $interface"
else
temp_result="$destination via $gateway dev $interface"
fi
echo "/sbin/ip route add $temp_result"
done
}
case $reason in
PREINIT)
echo "dhcp: PREINIT $netif up"
@@ -104,7 +149,7 @@ case $reason in
PREINIT6)
echo "dhcp: PREINIT6 $netif up"
linkup $netif
wait_for_ipv6_dad $netif
wait_for_ipv6_dad_link $netif
;;
BOUND)
@@ -129,6 +174,9 @@ case $reason in
{
echo '. /lib/net-lib.sh'
echo "setup_net $netif"
if [ -n "$new_classless_static_routes" ]; then
parse_option_121 $new_classless_static_routes
fi
echo "source_hook initqueue/online $netif"
[ -e /tmp/net.$netif.manualup ] || echo "/sbin/netroot $netif"
echo "rm -f -- $hookdir/initqueue/setup_net_$netif.sh"

View File

@@ -1,3 +1,6 @@
option classless-routes code 121 = array of unsigned integer 8;
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, domain-search, host-name,
root-path, interface-mtu;
root-path, interface-mtu, classless-routes;

View File

@@ -17,79 +17,12 @@ type ip_to_var >/dev/null 2>&1 || . /lib/net-lib.sh
# $netif reads easier than $1
netif=$1
use_bridge='false'
use_vlan='false'
# enslave this interface to bond?
for i in /tmp/bond.*.info; do
[ -e "$i" ] || continue
unset bondslaves
unset bondname
. "$i"
for slave in $bondslaves ; do
if [ "$netif" = "$slave" ] ; then
netif=$bondname
break 2
fi
done
done
for i in /tmp/team.*.info; do
[ -e "$i" ] || continue
unset teamslaves
unset teammaster
. "$i"
for slave in $teamslaves ; do
if [ "$netif" = "$slave" ] ; then
netif=$teammaster
fi
done
done
if [ -e /tmp/vlan.info ]; then
. /tmp/vlan.info
if [ "$netif" = "$phydevice" ]; then
if [ "$netif" = "$bondname" ] && [ -n "$DO_BOND_SETUP" ] ; then
: # We need to really setup bond (recursive call)
elif [ "$netif" = "$teammaster" ] && [ -n "$DO_TEAM_SETUP" ] ; then
: # We need to really setup team (recursive call)
else
netif="$vlanname"
use_vlan='true'
fi
fi
fi
# bridge this interface?
if [ -e /tmp/bridge.info ]; then
. /tmp/bridge.info
for ethname in $bridgeslaves ; do
if [ "$netif" = "$ethname" ]; then
if [ "$netif" = "$bondname" ] && [ -n "$DO_BOND_SETUP" ] ; then
: # We need to really setup bond (recursive call)
elif [ "$netif" = "$teammaster" ] && [ -n "$DO_TEAM_SETUP" ] ; then
: # We need to really setup team (recursive call)
elif [ "$netif" = "$vlanname" ] && [ -n "$DO_VLAN_SETUP" ]; then
: # We need to really setup vlan (recursive call)
else
netif="$bridgename"
use_bridge='true'
fi
fi
done
fi
# disable manual ifup while netroot is set for simplifying our logic
# in netroot case we prefer netroot to bringup $netif automaticlly
[ -n "$2" -a "$2" = "-m" ] && [ -z "$netroot" ] && manualup="$2"
if [ -n "$manualup" ]; then
>/tmp/net.$netif.manualup
rm -f /tmp/net.${netif}.did-setup
else
[ -e /tmp/net.${netif}.did-setup ] && exit 0
[ -e /sys/class/net/$netif/address ] && \
[ -e /tmp/net.$(cat /sys/class/net/$netif/address).did-setup ] && exit 0
# loopback is always handled the same way
if [ "$netif" = "lo" ] ; then
ip link set lo up
ip addr add 127.0.0.1/8 dev lo
exit 0
fi
# Run dhclient
@@ -105,11 +38,15 @@ do_dhcp() {
[ -e /tmp/dhclient.$netif.pid ] && return 0
if ! iface_has_link $netif; then
if ! iface_has_carrier $netif; then
warn "No carrier detected on interface $netif"
return 1
fi
[ -n "$macaddr" ] && ip link set address $macaddr dev $netif
[ -n "$mtu" ] && ip link set mtu $mtu dev $netif
ip -4 addr flush dev $netif
while [ $_COUNT -lt $_DHCPRETRY ]; do
info "Starting dhcp for interface $netif"
dhclient "$@" \
@@ -144,6 +81,8 @@ do_ipv6auto() {
echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_ra
echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_redirects
linkup $netif
[ -n "$macaddr" ] && ip link set address $macaddr dev $netif
[ -n "$mtu" ] && ip link set mtu $mtu dev $netif
wait_for_ipv6_auto $netif
[ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
@@ -155,7 +94,10 @@ do_ipv6auto() {
do_static() {
strstr $ip '*:*:*' && load_ipv6
if ! linkup $netif; then
if [ -z "$dev" ] && ! iface_has_carrier "$netif"; then
warn "No carrier detected on interface $netif"
return 1
elif ! linkup "$netif"; then
warn "Could not bring interface $netif up!"
return 1
fi
@@ -180,7 +122,7 @@ do_static() {
warn "Duplicate address detected for $ip for interface $netif."
return 1
fi
ip addr flush dev $netif
ip -4 addr flush dev $netif
ip addr add $ip/$mask ${srv:+peer $srv} brd + dev $netif
fi
@@ -190,124 +132,6 @@ do_static() {
return 0
}
# loopback is always handled the same way
if [ "$netif" = "lo" ] ; then
ip link set lo up
ip addr add 127.0.0.1/8 dev lo
exit 0
fi
# start bond if needed
if [ -e /tmp/bond.${netif}.info ]; then
. /tmp/bond.${netif}.info
if [ "$netif" = "$bondname" ] && [ ! -e /tmp/net.$bondname.up ] ; then # We are master bond device
modprobe bonding
echo "+$netif" > /sys/class/net/bonding_masters
ip link set $netif down
# Stolen from ifup-eth
# add the bits to setup driver parameters here
for arg in $bondoptions ; do
key=${arg%%=*};
value=${arg##*=};
# %{value:0:1} is replaced with non-bash specific construct
if [ "${key}" = "arp_ip_target" -a "${#value}" != "0" -a "+${value%%+*}" != "+" ]; then
OLDIFS=$IFS;
IFS=',';
for arp_ip in $value; do
echo +$arp_ip > /sys/class/net/${netif}/bonding/$key
done
IFS=$OLDIFS;
else
echo $value > /sys/class/net/${netif}/bonding/$key
fi
done
linkup $netif
for slave in $bondslaves ; do
ip link set $slave down
cat /sys/class/net/$slave/address > /tmp/net.${netif}.${slave}.hwaddr
echo "+$slave" > /sys/class/net/$bondname/bonding/slaves
linkup $slave
done
# add the bits to setup the needed post enslavement parameters
for arg in $BONDING_OPTS ; do
key=${arg%%=*};
value=${arg##*=};
if [ "${key}" = "primary" ]; then
echo $value > /sys/class/net/${netif}/bonding/$key
fi
done
fi
fi
if [ -e /tmp/team.${netif}.info ]; then
. /tmp/team.${netif}.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
teamdctl ${teammaster} port present ${slave} 2>/dev/null \
&& continue
ip link set dev $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 -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 dev $slave down
(
unset TEAM_PORT_CONFIG
_hwaddr=$(cat /sys/class/net/$slave/address)
_subchannels=$(iface_get_subchannels "$slave")
if [ -n "$_hwaddr" ] && [ -e "/etc/sysconfig/network-scripts/mac-${_hwaddr}.conf" ]; then
. "/etc/sysconfig/network-scripts/mac-${_hwaddr}.conf"
elif [ -n "$_subchannels" ] && [ -e "/etc/sysconfig/network-scripts/ccw-${_subchannels}.conf" ]; then
. "/etc/sysconfig/network-scripts/ccw-${_subchannels}.conf"
elif [ -e "/etc/sysconfig/network-scripts/ifcfg-${slave}" ]; then
. "/etc/sysconfig/network-scripts/ifcfg-${slave}"
fi
if [ -n "${TEAM_PORT_CONFIG}" ]; then
/usr/bin/teamdctl ${teammaster} port config update ${slave} "${TEAM_PORT_CONFIG}"
fi
)
teamdctl $teammaster port add $slave
done
ip link set dev $teammaster up
fi
fi
# XXX need error handling like dhclient-script
if [ -e /tmp/bridge.info ]; then
. /tmp/bridge.info
# start bridge if necessary
if [ "$netif" = "$bridgename" ] && [ ! -e /tmp/net.$bridgename.up ]; then
brctl addbr $bridgename
brctl setfd $bridgename 0
for ethname in $bridgeslaves ; do
if [ "$ethname" = "$bondname" ] ; then
DO_BOND_SETUP=yes ifup $bondname -m
elif [ "$ethname" = "$teammaster" ] ; then
DO_TEAM_SETUP=yes ifup $teammaster -m
elif [ "$ethname" = "$vlanname" ]; then
DO_VLAN_SETUP=yes ifup $vlanname -m
else
linkup $ethname
fi
brctl addif $bridgename $ethname
done
fi
fi
get_vid() {
case "$1" in
vlan*)
@@ -319,33 +143,211 @@ get_vid() {
esac
}
if [ "$netif" = "$vlanname" ] && [ ! -e /tmp/net.$vlanname.up ]; then
modprobe 8021q
if [ "$phydevice" = "$bondname" ] ; then
DO_BOND_SETUP=yes ifup $phydevice -m
elif [ "$phydevice" = "$teammaster" ] ; then
DO_TEAM_SETUP=yes ifup $phydevice -m
else
linkup "$phydevice"
fi
ip link add dev "$vlanname" link "$phydevice" type vlan id "$(get_vid $vlanname)"
ip link set "$vlanname" up
# check, if we need VLAN's for this interface
if [ -z "$DO_VLAN_PHY" ] && [ -e /tmp/vlan.${netif}.phy ]; then
unset DO_VLAN
NO_AUTO_DHCP=yes DO_VLAN_PHY=yes ifup "$netif"
modprobe -b -q 8021q
for i in /tmp/vlan.*.${netif}; do
[ -e "$i" ] || continue
read vlanname < "$i"
if [ -n "$vlanname" ]; then
linkup "$netif"
ip link add dev "$vlanname" link "$netif" type vlan id "$(get_vid $vlanname)"
ifup "$vlanname"
fi
done
exit 0
fi
# Check, if interface is VLAN interface
if ! [ -e /tmp/vlan.${netif}.phy ]; then
for i in /tmp/vlan.${netif}.*; do
[ -e "$i" ] || continue
export DO_VLAN=yes
break
done
fi
# bridge this interface?
if [ -z "$NO_BRIDGE_MASTER" ]; then
for i in /tmp/bridge.*.info; do
[ -e "$i" ] || continue
unset bridgeslaves
unset bridgename
. "$i"
for ethname in $bridgeslaves ; do
[ "$netif" != "$ethname" ] && continue
NO_BRIDGE_MASTER=yes NO_AUTO_DHCP=yes ifup $ethname
linkup $ethname
if [ ! -e /tmp/bridge.$bridgename.up ]; then
brctl addbr $bridgename
brctl setfd $bridgename 0
> /tmp/bridge.$bridgename.up
fi
brctl addif $bridgename $ethname
ifup $bridgename
exit 0
done
done
fi
# enslave this interface to bond?
if [ -z "$NO_BOND_MASTER" ]; then
for i in /tmp/bond.*.info; do
[ -e "$i" ] || continue
unset bondslaves
unset bondname
. "$i"
for slave in $bondslaves ; do
[ "$netif" != "$slave" ] && continue
# already setup
[ -e /tmp/bond.$bondname.up ] && exit 0
# wait for all slaves to show up
for slave in $bondslaves ; do
# try to create the slave (maybe vlan or bridge)
NO_BOND_MASTER=yes NO_AUTO_DHCP=yes ifup $slave
if ! ip link show dev $slave >/dev/null 2>&1; then
# wait for the last slave to show up
exit 0
fi
done
modprobe -q -b bonding
echo "+$bondname" > /sys/class/net/bonding_masters 2>/dev/null
ip link set $bondname down
# Stolen from ifup-eth
# add the bits to setup driver parameters here
for arg in $bondoptions ; do
key=${arg%%=*};
value=${arg##*=};
# %{value:0:1} is replaced with non-bash specific construct
if [ "${key}" = "arp_ip_target" -a "${#value}" != "0" -a "+${value%%+*}" != "+" ]; then
OLDIFS=$IFS;
IFS=',';
for arp_ip in $value; do
echo +$arp_ip > /sys/class/net/${bondname}/bonding/$key
done
IFS=$OLDIFS;
else
echo $value > /sys/class/net/${bondname}/bonding/$key
fi
done
linkup $bondname
for slave in $bondslaves ; do
cat /sys/class/net/$slave/address > /tmp/net.${bondname}.${slave}.hwaddr
ip link set $slave down
echo "+$slave" > /sys/class/net/$bondname/bonding/slaves
linkup $slave
done
# add the bits to setup the needed post enslavement parameters
for arg in $bondoptions ; do
key=${arg%%=*};
value=${arg##*=};
if [ "${key}" = "primary" ]; then
echo $value > /sys/class/net/${bondname}/bonding/$key
fi
done
> /tmp/bond.$bondname.up
NO_BOND_MASTER=yes ifup $bondname
exit $?
done
done
fi
if [ -z "$NO_TEAM_MASTER" ]; then
for i in /tmp/team.*.info; do
[ -e "$i" ] || continue
unset teammaster
unset teamslaves
. "$i"
for slave in $teamslaves ; do
[ "$netif" != "$slave" ] && continue
[ -e /tmp/team.$teammaster.up ] && exit 0
# wait for all slaves to show up
for slave in $teamslaves ; do
# try to create the slave (maybe vlan or bridge)
NO_TEAM_MASTER=yes NO_AUTO_DHCP=yes ifup $slave
if ! ip link show dev $slave >/dev/null 2>&1; then
# wait for the last slave to show up
exit 0
fi
done
if [ ! -e /tmp/team.$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="$working_slaves$slave "
fi
done
# Do not add slaves now
teamd -d -U -n -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
> /tmp/team.$teammaster.up
NO_TEAM_MASTER=yes ifup $teammaster
exit $?
fi
done
done
fi
# all synthetic interfaces done.. now check if the interface is available
if ! ip link show dev $netif >/dev/null 2>&1; then
exit 1
fi
# disable manual ifup while netroot is set for simplifying our logic
# in netroot case we prefer netroot to bringup $netif automaticlly
[ -n "$2" -a "$2" = "-m" ] && [ -z "$netroot" ] && manualup="$2"
if [ -n "$manualup" ]; then
>/tmp/net.$netif.manualup
rm -f /tmp/net.${netif}.did-setup
else
[ -e /tmp/net.${netif}.did-setup ] && exit 0
[ -z "$DO_VLAN" ] && \
[ -e /sys/class/net/$netif/address ] && \
[ -e /tmp/net.$(cat /sys/class/net/$netif/address).did-setup ] && exit 0
fi
# No ip lines default to dhcp
ip=$(getarg ip)
if [ -z "$ip" ]; then
for s in $(getargs nameserver); do
[ -n "$s" ] || continue
echo nameserver $s >> /tmp/net.$netif.resolv.conf
done
if [ -z "$NO_AUTO_DHCP" ] && [ -z "$ip" ]; then
if [ "$netroot" = "dhcp6" ]; then
do_dhcp -6
else
do_dhcp -4
fi
for s in $(getargs nameserver); do
[ -n "$s" ] || continue
echo nameserver $s >> /tmp/net.$netif.resolv.conf
done
fi
@@ -372,14 +374,8 @@ for p in $(getargs ip=); do
[ "$use_bridge" != 'true' ] && \
[ "$use_vlan" != 'true' ] && continue
# setup nameserver
for s in "$dns1" "$dns2" $(getargs nameserver); do
[ -n "$s" ] || continue
echo nameserver $s >> /tmp/net.$netif.resolv.conf
done
# Store config for later use
for i in ip srv gw mask hostname macaddr dns1 dns2; do
for i in ip srv gw mask hostname macaddr mtu dns1 dns2; do
eval '[ "$'$i'" ] && echo '$i'="$'$i'"'
done > /tmp/net.$netif.override
@@ -398,27 +394,34 @@ for p in $(getargs ip=); do
done
ret=$?
> /tmp/net.${netif}.up
# setup nameserver
for s in "$dns1" "$dns2" $(getargs nameserver); do
[ -n "$s" ] || continue
echo nameserver $s >> /tmp/net.$netif.resolv.conf
done
if [ -e /sys/class/net/${netif}/address ]; then
> /tmp/net.$(cat /sys/class/net/${netif}/address).up
fi
if [ $ret -eq 0 ]; then
> /tmp/net.${netif}.up
case $autoconf in
dhcp|on|any|dhcp6)
if [ -z "$DO_VLAN" ] && [ -e /sys/class/net/${netif}/address ]; then
> /tmp/net.$(cat /sys/class/net/${netif}/address).up
fi
case $autoconf in
dhcp|on|any|dhcp6)
;;
*)
if [ $ret -eq 0 ]; then
setup_net $netif
source_hook initqueue/online $netif
if [ -z "$manualup" ]; then
/sbin/netroot $netif
*)
if [ $ret -eq 0 ]; then
setup_net $netif
source_hook initqueue/online $netif
if [ -z "$manualup" ]; then
/sbin/netroot $netif
fi
fi
fi
;;
esac
exit 0
;;
esac
exit $ret
fi
done
# netif isn't the top stack? Then we should exit here.
@@ -429,7 +432,7 @@ if [ -n "$DO_BOND_SETUP" -o -n "$DO_TEAM_SETUP" -o -n "$DO_VLAN_SETUP" ]; then
fi
# no ip option directed at our interface?
if [ ! -e /tmp/net.${netif}.up ]; then
if [ -z "$NO_AUTO_DHCP" ] && [ ! -e /tmp/net.${netif}.up ]; then
if [ -e /tmp/net.bootdev ]; then
BOOTDEV=$(cat /tmp/net.bootdev)
if [ "$netif" = "$BOOTDEV" ] || [ "$BOOTDEV" = "$(cat /sys/class/net/${netif}/address)" ]; then

View File

@@ -69,7 +69,7 @@ installkernel() {
install() {
local _arch _i _dir
inst_multiple ip arping dhclient sed
inst_multiple ip arping dhclient sed awk
inst_multiple -o ping ping6
inst_multiple -o brctl
inst_multiple -o teamd teamdctl teamnl
@@ -91,6 +91,9 @@ install() {
inst_hook cmdline 99 "$moddir/parse-ifname.sh"
inst_hook cleanup 10 "$moddir/kill-dhclient.sh"
# Special network nameing for idrac USB devs
inst_rules 73-idrac.rules
# install all config files for teaming
unset TEAM_MASTER
unset TEAM_CONFIG

View File

@@ -1,6 +1,4 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
getargbool 0 rd.neednet && NEEDNET=1
@@ -14,11 +12,14 @@ command -v fix_bootif >/dev/null || . /lib/net-lib.sh
# Write udev rules
{
# bridge: attempt only the defined interface
if [ -e /tmp/bridge.info ]; then
. /tmp/bridge.info
IFACES="$IFACES ${bridgeslaves%% *}"
for i in /tmp/bridge.*.info; do
[ -e "$i" ] || continue
unset bridgeslaves
unset bridgename
. "$i"
RAW_IFACES="$RAW_IFACES $bridgeslaves"
MASTER_IFACES="$MASTER_IFACES $bridgename"
fi
done
# bond: attempt only the defined interface (override bridge defines)
for i in /tmp/bond.*.info; do
@@ -27,7 +28,7 @@ command -v fix_bootif >/dev/null || . /lib/net-lib.sh
unset bondname
. "$i"
# It is enough to fire up only one
IFACES="$IFACES ${bondslaves%% *}"
RAW_IFACES="$RAW_IFACES $bondslaves"
MASTER_IFACES="$MASTER_IFACES ${bondname}"
done
@@ -36,15 +37,25 @@ command -v fix_bootif >/dev/null || . /lib/net-lib.sh
unset teamslaves
unset teammaster
. "$i"
IFACES="$IFACES ${teamslaves}"
RAW_IFACES="$RAW_IFACES ${teamslaves}"
MASTER_IFACES="$MASTER_IFACES ${teammaster}"
done
if [ -e /tmp/vlan.info ]; then
. /tmp/vlan.info
IFACES="$IFACES $phydevice"
MASTER_IFACES="$MASTER_IFACES ${vlanname}"
fi
for j in /tmp/vlan.*.phy; do
[ -e "$j" ] || continue
unset phydevice
read phydevice < "$j"
RAW_IFACES="$RAW_IFACES $phydevice"
for i in /tmp/vlan.*.${phydevice}; do
[ -e "$i" ] || continue
unset vlanname
read vlanname < "$i"
MASTER_IFACES="$MASTER_IFACES ${vlanname}"
done
done
MASTER_IFACES="$(trim "$MASTER_IFACES")"
RAW_IFACES="$(trim "$RAW_IFACES")"
if [ -z "$IFACES" ]; then
[ -e /tmp/net.ifaces ] && read IFACES < /tmp/net.ifaces
@@ -59,10 +70,10 @@ command -v fix_bootif >/dev/null || . /lib/net-lib.sh
runcmd="RUN+=\"/sbin/initqueue --name ifup-\$env{INTERFACE} --unique --onetime $ifup\""
# We have some specific interfaces to handle
if [ -n "$IFACES" ]; then
if [ -n "${RAW_IFACES}${IFACES}" ]; then
echo 'SUBSYSTEM!="net", GOTO="net_end"'
echo 'ACTION!="add|change|move", GOTO="net_end"'
for iface in $IFACES; do
for iface in $IFACES $RAW_IFACES; do
case "$iface" in
??:??:??:??:??:??) # MAC address
cond="ATTR{address}==\"$iface\""
@@ -83,13 +94,7 @@ command -v fix_bootif >/dev/null || . /lib/net-lib.sh
done
echo 'LABEL="net_end"'
if [ -n "$MASTER_IFACES" ]; then
wait_ifaces=$MASTER_IFACES
else
wait_ifaces=$IFACES
fi
for iface in $wait_ifaces; do
for iface in $IFACES; do
if [ "$bootdev" = "$iface" ] || [ "$NEEDNET" = "1" ]; then
echo "[ -f /tmp/net.${iface}.did-setup ]" >$hookdir/initqueue/finished/wait-$iface.sh
fi

View File

@@ -102,7 +102,8 @@ ifdown() {
ip addr flush dev $netif
echo "#empty" > /etc/resolv.conf
rm -f -- /tmp/net.$netif.did-setup
[ -e /sys/class/net/$netif/address ] && \
[ -z "$DO_VLAN" ] && \
[ -e /sys/class/net/$netif/address ] && \
rm -f -- /tmp/net.$(cat /sys/class/net/$netif/address).did-setup
# TODO: send "offline" uevent?
}
@@ -111,7 +112,8 @@ setup_net() {
local netif="$1" f="" gw_ip="" netroot_ip="" iface="" IFACES=""
local _p
[ -e /tmp/net.$netif.did-setup ] && return
[ -e /sys/class/net/$netif/address ] && \
[ -z "$DO_VLAN" ] && \
[ -e /sys/class/net/$netif/address ] && \
[ -e /tmp/net.$(cat /sys/class/net/$netif/address).did-setup ] && return
[ -e "/tmp/net.ifaces" ] && read IFACES < /tmp/net.ifaces
[ -z "$IFACES" ] && IFACES="$netif"
@@ -121,7 +123,7 @@ setup_net() {
[ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
# set up resolv.conf
[ -e /tmp/net.$netif.resolv.conf ] && \
cp -f /tmp/net.$netif.resolv.conf /etc/resolv.conf
awk '!array[$0]++' /tmp/net.$netif.resolv.conf > /etc/resolv.conf
[ -e /tmp/net.$netif.gw ] && . /tmp/net.$netif.gw
# add static route
@@ -168,7 +170,8 @@ setup_net() {
unset layer2
> /tmp/net.$netif.did-setup
[ -e /sys/class/net/$netif/address ] && \
[ -z "$DO_VLAN" ] && \
[ -e /sys/class/net/$netif/address ] && \
> /tmp/net.$(cat /sys/class/net/$netif/address).did-setup
}
@@ -211,7 +214,7 @@ set_ifname() {
fix_bootif() {
local macaddr=${1}
local IFS='-'
macaddr=$(for i in ${macaddr} ; do echo -n $i:; done)
macaddr=$(printf '%s:' ${macaddr})
macaddr=${macaddr%:}
# strip hardware type field from pxelinux
[ -n "${macaddr%??:??:??:??:??:??}" ] && macaddr=${macaddr#??:}
@@ -235,22 +238,51 @@ ibft_to_cmdline() {
[ -e /tmp/net.${dev}.has_ibft_config ] && continue
[ -e ${iface}/flags ] && flags=$(read a < ${iface}/flags; echo $a)
# Skip invalid interfaces
(( $flags & 1 )) || continue
[ -e ${iface}/dhcp ] && dhcp=$(read a < ${iface}/dhcp; echo $a)
[ -e ${iface}/origin ] && origin=$(read a < ${iface}/origin; echo $a)
[ -e ${iface}/ip-addr ] && ip=$(read a < ${iface}/ip-addr; echo $a)
if [ -n "$dhcp" ]; then
echo "ip=$dev:dhcp"
if [ -n "$ip" ] ; then
case "$ip" in
*.*.*.*)
family=ipv4
;;
*:*)
family=ipv6
;;
esac
fi
if [ -n "$dhcp" ] || [ "$origin" -eq 3 ]; then
if [ "$family" = "ipv6" ] ; then
echo "ip=$dev:dhcp6"
else
echo "ip=$dev:dhcp"
fi
elif [ -e ${iface}/ip-addr ]; then
[ -e ${iface}/ip-addr ] && ip=$(read a < ${iface}/ip-addr; echo $a)
# skip not assigned ip adresses
[ "$ip" = "0.0.0.0" ] && continue
[ -e ${iface}/gateway ] && gw=$(read a < ${iface}/gateway; echo $a)
[ "$gateway" = "0.0.0.0" ] && unset $gateway
[ -e ${iface}/subnet-mask ] && mask=$(read a < ${iface}/subnet-mask; echo $a)
[ -e ${iface}/prefix-len ] && prefix=$(read a < ${iface}/prefix-len; echo $a)
[ -e ${iface}/primary-dns ] && dns1=$(read a < ${iface}/primary-dns; echo $a)
[ "$dns1" = "0.0.0.0" ] && unset $dns1
[ -e ${iface}/secondary-dns ] && dns2=$(read a < ${iface}/secondary-dns; echo $a)
[ "$dns2" = "0.0.0.0" ] && unset $dns2
[ -e ${iface}/hostname ] && hostname=$(read a < ${iface}/hostname; echo $a)
if [ "$family" = "ipv6" ] ; then
if [ -n "$ip" ] ; then
ip="[$ip]"
[ -n "$prefix" ] || prefix=64
mask="$prefix"
fi
if [ -n "$gw" ] ; then
gw="[${gw}]"
fi
fi
if [ -n "$ip" ] && [ -n "$mask" ]; then
echo "ip=$ip::$gw:$mask:$hostname:$dev:none${dns1:+:$dns1}${dns2:+:$dns2}"
else
@@ -406,50 +438,84 @@ ip_to_var() {
done
unset ip srv gw mask hostname dev autoconf macaddr mtu dns1 dns2
case $# in
0) autoconf="error" ;;
1) autoconf=$1 ;;
2) [ -n "$1" ] && dev=$1; [ -n "$2" ] && autoconf=$2 ;;
3) [ -n "$1" ] && dev=$1; [ -n "$2" ] && autoconf=$2; [ -n "$3" ] && mtu=$3 ;;
4) [ -n "$1" ] && dev=$1; [ -n "$2" ] && autoconf=$2; [ -n "$3" ] && mtu=$3; [ -n "$4" ] && macaddr=$4 ;;
*) [ -n "$1" ] && ip=$1; [ -n "$2" ] && srv=$2; [ -n "$3" ] && gw=$3; [ -n "$4" ] && mask=$4;
[ -n "$5" ] && hostname=$5; [ -n "$6" ] && dev=$6; [ -n "$7" ] && autoconf=$7;
case "$8" in
[0-9]*:*|[0-9]*.[0-9]*.[0-9]*.[0-9]*)
dns1="$8"
[ -n "$9" ] && dns2="$9"
;;
[0-9]*)
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
;;
esac
# ip=<ipv4-address> means anaconda-style static config argument cluster:
# ip=<ip> gateway=<gw> netmask=<nm> hostname=<host> mtu=<mtu>
# ksdevice={link|bootif|ibft|<MAC>|<ifname>}
if strstr "$autoconf" "*.*.*.*"; then
ip="$autoconf"
gw=$(getarg gateway=)
mask=$(getarg netmask=)
hostname=$(getarg hostname=)
dev=$(getarg ksdevice=)
autoconf="none"
mtu=$(getarg mtu=)
# handle special values for ksdevice
case "$dev" in
bootif|BOOTIF) dev=$(fix_bootif $(getarg BOOTIF=)) ;;
link) dev="" ;; # FIXME: do something useful with this
ibft) dev="" ;; # ignore - ibft is handled elsewhere
esac
if [ $# -eq 0 ]; then
autoconf="error"
return 0
fi
if [ $# -eq 1 ]; then
# format: ip={dhcp|on|any|dhcp6|auto6}
# or
# ip=<ipv4-address> means anaconda-style static config argument cluster
autoconf="$1"
if strstr "$autoconf" "*.*.*.*"; then
# ip=<ipv4-address> means anaconda-style static config argument cluster:
# ip=<ip> gateway=<gw> netmask=<nm> hostname=<host> mtu=<mtu>
# ksdevice={link|bootif|ibft|<MAC>|<ifname>}
ip="$autoconf"
gw=$(getarg gateway=)
mask=$(getarg netmask=)
hostname=$(getarg hostname=)
dev=$(getarg ksdevice=)
autoconf="none"
mtu=$(getarg mtu=)
# handle special values for ksdevice
case "$dev" in
bootif|BOOTIF) dev=$(fix_bootif $(getarg BOOTIF=)) ;;
link) dev="" ;; # FIXME: do something useful with this
ibft) dev="" ;; # ignore - ibft is handled elsewhere
esac
fi
return 0
fi
if [ "$2" = "dhcp" -o "$2" = "on" -o "$2" = "any" -o "$2" = "dhcp6" -o "$2" = "auto6" ]; then
# format: ip=<interface>:{dhcp|on|any|dhcp6|auto6}[:[<mtu>][:<macaddr>]]
[ -n "$1" ] && dev="$1"
[ -n "$2" ] && autoconf="$2"
[ -n "$3" ] && mtu=$3
if [ -z "$5" ]; then
macaddr="$4"
else
macaddr="${4}:${5}:${6}:${7}:${8}:${9}"
fi
return 0
fi
# format: ip=<client-IP>:[<peer>]:<gateway-IP>:<netmask>:<client_hostname>:<interface>:{none|off|dhcp|on|any|dhcp6|auto6|ibft}:[:[<mtu>][:<macaddr>]]
[ -n "$1" ] && ip=$1
[ -n "$2" ] && srv=$2
[ -n "$3" ] && gw=$3
[ -n "$4" ] && mask=$4
[ -n "$5" ] && hostname=$5
[ -n "$6" ] && dev=$6
[ -n "$7" ] && autoconf=$7
case "$8" in
[0-9]*:*|[0-9]*.[0-9]*.[0-9]*.[0-9]*)
dns1="$8"
[ -n "$9" ] && dns2="$9"
;;
[0-9]*)
mtu="$8"
if [ -n "${9}" -a -z "${10}" ]; then
macaddr="${9}"
elif [ -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
;;
*)
if [ -n "${9}" -a -z "${10}" ]; then
macaddr="${9}"
elif [ -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
return 0
}
route_to_var() {
@@ -489,8 +555,13 @@ parse_ifname_opts() {
# udev requires MAC addresses to be lower case
ifname_mac=$(echo $2:$3:$4:$5:$6:$7 | sed 'y/ABCDEF/abcdef/')
;;
21)
# infiniband MAC addrs are 20 bytes long not 6
ifname_if=$1
ifname_mac=$(echo $2:$3:$4:$5:$6:$7:$8:$9:$10:$11:$12:13:$14:$15$16:$17:$18:$19:$20:$21 | sed 'y/ABCDEF/abcdef/')
;;
*)
die "Invalid arguments for ifname="
die "Invalid arguments for ifname=$1"
;;
esac
@@ -499,7 +570,7 @@ parse_ifname_opts() {
warn "ifname=$ifname_if uses the kernel name space for interfaces"
warn "This can fail for multiple network interfaces and is discouraged!"
warn "Please use a custom name like \"netboot\" or \"bluesocket\""
warn "or use biosdevname and no ifname= at all."
warn "or use the persistent interface names from udev or biosdevname and no ifname= at all."
;;
esac
@@ -531,22 +602,20 @@ wait_for_if_up() {
while [ $cnt -lt $timeout ]; do
li=$(ip -o link show up dev $1)
if ! strstr "$li" "NO-CARRIER"; then
if [ -n "$li" ]; then
case "$li" in
*\<UP*)
return 0;;
*\<*,UP\>*)
return 0;;
*\<*,UP,*\>*)
return 0;;
esac
fi
if strstr "$li" "LOWER_UP" \
&& strstr "$li" "state UNKNOWN" \
&& ! strstr "$li" "DORMANT"; then
return 0
fi
if [ -n "$li" ]; then
case "$li" in
*\<UP*)
return 0;;
*\<*,UP\>*)
return 0;;
*\<*,UP,*\>*)
return 0;;
esac
fi
if strstr "$li" "LOWER_UP" \
&& strstr "$li" "state UNKNOWN" \
&& ! strstr "$li" "DORMANT"; then
return 0
fi
sleep 0.1
cnt=$(($cnt+1))
@@ -569,16 +638,34 @@ wait_for_route_ok() {
return 1
}
wait_for_ipv6_dad() {
wait_for_ipv6_dad_link() {
local cnt=0
local li
local timeout="$(getargs rd.net.timeout.ipv6dad=)"
timeout=${timeout:-50}
timeout=$(($timeout*10))
while [ $cnt -lt $timeout ]; do
li=$(ip -6 addr show dev $1 scope link)
strstr "$li" "tentative" || return 0
[ -z "$(ip -6 addr show dev "$1" scope link tentative)" ] \
&& return 0
[ -n "$(ip -6 addr show dev "$1" scope link dadfailed)" ] \
&& return 1
sleep 0.1
cnt=$(($cnt+1))
done
return 1
}
wait_for_ipv6_dad() {
local cnt=0
local timeout="$(getargs rd.net.timeout.ipv6dad=)"
timeout=${timeout:-50}
timeout=$(($timeout*10))
while [ $cnt -lt $timeout ]; do
[ -z "$(ip -6 addr show dev "$1" tentative)" ] \
&& return 0
[ -n "$(ip -6 addr show dev "$1" dadfailed)" ] \
&& return 1
sleep 0.1
cnt=$(($cnt+1))
done
@@ -587,16 +674,14 @@ wait_for_ipv6_dad() {
wait_for_ipv6_auto() {
local cnt=0
local li
local timeout="$(getargs rd.net.timeout.ipv6auto=)"
timeout=${timeout:-40}
timeout=$(($timeout*10))
while [ $cnt -lt $timeout ]; do
li=$(ip -6 addr show dev $1)
if ! strstr "$li" "tentative"; then
strstr "$li" "dynamic" && return 0
fi
[ -z "$(ip -6 addr show dev "$1" tentative)" ] \
&& [ -n "$(ip -6 route list proto ra dev "$1")" ] \
&& return 0
sleep 0.1
cnt=$(($cnt+1))
done
@@ -614,7 +699,7 @@ hostname() {
cat /proc/sys/kernel/hostname
}
iface_has_link() {
iface_has_carrier() {
local cnt=0
local interface="$1" flags=""
[ -n "$interface" ] || return 2
@@ -625,14 +710,27 @@ iface_has_link() {
timeout=$(($timeout*10))
linkup "$1"
li=$(ip -o link show up dev $1)
strstr "$li" "NO-CARRIER" && _no_carrier_flag=1
while [ $cnt -lt $timeout ]; do
[ "$(cat $interface/carrier)" = 1 ] && return 0
if [ -n "$_no_carrier_flag" ]; then
# NO-CARRIER flag was cleared
strstr "$li" "NO-CARRIER" || return 0
fi
# double check the syscfs carrier flag
[ -e "$interface/carrier" ] && [ "$(cat $interface/carrier)" = 1 ] && return 0
sleep 0.1
cnt=$(($cnt+1))
done
return 1
}
iface_has_link() {
iface_has_carrier "$@"
}
find_iface_with_link() {
local iface_path="" iface=""
for iface_path in /sys/class/net/*; do

View File

@@ -10,14 +10,6 @@
# bond without parameters assumes bond=bond0:eth0,eth1:mode=balance-rr
#
# return if bond already parsed
[ -n "$bondname" ] && return
# Check if bond parameter is valid
if getarg bond= >/dev/null ; then
:
fi
# We translate list of slaves to space-separated here to mwke it easier to loop over them in ifup
# Ditto for bonding options
parsebond() {
@@ -28,7 +20,6 @@ parsebond() {
v=${v#*:}
done
unset bondname bondslaves bondoptions
case $# in
0) bondname=bond0; bondslaves="eth0 eth1" ;;
1) bondname=$1; bondslaves="eth0 eth1" ;;
@@ -38,14 +29,13 @@ parsebond() {
esac
}
unset bondname bondslaves bondoptions
# Parse bond for bondname, bondslaves, bondmode and bondoptions
if getarg bond >/dev/null; then
# Read bond= parameters if they exist
bond="$(getarg bond=)"
if [ ! "$bond" = "bond" ]; then
parsebond "$(getarg bond=)"
for bond in $(getargs bond=); do
unset bondname
unset bondslaves
unset bondoptions
if [ "$bond" != "bond" ]; then
parsebond "$bond"
fi
# Simple default bond
if [ -z "$bondname" ]; then
@@ -57,5 +47,4 @@ if getarg bond >/dev/null; then
echo "bondname=$bondname" > /tmp/bond.${bondname}.info
echo "bondslaves=\"$bondslaves\"" >> /tmp/bond.${bondname}.info
echo "bondoptions=\"$bondoptions\"" >> /tmp/bond.${bondname}.info
return
fi
done

View File

@@ -1,6 +1,4 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
#
# Format:
# bridge=<bridgename>:<bridgeslaves>
@@ -9,14 +7,6 @@
# bridge without parameters assumes bridge=br0:eth0
#
# return if bridge already parsed
[ -n "$bridgename" ] && return
# Check if bridge parameter is valid
if getarg bridge= >/dev/null ; then
command -v brctl >/dev/null 2>&1 || die "No 'brctl' installed"
fi
parsebridge() {
local v=${1}:
set --
@@ -24,8 +14,6 @@ parsebridge() {
set -- "$@" "${v%%:*}"
v=${v#*:}
done
unset bridgename bridgeslaves
case $# in
0) bridgename=br0; bridgeslaves=$iface ;;
1) die "bridge= requires two parameters" ;;
@@ -34,14 +22,13 @@ parsebridge() {
esac
}
unset bridgename bridgeslaves
iface=eth0
# Parse bridge for bridgename and bridgeslaves
if bridge="$(getarg bridge)"; then
for bridge in $(getargs bridge=); do
unset bridgename
unset bridgeslaves
iface=eth0
# Read bridge= parameters if they exist
if [ -n "$bridge" ]; then
if [ "$bridge" != "bridge" ]; then
parsebridge $bridge
fi
# Simple default bridge
@@ -49,7 +36,6 @@ if bridge="$(getarg bridge)"; then
bridgename=br0
bridgeslaves=$iface
fi
echo "bridgename=$bridgename" > /tmp/bridge.info
echo "bridgeslaves=\"$bridgeslaves\"" >> /tmp/bridge.info
return
fi
echo "bridgename=$bridgename" > /tmp/bridge.${bridgename}.info
echo "bridgeslaves=\"$bridgeslaves\"" >> /tmp/bridge.${bridgename}.info
done

View File

@@ -38,10 +38,12 @@ unset count
# If needed, check if bootdev= contains anything usable
BOOTDEV=$(getarg bootdev=)
if [ -n "$NEEDBOOTDEV" ] && getargbool 1 rd.neednet; then
if [ -n "$NEEDBOOTDEV" ] && ! getargbool 0 rd.neednet; then
#[ -z "$BOOTDEV" ] && warn "Please supply bootdev argument for multiple ip= lines"
echo "rd.neednet=1" > /etc/cmdline.d/dracut-neednet.conf
info "Multiple ip= arguments: assuming rd.neednet=1"
else
unset NEEDBOOTDEV
fi
# Check ip= lines
@@ -50,17 +52,14 @@ for p in $(getargs ip=); do
ip_to_var $p
# make first device specified the BOOTDEV
if [ -z "$BOOTDEV" ] && [ -n "$dev" ]; then
if [ -n "$NEEDBOOTDEV" ] && [ -z "$BOOTDEV" ] && [ -n "$dev" ]; then
BOOTDEV="$dev"
[ -n "$NEEDBOOTDEV" ] && info "Setting bootdev to '$BOOTDEV'"
info "Setting bootdev to '$BOOTDEV'"
fi
# skip ibft since we did it above
[ "$autoconf" = "ibft" ] && continue
# We need to have an ip= line for the specified bootdev
[ -n "$NEEDBOOTDEV" ] && [ "$dev" = "$BOOTDEV" ] && BOOTDEVOK=1
# Empty autoconf defaults to 'dhcp'
if [ -z "$autoconf" ] ; then
warn "Empty autoconf values default to dhcp"
@@ -80,8 +79,8 @@ for p in $(getargs ip=); do
;;
auto6);;
dhcp|dhcp6|on|any) \
[ -n "$NEEDBOOTDEV" ] && [ -z "$dev" ] && \
die "Sorry, 'ip=$p' does not make sense for multiple interface configurations"
#[ -n "$NEEDBOOTDEV" ] && [ -z "$dev" ] && \
# die "Sorry, 'ip=$p' does not make sense for multiple interface configurations"
[ -n "$ip" ] && \
die "For argument 'ip=$p'\nSorry, setting client-ip does not make sense for '$autoopt'"
;;

View File

@@ -6,14 +6,6 @@
# 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 --
@@ -22,33 +14,22 @@ parseteam() {
v=${v#*:}
done
unset teammaster teamslaves
case $# in
2) teammaster=$1; teamslaves=$(str_replace "$2" "," " ") ;;
*) warn "team= requires two parameters"; return 1;;
2) teammaster=$1; teamslaves=$(str_replace "$2" "," " ") ;;
*) die "team= requires two parameters" ;;
esac
return 0
}
unset teammaster teamslaves
if getarg team>/dev/null; then
# Read team= parameters if they exist
for team in $(getargs team); do
[ "$team" = "team" ] && continue
for team in $(getargs team=); do
unset teammaster teamslaves
parseteam "$(getarg team=)"
unset teammaster
unset teamslaves
parseteam "$team" || continue
echo "teammaster=$teammaster" > /tmp/team.${teammaster}.info
echo "teamslaves=\"$teamslaves\"" >> /tmp/team.${teammaster}.info
if ! [ -e /etc/teamd/${teammaster}.conf ]; then
warn "Team master $teammaster specified, but no /etc/teamd/$teammaster.conf present. Using activebackup."
mkdir -p /etc/teamd
printf -- "%s" '{"runner": {"name": "activebackup"}, "link_watch": {"name": "ethtool"}}' > "/etc/teamd/${teammaster}.conf"
fi
done
fi
echo "teammaster=$teammaster" > /tmp/team.${teammaster}.info
echo "teamslaves=\"$teamslaves\"" >> /tmp/team.${teammaster}.info
if ! [ -e /etc/teamd/${teammaster}.conf ]; then
warn "Team master $teammaster specified, but no /etc/teamd/$teammaster.conf present. Using activebackup."
mkdir -p /etc/teamd
printf -- "%s" '{"runner": {"name": "activebackup"}, "link_watch": {"name": "ethtool"}}' > "/etc/teamd/${teammaster}.conf"
fi
done

View File

@@ -4,14 +4,6 @@
# vlan=<vlanname>:<phydevice>
#
# return if vlan already parsed
[ -n "$vlanname" ] && return
# Check if vlan parameter is valid
if getarg vlan= >/dev/null ; then
:
fi
parsevlan() {
local v=${1}:
set --
@@ -27,16 +19,11 @@ parsevlan() {
esac
}
unset vlanname phydevice
for vlan in $(getargs vlan=); do
unset vlanname
unset phydevice
parsevlan "$vlan"
if getarg vlan >/dev/null; then
# Read vlan= parameters if they exist
vlan="$(getarg vlan=)"
if [ ! "$vlan" = "vlan" ]; then
parsevlan "$(getarg vlan=)"
fi
echo "vlanname=\"$vlanname\"" > /tmp/vlan.info
echo "phydevice=\"$phydevice\"" >> /tmp/vlan.info
return
fi
echo "$phydevice" > /tmp/vlan.${phydevice}.phy
echo "$vlanname" > /tmp/vlan.${vlanname}.${phydevice}
done

View File

@@ -7,14 +7,6 @@ type is_persistent_ethernet_name >/dev/null 2>&1 || . /lib/net-lib.sh
udevadm settle --timeout=30
if [ -e /tmp/bridge.info ]; then
. /tmp/bridge.info
fi
if [ -e /tmp/vlan.info ]; then
. /tmp/vlan.info
fi
mkdir -m 0755 -p /tmp/ifcfg/
mkdir -m 0755 -p /tmp/ifcfg-leases/
@@ -24,7 +16,7 @@ get_config_line_by_subchannel()
local line
CHANNELS="$1"
while read line; do
while read line || [ -n "$line" ]; do
if strstr "$line" "$CHANNELS"; then
echo $line
return 0
@@ -50,7 +42,7 @@ print_s390() {
for i in /sys/class/net/$_netif/device/cdev[0-9]*; do
[ -e $i ] || continue
channel=$(readlink -f $i)
echo -n "${channel##*/},"
printf '%s' "${channel##*/},"
done
})
[ -n "$SUBCHANNELS" ] || return 1
@@ -132,6 +124,8 @@ for netup in /tmp/net.*.did-setup ; do
unset bondslaves
unset bondname
unset bondoptions
unset bridgename
unset bridgeslaves
unset uuid
unset ip
unset gw
@@ -141,9 +135,12 @@ for netup in /tmp/net.*.did-setup ; do
unset slave
unset ethname
unset vlan
unset phydevice
[ -e /tmp/bond.${netif}.info ] && . /tmp/bond.${netif}.info
[ -e /tmp/bridge.${netif}.info ] && . /tmp/bridge.${netif}.info
[ -e /tmp/team.${netif}.info ] && . /tmp/team.${netif}.info
[ -e /tmp/net.${netif}.override ] && . /tmp/net.${netif}.override
uuid=$(cat /proc/sys/kernel/random/uuid)
if [ "$netif" = "$bridgename" ]; then
@@ -151,11 +148,17 @@ for netup in /tmp/net.*.did-setup ; do
elif [ "$netif" = "$teammaster" ]; then
team=yes
elif [ "$netif" = "$bondname" ]; then
# $netif can't be bridge and bond at the same time
# $netif can't be bridge and bond at the same time
bond=yes
fi
if [ "$netif" = "$vlanname" ]; then
vlan=yes
if ! [ -e /tmp/vlan.${netif}.phy ]; then
for i in /tmp/vlan.${netif}.*; do
[ ! -e "$i" ] && continue
phydevice=${i##/tmp/vlan.${netif}.}
vlan=yes
break
done
fi
# skip team interfaces for now, the host config must be in sync
@@ -178,8 +181,6 @@ for netup in /tmp/net.*.did-setup ; do
fi
cp /tmp/dhclient.$netif.lease /tmp/ifcfg-leases/dhclient-$uuid-$netif.lease
else
# If we've booted with static ip= lines, the override file is there
[ -e /tmp/net.$netif.override ] && . /tmp/net.$netif.override
if strstr "$ip" '*:*:*'; then
echo "IPV6INIT=yes"
echo "IPV6_AUTOCONF=no"
@@ -209,10 +210,7 @@ for netup in /tmp/net.*.did-setup ; do
# bridge needs different things written to ifcfg
if [ -z "$bridge" ] && [ -z "$bond" ] && [ -z "$vlan" ] && [ -z "$team" ]; then
# standard interface
{
echo "TYPE=Ethernet"
[ -n "$mtu" ] && echo "MTU=\"$mtu\""
} >> /tmp/ifcfg/ifcfg-$netif
echo "TYPE=Ethernet" >> /tmp/ifcfg/ifcfg-$netif
fi
if [ -n "$vlan" ] ; then
@@ -245,7 +243,7 @@ for netup in /tmp/net.*.did-setup ; do
echo "MASTER=\"$netif\""
echo "UUID=\"$(cat /proc/sys/kernel/random/uuid)\""
unset macaddr
[ -e /tmp/net.$slave.override ] && . /tmp/net.$slave.override
[ -e /tmp/net.${slave}.override ] && . /tmp/net.${slave}.override
interface_bind "$slave" "$macaddr"
) >> /tmp/ifcfg/ifcfg-$slave
done
@@ -268,7 +266,7 @@ for netup in /tmp/net.*.did-setup ; do
echo "BRIDGE=\"$bridgename\""
echo "UUID=\"$(cat /proc/sys/kernel/random/uuid)\""
unset macaddr
[ -e /tmp/net.$slave.override ] && . /tmp/net.$slave.override
[ -e /tmp/net.${slave}.override ] && . /tmp/net.${slave}.override
interface_bind "$slave" "$macaddr"
) >> /tmp/ifcfg/ifcfg-$slave
done

View File

@@ -28,7 +28,7 @@ install() {
_crt=$(grep -F --binary-files=text -z .crt $_lib)
[[ $_crt ]] || continue
[[ $_crt == /*/* ]] || continue
if ! inst_simple "$_crt"; then
if ! inst "$_crt"; then
dwarn "Couldn't install '$_crt' SSL CA cert bundle; HTTPS might not work."
continue
fi

View File

@@ -106,7 +106,7 @@ nfs_fetch_url() {
local filepath="${path%/*}" filename="${path##*/}" mntdir=""
# skip mount if server:/filepath is already mounted
mntdir=$(nfs_already_mounted "$server" "$path")
mntdir=$(nfs_already_mounted "$server" "$filepath")
if [ -z "$mntdir" ]; then
local mntdir="$(mkuniqdir /run nfs_mnt)"
mount_nfs "$nfs:$server:$filepath${options:+:$options}" "$mntdir"

View File

@@ -5,7 +5,7 @@
installkernel() {
if [[ -z $drivers ]]; then
block_module_filter() {
local _blockfuncs='ahci_platform_get_resources|ata_scsi_ioctl|scsi_add_host|blk_cleanup_queue|register_mtd_blktrans|scsi_esp_register|register_virtio_device|usb_stor_disconnect|mmc_add_host|sdhci_pltfm_init'
local _blockfuncs='ahci_platform_get_resources|ata_scsi_ioctl|scsi_add_host|blk_cleanup_queue|register_mtd_blktrans|scsi_esp_register|register_virtio_device|usb_stor_disconnect|mmc_add_host|sdhci_add_host'
# subfunctions inherit following FDs
local _merge=8 _side2=9
function bmf1() {
@@ -52,18 +52,20 @@ installkernel() {
"=drivers/input/serio" \
"=drivers/input/keyboard"
if [[ "$(uname -p)" == arm* ]]; then
# arm specific modules
if [[ "$(uname -m)" == arm* || "$(uname -m)" == aarch64 ]]; then
# arm/aarch64 specific modules
hostonly='' instmods \
connector-hdmi connector-dvi encoder-tfp410 \
encoder-tpd12s015 i2c-tegra gpio-regulator \
as3722-regulator orion-ehci ehci-tegra
instmods \
"=drivers/dma" \
"=drivers/i2c/busses" \
"=drivers/regulator" \
"=drivers/rtc" \
"=drivers/usb/host" \
"=drivers/usb/phy" \
"=drivers/scsi/hisi_sas" \
${NULL}
fi

View File

@@ -17,14 +17,14 @@ SNAPSIZE=$(getargs rd.lvm.snapsize -d rd_LVM_SNAPSIZE=)
lvmdevs=$(
for f in /tmp/.lvm_scan-*; do
[ -e "$f" ] || continue
echo -n "${f##/tmp/.lvm_scan-} "
printf '%s' "${f##/tmp/.lvm_scan-} "
done
)
if [ ! -e /etc/lvm/lvm.conf ]; then
{
echo 'devices {';
echo -n ' filter = [ '
printf ' filter = [ '
for dev in $lvmdevs; do
printf '"a|^/dev/%s$|", ' $dev;
done;

View File

@@ -42,6 +42,10 @@ cmdline() {
done
}
installkernel() {
instmods dm-snapshot
}
# called by dracut
install() {
local _i
@@ -56,13 +60,16 @@ install() {
inst_rules "$moddir/64-lvm.rules"
if [[ $hostonly ]] || [[ $lvmconf = "yes" ]]; then
if [ -f /etc/lvm/lvm.conf ]; then
inst_simple /etc/lvm/lvm.conf
# FIXME: near-term hack to establish read-only locking;
# use command-line lvm.conf editor once it is available
sed -i -e 's/\(^[[:space:]]*\)locking_type[[:space:]]*=[[:space:]]*[[:digit:]]/\1locking_type = 4/' ${initdir}/etc/lvm/lvm.conf
sed -i -e 's/\(^[[:space:]]*\)use_lvmetad[[:space:]]*=[[:space:]]*[[:digit:]]/\1use_lvmetad = 0/' ${initdir}/etc/lvm/lvm.conf
fi
for f in /etc/lvm/lvm.conf /etc/lvm/lvm_*.conf; do
[ -e "$f" ] || continue
inst_simple "$f"
if [ -f "${initdir}/$f" ]; then
# FIXME: near-term hack to establish read-only locking;
# use command-line lvm.conf editor once it is available
sed -i -e 's/\(^[[:space:]]*\)locking_type[[:space:]]*=[[:space:]]*[[:digit:]]/\1locking_type = 4/' "${initdir}/$f"
sed -i -e 's/\(^[[:space:]]*\)use_lvmetad[[:space:]]*=[[:space:]]*[[:digit:]]/\1use_lvmetad = 0/' "${initdir}/$f"
fi
done
fi
if ! [[ -e ${initdir}/etc/lvm/lvm.conf ]]; then

View File

@@ -11,9 +11,10 @@ is_mpath() {
majmin_to_mpath_dev() {
local _dev
for i in `ls -1 /dev/mapper/mpath*`; do
dev=$(get_maj_min $i)
if [ "$dev" = "$1" ]; then
for i in /dev/mapper/*; do
[[ $i == /dev/mapper/control ]] && continue
_dev=$(get_maj_min $i)
if [ "$_dev" = "$1" ]; then
echo $i
return
fi

View File

@@ -4,6 +4,14 @@
# called by dracut
check() {
local _fcoe_ctlr
[[ $hostonly ]] || [[ $mount_needs ]] && {
for c in /sys/bus/fcoe/devices/ctlr_* ; do
[ -L $c ] || continue
_fcoe_ctlr=$c
done
[ -z "$_fcoe_ctlr" ] && return 255
}
[[ $hostonly ]] || [[ $mount_needs ]] && {
[ -d /sys/firmware/efi ] || return 255
}

View File

@@ -13,8 +13,6 @@ PATH=/usr/sbin:/usr/bin:/sbin:/bin
# Huh? Missing arguments ??
[ -z "$1" -o -z "$2" ] && exit 1
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
@@ -22,6 +20,14 @@ netif=$1
dcb=$2
vlan="yes"
iflink=$(cat /sys/class/net/$netif/iflink)
ifindex=$(cat /sys/class/net/$netif/ifindex)
if [ "$iflink" != "$ifindex" ] ; then
# Skip VLAN devices
exit 0
fi
ip link set dev $netif up
linkup "$netif"
netdriver=$(readlink -f /sys/class/net/$netif/device/driver)
@@ -43,10 +49,6 @@ write_fcoemon_cfg() {
}
if [ "$dcb" = "dcb" ]; then
# Note lldpad will stay running after switchroot, the system initscripts
# are to kill it and start a new lldpad to take over. Data is transfered
# between the 2 using a shm segment
lldpad -d
# wait for lldpad to be ready
i=0
while [ $i -lt 60 ]; do
@@ -56,10 +58,6 @@ if [ "$dcb" = "dcb" ]; then
i=$(($i+1))
done
# on some systems lldpad needs some time
# sleep until we find a better solution
sleep 30
while [ $i -lt 60 ]; do
dcbtool sc "$netif" dcb on && break
info "Retrying to turn dcb on"

View File

@@ -0,0 +1,14 @@
#!/bin/bash
# Note lldpad will stay running after switchroot, the system initscripts
# are to kill it and start a new lldpad to take over. Data is transfered
# between the 2 using a shm segment
lldpad -d
# wait for lldpad to be ready
i=0
while [ $i -lt 60 ]; do
lldptool -p && break
info "Waiting for lldpad to be ready"
sleep 1
i=$(($i+1))
done

View File

@@ -3,7 +3,17 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
local _fcoe_ctlr
[[ $hostonly ]] || [[ $mount_needs ]] && {
for c in /sys/bus/fcoe/devices/ctlr_* ; do
[ -L $c ] || continue
_fcoe_ctlr=$c
done
[ -z "$_fcoe_ctlr" ] && return 255
}
require_binaries dcbtool fipvlan lldpad ip readlink fcoemon fcoeadm || return 1
return 0
}
@@ -16,17 +26,62 @@ installkernel() {
instmods fcoe 8021q edd
}
get_vlan_parent() {
local link=$1
[ -d $link ] || return
read iflink < $link/iflink
for if in /sys/class/net/* ; do
read idx < $if/ifindex
if [ $idx -eq $iflink ] ; then
echo ${if##*/}
fi
done
}
# called by dracut
cmdline() {
for c in /sys/bus/fcoe/devices/ctlr_* ; do
[ -L $c ] || continue
read enabled < $c/enabled
[ $enabled -eq 0 ] && continue
d=$(cd -P $c; echo $PWD)
i=${d%/*}
read mac < ${i}/address
s=$(dcbtool gc ${i##*/} dcb | sed -n 's/^DCB State:\t*\(.*\)/\1/p')
if [ -z "$s" ] ; then
p=$(get_vlan_parent ${i})
if [ "$p" ] ; then
s=$(dcbtool gc ${p} dcb | sed -n 's/^DCB State:\t*\(.*\)/\1/p')
fi
fi
if [ "$s" = "on" ] ; then
dcb="dcb"
else
dcb="nodcb"
fi
echo "fcoe=${mac}:${dcb}"
done
}
# called by dracut
install() {
inst_multiple ip dcbtool fipvlan lldpad readlink lldptool fcoemon fcoeadm
inst_libdir_file 'libhbalinux.so*'
inst "/etc/hba.conf" "/etc/hba.conf"
[[ -e /etc/hba.conf ]] && inst "/etc/hba.conf" "/etc/hba.conf"
mkdir -m 0755 -p "$initdir/var/lib/lldpad"
mkdir -m 0755 -p "$initdir/etc/fcoe"
if [[ $hostonly_cmdline == "yes" ]] ; then
local _fcoeconf=$(cmdline)
[[ $_fcoeconf ]] && printf "%s\n" "$_fcoeconf" >> "${initdir}/etc/cmdline.d/95fcoe.conf"
fi
inst "$moddir/fcoe-up.sh" "/sbin/fcoe-up"
inst "$moddir/fcoe-edd.sh" "/sbin/fcoe-edd"
inst "$moddir/fcoe-genrules.sh" "/sbin/fcoe-genrules.sh"
inst_hook pre-trigger 03 "$moddir/lldpad.sh"
inst_hook cmdline 99 "$moddir/parse-fcoe.sh"
inst_hook cleanup 90 "$moddir/cleanup-fcoe.sh"
dracut_need_initqueue

View File

@@ -22,17 +22,15 @@
# BRCM: Later, should check whether bnx2x is loaded first before loading bnx2fc so do not load bnx2fc when there are no Broadcom adapters
[ -e /sys/bus/fcoe/ctlr_create ] || modprobe -a fcoe || die "FCoE requested but kernel/initrd does not support FCoE"
[ -e /sys/bus/fcoe/ctlr_create ] || modprobe -b -a fcoe || die "FCoE requested but kernel/initrd does not support FCoE"
modprobe bnx2fc >/dev/null 2>&1
udevadm settle --timeout=30
# FCoE actually supported?
[ -e /sys/bus/fcoe/ctlr_create ] || modprobe fcoe || die "FCoE requested but kernel/initrd does not support FCoE"
initqueue --onetime modprobe -b -q bnx2fc
parse_fcoe_opts() {
local OLDIFS="$IFS"
local IFS=:
set $fcoe
IFS="$OLDIFS"
case $# in
2)

View File

@@ -78,23 +78,23 @@ handle_netroot()
# override conf settings by command line options
arg=$(getargs rd.iscsi.initiator -d iscsi_initiator=)
[ -n "$arg" ] && iscsi_initiator=$arg
[ -n "$arg" ] && iscsi_initiator="$arg"
arg=$(getargs rd.iscsi.target.name -d iscsi_target_name=)
[ -n "$arg" ] && iscsi_target_name=$arg
[ -n "$arg" ] && iscsi_target_name="$arg"
arg=$(getargs rd.iscsi.target.ip -d iscsi_target_ip)
[ -n "$arg" ] && iscsi_target_ip=$arg
[ -n "$arg" ] && iscsi_target_ip="$arg"
arg=$(getargs rd.iscsi.target.port -d iscsi_target_port=)
[ -n "$arg" ] && iscsi_target_port=$arg
[ -n "$arg" ] && iscsi_target_port="$arg"
arg=$(getargs rd.iscsi.target.group -d iscsi_target_group=)
[ -n "$arg" ] && iscsi_target_group=$arg
[ -n "$arg" ] && iscsi_target_group="$arg"
arg=$(getargs rd.iscsi.username -d iscsi_username=)
[ -n "$arg" ] && iscsi_username=$arg
[ -n "$arg" ] && iscsi_username="$arg"
arg=$(getargs rd.iscsi.password -d iscsi_password)
[ -n "$arg" ] && iscsi_password=$arg
[ -n "$arg" ] && iscsi_password="$arg"
arg=$(getargs rd.iscsi.in.username -d iscsi_in_username=)
[ -n "$arg" ] && iscsi_in_username=$arg
[ -n "$arg" ] && iscsi_in_username="$arg"
arg=$(getargs rd.iscsi.in.password -d iscsi_in_password=)
[ -n "$arg" ] && iscsi_in_password=$arg
[ -n "$arg" ] && iscsi_in_password="$arg"
for p in $(getargs rd.iscsi.param -d iscsi_param); do
iscsi_param="$iscsi_param --param $p"
done
@@ -109,9 +109,9 @@ handle_netroot()
# XXX is this needed?
getarg ro && iscsirw=ro
getarg rw && iscsirw=rw
fsopts=${fsopts:+$fsopts,}${iscsirw}
fsopts="${fsopts:+$fsopts,}${iscsirw}"
if [ -z $iscsi_initiator ] && [ -f /sys/firmware/ibft/initiator/initiator-name ] && ! [ -f /tmp/iscsi_set_initiator ]; then
if [ -z "$iscsi_initiator" ] && [ -f /sys/firmware/ibft/initiator/initiator-name ] && ! [ -f /tmp/iscsi_set_initiator ]; then
iscsi_initiator=$(while read line || [ -n "$line" ]; do echo $line;done < /sys/firmware/ibft/initiator/initiator-name)
echo "InitiatorName=$iscsi_initiator" > /run/initiatorname.iscsi
rm -f /etc/iscsi/initiatorname.iscsi
@@ -122,14 +122,14 @@ handle_netroot()
> /tmp/iscsi_set_initiator
fi
if [ -z $iscsi_initiator ]; then
if [ -z "$iscsi_initiator" ]; then
[ -f /run/initiatorname.iscsi ] && . /run/initiatorname.iscsi
[ -f /etc/initiatorname.iscsi ] && . /etc/initiatorname.iscsi
[ -f /etc/iscsi/initiatorname.iscsi ] && . /etc/iscsi/initiatorname.iscsi
iscsi_initiator=$InitiatorName
fi
if [ -z $iscsi_initiator ]; then
if [ -z "$iscsi_initiator" ]; then
iscsi_initiator=$(iscsi-iname)
echo "InitiatorName=$iscsi_initiator" > /run/initiatorname.iscsi
rm -f /etc/iscsi/initiatorname.iscsi
@@ -182,17 +182,18 @@ handle_netroot()
if [ "$status" != "activating" ] && ! systemctl is-failed "$netroot_enc" >/dev/null 2>&1; then
systemd-run --service-type=oneshot --remain-after-exit --quiet \
--description="Login iSCSI Target $iscsi_target_name" \
-p 'DefaultDependencies=no' \
--unit="$netroot_enc" -- \
$(command -v iscsistart) \
-i $iscsi_initiator -t $iscsi_target_name \
-g $iscsi_target_group -a $iscsi_target_ip \
-p $iscsi_target_port \
${iscsi_username:+-u $iscsi_username} \
${iscsi_password:+-w $iscsi_password} \
${iscsi_in_username:+-U $iscsi_in_username} \
${iscsi_in_password:+-W $iscsi_in_password} \
${iscsi_iface_name:+--param iface.iscsi_ifacename=$iscsi_iface_name} \
${iscsi_netdev_name:+--param iface.net_ifacename=$iscsi_netdev_name} \
-i "$iscsi_initiator" -t "$iscsi_target_name" \
-g "$iscsi_target_group" -a "$iscsi_target_ip" \
-p "$iscsi_target_port" \
${iscsi_username:+-u "$iscsi_username"} \
${iscsi_password:+-w "$iscsi_password"} \
${iscsi_in_username:+-U "$iscsi_in_username"} \
${iscsi_in_password:+-W "$iscsi_in_password"} \
${iscsi_iface_name:+--param "iface.iscsi_ifacename=$iscsi_iface_name"} \
${iscsi_netdev_name:+--param "iface.net_ifacename=$iscsi_netdev_name"} \
${iscsi_param} >/dev/null 2>&1 \
&& { > $hookdir/initqueue/work ; }
else
@@ -201,15 +202,15 @@ handle_netroot()
fi
fi
else
iscsistart -i $iscsi_initiator -t $iscsi_target_name \
-g $iscsi_target_group -a $iscsi_target_ip \
-p $iscsi_target_port \
${iscsi_username:+-u $iscsi_username} \
${iscsi_password:+-w $iscsi_password} \
${iscsi_in_username:+-U $iscsi_in_username} \
${iscsi_in_password:+-W $iscsi_in_password} \
${iscsi_iface_name:+--param iface.iscsi_ifacename=$iscsi_iface_name} \
${iscsi_netdev_name:+--param iface.net_ifacename=$iscsi_netdev_name} \
iscsistart -i "$iscsi_initiator" -t "$iscsi_target_name" \
-g "$iscsi_target_group" -a "$iscsi_target_ip" \
-p "$iscsi_target_port" \
${iscsi_username:+-u "$iscsi_username"} \
${iscsi_password:+-w "$iscsi_password"} \
${iscsi_in_username:+-U "$iscsi_in_username"} \
${iscsi_in_password:+-W "$iscsi_in_password"} \
${iscsi_iface_name:+--param "iface.iscsi_ifacename=$iscsi_iface_name"} \
${iscsi_netdev_name:+--param "iface.net_ifacename=$iscsi_netdev_name"} \
${iscsi_param} \
&& { > $hookdir/initqueue/work ; }
fi

View File

@@ -29,6 +29,46 @@ check() {
return 0
}
get_ibft_mod() {
local ibft_mac=$1
local iface_mac iface_mod
# Return the iSCSI offload module for a given MAC address
for iface_desc in $(iscsiadm -m iface | cut -f 2 -d ' '); do
iface_mod=${iface_desc%%,*}
iface_mac=${iface_desc#*,}
iface_mac=${iface_mac%%,*}
if [ "$ibft_mac" = "$iface_mac" ] ; then
echo $iface_mod
return 0
fi
done
}
install_ibft() {
# When iBFT / iscsi_boot is detected:
# - Use 'ip=ibft' to set up iBFT network interface
# Note: bnx2i is using a different MAC address of iSCSI offloading
# so the 'ip=ibft' parameter must not be set
# - specify firmware booting cmdline parameter
for d in /sys/firmware/* ; do
if [ -d ${d}/ethernet0 ] ; then
read ibft_mac < ${d}/ethernet0/mac
ibft_mod=$(get_ibft_mod $ibft_mac)
fi
if [ -z "$ibft_mod" ] && [ -d ${d}/ethernet1 ] ; then
read ibft_mac < ${d}/ethernet1/mac
ibft_mod=$(get_ibft_mod $ibft_mac)
fi
if [ -d ${d}/initiator ] ; then
if [ ${d##*/} = "ibft" ] && [ "$ibft_mod" != "bnx2i" ] ; then
echo -n "ip=ibft "
fi
echo -n "rd.iscsi.firmware=1"
fi
done
}
depends() {
echo network rootfs-block
}
@@ -75,9 +115,22 @@ installkernel() {
| iscsi_module_filter | instmods
}
cmdline() {
install_ibft
}
# called by dracut
install() {
inst_multiple umount iscsistart hostname iscsi-iname
inst_multiple -o iscsiuio
inst_libdir_file 'libgcc_s.so*'
# Detect iBFT and perform mandatory steps
if [[ $hostonly_cmdline == "yes" ]] ; then
local _ibftconf=$(install_ibft)
[[ $_ibftconf ]] && printf "%s\n" "$_ibftconf" >> "${initdir}/etc/cmdline.d/95iscsi.conf"
fi
inst_hook cmdline 90 "$moddir/parse-iscsiroot.sh"
inst_hook cleanup 90 "$moddir/cleanup-iscsi.sh"
inst "$moddir/iscsiroot.sh" "/sbin/iscsiroot"

View File

@@ -89,16 +89,11 @@ if [ -z "$netroot" ] || ! [ "${netroot%%:*}" = "iscsi" ]; then
fi
initqueue --unique --onetime --timeout /sbin/iscsiroot timeout "$netroot" "$NEWROOT"
modprobe -b -q qla4xxx
modprobe -b -q cxgb3i
modprobe -b -q cxgb4i
modprobe -b -q bnx2i
modprobe -b -q be2iscsi
initqueue --onetime modprobe --all -b -q qla4xxx cxgb3i cxgb4i bnx2i be2iscsi
# ISCSI actually supported?
if ! [ -e /sys/module/iscsi_tcp ]; then
modprobe -q iscsi_tcp || die "iscsiroot requested but kernel/initrd does not support iscsi"
modprobe -b -q iscsi_tcp || die "iscsiroot requested but kernel/initrd does not support iscsi"
fi
if [ -n "$netroot" ] && [ "$root" != "/dev/root" ] && [ "$root" != "dhcp" ]; then

View File

@@ -4,8 +4,6 @@
check() {
local _rootdev
# If our prerequisites are not met, fail.
require_binaries nbd-client || return 1
# if an nbd device is not somewhere in the chain of devices root is
# mounted on, fail the hostonly check.
@@ -16,6 +14,7 @@ check() {
[[ -b /dev/block/$_rootdev ]] || return 1
check_block_and_slaves is_nbd "$_rootdev" || return 255
}
require_binaries nbd-client || return 1
return 0
}

View File

@@ -25,7 +25,7 @@ depends() {
}
installkernel() {
instmods nfs sunrpc ipv6 nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files
hostonly='' instmods =net/sunrpc =fs/nfs ipv6 nfs_acl nfs_layout_nfsv41_files
}
install() {

View File

@@ -44,10 +44,17 @@ inst_sshenv()
if [[ -f /etc/ssh/ssh_config ]]; then
inst_simple /etc/ssh/ssh_config
sed -i -e 's/\(^[[:space:]]*\)ProxyCommand/\1# ProxyCommand/' ${initdir}/etc/ssh/ssh_config
while read key val; do
[[ $key != "GlobalKnownHostsFile" ]] && continue
inst_simple "$val"
break
while read key val || [ -n "$key" ]; do
if [[ $key == "GlobalKnownHostsFile" ]]; then
inst_simple "$val"
# Copy customized UserKnowHostsFile
elif [[ $key == "UserKnownHostsFile" ]]; then
# Make sure that ~/foo will be copied as /root/foo in kdump's initramfs
if str_starts "$val" "~/"; then
val="/root/${val#"~/"}"
fi
inst_simple "$val"
fi
done < /etc/ssh/ssh_config
fi

View File

@@ -27,6 +27,7 @@ install() {
fi
inst_rules \
40-redhat-cpu-hotplug.rules \
40-redhat.rules \
50-firmware.rules \
50-udev-default.rules \

View File

@@ -37,5 +37,10 @@ installkernel() {
install() {
inst_hook cmdline 95 "$moddir/parse-virtfs.sh"
inst_hook mount 99 "$moddir/mount-virtfs.sh"
if ! dracut_module_included "systemd"; then
inst_hook mount 99 "$moddir/mount-virtfs.sh"
else
inst_script "$moddir/virtfs-generator.sh" $systemdutildir/system-generators/dracut-virtfs-generator
fi
}

View File

@@ -3,7 +3,7 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
if [ "${root%%:*}" = "virtfs" ] ; then
modprobe 9pnet_virtio
initqueue --onetime modprobe -b -q 9pnet_virtio
rootok=1
fi

View File

@@ -0,0 +1,39 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
[ -z "$root" ] && root=$(getarg root=)
[ "${root%%:*}" = "virtfs" ] || exit 0
GENERATOR_DIR="$2"
[ -z "$GENERATOR_DIR" ] && exit 1
[ -d "$GENERATOR_DIR" ] || mkdir "$GENERATOR_DIR"
ROOTFLAGS=$(getarg rootflags=) || ROOTFLAGS="trans=virtio,version=9p2000.L"
ROOTFSTYPE=$(getarg rootfstype=) || ROOTFSTYPE="9p"
root=${root#virtfs:}
if getarg "ro"; then
if [ -n "$ROOTFLAGS" ]; then
ROOTFLAGS="$ROOTFLAGS,ro"
else
ROOTFLAGS="ro"
fi
fi
{
echo "[Unit]"
echo "Before=initrd-root-fs.target"
echo "[Mount]"
echo "Where=/sysroot"
echo "What=${root}"
[ -n "$ROOTFSTYPE" ] && echo "Type=${ROOTFSTYPE}"
[ -n "$ROOTFLAGS" ] && echo "Options=${ROOTFLAGS}"
} > "$GENERATOR_DIR"/sysroot.mount
exit 0

View File

@@ -15,6 +15,7 @@ After=systemd-journald.socket
Wants=systemd-journald.socket
ConditionPathExists=/etc/initrd-release
ConditionKernelCommandLine=rd.cmdline=ask
Conflicts=shutdown.target emergency.target
[Service]
Environment=DRACUT_SYSTEMD=1

View File

@@ -20,6 +20,7 @@ ConditionDirectoryNotEmpty=|/lib/dracut/hooks/cmdline
ConditionKernelCommandLine=|rd.break=cmdline
ConditionKernelCommandLine=|resume
ConditionKernelCommandLine=|noresume
Conflicts=shutdown.target emergency.target
[Service]
Environment=DRACUT_SYSTEMD=1

View File

@@ -22,7 +22,12 @@ getargbool 0 rd.udev.log-priority=debug -d rd.udev.debug -d -n -y rdudevdebug &&
source_conf /etc/conf.d
root=$(getarg root=)
# Get the "root=" parameter from the kernel command line, but differentiate
# between the case where it was set to the empty string and the case where it
# wasn't specified at all.
if ! root="$(getarg root=)"; then
root_unset='UNSET'
fi
rflags="$(getarg rootflags=)"
getargbool 0 ro && rflags="${rflags},ro"
@@ -38,14 +43,14 @@ export root
export rflags
export fstype
make_trace_mem "hook cmdline" '1+:mem' '1+:iomem' '3+:slab'
make_trace_mem "hook cmdline" '1+:mem' '1+:iomem' '3+:slab' '4+:komem'
# run scriptlets to parse the command line
getarg 'rd.break=cmdline' -d 'rdbreak=cmdline' && emergency_shell -n cmdline "Break before cmdline"
source_hook cmdline
[ -f /lib/dracut/parse-resume.sh ] && . /lib/dracut/parse-resume.sh
case "$root" in
case "${root}${root_unset}" in
block:LABEL=*|LABEL=*)
root="${root#block:}"
root="$(echo $root | sed 's,/,\\x2f,g')"
@@ -66,11 +71,16 @@ case "$root" in
/dev/*)
root="block:${root}"
rootok=1 ;;
UNSET|gpt-auto)
# systemd's gpt-auto-generator handles this case.
rootok=1 ;;
esac
[ -z "$root" ] && die "No or empty root= argument"
[ -z "${root}${root_unset}" ] && die "Empty root= argument"
[ -z "$rootok" ] && die "Don't know how to handle 'root=$root'"
[ "$root" = "UNSET" ] && unset root
export root rflags fstype netroot NEWROOT
export -p > /dracut-state.sh

View File

@@ -12,8 +12,8 @@ Description=Dracut Emergency Shell
DefaultDependencies=no
After=systemd-vconsole-setup.service
Wants=systemd-vconsole-setup.service
Conflicts=emergency.service emergency.target
ConditionPathExists=!/lib/dracut/no-emergency-shell
Conflicts=shutdown.target emergency.target
[Service]
Environment=HOME=/

View File

@@ -16,6 +16,7 @@ export _rdshell_name="dracut" action="Boot" hook="emergency"
source_hook "$hook"
_emergency_action=$(getarg rd.emergency)
if getargbool 1 rd.shell -d -y rdshell || getarg rd.break -d rdbreak; then
echo
@@ -33,9 +34,18 @@ if getargbool 1 rd.shell -d -y rdshell || getarg rd.break -d rdbreak; then
exec sh -i -l
else
warn "$action has failed. To debug this issue add \"rd.shell rd.debug\" to the kernel command line."
exit 1
[ -z "$_emergency_action" ] && _emergency_action=halt
fi
/bin/rm -f -- /.console_lock
case "$_emergency_action" in
reboot)
reboot || exit 1;;
poweroff)
poweroff || exit 1;;
halt)
halt || exit 1;;
esac
exit 0

View File

@@ -23,6 +23,7 @@ ConditionPathExistsGlob=|/lib/dracut/hooks/initqueue/finished/*.sh
ConditionPathExistsGlob=|/lib/dracut/hooks/initqueue/online/*.sh
ConditionPathExistsGlob=|/lib/dracut/hooks/initqueue/timeout/*.sh
ConditionKernelCommandLine=|rd.break=initqueue
Conflicts=shutdown.target emergency.target
[Service]
Environment=DRACUT_SYSTEMD=1

View File

@@ -15,6 +15,7 @@ After=dracut-initqueue.service dracut-pre-mount.service
ConditionPathExists=/etc/initrd-release
ConditionDirectoryNotEmpty=|/lib/dracut/hooks/mount
ConditionKernelCommandLine=|rd.break=mount
Conflicts=shutdown.target emergency.target
[Service]
Environment=DRACUT_SYSTEMD=1

View File

@@ -17,6 +17,7 @@ After=cryptsetup.target
ConditionPathExists=/etc/initrd-release
ConditionDirectoryNotEmpty=|/lib/dracut/hooks/pre-mount
ConditionKernelCommandLine=|rd.break=pre-mount
Conflicts=shutdown.target emergency.target
[Service]
Environment=DRACUT_SYSTEMD=1

View File

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

View File

@@ -16,6 +16,7 @@ Before=initrd-cleanup.service
Wants=remote-fs.target
After=remote-fs.target
ConditionPathExists=/etc/initrd-release
Conflicts=shutdown.target emergency.target
[Service]
Environment=DRACUT_SYSTEMD=1

View File

@@ -10,12 +10,13 @@ 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'
make_trace_mem "hook pre-pivot" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
# 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"
source_hook pre-pivot
cleanup_trace_mem
# pre pivot cleanup scripts are sourced just before we switch over to the new root.
getarg 'rd.break=cleanup' 'rdbreak=cleanup' && emergency_shell -n cleanup "Break cleanup"
source_hook cleanup

View File

@@ -17,6 +17,7 @@ Wants=dracut-pre-udev.service systemd-udevd.service
ConditionPathExists=/etc/initrd-release
ConditionDirectoryNotEmpty=|/lib/dracut/hooks/pre-trigger
ConditionKernelCommandLine=|rd.break=pre-trigger
Conflicts=shutdown.target emergency.target
[Service]
Environment=DRACUT_SYSTEMD=1

View File

@@ -10,7 +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"
make_trace_mem "hook pre-trigger" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
source_hook pre-trigger

View File

@@ -20,6 +20,7 @@ ConditionKernelCommandLine=|rd.break=pre-udev
ConditionKernelCommandLine=|rd.driver.blacklist
ConditionKernelCommandLine=|rd.driver.pre
ConditionKernelCommandLine=|rd.driver.post
Conflicts=shutdown.target emergency.target
[Service]
Environment=DRACUT_SYSTEMD=1

View File

@@ -13,20 +13,21 @@ DefaultDependencies=no
After=systemd-vconsole-setup.service
Wants=systemd-vconsole-setup.service
ConditionPathExists=!/lib/dracut/no-emergency-shell
Conflicts=shutdown.target
[Service]
Environment=HOME=/
Environment=DRACUT_SYSTEMD=1
Environment=NEWROOT=/sysroot
WorkingDirectory=/
ExecStart=/bin/dracut-emergency
ExecStopPost=-/usr/bin/systemctl --fail --no-block default
Type=oneshot
ExecStart=-/bin/dracut-emergency
ExecStopPost=-/usr/bin/systemctl --no-block isolate default.target
StandardInput=tty-force
StandardOutput=inherit
StandardError=inherit
KillMode=process
IgnoreSIGPIPE=no
TimeoutStartSec=0
# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash
# terminates cleanly.

View File

@@ -22,6 +22,17 @@ installkernel() {
instmods -s efivarfs
}
ug_check_and_add() {
local name="$1"
local file="$2"
if egrep -q "^$name:" "$file" 2>/dev/null \
&& ! egrep -q "^$name:" "$initdir$file" 2>/dev/null; then
egrep "^$name:" "$file" 2>/dev/null >> "$initdir$file"
fi
}
install() {
local _mods
@@ -30,6 +41,12 @@ install() {
exit 1
fi
ug_check_and_add "wheel" "/etc/passwd"
ug_check_and_add "wheel" "/etc/group"
ug_check_and_add "adm" "/etc/passwd"
ug_check_and_add "adm" "/etc/group"
inst_multiple -o \
$systemdutildir/systemd \
$systemdutildir/systemd-cgroups-agent \
@@ -120,6 +137,7 @@ install() {
\
$systemdsystemunitdir/slices.target \
$systemdsystemunitdir/system.slice \
$systemdsystemunitdir/-.slice \
\
$tmpfilesdir/systemd.conf \
\
@@ -237,9 +255,10 @@ install() {
mkdir -p "$initdir/etc/systemd"
# turn off RateLimit for journal
# We must use a volatile journal, and we don't want rate-limiting
{
echo "[Journal]"
echo "Storage=volatile"
echo "RateLimitInterval=0"
echo "RateLimitBurst=0"
} >> "$initdir/etc/systemd/journald.conf"

View File

@@ -7,6 +7,7 @@ type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
generator_wait_for_dev()
{
local _name
local _timeout
_name="$(str_replace "$1" '/' '\x2f')"
@@ -26,10 +27,11 @@ generator_wait_for_dev()
fi
if ! [ -f /run/systemd/generator/${_name}.device.d/timeout.conf ]; then
_timeout=$(getarg rd.device.timeout || printf "0")
mkdir -p /run/systemd/generator/${_name}.device.d
{
echo "[Unit]"
echo "JobTimeoutSec=0"
echo "JobTimeoutSec=$_timeout"
} > /run/systemd/generator/${_name}.device.d/timeout.conf
fi
}

View File

@@ -14,7 +14,7 @@ filtersubvol() {
while [ $# -gt 0 ]; do
case $1 in
subvol\=*) :;;
*) echo -n "${1}," ;;
*) printf '%s' "${1}," ;;
esac
shift
done

View File

@@ -39,6 +39,13 @@ str_ends() {
[ "${1%*$2}" != "$1" ]
}
trim() {
local var="$*"
var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
echo -n "$var"
}
if [ -z "$DRACUT_SYSTEMD" ]; then
warn() {
@@ -288,7 +295,7 @@ _dogetargs() {
fi
done
if [ -n "$_found" ]; then
[ $# -gt 0 ] && echo -n "$@"
[ $# -gt 0 ] && printf '%s' "$*"
return 0
fi
return 1;
@@ -319,7 +326,9 @@ getargs() {
done
if [ -n "$_gfound" ]; then
if [ $# -gt 0 ]; then
echo -n "$@"
printf '%s' "$*"
else
printf 1
fi
debug_on
return 0
@@ -878,6 +887,7 @@ wait_for_dev()
local _name
local _needreload
local _noreload
local _timeout
if [ "$1" = "-n" ]; then
_noreload=1
@@ -904,10 +914,11 @@ wait_for_dev()
fi
if ! [ -f ${PREFIX}/etc/systemd/system/${_name}.device.d/timeout.conf ]; then
_timeout=$(getarg rd.device.timeout || printf "0")
mkdir -p ${PREFIX}/etc/systemd/system/${_name}.device.d
{
echo "[Unit]"
echo "JobTimeoutSec=0"
echo "JobTimeoutSec=$_timeout"
} > ${PREFIX}/etc/systemd/system/${_name}.device.d/timeout.conf
_needreload=1
fi
@@ -1057,6 +1068,8 @@ emergency_shell()
local _ctty
set +e
local _rdshell_name="dracut" action="Boot" hook="emergency"
local _emergency_action
if [ "$1" = "-n" ]; then
_rdshell_name=$2
shift 2
@@ -1075,20 +1088,26 @@ emergency_shell()
source_hook "$hook"
echo
_emergency_action=$(getarg rd.emergency)
[ -z "$_emergency_action" ] \
&& [ -e /run/initramfs/.die ] \
&& _emergency_action=halt
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 rd.debug\" to the kernel command line."
# cause a kernel panic
exit 1
[ -z "$_emergency_action" ] && _emergency_action=halt
fi
if [ -e /run/initramfs/.die ]; then
if [ -n "$DRACUT_SYSTEMD" ]; then
systemctl --no-block --force halt
fi
exit 1
fi
case "$_emergency_action" in
reboot)
reboot || exit 1;;
poweroff)
poweroff || exit 1;;
halt)
halt || exit 1;;
esac
}
action_on_fail()
@@ -1158,12 +1177,20 @@ are_lists_eq() {
setmemdebug() {
if [ -z "$DEBUG_MEM_LEVEL" ]; then
export DEBUG_MEM_LEVEL=$(getargnum 0 0 3 rd.memdebug)
export DEBUG_MEM_LEVEL=$(getargnum 0 0 4 rd.memdebug)
fi
}
setmemdebug
cleanup_trace_mem()
{
# tracekomem based on kernel trace needs cleanup after use.
if [ "$DEBUG_MEM_LEVEL" -eq 4 ]; then
tracekomem --cleanup
fi
}
# parameters: msg [trace_level:trace]...
make_trace_mem()
{
@@ -1248,5 +1275,8 @@ show_memstats()
iomem)
cat /proc/iomem
;;
komem)
tracekomem
;;
esac
}

View File

@@ -124,7 +124,7 @@ if getarg "rd.cmdline=ask"; then
fi
# run scriptlets to parse the command line
make_trace_mem "hook cmdline" '1+:mem' '1+:iomem' '3+:slab'
make_trace_mem "hook cmdline" '1+:mem' '1+:iomem' '3+:slab' '4+:komem'
getarg 'rd.break=cmdline' -d 'rdbreak=cmdline' && emergency_shell -n cmdline "Break before cmdline"
source_hook cmdline
@@ -153,7 +153,7 @@ getargbool 0 rd.udev.info -d -y rdudevinfo && udevadm control "$UDEV_LOG_PRIO_AR
getargbool 0 rd.udev.debug -d -y rdudevdebug && udevadm control "$UDEV_LOG_PRIO_ARG=debug"
udevproperty "hookdir=$hookdir"
make_trace_mem "hook pre-trigger" '1:shortmem' '2+:mem' '3+:slab'
make_trace_mem "hook pre-trigger" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
getarg 'rd.break=pre-trigger' -d 'rdbreak=pre-trigger' && emergency_shell -n pre-trigger "Break before pre-trigger"
source_hook pre-trigger
@@ -214,7 +214,8 @@ while :; do
main_loop=$(($main_loop+1))
[ $main_loop -gt $RDRETRY ] \
&& { flock -s 9 ; action_on_fail "Could not boot." && break; } 9>/.console_lock
&& { flock -s 9 ; action_on_fail "Could not boot."; } 9>/.console_lock \
&& break
done
unset job
unset queuetriggered
@@ -223,7 +224,7 @@ unset RDRETRY
# pre-mount happens before we try to mount the root filesystem,
# and happens once.
make_trace_mem "hook pre-mount" '1:shortmem' '2+:mem' '3+:slab'
make_trace_mem "hook pre-mount" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
getarg 'rd.break=pre-mount' -d 'rdbreak=pre-mount' && emergency_shell -n pre-mount "Break pre-mount"
source_hook pre-mount
@@ -253,17 +254,18 @@ while :; do
done
{
echo -n "Mounted root filesystem "
while read dev mp rest; do [ "$mp" = "$NEWROOT" ] && echo $dev; done < /proc/mounts
printf "Mounted root filesystem "
while read dev mp rest || [ -n "$dev" ]; do [ "$mp" = "$NEWROOT" ] && echo $dev; done < /proc/mounts
} | vinfo
# pre pivot scripts are sourced just before we doing cleanup and switch over
# to the new root.
make_trace_mem "hook pre-pivot" '1:shortmem' '2+:mem' '3+:slab'
make_trace_mem "hook pre-pivot" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
getarg 'rd.break=pre-pivot' -d 'rdbreak=pre-pivot' && emergency_shell -n pre-pivot "Break pre-pivot"
source_hook pre-pivot
make_trace_mem "hook cleanup" '1:shortmem' '2+:mem' '3+:slab'
cleanup_trace_mem
# pre pivot cleanup scripts are sourced just before we switch over to the new root.
getarg 'rd.break=cleanup' -d 'rdbreak=cleanup' && emergency_shell -n cleanup "Break cleanup"
source_hook cleanup

191
modules.d/99base/memtrace-ko.sh Executable file
View File

@@ -0,0 +1,191 @@
#!/bin/sh
# Try to find out kernel modules with large total memory allocation during loading.
# For large slab allocation, it will fall into buddy, also not trace "mm_page_free"
# considering large free is quite rare for module_init, thus saving tons of events
# to avoid trace data overwritten.
#
# Therefore, tracing "mm_page_alloc"alone should be enough for the purpose.
# "sys/kernel/tracing" has the priority if exists.
get_trace_base() {
# trace access through debugfs would be obsolete if "/sys/kernel/tracing" is available.
if [ -d "/sys/kernel/tracing" ]; then
echo "/sys/kernel"
else
echo "/sys/kernel/debug"
fi
}
# We want to enable these trace events.
get_want_events() {
echo "module:module_put module:module_load kmem:mm_page_alloc"
}
get_event_filter() {
echo "comm == systemd-udevd || comm == modprobe || comm == insmod"
}
is_trace_ready() {
local trace_base want_events current_events
trace_base=$(get_trace_base)
! [ -f "$trace_base/tracing/trace" ] && return 1
[ "$(cat $trace_base/tracing/tracing_on)" -eq 0 ] && return 1
# Also check if trace events were properly setup.
want_events=$(get_want_events)
current_events=$(echo $(cat $trace_base/tracing/set_event))
[ "$current_events" != "$want_events" ] && return 1
return 0
}
prepare_trace() {
local trace_base
trace_base=$(get_trace_base)
# old debugfs interface case.
if ! [ -d "$trace_base/tracing" ]; then
mount none -t debugfs $trace_base
# new tracefs interface case.
elif ! [ -f "$trace_base/tracing/trace" ]; then
mount none -t tracefs "$trace_base/tracing"
fi
if ! [ -f "$trace_base/tracing/trace" ]; then
echo "WARN: Mount trace failed for kernel module memory analyzing."
return 1
fi
# Active all the wanted trace events.
echo "$(get_want_events)" > $trace_base/tracing/set_event
# There are three kinds of known applications for module loading:
# "systemd-udevd", "modprobe" and "insmod".
# Set them as the global events filter.
# NOTE: Some kernel may not support this format of filter, anyway
# the operation will fail and it doesn't matter.
echo "$(get_event_filter)" > $trace_base/tracing/events/kmem/filter 2>&1
echo "$(get_event_filter)" > $trace_base/tracing/events/module/filter 2>&1
# Set the number of comm-pid if supported.
if [ -f "$trace_base/tracing/saved_cmdlines_size" ]; then
# Thanks to filters, 4096 is big enough(also well supported).
echo 4096 > $trace_base/tracing/saved_cmdlines_size
fi
# Enable and clear trace data for the first time.
echo 1 > $trace_base/tracing/tracing_on
echo > $trace_base/tracing/trace
echo "Prepare trace success."
return 0
}
order_to_pages()
{
local pages=1
local order=$1
while [ "$order" != 0 ]; do
order=$((order-1))
pages=$(($pages*2))
done
echo $pages
}
parse_trace_data() {
local module_name tmp_eval pages
cat "$(get_trace_base)/tracing/trace" | while read pid cpu flags ts function args
do
# Skip comment lines
if [ "$pid" = "#" ]; then
continue
fi
pid=${pid##*-}
function=${function%:}
if [ "$function" = "module_load" ]; then
# One module is being loaded, save the task pid for tracking.
# Remove the trailing after whitespace, there may be the module flags.
module_name=${args%% *}
# Mark current_module to track the task.
eval current_module_$pid="$module_name"
tmp_eval=$(eval echo '${module_loaded_'${module_name}'}')
if [ -n "$tmp_eval" ]; then
echo "WARN: \"$module_name\" was loaded multiple times!"
fi
eval unset module_loaded_$module_name
eval nr_alloc_pages_$module_name=0
continue
fi
module_name=$(eval echo '${current_module_'${pid}'}')
if [ -z "$module_name" ]; then
continue
fi
# Once we get here, the task is being tracked(is loading a module).
if [ "$function" = "module_put" ]; then
# Mark the module as loaded when the first module_put event happens after module_load.
tmp_eval=$(eval echo '${nr_alloc_pages_'${module_name}'}')
echo "$tmp_eval pages consumed by \"$module_name\""
eval module_loaded_$module_name=1
# Module loading finished, so untrack the task.
eval unset current_module_$pid
eval unset nr_alloc_pages_$module_name
continue
fi
if [ "$function" = "mm_page_alloc" ]; then
# Get order first, then convert to actual pages.
pages=$(echo $args | sed -e 's/.*order=\([0-9]*\) .*/\1/')
pages=$(order_to_pages "$pages")
tmp_eval=$(eval echo '${nr_alloc_pages_'${module_name}'}')
eval nr_alloc_pages_$module_name="$(($tmp_eval+$pages))"
fi
done
}
cleanup_trace() {
local trace_base
if is_trace_ready; then
trace_base=$(get_trace_base)
echo 0 > $trace_base/tracing/tracing_on
echo > $trace_base/tracing/trace
echo > $trace_base/tracing/set_event
echo 0 > $trace_base/tracing/events/kmem/filter
echo 0 > $trace_base/tracing/events/module/filter
fi
}
show_usage() {
echo "Find out kernel modules with large memory consumption during loading based on trace."
echo "Usage:"
echo "1) run it first to setup trace."
echo "2) run again to parse the trace data if any."
echo "3) run with \"--cleanup\" option to cleanup trace after use."
}
if [ "$1" = "--help" ]; then
show_usage
exit 0
fi
if [ "$1" = "--cleanup" ]; then
cleanup_trace
exit 0
fi
if is_trace_ready ; then
echo "tracekomem - Rough memory consumption by loading kernel modules (larger value with better accuracy)"
parse_trace_data
else
prepare_trace
fi
exit $?

View File

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

View File

@@ -13,7 +13,7 @@ depends() {
install() {
local _d
inst_multiple umount poweroff reboot halt losetup
inst_multiple umount poweroff reboot halt losetup stat
inst_multiple -o kexec
inst "$moddir/shutdown.sh" "$prefix/shutdown"
[ -e "${initdir}/lib" ] || mkdir -m 0755 -p ${initdir}/lib

View File

@@ -14,6 +14,10 @@ export TERM=linux
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
. /lib/dracut-lib.sh
if [ "$(stat -c '%T' -f /)" = "tmpfs" ]; then
mount -o remount,rw /
fi
mkdir /oldsys
for i in sys proc run dev; do
mkdir /oldsys/$i

View File

@@ -2,13 +2,14 @@
check:
@[ "$$EUID" == "0" ] || { echo "'check' must be run as root! Please use 'sudo'."; exit 1; }
@for i in TEST-[0-9]*; do \
@{ ret=0; \
for i in TEST-[0-9]*; do \
[ -d $$i ] || continue ; \
[ -f $$i/Makefile ] || continue ; \
if [ -n "$$TESTS" ]; then t=$${i##TEST-}; t=$${t%%-*}; [ "$${TESTS#*$$t*}" != "$$TESTS" ] || continue; fi; \
if [ -n "$$SKIP" ]; then t=$${i##TEST-}; t=$${t%%-*}; [ "$${SKIP#*$$t*}" != "$$SKIP" ] && continue; fi; \
$(MAKE) -C $$i all ; \
done
$(MAKE) -C $$i all ; ret=$$((ret + $$?)); \
done; exit $$ret; }
clean:
@for i in TEST-[0-9]*; do \

View File

@@ -14,7 +14,8 @@ test_run() {
-m 256M -smp 2 -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-watchdog i6300esb -watchdog-action poweroff \
-append "root=LABEL=dracut rw systemd.log_level=debug systemd.log_target=console rd.retry=3 rd.debug console=ttyS0,115200n81 $DEBUGFAIL" \
-no-reboot \
-append "panic=1 root=LABEL=dracut rw systemd.log_level=debug systemd.log_target=console rd.retry=3 rd.debug console=ttyS0,115200n81 $DEBUGFAIL rd.memdebug=4" \
-initrd $TESTDIR/initramfs.testing || return 1
grep -F -m 1 -q dracut-root-block-success $TESTDIR/result || return 1
}
@@ -45,7 +46,7 @@ test_setup() {
find_binary plymouth >/dev/null && inst_multiple plymouth
(cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
)
# second, install the files needed to make the root filesystem
@@ -62,7 +63,7 @@ test_setup() {
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash udev-rules base rootfs-block fs-lib kernel-modules fs-lib" \
-m "udev-rules base rootfs-block fs-lib kernel-modules fs-lib" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
--nomdadmconf \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
@@ -85,7 +86,7 @@ test_setup() {
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-a "debug watchdog" \
-o "plymouth" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod i6300esb ib700wdt" \

View File

@@ -4,7 +4,7 @@ strstr() { [ "${1#*$2*}" != "$1" ]; }
CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
plymouth --quit
exec </dev/console >/dev/console 2>&1
echo "dracut-root-block-success" >/dev/sda1
echo "dracut-root-block-success" >/dev/sdb
export TERM=linux
export PS1='initramfs-test:\w\$ '
[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab

View File

@@ -4,19 +4,24 @@ TEST_DESCRIPTION="root filesystem on a ext3 filesystem"
KVERSION="${KVERSION-$(uname -r)}"
# Uncomment this to debug failures
#DEBUGFAIL="rd.shell"
#DEBUGFAIL="rd.shell loglevel=77 systemd.log_level=debug systemd.log_target=console"
#DEBUGFAIL="rd.shell rd.break=initqueue"
test_run() {
dd if=/dev/zero of=$TESTDIR/marker.disk bs=1M count=80
$testdir/run-qemu \
-hda $TESTDIR/root.ext3 \
-hdb $TESTDIR/marker.disk \
-m 256M -smp 2 -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "root=LABEL=dracut rw loglevel=77 systemd.log_level=debug systemd.log_target=console rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug init=/sbin/init $DEBUGFAIL" \
-no-reboot \
-append "panic=1 root=LABEL=dracut rw loglevel=77 rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 init=/sbin/init $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
grep -F -m 1 -q dracut-root-block-success $TESTDIR/root.ext3 || return 1
grep -F -m 1 -q dracut-root-block-success $TESTDIR/marker.disk || return 1
}
test_setup() {
rm -f -- $TESTDIR/root.ext3
rm -f -- $TESTDIR/marker.disk
# Create the blank file to use as a root filesystem
dd if=/dev/null of=$TESTDIR/root.ext3 bs=1M seek=80
@@ -41,7 +46,7 @@ test_setup() {
find_binary plymouth >/dev/null && inst_multiple plymouth
(cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
)
# second, install the files needed to make the root filesystem
@@ -58,7 +63,7 @@ test_setup() {
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash udev-rules base rootfs-block fs-lib kernel-modules" \
-m "udev-rules base rootfs-block fs-lib kernel-modules" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
--nomdadmconf \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
@@ -81,7 +86,7 @@ test_setup() {
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-a "debug systemd" \
-o "network plymouth" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \

View File

@@ -20,7 +20,8 @@ client_run() {
-hdc $TESTDIR/result \
-m 256M -smp 2 -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "root=LABEL=dracut $client_opts rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 $DEBUGFAIL" \
-no-reboot \
-append "panic=1 root=LABEL=dracut $client_opts rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
if (($? != 0)); then
@@ -72,7 +73,7 @@ test_setup() {
find_binary plymouth >/dev/null && inst_multiple plymouth
(cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
)
# second, install the files needed to make the root filesystem
@@ -89,7 +90,7 @@ test_setup() {
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash udev-rules btrfs base rootfs-block fs-lib kernel-modules" \
-m "udev-rules btrfs base rootfs-block fs-lib kernel-modules" \
-d "piix ide-gd_mod ata_piix btrfs sd_mod" \
--nomdadmconf \
--nohardlink \
@@ -119,7 +120,7 @@ test_setup() {
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-a "debug" \
-o "network plymouth" \
-d "piix ide-gd_mod ata_piix btrfs sd_mod i6300esb ib700wdt" \

View File

@@ -19,7 +19,7 @@ if ismounted /usr && [ ! -s /failed ]; then
echo "dracut-root-block-success" >/dev/sdc
fi
journalctl --full --no-pager -o short-monotonic
#journalctl --full --no-pager -o short-monotonic
if [ -s /failed ]; then
echo "**************************FAILED**************************"

View File

@@ -22,7 +22,8 @@ client_run() {
-hdc $TESTDIR/result \
-m 256M -smp 2 -nographic \
-net none \
-append "root=LABEL=dracut $client_opts rd.retry=3 console=ttyS0,115200n81 selinux=0 $DEBUGOUT $DEBUGFAIL" \
-no-reboot \
-append "panic=1 $client_opts rd.device.timeout=20 rd.retry=3 console=ttyS0,115200n81 selinux=0 $DEBUGOUT $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
if (($? != 0)); then
@@ -39,9 +40,11 @@ client_run() {
}
test_run() {
client_run "no option specified" || return 1
client_run "readonly root" "ro" || return 1
client_run "writeable root" "rw" || return 1
client_run "no root specified (failme)" "failme" && return 1
client_run "wrong root specified (failme)" "root=LABEL=dracut1" "failme" && return 1
client_run "no option specified" "root=LABEL=dracut" || return 1
client_run "readonly root" "root=LABEL=dracut" "ro" || return 1
client_run "writeable root" "root=LABEL=dracut" "rw" || return 1
return 0
}
@@ -70,7 +73,7 @@ test_setup() {
ln -sfn /run "$initdir/var/run"
ln -sfn /run/lock "$initdir/var/lock"
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip route \
inst_multiple -o sh df free ls shutdown poweroff stty cat ps ln ip route \
mount dmesg ifconfig dhclient mkdir cp ping dhclient \
umount strace less setsid tree systemctl reset
@@ -163,7 +166,7 @@ EOF
/etc/security \
/lib64/security \
/lib/security -xtype f \
| while read file; do
2>/dev/null | while read file; do
inst_multiple -o $file
done
@@ -204,7 +207,7 @@ EOF
cp -a /etc/ld.so.conf* $initdir/etc
ldconfig -r "$initdir"
ddebug "Strip binaeries"
find "$initdir" -perm +111 -type f | xargs -r strip --strip-unneeded | ddebug
find "$initdir" -perm /111 -type f | xargs -r strip --strip-unneeded | ddebug
# copy depmod files
inst /lib/modules/$kernel/modules.order
@@ -232,7 +235,7 @@ EOF
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash udev-rules btrfs base rootfs-block fs-lib kernel-modules" \
-m "udev-rules btrfs base rootfs-block fs-lib kernel-modules" \
-d "piix ide-gd_mod ata_piix btrfs sd_mod" \
--nomdadmconf \
--nohardlink \
@@ -261,10 +264,10 @@ EOF
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-a "debug systemd" \
-I "/etc/machine-id /etc/hostname" \
-o "dash network plymouth lvm mdraid resume crypt i18n caps dm terminfo usrmount" \
-o "network plymouth lvm mdraid resume crypt i18n caps dm terminfo usrmount" \
-d "piix ide-gd_mod ata_piix btrfs sd_mod i6300esb ib700wdt" \
-f $TESTDIR/initramfs.testing $KVERSION || return 1

View File

@@ -18,7 +18,7 @@ mdadm --create /dev/md0 --run --auto=yes --level=5 --raid-devices=3 /dev/sda2 /d
# randomly.
mdadm -W /dev/md0
set -e
echo -n test >keyfile
printf test >keyfile
cryptsetup -q luksFormat /dev/md0 /keyfile
echo "The passphrase is test"
cryptsetup luksOpen /dev/md0 dracut_crypt_test </keyfile

View File

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

View File

@@ -12,7 +12,8 @@ test_run() {
-hda $DISKIMAGE \
-m 256M -smp 2 -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "root=/dev/dracut/root rd.auto rw rd.retry=10 console=ttyS0,115200n81 selinux=0 $DEBUGFAIL" \
-no-reboot \
-append "panic=1 root=/dev/dracut/root rd.auto rw rd.retry=10 console=ttyS0,115200n81 selinux=0 $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
grep -F -m 1 -q dracut-root-block-success $DISKIMAGE || return 1
}
@@ -43,7 +44,7 @@ test_setup() {
inst_multiple -o /lib/systemd/systemd-shutdown
find_binary plymouth >/dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
)
# second, install the files needed to make the root filesystem
@@ -60,7 +61,7 @@ test_setup() {
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules" \
-m "crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
--nomdadmconf \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
@@ -88,7 +89,7 @@ test_setup() {
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "plymouth network" \
-a "debug" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \

View File

@@ -11,7 +11,8 @@ test_run() {
-hda $TESTDIR/root.ext2 \
-m 256M -smp 2 -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "root=/dev/dracut/root rw rd.auto=1 quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
-no-reboot \
-append "panic=1 root=/dev/dracut/root rw rd.auto=1 quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
grep -F -m 1 -q dracut-root-block-success $TESTDIR/root.ext2 || return 1
}
@@ -40,7 +41,7 @@ test_setup() {
(cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
cp -a /etc/ld.so.conf* $initdir/etc
mkdir $initdir/run
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
)
# second, install the files needed to make the root filesystem
@@ -57,7 +58,7 @@ test_setup() {
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules" \
-m "lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
@@ -74,7 +75,7 @@ test_setup() {
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "plymouth network" \
-a "debug" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \

View File

@@ -20,7 +20,7 @@ mdadm --create /dev/md0 --run --auto=yes --level=5 --raid-devices=3 /dev/sdb /de
# wait for the array to finish initailizing, otherwise this sometimes fails
# randomly.
mdadm -W /dev/md0
echo -n test >keyfile
printf test >keyfile
cryptsetup -q luksFormat /dev/md0 /keyfile
echo "The passphrase is test"
set -e

View File

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

View File

@@ -19,7 +19,8 @@ client_run() {
-hdc $TESTDIR/disk2.img.new \
-hdd $TESTDIR/disk3.img.new \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "$* root=LABEL=root rw rd.retry=20 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL " \
-no-reboot \
-append "panic=1 $* root=LABEL=root rw rd.retry=20 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL " \
-initrd $TESTDIR/initramfs.testing
if ! grep -F -m 1 -q dracut-root-block-success $TESTDIR/root.ext2; then
echo "CLIENT TEST END: $@ [FAIL]"
@@ -36,19 +37,19 @@ test_run() {
echo "MD_UUID=$MD_UUID"
read LUKS_UUID < $TESTDIR/luksuuid
client_run failme && return 1
client_run rd.auto || return 1
client_run rd.device.timeout=60 failme && return 1
client_run rd.device.timeout=60 rd.auto || return 1
client_run rd.luks.uuid=$LUKS_UUID rd.md.uuid=$MD_UUID rd.md.conf=0 rd.lvm.vg=dracut || return 1
client_run rd.device.timeout=60 rd.luks.uuid=$LUKS_UUID rd.md.uuid=$MD_UUID rd.md.conf=0 rd.lvm.vg=dracut || return 1
client_run rd.luks.uuid=$LUKS_UUID rd.md.uuid=failme rd.md.conf=0 rd.lvm.vg=dracut failme && return 1
client_run rd.device.timeout=60 rd.luks.uuid=$LUKS_UUID rd.md.uuid=failme rd.md.conf=0 rd.lvm.vg=dracut failme && return 1
client_run rd.luks.uuid=$LUKS_UUID rd.md.uuid=$MD_UUID rd.lvm=0 failme && return 1
client_run rd.luks.uuid=$LUKS_UUID rd.md.uuid=$MD_UUID rd.lvm=0 rd.auto=1 failme && return 1
client_run rd.luks.uuid=$LUKS_UUID rd.md.uuid=$MD_UUID rd.lvm.vg=failme failme && return 1
client_run rd.device.timeout=60 rd.luks.uuid=$LUKS_UUID rd.md.uuid=$MD_UUID rd.lvm=0 failme && return 1
client_run rd.device.timeout=60 rd.luks.uuid=$LUKS_UUID rd.md.uuid=$MD_UUID rd.lvm=0 rd.auto=1 failme && return 1
client_run rd.device.timeout=60 rd.luks.uuid=$LUKS_UUID rd.md.uuid=$MD_UUID rd.lvm.vg=failme failme && return 1
client_run rd.luks.uuid=$LUKS_UUID rd.md.uuid=$MD_UUID rd.lvm.vg=dracut || return 1
client_run rd.luks.uuid=$LUKS_UUID rd.md.uuid=$MD_UUID rd.lvm.lv=dracut/failme failme && return 1
client_run rd.device.timeout=60 rd.luks.uuid=$LUKS_UUID rd.md.uuid=$MD_UUID rd.lvm.lv=dracut/failme failme && return 1
client_run rd.luks.uuid=$LUKS_UUID rd.md.uuid=$MD_UUID rd.lvm.lv=dracut/root || return 1
return 0
@@ -81,7 +82,7 @@ test_setup() {
find_binary plymouth >/dev/null && inst_multiple plymouth
(cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
)
# second, install the files needed to make the root filesystem
@@ -98,7 +99,7 @@ test_setup() {
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules" \
-m "crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
@@ -131,7 +132,7 @@ test_setup() {
echo -n test > $initdir/etc/key
)
sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "plymouth network" \
-a "debug" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \

View File

@@ -14,7 +14,7 @@ sfdisk -C 2560 -H 2 -S 32 -L /dev/sda <<EOF
,800
EOF
udevadm settle
echo -n test >keyfile
printf test >keyfile
cryptsetup -q luksFormat /dev/sda2 /keyfile
cryptsetup -q luksFormat /dev/sda3 /keyfile
cryptsetup -q luksFormat /dev/sda4 /keyfile

View File

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

View File

@@ -19,7 +19,8 @@ test_run() {
-hdb $TESTDIR/check-success.img \
-m 256M -smp 2 -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "root=/dev/dracut/root rw rd.auto rd.retry=20 console=ttyS0,115200n81 selinux=0 rd.debug rootwait $LUKSARGS $DEBUGFAIL" \
-no-reboot \
-append "panic=1 root=/dev/dracut/root rw rd.auto rd.retry=20 console=ttyS0,115200n81 selinux=0 $LUKSARGS rd.device.timeout=40 $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
grep -F -m 1 -q dracut-root-block-success $TESTDIR/check-success.img || return 1
echo "CLIENT TEST END: [OK]"
@@ -32,7 +33,8 @@ test_run() {
-hdb $TESTDIR/check-success.img \
-m 256M -smp 2 -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "root=/dev/dracut/root rw quiet rd.auto rd.retry=20 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
-no-reboot \
-append "panic=1 root=/dev/dracut/root rw quiet rd.auto rd.retry=20 rd.info console=ttyS0,115200n81 selinux=0 rd.device.timeout=40 $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
grep -F -m 1 -q dracut-root-block-success $TESTDIR/check-success.img || return 1
echo "CLIENT TEST END: [OK]"
@@ -45,7 +47,8 @@ test_run() {
-hdb $TESTDIR/check-success.img \
-m 256M -smp 2 -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "root=/dev/dracut/root rw quiet rd.auto rd.retry=10 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL rd.luks.uuid=failme" \
-no-reboot \
-append "panic=1 root=/dev/dracut/root rw quiet rd.auto rd.retry=10 rd.info console=ttyS0,115200n81 selinux=0 rd.debug rd.luks.uuid=failme rd.device.timeout=40 $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
grep -F -m 1 -q dracut-root-block-success $TESTDIR/check-success.img && return 1
echo "CLIENT TEST END: [OK]"
@@ -77,7 +80,7 @@ test_setup() {
find_binary plymouth >/dev/null && inst_multiple plymouth
(cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
)
# second, install the files needed to make the root filesystem
@@ -94,7 +97,7 @@ test_setup() {
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules" \
-m "crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
@@ -127,7 +130,7 @@ test_setup() {
done > $initdir/etc/crypttab
echo -n test > $initdir/etc/key
)
sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "plymouth network" \
-a "debug" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \

View File

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

View File

@@ -15,7 +15,8 @@ client_run() {
-hdc $TESTDIR/disk2 \
-m 256M -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "$* root=LABEL=root rw debug rd.retry=20 rd.debug console=ttyS0,115200n81 selinux=0 rd.info $DEBUGFAIL" \
-no-reboot \
-append "panic=1 $* root=LABEL=root rw debug rd.retry=20 rd.debug console=ttyS0,115200n81 selinux=0 rd.info $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
if ! grep -F -m 1 -q dracut-root-block-success $TESTDIR/root.ext2; then
echo "CLIENT TEST END: $@ [FAIL]"
@@ -33,8 +34,8 @@ test_run() {
client_run rd.auto rd.md.uuid=$MD_UUID rd.dm=0 || return 1
# This test succeeds, because the mirror parts are found without
# assembling the mirror itsself, which is what we want
client_run rd.auto rd.md.uuid=$MD_UUID rd.md=0 rd.md.imsm failme && return 1
client_run rd.auto rd.md.uuid=$MD_UUID rd.md=0 failme && return 1
client_run rd.auto rd.md.uuid=$MD_UUID rd.md=0 rd.md.imsm failme rd.device.timeout=40 && return 1
client_run rd.auto rd.md.uuid=$MD_UUID rd.md=0 failme rd.device.timeout=40 && return 1
# the following test hangs on newer md
client_run rd.auto rd.md.uuid=$MD_UUID rd.dm=0 rd.md.imsm rd.md.conf=0 || return 1
return 0
@@ -70,7 +71,7 @@ test_setup() {
(cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
cp -a /etc/ld.so.conf* $initdir/etc
mkdir $initdir/run
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
)
# second, install the files needed to make the root filesystem
@@ -86,7 +87,7 @@ test_setup() {
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash lvm mdraid dmraid udev-rules base rootfs-block fs-lib kernel-modules" \
-m "lvm mdraid dmraid udev-rules base rootfs-block fs-lib kernel-modules" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod dm-multipath dm-crypt dm-round-robin faulty linear multipath raid0 raid10 raid1 raid456" \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
@@ -109,7 +110,7 @@ test_setup() {
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "plymouth network" \
-a "debug" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \

View File

@@ -11,7 +11,8 @@ test_run() {
-hda $DISKIMAGE \
-m 256M -smp 2 -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "root=LABEL=root rw rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 $DEBUGFAIL" \
-no-reboot \
-append "panic=1 root=LABEL=root rw rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
dd if=$DISKIMAGE bs=512 count=2 | grep -F -m 1 -q dracut-root-block-success $DISKIMAGE || return 1
}
@@ -41,7 +42,7 @@ test_setup() {
find_binary plymouth >/dev/null && inst_multiple plymouth
(cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
)
# second, install the files needed to make the root filesystem
@@ -58,7 +59,7 @@ test_setup() {
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash btrfs udev-rules base rootfs-block fs-lib kernel-modules" \
-m "btrfs udev-rules base rootfs-block fs-lib kernel-modules" \
-d "piix ide-gd_mod ata_piix btrfs sd_mod" \
--nomdadmconf \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
@@ -82,7 +83,7 @@ test_setup() {
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "plymouth network" \
-a "debug" \
-d "piix ide-gd_mod ata_piix btrfs sd_mod" \

View File

@@ -21,7 +21,8 @@ test_run() {
-hda "$TESTDIR"/root.img \
-m 256M -smp 2 -nographic \
-net none -kernel /boot/vmlinuz-"$KVERSION" \
-append "root=live:CDLABEL=LiveCD live rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
-no-reboot \
-append "panic=1 root=live:CDLABEL=LiveCD live rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
-initrd "$TESTDIR"/initramfs.testing
grep -F -m 1 -q dracut-root-block-success -- "$TESTDIR"/root.img || return 1
}
@@ -38,9 +39,9 @@ test_setup() {
dd if=/dev/zero of="$TESTDIR"/root.img count=100
sudo $basedir/dracut.sh -l -i "$TESTDIR"/overlay / \
$basedir/dracut.sh -l -i "$TESTDIR"/overlay / \
-a "debug dmsquash-live" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod sr_mod" \
-f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1
mkdir -p -- "$TESTDIR"/root-source
@@ -69,7 +70,7 @@ test_setup() {
find_binary plymouth >/dev/null && inst_multiple plymouth
(cd "$initdir"; mkdir -p -- dev sys proc etc var/run tmp )
cp -a -- /etc/ld.so.conf* "$initdir"/etc
sudo ldconfig -r -- "$initdir"
ldconfig -r "$initdir"
)
python create.py -d -c livecd-fedora-minimal.ks
return 0

View File

@@ -11,7 +11,8 @@ test_run() {
-hda $TESTDIR/root.ext2 \
-m 256M -smp 2 -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "root=/dev/dracut/root rw rd.auto=1 quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
-no-reboot \
-append "panic=1 root=/dev/dracut/root rw rd.auto=1 quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
grep -F -m 1 -q dracut-root-block-success $TESTDIR/root.ext2 || return 1
}
@@ -40,7 +41,7 @@ test_setup() {
(cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
cp -a /etc/ld.so.conf* $initdir/etc
mkdir $initdir/run
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
)
# second, install the files needed to make the root filesystem
@@ -57,7 +58,7 @@ test_setup() {
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules" \
-m "lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules" \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
@@ -74,7 +75,7 @@ test_setup() {
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "plymouth network" \
-a "debug" -I lvs \
-d "piix ide-gd_mod ata_piix ext2 sd_mod" \

View File

@@ -23,10 +23,11 @@ run_server() {
-serial ${SERIAL:-null} \
-watchdog i6300esb -watchdog-action poweroff \
-kernel /boot/vmlinuz-$KVERSION \
-append "rd.debug loglevel=77 root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0" \
-no-reboot \
-append "panic=1 rd.debug loglevel=77 root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.server \
-pidfile $TESTDIR/server.pid -daemonize || return 1
sudo chmod 644 $TESTDIR/server.pid || return 1
chmod 644 $TESTDIR/server.pid || return 1
# Cleanup the terminal if we have one
tty -s && stty sane
@@ -58,7 +59,8 @@ client_test() {
-net socket,connect=127.0.0.1:12320 \
-kernel /boot/vmlinuz-$KVERSION \
-watchdog i6300esb -watchdog-action poweroff \
-append "$cmdline $DEBUGFAIL rd.debug rd.retry=10 rd.info quiet ro console=ttyS0,115200n81 selinux=0" \
-no-reboot \
-append "panic=1 $cmdline $DEBUGFAIL rd.debug rd.retry=10 rd.info quiet ro console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.testing
if [[ $? -ne 0 ]] || ! grep -F -m 1 -q nfs-OK $TESTDIR/client.img; then
@@ -185,7 +187,7 @@ test_nfsv4() {
test_run() {
if [[ -s server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
kill -TERM $(cat $TESTDIR/server.pid)
rm -f -- $TESTDIR/server.pid
fi
@@ -200,7 +202,7 @@ test_run() {
ret=$?
if [[ -s $TESTDIR/server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
kill -TERM $(cat $TESTDIR/server.pid)
rm -f -- $TESTDIR/server.pid
fi
@@ -212,7 +214,7 @@ test_setup() {
dd if=/dev/null of=$TESTDIR/server.ext3 bs=1M seek=60
mke2fs -j -F $TESTDIR/server.ext3
mkdir $TESTDIR/mnt
sudo mount -o loop $TESTDIR/server.ext3 $TESTDIR/mnt
mount -o loop $TESTDIR/server.ext3 $TESTDIR/mnt
export kernel=$KVERSION
@@ -279,7 +281,7 @@ test_setup() {
inst /etc/group /etc/group
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
dracut_kernel_post
)
@@ -318,14 +320,14 @@ test_setup() {
inst_libdir_file -n "$_nsslibs" 'libnss_*.so*'
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
)
mkdir -p $TESTDIR/mnt/nfs/nfs3-5
mkdir -p $TESTDIR/mnt/nfs/ip/192.168.50.101
mkdir -p $TESTDIR/mnt/nfs/tftpboot/nfs4-5
sudo umount $TESTDIR/mnt
umount $TESTDIR/mnt
rm -fr -- $TESTDIR/mnt
# Make an overlay with needed tools for the test harness
@@ -340,13 +342,13 @@ test_setup() {
# Make server's dracut image
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash udev-rules base rootfs-block fs-lib debug kernel-modules watchdog" \
-m "udev-rules base rootfs-block fs-lib debug kernel-modules watchdog" \
-d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod e1000 i6300esb" \
-f $TESTDIR/initramfs.server $KVERSION || return 1
# Make client's dracut image
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "plymouth dash" \
-o "plymouth" \
-a "debug watchdog" \
-d "af_packet piix ide-gd_mod ata_piix sd_mod e1000 nfs sunrpc i6300esb" \
-f $TESTDIR/initramfs.testing $KVERSION || return 1
@@ -354,7 +356,7 @@ test_setup() {
test_cleanup() {
if [[ -s $TESTDIR/server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
kill -TERM $(cat $TESTDIR/server.pid)
rm -f -- $TESTDIR/server.pid
fi
}

View File

@@ -25,10 +25,11 @@ run_server() {
-net nic,macaddr=52:54:00:12:34:56,model=e1000 \
-net nic,macaddr=52:54:00:12:34:57,model=e1000 \
-net socket,listen=127.0.0.1:12330 \
-append "root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0 $SERVER_DEBUG" \
-no-reboot \
-append "panic=1 root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0 $SERVER_DEBUG" \
-initrd $TESTDIR/initramfs.server \
-pidfile $TESTDIR/server.pid -daemonize || return 1
sudo chmod 644 $TESTDIR/server.pid || return 1
chmod 644 $TESTDIR/server.pid || return 1
# Cleanup the terminal if we have one
tty -s && stty sane
@@ -49,7 +50,8 @@ run_client() {
-net nic,macaddr=52:54:00:12:34:00,model=e1000 \
-net nic,macaddr=52:54:00:12:34:01,model=e1000 \
-net socket,connect=127.0.0.1:12330 \
-append "rw rd.auto rd.retry=50 console=ttyS0,115200n81 selinux=0 rd.debug=0 $DEBUGFAIL $*" \
-no-reboot \
-append "panic=1 rw rd.auto rd.device.timeout=300 rd.retry=50 console=ttyS0,115200n81 selinux=0 rd.debug=0 $DEBUGFAIL $*" \
-initrd $TESTDIR/initramfs.testing
if ! grep -F -m 1 -q iscsi-OK $TESTDIR/client.img; then
echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
@@ -129,15 +131,15 @@ test_run() {
do_test_run
ret=$?
if [[ -s $TESTDIR/server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
kill -TERM $(cat $TESTDIR/server.pid)
rm -f -- $TESTDIR/server.pid
fi
return $ret
}
test_setup() {
if [ ! -x /usr/sbin/iscsi-target ]; then
echo "Need iscsi-target from netbsd-iscsi"
if ! command -v tgtd &>/dev/null || ! command -v tgtadm &>/dev/null; then
echo "Need tgtd and tgtadm from scsi-target-utils"
return 1
fi
@@ -169,7 +171,7 @@ test_setup() {
inst_simple /etc/os-release
inst ./client-init.sh /sbin/init
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
)
# second, install the files needed to make the root filesystem
@@ -186,7 +188,7 @@ test_setup() {
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules" \
-m "crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
@@ -216,8 +218,8 @@ test_setup() {
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "dash plymouth dmraid nfs" \
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "plymouth dmraid nfs" \
-a "debug" \
-d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod" \
--no-hostonly-cmdline -N \
@@ -227,7 +229,7 @@ test_setup() {
dd if=/dev/null of=$TESTDIR/server.ext3 bs=1M seek=60
mkfs.ext3 -j -F $TESTDIR/server.ext3
mkdir $TESTDIR/mnt
sudo mount -o loop $TESTDIR/server.ext3 $TESTDIR/mnt
mount -o loop $TESTDIR/server.ext3 $TESTDIR/mnt
kernel=$KVERSION
(
@@ -259,16 +261,16 @@ test_setup() {
inst /etc/group /etc/group
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
dracut_kernel_post
)
sudo umount $TESTDIR/mnt
umount $TESTDIR/mnt
rm -fr -- $TESTDIR/mnt
# Make server's dracut image
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-a "dash udev-rules base rootfs-block fs-lib debug kernel-modules" \
-a "udev-rules base rootfs-block fs-lib debug kernel-modules" \
-d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod e1000 drbg" \
--no-hostonly-cmdline -N \
-f $TESTDIR/initramfs.server $KVERSION || return 1
@@ -277,7 +279,7 @@ test_setup() {
test_cleanup() {
if [[ -s $TESTDIR/server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
kill -TERM $(cat $TESTDIR/server.pid)
rm -f -- $TESTDIR/server.pid
fi
}

View File

@@ -5,7 +5,7 @@ for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
done
rm -f -- /etc/lvm/lvm.conf
udevadm control --reload
echo -n test >keyfile
printf test >keyfile
cryptsetup -q luksFormat /dev/sdb /keyfile
echo "The passphrase is test"
cryptsetup luksOpen /dev/sdb dracut_crypt_test </keyfile && \

View File

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

View File

@@ -24,9 +24,10 @@ run_server() {
-net socket,listen=127.0.0.1:12340 \
-serial $SERIAL \
-kernel /boot/vmlinuz-$KVERSION \
-append "root=/dev/sda rootfstype=ext2 rw quiet console=ttyS0,115200n81 selinux=0" \
-no-reboot \
-append "panic=1 root=/dev/sda rootfstype=ext2 rw quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.server -pidfile $TESTDIR/server.pid -daemonize || return 1
sudo chmod 644 $TESTDIR/server.pid || return 1
chmod 644 $TESTDIR/server.pid || return 1
# Cleanup the terminal if we have one
tty -s && stty sane
@@ -61,7 +62,8 @@ client_test() {
-net nic,macaddr=$mac,model=e1000 \
-net socket,connect=127.0.0.1:12340 \
-kernel /boot/vmlinuz-$KVERSION \
-append "$cmdline $DEBUGFAIL rd.auto rd.info rd.retry=10 ro console=ttyS0,115200n81 selinux=0 " \
-no-reboot \
-append "panic=1 $cmdline $DEBUGFAIL rd.auto rd.info rd.retry=10 ro console=ttyS0,115200n81 selinux=0 " \
-initrd $TESTDIR/initramfs.testing
if [[ $? -ne 0 ]] || ! grep -F -m 1 -q nbd-OK $TESTDIR/flag.img; then
@@ -95,7 +97,6 @@ client_test() {
}
test_run() {
modinfo nbd &>/dev/null || { echo "Kernel does not support nbd"; exit 1; }
if ! run_server; then
echo "Failed to start server" 1>&2
return 1
@@ -180,7 +181,7 @@ client_run() {
"root=LABEL=dracut rd.luks.uuid=$ID_FS_UUID rd.lv.vg=dracut netroot=dhcp" || return 1
if [[ -s server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
kill -TERM $(cat $TESTDIR/server.pid)
rm -f -- $TESTDIR/server.pid
fi
@@ -208,7 +209,7 @@ make_encrypted_root() {
inst_simple /etc/os-release
find_binary plymouth >/dev/null && inst_multiple plymouth
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
)
# second, install the files needed to make the root filesystem
@@ -226,7 +227,7 @@ make_encrypted_root() {
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules" \
-m "crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules" \
-d "piix ide-gd_mod ata_piix ext2 ext3 sd_mod" \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf -- $TESTDIR/overlay
@@ -248,7 +249,7 @@ make_client_root() {
dd if=/dev/null of=$TESTDIR/nbd.ext2 bs=1M seek=30
mke2fs -F -j $TESTDIR/nbd.ext2
mkdir $TESTDIR/mnt
sudo mount -o loop $TESTDIR/nbd.ext2 $TESTDIR/mnt
mount -o loop $TESTDIR/nbd.ext2 $TESTDIR/mnt
kernel=$KVERSION
(
@@ -272,10 +273,10 @@ make_client_root() {
inst $i
done
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
)
sudo umount $TESTDIR/mnt
umount $TESTDIR/mnt
rm -fr -- $TESTDIR/mnt
}
@@ -283,7 +284,7 @@ make_server_root() {
dd if=/dev/null of=$TESTDIR/server.ext2 bs=1M seek=30
mke2fs -F $TESTDIR/server.ext2
mkdir $TESTDIR/mnt
sudo mount -o loop $TESTDIR/server.ext2 $TESTDIR/mnt
mount -o loop $TESTDIR/server.ext2 $TESTDIR/mnt
kernel=$KVERSION
(
@@ -317,17 +318,14 @@ make_server_root() {
done
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
ldconfig -r "$initdir"
)
sudo umount $TESTDIR/mnt
umount $TESTDIR/mnt
rm -fr -- $TESTDIR/mnt
}
test_setup() {
modinfo nbd &>/dev/null || { echo "Kernel does not support nbd"; exit 1; }
make_encrypted_root || return 1
make_client_root || return 1
make_server_root || return 1
@@ -351,12 +349,12 @@ test_setup() {
echo -n test > $initdir/etc/key
)
sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash udev-rules rootfs-block fs-lib base debug kernel-modules" \
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "udev-rules rootfs-block fs-lib base debug kernel-modules" \
-d "af_packet piix ide-gd_mod ata_piix ext2 ext3 sd_mod e1000" \
-f $TESTDIR/initramfs.server $KVERSION || return 1
sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-o "plymouth" \
-a "debug watchdog" \
-d "af_packet piix ide-gd_mod ata_piix ext2 ext3 sd_mod e1000 i6300esb ib700wdt" \
@@ -365,11 +363,17 @@ test_setup() {
kill_server() {
if [[ -s $TESTDIR/server.pid ]]; then
sudo kill -TERM $(cat $TESTDIR/server.pid)
kill -TERM $(cat $TESTDIR/server.pid)
rm -f -- $TESTDIR/server.pid
fi
}
test_check() {
modinfo nbd &>/dev/null || { echo "Kernel does not support nbd"; return 1; }
command -v nbd-client &>/dev/null || { echo "No nbd-client available"; return 1; }
command -v nbd-server &>/dev/null || { echo "No nbd-server available"; return 1; }
}
test_cleanup() {
kill_server
}

Some files were not shown because too many files have changed in this diff Show More