Compare commits
209 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6b82776107 | ||
![]() |
57c3103a69 | ||
![]() |
1126a69746 | ||
![]() |
6193b3a6e2 | ||
![]() |
e8a7c2a152 | ||
![]() |
65623826c1 | ||
![]() |
e42ab58a70 | ||
![]() |
937b808a0d | ||
![]() |
2ee1e96e1a | ||
![]() |
c6ccef8827 | ||
![]() |
97dd467e8e | ||
![]() |
fc87cf0e7e | ||
![]() |
75d6e4366a | ||
![]() |
d76ccd07bc | ||
![]() |
e5c337c3b3 | ||
![]() |
e4034dcae3 | ||
![]() |
da6411f59c | ||
![]() |
af97814e42 | ||
![]() |
ecd196732f | ||
![]() |
5f381a151f | ||
![]() |
8df75b1573 | ||
![]() |
013030d947 | ||
![]() |
f055e5126f | ||
![]() |
c9e0ee2c91 | ||
![]() |
f421aa0f16 | ||
![]() |
125bb747c3 | ||
![]() |
903d6fc2fc | ||
![]() |
249dcc61ea | ||
![]() |
26273649dc | ||
![]() |
15384bcedb | ||
![]() |
dd235965dd | ||
![]() |
388c771a28 | ||
![]() |
f264cfbe8a | ||
![]() |
de688a407c | ||
![]() |
58a5434f75 | ||
![]() |
9dfcc5f066 | ||
![]() |
014a78261d | ||
![]() |
e8ffd4b3d4 | ||
![]() |
19da2dda22 | ||
![]() |
5aadb10791 | ||
![]() |
7812b7a7b0 | ||
![]() |
69a889ee67 | ||
![]() |
9b1d79993d | ||
![]() |
a0e7bc11c8 | ||
![]() |
f93c34935f | ||
![]() |
e076279d38 | ||
![]() |
43d6b9d008 | ||
![]() |
69b5de6251 | ||
![]() |
0259f1c246 | ||
![]() |
240c2fea10 | ||
![]() |
75bf5df420 | ||
![]() |
50c3405ce0 | ||
![]() |
50d75a50fb | ||
![]() |
3d1c9a76e7 | ||
![]() |
0fe8ed5ccb | ||
![]() |
fe89c8f9df | ||
![]() |
6ef3173e86 | ||
![]() |
015d5aee92 | ||
![]() |
0489607bf6 | ||
![]() |
e2afcc958b | ||
![]() |
0e842c4b8b | ||
![]() |
063d6acb7b | ||
![]() |
8131fd3c11 | ||
![]() |
744afe7531 | ||
![]() |
17092b128c | ||
![]() |
7b9bbc2a82 | ||
![]() |
994a6cdd88 | ||
![]() |
3674e2e16f | ||
![]() |
436052a84b | ||
![]() |
784c92876b | ||
![]() |
fb008ce665 | ||
![]() |
02d0d0a208 | ||
![]() |
5ae8333947 | ||
![]() |
ea8bef9893 | ||
![]() |
3186abd76e | ||
![]() |
a603e1f3a6 | ||
![]() |
2877acadc0 | ||
![]() |
414834306b | ||
![]() |
01e66d43d8 | ||
![]() |
e186d99780 | ||
![]() |
3ce2235abb | ||
![]() |
9301650e17 | ||
![]() |
d971a570d0 | ||
![]() |
72ae0fd418 | ||
![]() |
fa861e2cbf | ||
![]() |
b120b0c116 | ||
![]() |
1bb76cea72 | ||
![]() |
5fd8d27383 | ||
![]() |
d381343caa | ||
![]() |
11366030aa | ||
![]() |
455f87f41f | ||
![]() |
73cf135d80 | ||
![]() |
0ee8c37f39 | ||
![]() |
968eb46fce | ||
![]() |
904c466cdb | ||
![]() |
ba5efdcffa | ||
![]() |
afeb39aa85 | ||
![]() |
a081e072d8 | ||
![]() |
aa40b82145 | ||
![]() |
81bb61b525 | ||
![]() |
7b4173d698 | ||
![]() |
13a61f82ba | ||
![]() |
d2fd423a8d | ||
![]() |
f432d367fc | ||
![]() |
6dcb4867ae | ||
![]() |
05a38caaf2 | ||
![]() |
443d167a95 | ||
![]() |
33710dfbfc | ||
![]() |
c87d489ca6 | ||
![]() |
99e72a4b1c | ||
![]() |
39c4892772 | ||
![]() |
8c67fb9123 | ||
![]() |
1d267fb82c | ||
![]() |
91896ab68e | ||
![]() |
1b23c6c65c | ||
![]() |
b8e6c051c6 | ||
![]() |
fc77aca7dd | ||
![]() |
7a7b8c1740 | ||
![]() |
8dd6ff8d6a | ||
![]() |
10e6bf0e43 | ||
![]() |
cd6679c716 | ||
![]() |
20171c7519 | ||
![]() |
b7c7b16d4e | ||
![]() |
b077d18963 | ||
![]() |
2f42cfcbeb | ||
![]() |
0eb1afa9ea | ||
![]() |
2c9f267268 | ||
![]() |
038f142ef9 | ||
![]() |
1492490070 | ||
![]() |
0eb1ee3db2 | ||
![]() |
4c83fd10ab | ||
![]() |
f69cd051ab | ||
![]() |
0be17528e5 | ||
![]() |
e5439c9b37 | ||
![]() |
573e508554 | ||
![]() |
7b0ce59233 | ||
![]() |
7a90c8b343 | ||
![]() |
84d845fc7d | ||
![]() |
aea64fe178 | ||
![]() |
271a64bfd1 | ||
![]() |
fd8506b5da | ||
![]() |
4c5f1b3b4a | ||
![]() |
a95fe14581 | ||
![]() |
6efee60f93 | ||
![]() |
22a907b383 | ||
![]() |
ca46c751d1 | ||
![]() |
ca64eeec79 | ||
![]() |
9aa224cc19 | ||
![]() |
13264563a9 | ||
![]() |
cc3f588071 | ||
![]() |
42dd8928a8 | ||
![]() |
6d22a6860e | ||
![]() |
bac74f05e3 | ||
![]() |
a320422588 | ||
![]() |
5bc318633f | ||
![]() |
53310e44c9 | ||
![]() |
a7805d1297 | ||
![]() |
435af39a00 | ||
![]() |
323093b621 | ||
![]() |
61b5ee6d1d | ||
![]() |
55712f46c0 | ||
![]() |
53e4ab7174 | ||
![]() |
b7f5e42c57 | ||
![]() |
603a0fe0a3 | ||
![]() |
f105eaebb8 | ||
![]() |
f501c955e8 | ||
![]() |
b9668f8f00 | ||
![]() |
a4cbfd719b | ||
![]() |
7335bd1e23 | ||
![]() |
26eeb4af8d | ||
![]() |
d6b9aac6d0 | ||
![]() |
3186a0aa15 | ||
![]() |
cc7d2eeb36 | ||
![]() |
b4ad021d34 | ||
![]() |
f45726652f | ||
![]() |
ced0638e2c | ||
![]() |
8175f5eb82 | ||
![]() |
017c16b97a | ||
![]() |
320b8d5c0c | ||
![]() |
0b7c2400c3 | ||
![]() |
fefb96f43f | ||
![]() |
1472b5486b | ||
![]() |
e6ae0c6128 | ||
![]() |
ac422d577c | ||
![]() |
484aba4298 | ||
![]() |
b14e0fb826 | ||
![]() |
863105bce1 | ||
![]() |
15ec719501 | ||
![]() |
249a94ab04 | ||
![]() |
6656e1547f | ||
![]() |
688afe0fc3 | ||
![]() |
8fb06a0562 | ||
![]() |
68021e85c9 | ||
![]() |
12aa314819 | ||
![]() |
bff5416520 | ||
![]() |
9eab750787 | ||
![]() |
f31220ec88 | ||
![]() |
043d61b542 | ||
![]() |
0d7b00a230 | ||
![]() |
a48ea27deb | ||
![]() |
9d030e4ef1 | ||
![]() |
3a39dd027f | ||
![]() |
de8cc25d70 | ||
![]() |
ba977abe63 | ||
![]() |
69762959ae | ||
![]() |
851946468a | ||
![]() |
28665b4fa5 | ||
![]() |
17985b2575 | ||
![]() |
2f20797a40 |
31
Makefile
31
Makefile
@@ -1,6 +1,6 @@
|
||||
-include dracut-version.sh
|
||||
|
||||
VERSION = $(shell [ -d .git ] && git describe --abbrev=0 --tags 2>/dev/null || echo $(DRACUT_VERSION))
|
||||
VERSION = $(shell [ -d .git ] && git describe --abbrev=0 2>/dev/null || echo $(DRACUT_VERSION))
|
||||
GITVERSION = $(shell [ -d .git ] && { v=$$(git describe --tags 2>/dev/null); [ $${v\#*-} != $$v ] && echo -$${v\#*-}; } )
|
||||
|
||||
-include Makefile.inc
|
||||
@@ -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
|
||||
|
||||
@@ -38,9 +39,9 @@ man8pages = dracut.8 \
|
||||
|
||||
manpages = $(man1pages) $(man5pages) $(man7pages) $(man8pages)
|
||||
|
||||
.PHONY: install clean archive rpm testimage test all check AUTHORS doc dracut-version.sh
|
||||
.PHONY: install clean archive rpm srpm 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,17 @@ 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 )
|
||||
|
||||
srpm: dracut-$(VERSION).tar.bz2 syncheck
|
||||
rpmbuild=$$(mktemp -d -t rpmbuild-dracut.XXXXXX); src=$$(pwd); \
|
||||
cp dracut-$(VERSION).tar.bz2 "$$rpmbuild"; \
|
||||
LC_MESSAGES=C $$src/git2spec.pl $(VERSION) "$$rpmbuild" < dracut.spec > $$rpmbuild/dracut.spec; \
|
||||
(cd "$$rpmbuild"; \
|
||||
rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" \
|
||||
--define "_specdir $$PWD" --define "_srcrpmdir $$PWD" \
|
||||
--define "_rpmdir $$PWD" -bs dracut.spec; ) && \
|
||||
( 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
5
README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# dracut RHEL-7 branch
|
||||
|
||||
dracut is an initramfs infrastructure.
|
||||
|
||||
CentOS CI Status: [](https://ci.centos.org/job/dracut-push-rhel-7/)
|
@@ -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
|
||||
;;
|
||||
|
@@ -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/. ]]
|
||||
@@ -589,7 +593,8 @@ for_each_host_dev_fs()
|
||||
local _dev
|
||||
local _ret=1
|
||||
|
||||
[[ "${!host_fs_types[@]}" ]] || return 0
|
||||
[[ "${#host_fs_types[@]}" ]] || return 2
|
||||
|
||||
|
||||
for _dev in "${!host_fs_types[@]}"; do
|
||||
$_func "$_dev" "${host_fs_types[$_dev]}" && _ret=0
|
||||
@@ -611,13 +616,14 @@ check_block_and_slaves() {
|
||||
[[ -b /dev/block/$2 ]] || return 1 # Not a block device? So sorry.
|
||||
if ! lvm_internal_dev $2; then "$1" $2 && return; fi
|
||||
check_vol_slaves "$@" && return 0
|
||||
if [[ -f /sys/dev/block/$2/../dev ]]; then
|
||||
if [[ -f /sys/dev/block/$2/../dev ]] && [[ /sys/dev/block/$2/../subsystem -ef /sys/class/block ]]; then
|
||||
check_block_and_slaves $1 $(<"/sys/dev/block/$2/../dev") && return 0
|
||||
fi
|
||||
[[ -d /sys/dev/block/$2/slaves ]] || return 1
|
||||
for _x in /sys/dev/block/$2/slaves/*/dev; do
|
||||
[[ -f $_x ]] || continue
|
||||
check_block_and_slaves $1 $(<"$_x") && return 0
|
||||
for _x in /sys/dev/block/$2/slaves/*; do
|
||||
[[ -f $_x/dev ]] || continue
|
||||
[[ $_x/subsystem -ef /sys/class/block ]] || continue
|
||||
check_block_and_slaves $1 $(<"$_x/dev") && return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
@@ -628,14 +634,15 @@ check_block_and_slaves_all() {
|
||||
if ! lvm_internal_dev $2 && "$1" $2; then
|
||||
_ret=0
|
||||
fi
|
||||
check_vol_slaves "$@" && return 0
|
||||
if [[ -f /sys/dev/block/$2/../dev ]]; then
|
||||
check_vol_slaves_all "$@" && return 0
|
||||
if [[ -f /sys/dev/block/$2/../dev ]] && [[ /sys/dev/block/$2/../subsystem -ef /sys/class/block ]]; then
|
||||
check_block_and_slaves_all $1 $(<"/sys/dev/block/$2/../dev") && _ret=0
|
||||
fi
|
||||
[[ -d /sys/dev/block/$2/slaves ]] || return 1
|
||||
for _x in /sys/dev/block/$2/slaves/*/dev; do
|
||||
[[ -f $_x ]] || continue
|
||||
check_block_and_slaves_all $1 $(<"$_x") && _ret=0
|
||||
for _x in /sys/dev/block/$2/slaves/*; do
|
||||
[[ -f $_x/dev ]] || continue
|
||||
[[ $_x/subsystem -ef /sys/class/block ]] || continue
|
||||
check_block_and_slaves_all $1 $(<"$_x/dev") && _ret=0
|
||||
done
|
||||
return $_ret
|
||||
}
|
||||
@@ -648,9 +655,9 @@ for_each_host_dev_and_slaves_all()
|
||||
local _dev
|
||||
local _ret=1
|
||||
|
||||
[[ "${host_devs[@]}" ]] || return 0
|
||||
[[ "${host_devs[@]}" ]] || return 2
|
||||
|
||||
for _dev in ${host_devs[@]}; do
|
||||
for _dev in "${host_devs[@]}"; do
|
||||
[[ -b "$_dev" ]] || continue
|
||||
if check_block_and_slaves_all $_func $(get_maj_min $_dev); then
|
||||
_ret=0
|
||||
@@ -664,9 +671,9 @@ for_each_host_dev_and_slaves()
|
||||
local _func="$1"
|
||||
local _dev
|
||||
|
||||
[[ "${host_devs[@]}" ]] || return 0
|
||||
[[ "${host_devs[@]}" ]] || return 2
|
||||
|
||||
for _dev in ${host_devs[@]}; do
|
||||
for _dev in "${host_devs[@]}"; do
|
||||
[[ -b "$_dev" ]] || continue
|
||||
check_block_and_slaves $_func $(get_maj_min $_dev) && return 0
|
||||
done
|
||||
@@ -680,25 +687,44 @@ for_each_host_dev_and_slaves()
|
||||
# but you cannot create the logical volume without the volume group.
|
||||
# And the volume group might be bigger than the devices the LV needs.
|
||||
check_vol_slaves() {
|
||||
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=$(printf "%s\n" "$_vg")
|
||||
if [[ $_vg ]]; then
|
||||
for _pv in $(lvm vgs --noheadings -o pv_name "$_vg" 2>/dev/null)
|
||||
do
|
||||
check_block_and_slaves $1 $(get_maj_min $_pv) && return 0
|
||||
done
|
||||
fi
|
||||
fi
|
||||
done
|
||||
local _lv _vg _pv _dm _majmin
|
||||
_majmin="$2"
|
||||
_lv="/dev/block/$_majmin"
|
||||
_dm=/sys/dev/block/$_majmin/dm
|
||||
[[ -f $_dm/uuid && $(<$_dm/uuid) =~ LVM-* ]] || return 1
|
||||
_vg=$(dmsetup splitname --noheadings -o vg_name $(<"$_dm/name") )
|
||||
# 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 $1 $(get_maj_min $_pv) && return 0
|
||||
done
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
check_vol_slaves_all() {
|
||||
local _lv _vg _pv _majmin
|
||||
_majmin="$2"
|
||||
_lv="/dev/block/$_majmin"
|
||||
_dm="/sys/dev/block/$_majmin/dm"
|
||||
[[ -f $_dm/uuid && $(<$_dm/uuid) =~ LVM-* ]] || return 1
|
||||
_vg=$(dmsetup splitname --noheadings -o vg_name $(<"$_dm/name") )
|
||||
# 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
|
||||
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
|
||||
@@ -1214,7 +1240,7 @@ check_mount() {
|
||||
local _ret
|
||||
local _moddep
|
||||
|
||||
[ "${#host_fs_types[*]}" -le 0 ] && return 1
|
||||
[ "${#host_fs_types[@]}" -le 0 ] && return 1
|
||||
|
||||
# If we are already scheduled to be loaded, no need to check again.
|
||||
[[ " $mods_to_load " == *\ $_mod\ * ]] && return 0
|
||||
@@ -1710,9 +1736,8 @@ get_ucode_file ()
|
||||
local stepping=`grep -E "stepping" /proc/cpuinfo | head -1 | sed s/.*:\ //`
|
||||
|
||||
if [[ "$(get_cpu_vendor)" == "AMD" ]]; then
|
||||
# If family greater or equal than 0x15
|
||||
if [[ $family -ge 21 ]]; then
|
||||
printf "microcode_amd_fam15h.bin"
|
||||
printf "microcode_amd_fam%xh.bin" $family
|
||||
else
|
||||
printf "microcode_amd.bin"
|
||||
fi
|
||||
@@ -1723,6 +1748,17 @@ get_ucode_file ()
|
||||
fi
|
||||
}
|
||||
|
||||
# Get currently loaded modules
|
||||
# sorted, and delimited by newline
|
||||
get_loaded_kernel_modules ()
|
||||
{
|
||||
local modules=( )
|
||||
while read _module _size _used _used_by; do
|
||||
modules+=( "$_module" )
|
||||
done <<< "$(lsmod | sed -n '1!p')"
|
||||
printf '%s\n' "${modules[@]}" | sort
|
||||
}
|
||||
|
||||
# Not every device in /dev/mapper should be examined.
|
||||
# If it is an LVM device, touch only devices which have /dev/VG/LV symlink.
|
||||
lvm_internal_dev() {
|
||||
@@ -1734,3 +1770,14 @@ lvm_internal_dev() {
|
||||
[[ ${DM_LV_LAYER} ]] || [[ ! -L /dev/${DM_VG_NAME}/${DM_LV_NAME} ]]
|
||||
}
|
||||
|
||||
# Use with form hostonly="$(optional_hostonly)" inst_xxxx <args>
|
||||
# If hosotnly mode is set to "strict", hostonly restrictions will still
|
||||
# be applied, else will ignore hostonly mode and try to install all
|
||||
# given modules.
|
||||
optional_hostonly() {
|
||||
if [[ $hostonly_mode = "strict" ]]; then
|
||||
printf -- "$hostonly"
|
||||
else
|
||||
printf ""
|
||||
fi
|
||||
}
|
||||
|
@@ -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" &
|
||||
|
26
dracut.8.asc
26
dracut.8.asc
@@ -136,6 +136,19 @@ example:
|
||||
----
|
||||
===============================
|
||||
|
||||
**--force-drivers** _<list of kernel modules>_::
|
||||
See add-drivers above. But in this case it is ensured that the drivers
|
||||
are tried to be loaded early via modprobe.
|
||||
+
|
||||
[NOTE]
|
||||
===============================
|
||||
If [LIST] has multiple arguments, then you have to put these in quotes. For
|
||||
example:
|
||||
----
|
||||
# dracut --force-drivers "kmodule1 kmodule2" ...
|
||||
----
|
||||
===============================
|
||||
|
||||
**--omit-drivers** _<list of kernel modules>_::
|
||||
specify a space-separated list of kernel modules not to add to the
|
||||
initramfs.
|
||||
@@ -306,6 +319,16 @@ provide a valid _/etc/fstab_.
|
||||
**--no-hostonly-cmdline**:
|
||||
Do not store kernel command line arguments needed in the initramfs
|
||||
|
||||
**--no-hostonly-default-device**:
|
||||
Do not generate implicit host devices like root, swap, fstab, etc.
|
||||
Use "--mount" or "--add-device" to explicitly add devices as needed.
|
||||
|
||||
**--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 +372,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
|
||||
|
@@ -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**::
|
||||
@@ -441,7 +449,7 @@ USB Android phone::
|
||||
* enp0s29u1u2
|
||||
=====================
|
||||
|
||||
**ip=**__{dhcp|on|any|dhcp6|auto6}__::
|
||||
**ip=**__{dhcp|on|any|dhcp6|auto6|either6}__::
|
||||
dhcp|on|any::: get ip from dhcp server from all interfaces. If root=dhcp,
|
||||
loop sequentially through all interfaces (eth0, eth1, ...) and use the first
|
||||
with a valid DHCP root-path.
|
||||
@@ -450,6 +458,8 @@ USB Android phone::
|
||||
|
||||
dhcp6::: IPv6 DHCP
|
||||
|
||||
either6::: if auto6 fails, then dhcp6
|
||||
|
||||
**ip=**__<interface>__:__{dhcp|on|any|dhcp6|auto6}__[:[__<mtu>__][:__<macaddr>__]]::
|
||||
This parameter can be specified multiple times.
|
||||
+
|
||||
@@ -461,7 +471,7 @@ cannot be used in conjunction with the **ifname** argument for the
|
||||
same <interface>.
|
||||
=====================
|
||||
|
||||
**ip=**__<client-IP>__:[__<peer>__]:__<gateway-IP>__:__<netmask>__:__<client_hostname>__:__<interface>__:__{none|off|dhcp|on|any|dhcp6|auto6|ibft}__:[:[__<mtu>__][:__<macaddr>__]]::
|
||||
**ip=**__<client-IP>__:[__<peer>__]:__<gateway-IP>__:__<netmask>__:__<client_hostname>__:__<interface>__:__{none|off|dhcp|on|any|dhcp6|auto6|ibft}__[:[__<mtu>__][:__<macaddr>__]]::
|
||||
explicit network configuration. If you want do define a IPv6 address, put it
|
||||
in brackets (e.g. [2001:DB8::1]). This parameter can be specified multiple
|
||||
times. __<peer>__ is optional and is the address of the remote endpoint
|
||||
|
@@ -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_.
|
||||
@@ -49,6 +54,10 @@ Configuration files must have the extension .conf; other extensions are ignored.
|
||||
Specify a space-separated list of kernel modules to add to the initramfs.
|
||||
The kernel modules have to be specified without the ".ko" suffix.
|
||||
|
||||
*force_drivers+=*" __<list of kernel modules>__ "::
|
||||
See add_drivers above. But in this case it is ensured that the drivers
|
||||
are tried to be loaded early via modprobe.
|
||||
|
||||
*omit_drivers+=*" __<kernel modules>__ "::
|
||||
Specify a space-separated list of kernel modules not to add to the
|
||||
initramfs. The kernel modules have to be specified without the ".ko" suffix.
|
||||
@@ -66,6 +75,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 +92,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.
|
||||
|
@@ -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
|
||||
|
256
dracut.sh
256
dracut.sh
@@ -23,6 +23,8 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
unset BASH_ENV
|
||||
|
||||
# store for logging
|
||||
dracut_args=( "$@" )
|
||||
|
||||
@@ -81,6 +83,10 @@ Creates initial ramdisk images for preloading modules
|
||||
exclusively include in the initramfs.
|
||||
--add-drivers [LIST] Specify a space-separated list of kernel
|
||||
modules to add to the initramfs.
|
||||
--force-drivers [LIST] Specify a space-separated list of kernel
|
||||
modules to add to the initramfs and make sure they
|
||||
are tried to be loaded via modprobe same as passing
|
||||
rd.driver.pre=DRIVER kernel parameter.
|
||||
--omit-drivers [LIST] Specify a space-separated list of kernel
|
||||
modules not to add to the initramfs.
|
||||
--filesystems [LIST] Specify a space-separated list of kernel filesystem
|
||||
@@ -137,10 +143,32 @@ Creates initial ramdisk images for preloading modules
|
||||
-H, --hostonly Host-Only mode: Install only what is needed for
|
||||
booting the local host instead of a generic host.
|
||||
-N, --no-hostonly Disables Host-Only mode
|
||||
--hostonly-mode <mode>
|
||||
Specify the hostonly mode to use. <mode> could be
|
||||
one of "sloppy" or "strict". "sloppy" mode is used
|
||||
by default.
|
||||
In "sloppy" hostonly mode, extra drivers and modules
|
||||
will be installed, so minor hardware change won't make
|
||||
the image unbootable (eg. changed keyboard), and the
|
||||
image is still portable among similar hosts.
|
||||
With "strict" mode enabled, anything not necessary
|
||||
for booting the local host in its current state will
|
||||
not be included, and modules may do some extra job
|
||||
to save more space. Minor change of hardware or
|
||||
environment could make the image unbootable.
|
||||
DO NOT use "strict" mode unless you know what you
|
||||
are doing.
|
||||
--hostonly-cmdline Store kernel command line arguments needed
|
||||
in the initramfs
|
||||
--no-hostonly-cmdline Do not store kernel command line arguments needed
|
||||
in the initramfs
|
||||
--no-hostonly-default-device
|
||||
Do not generate implicit host devices like root,
|
||||
swap, fstab, etc. Use "--mount" or "--add-device"
|
||||
to explicitly add devices as needed.
|
||||
--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 +186,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.
|
||||
@@ -299,12 +329,14 @@ rearrange_params()
|
||||
--long add: \
|
||||
--long force-add: \
|
||||
--long add-drivers: \
|
||||
--long force-drivers: \
|
||||
--long omit-drivers: \
|
||||
--long modules: \
|
||||
--long omit: \
|
||||
--long drivers: \
|
||||
--long filesystems: \
|
||||
--long install: \
|
||||
--long install-optional: \
|
||||
--long fwdir: \
|
||||
--long libdirs: \
|
||||
--long fscks: \
|
||||
@@ -349,8 +381,10 @@ rearrange_params()
|
||||
--long host-only \
|
||||
--long no-hostonly \
|
||||
--long no-host-only \
|
||||
--long hostonly-mode: \
|
||||
--long hostonly-cmdline \
|
||||
--long no-hostonly-cmdline \
|
||||
--long no-hostonly-default-device \
|
||||
--long persistent-policy: \
|
||||
--long fstab \
|
||||
--long help \
|
||||
@@ -465,12 +499,16 @@ while :; do
|
||||
-a|--add) push add_dracutmodules_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
|
||||
--force-add) push force_add_dracutmodules_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
|
||||
--add-drivers) push add_drivers_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
|
||||
--force-drivers) push force_drivers_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
|
||||
--omit-drivers) push omit_drivers_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
|
||||
-m|--modules) push dracutmodules_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
|
||||
-o|--omit) push omit_dracutmodules_l "$2"; PARMS_TO_STORE+=" '$2'"; shift;;
|
||||
-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;;
|
||||
@@ -528,6 +566,8 @@ while :; do
|
||||
hostonly_l="yes" ;;
|
||||
-N|--no-hostonly|--no-host-only)
|
||||
hostonly_l="no" ;;
|
||||
--hostonly-mode)
|
||||
hostonly_mode_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
|
||||
--hostonly-cmdline)
|
||||
hostonly_cmdline_l="yes" ;;
|
||||
--hostonly-i18n)
|
||||
@@ -536,6 +576,8 @@ while :; do
|
||||
i18n_install_all_l="yes" ;;
|
||||
--no-hostonly-cmdline)
|
||||
hostonly_cmdline_l="no" ;;
|
||||
--no-hostonly-default-device)
|
||||
hostonly_default_device="no" ;;
|
||||
--persistent-policy)
|
||||
persistent_policy_l="$2"; PARMS_TO_STORE+=" '$2'"; shift;;
|
||||
--fstab) use_fstab_l="yes" ;;
|
||||
@@ -722,6 +764,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=''
|
||||
@@ -775,13 +823,14 @@ stdloglvl=$((stdloglvl + verbosity_mod_l))
|
||||
[[ $prefix = "/" ]] && unset prefix
|
||||
[[ $hostonly_l ]] && hostonly=$hostonly_l
|
||||
[[ $hostonly_cmdline_l ]] && hostonly_cmdline=$hostonly_cmdline_l
|
||||
[[ $hostonly_mode_l ]] && hostonly_mode=$hostonly_mode_l
|
||||
[[ $i18n_install_all_l ]] && i18n_install_all=$i18n_install_all_l
|
||||
[[ $persistent_policy_l ]] && persistent_policy=$persistent_policy_l
|
||||
[[ $use_fstab_l ]] && use_fstab=$use_fstab_l
|
||||
[[ $mdadmconf_l ]] && mdadmconf=$mdadmconf_l
|
||||
[[ $lvmconf_l ]] && lvmconf=$lvmconf_l
|
||||
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
|
||||
[[ $fw_dir ]] || fw_dir="/lib/firmware/updates /lib/firmware"
|
||||
[[ $fw_dir ]] || fw_dir="/lib/firmware/updates /lib/firmware /lib/firmware/$kernel"
|
||||
[[ $tmpdir_l ]] && tmpdir="$tmpdir_l"
|
||||
[[ $tmpdir ]] || tmpdir=/var/tmp
|
||||
[[ $INITRD_COMPRESS ]] && compress=$INITRD_COMPRESS
|
||||
@@ -812,32 +861,41 @@ fi
|
||||
[[ $hostonly = yes ]] && hostonly="-h"
|
||||
[[ $hostonly != "-h" ]] && unset hostonly
|
||||
|
||||
case $hostonly_mode in
|
||||
'')
|
||||
[[ $hostonly ]] && hostonly_mode="sloppy" ;;
|
||||
sloppy|strict)
|
||||
if [[ ! $hostonly ]]; then
|
||||
unset hostonly_mode
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
printf "%s\n" "dracut: Invalid hostonly mode '$hostonly_mode'." >&2
|
||||
exit 1
|
||||
esac
|
||||
|
||||
|
||||
|
||||
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"
|
||||
|
||||
@@ -848,6 +906,10 @@ if [[ $print_cmdline ]]; then
|
||||
kmsgloglvl=0
|
||||
fi
|
||||
|
||||
if [[ -f $dracutbasedir/dracut-version.sh ]]; then
|
||||
. $dracutbasedir/dracut-version.sh
|
||||
fi
|
||||
|
||||
if [[ -f $dracutbasedir/dracut-init.sh ]]; then
|
||||
. $dracutbasedir/dracut-init.sh
|
||||
else
|
||||
@@ -866,10 +928,6 @@ if ! [[ $print_cmdline ]]; then
|
||||
rm -fr -- ${initdir}/*
|
||||
fi
|
||||
|
||||
if [[ -f $dracutbasedir/dracut-version.sh ]]; then
|
||||
. $dracutbasedir/dracut-version.sh
|
||||
fi
|
||||
|
||||
# Verify bash version, current minimum is 3.1
|
||||
if (( BASH_VERSINFO[0] < 4 )); then
|
||||
dfatal 'You need at least Bash 4 to use dracut, sorry.'
|
||||
@@ -879,6 +937,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
|
||||
@@ -894,6 +970,13 @@ if (( ${#add_drivers_l[@]} )); then
|
||||
fi
|
||||
add_drivers=${add_drivers/-/_}
|
||||
|
||||
if (( ${#force_drivers_l[@]} )); then
|
||||
while pop force_drivers_l val; do
|
||||
force_drivers+=" $val "
|
||||
done
|
||||
fi
|
||||
force_drivers=${force_drivers/-/_}
|
||||
|
||||
if (( ${#omit_drivers_l[@]} )); then
|
||||
while pop omit_drivers_l val; do
|
||||
omit_drivers+=" $val "
|
||||
@@ -910,6 +993,7 @@ fi
|
||||
omit_drivers_corrected=""
|
||||
for d in $omit_drivers; do
|
||||
[[ " $drivers $add_drivers " == *\ $d\ * ]] && continue
|
||||
[[ " $drivers $force_drivers " == *\ $d\ * ]] && continue
|
||||
omit_drivers_corrected+="$d|"
|
||||
done
|
||||
omit_drivers="${omit_drivers_corrected%|}"
|
||||
@@ -942,9 +1026,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
|
||||
@@ -1007,7 +1096,7 @@ if (( ${#add_device_l[@]} )); then
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ $hostonly ]]; then
|
||||
if [[ $hostonly ]] && [[ "$hostonly_default_device" != "no" ]]; then
|
||||
# in hostonly mode, determine all devices, which have to be accessed
|
||||
# and examine them for filesystem types
|
||||
|
||||
@@ -1082,8 +1171,10 @@ if [[ $hostonly ]]; then
|
||||
[[ -b $_dev ]] && push host_devs "$_dev"
|
||||
done < /etc/fstab
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [[ $hostonly ]]; then
|
||||
# record all host modaliases
|
||||
declare -A host_modalias
|
||||
find /sys/devices/ -name uevent -print > "$initdir/.modalias"
|
||||
@@ -1104,9 +1195,23 @@ if [[ $hostonly ]]; then
|
||||
|
||||
# check /proc/modules
|
||||
declare -A host_modules
|
||||
while read m rest; do
|
||||
host_modules["$m"]=1
|
||||
done </proc/modules
|
||||
declare new_module_found=1
|
||||
declare tmpmodules=$(mktemp --tmpdir="$TMPDIR/" -t proc_modules.XXXXXX)
|
||||
while [[ $new_module_found ]]; do
|
||||
new_module_found=
|
||||
sleep 0.1
|
||||
#reading from procfs can be broken, so copy the file elsewhere
|
||||
cp -f /proc/modules "$tmpmodules"
|
||||
while read m rest; do
|
||||
[ -z "$m" ] && continue
|
||||
[[ ${host_modules["$m"]} ]] && continue
|
||||
host_modules["$m"]=1
|
||||
new_module_found=1
|
||||
done < "$tmpmodules"
|
||||
done
|
||||
rm "$tmpmodules"
|
||||
unset new_module_found
|
||||
unset tmpmodules
|
||||
fi
|
||||
|
||||
unset m
|
||||
@@ -1129,7 +1234,7 @@ _get_fs_type() {
|
||||
return 1
|
||||
}
|
||||
|
||||
for dev in ${host_devs[@]}; do
|
||||
for dev in "${host_devs[@]}"; do
|
||||
_get_fs_type "$dev"
|
||||
check_block_and_slaves_all _get_fs_type "$(get_maj_min "$dev")"
|
||||
done
|
||||
@@ -1150,6 +1255,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
|
||||
@@ -1320,6 +1431,9 @@ dinfo "*** Including modules done ***"
|
||||
|
||||
## final stuff that has to happen
|
||||
if [[ $no_kernel != yes ]]; then
|
||||
if [[ $hostonly ]]; then
|
||||
echo "$(get_loaded_kernel_modules)" > $initdir/lib/dracut/loaded-kernel-modules.txt
|
||||
fi
|
||||
|
||||
if [[ $drivers ]]; then
|
||||
hostonly='' instmods $drivers
|
||||
@@ -1328,6 +1442,13 @@ if [[ $no_kernel != yes ]]; then
|
||||
if [[ $add_drivers ]]; then
|
||||
hostonly='' instmods -c $add_drivers
|
||||
fi
|
||||
if [[ $force_drivers ]]; then
|
||||
hostonly='' instmods -c $force_drivers
|
||||
rm -f $initdir/etc/cmdline.d/20-force_driver.conf
|
||||
for mod in $force_drivers; do
|
||||
echo "rd.driver.pre=$mod" >>$initdir/etc/cmdline.d/20-force_drivers.conf
|
||||
done
|
||||
fi
|
||||
if [[ $filesystems ]]; then
|
||||
hostonly='' instmods -c $filesystems
|
||||
fi
|
||||
@@ -1349,6 +1470,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"
|
||||
|
||||
@@ -1384,26 +1506,29 @@ if [[ $kernel_only != yes ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
while pop include_src src && pop include_target tgt; do
|
||||
if [[ $src && $tgt ]]; then
|
||||
while pop include_src src && pop include_target target; do
|
||||
if [[ $src && $target ]]; then
|
||||
if [[ -f $src ]]; then
|
||||
inst $src $tgt
|
||||
inst $src $target
|
||||
else
|
||||
ddebug "Including directory: $src"
|
||||
mkdir -p "${initdir}/${tgt}"
|
||||
destdir="${initdir}/${target}"
|
||||
mkdir -p "$destdir"
|
||||
# check for preexisting symlinks, so we can cope with the
|
||||
# symlinks to $prefix
|
||||
for i in "$src"/*; do
|
||||
[[ -e "$i" || -h "$i" ]] || continue
|
||||
s=${initdir}/${tgt}/${i#$src/}
|
||||
if [[ -d "$i" ]]; then
|
||||
if ! [[ -e "$s" ]]; then
|
||||
mkdir -m 0755 -p "$s"
|
||||
chmod --reference="$i" "$s"
|
||||
# Objectname is a file or a directory
|
||||
for objectname in "$src"/*; do
|
||||
[[ -e "$objectname" || -h "$objectname" ]] || continue
|
||||
if [[ -d "$objectname" ]]; then
|
||||
# objectname is a directory, let's compute the final directory name
|
||||
object_destdir=${destdir}/${objectname#$src/}
|
||||
if ! [[ -e "$object_destdir" ]]; then
|
||||
mkdir -m 0755 -p "$object_destdir"
|
||||
chmod --reference="$objectname" "$object_destdir"
|
||||
fi
|
||||
cp --reflink=auto --sparse=auto -fa -t "$s" "$i"/*
|
||||
cp --reflink=auto --sparse=auto -fa -t "$object_destdir" "$objectname"/*
|
||||
else
|
||||
cp --reflink=auto --sparse=auto -fa -t "$s" "$i"
|
||||
cp --reflink=auto --sparse=auto -fa -t "$destdir" "$objectname"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
@@ -1470,8 +1595,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 +1623,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 +1661,53 @@ 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
|
||||
|
||||
|
||||
if ! sync "$outfile" 2> /dev/null; then
|
||||
dinfo "dracut: sync operartion on newly created initramfs $outfile failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
@@ -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
|
||||
@@ -343,6 +346,7 @@ rm -rf -- $RPM_BUILD_ROOT
|
||||
%{dracutlibdir}/modules.d/90dm
|
||||
%{dracutlibdir}/modules.d/90dmraid
|
||||
%{dracutlibdir}/modules.d/90dmsquash-live
|
||||
%{dracutlibdir}/modules.d/90dmsquash-live-ntfs
|
||||
%{dracutlibdir}/modules.d/90kernel-modules
|
||||
%{dracutlibdir}/modules.d/90lvm
|
||||
%{dracutlibdir}/modules.d/90mdraid
|
||||
|
62
lsinitrd.sh
62
lsinitrd.sh
@@ -113,7 +113,7 @@ fi
|
||||
extract_files()
|
||||
{
|
||||
(( ${#filenames[@]} == 1 )) && nofileinfo=1
|
||||
for f in ${!filenames[@]}; do
|
||||
for f in "${!filenames[@]}"; do
|
||||
[[ $nofileinfo ]] || echo "initramfs:/$f"
|
||||
[[ $nofileinfo ]] || echo "========================================================================"
|
||||
$CAT $image 2>/dev/null | cpio --extract --verbose --quiet --to-stdout $f 2>/dev/null
|
||||
@@ -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()
|
||||
{
|
||||
|
8
modules.d/01fips/fips-load-crypto.sh
Normal file
8
modules.d/01fips/fips-load-crypto.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
if ! fipsmode=$(getarg fips) || [ $fipsmode = "0" ]; then
|
||||
rm -f -- /etc/modprobe.d/fips.conf >/dev/null 2>&1
|
||||
else
|
||||
. /sbin/fips.sh
|
||||
fips_load_crypto || die "FIPS integrity test failed"
|
||||
fi
|
@@ -71,6 +71,34 @@ do_rhevh_check()
|
||||
return 0
|
||||
}
|
||||
|
||||
fips_load_crypto()
|
||||
{
|
||||
FIPSMODULES=$(cat /etc/fipsmodules)
|
||||
|
||||
info "Loading and integrity checking all crypto modules"
|
||||
mv /etc/modprobe.d/fips.conf /etc/modprobe.d/fips.conf.bak
|
||||
for _module in $FIPSMODULES; do
|
||||
if [ "$_module" != "tcrypt" ]; then
|
||||
if ! modprobe "${_module}" 2>/tmp/fips.modprobe_err; then
|
||||
# check if kernel provides generic algo
|
||||
_found=0
|
||||
while read _k _s _v; do
|
||||
[ "$_k" != "name" -a "$_k" != "driver" ] && continue
|
||||
[ "$_v" != "$_module" ] && [ "crypto-$_v" != "$_module" ] && continue
|
||||
_found=1
|
||||
break
|
||||
done </proc/crypto
|
||||
[ "$_found" = "0" ] && cat /tmp/fips.modprobe_err >&2 && return 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
mv /etc/modprobe.d/fips.conf.bak /etc/modprobe.d/fips.conf
|
||||
|
||||
info "Self testing crypto algorithms"
|
||||
modprobe tcrypt || return 1
|
||||
rmmod tcrypt
|
||||
}
|
||||
|
||||
do_fips()
|
||||
{
|
||||
local _v
|
||||
@@ -80,43 +108,36 @@ do_fips()
|
||||
|
||||
KERNEL=$(uname -r)
|
||||
|
||||
if ! [ -e "/boot/.vmlinuz-${KERNEL}.hmac" ]; then
|
||||
warn "/boot/.vmlinuz-${KERNEL}.hmac does not exist"
|
||||
return 1
|
||||
fi
|
||||
|
||||
FIPSMODULES=$(cat /etc/fipsmodules)
|
||||
|
||||
info "Loading and integrity checking all crypto modules"
|
||||
mv /etc/modprobe.d/fips.conf /etc/modprobe.d/fips.conf.bak
|
||||
for _module in $FIPSMODULES; do
|
||||
if [ "$_module" != "tcrypt" ]; then
|
||||
if ! modprobe "${_module}"; then
|
||||
# check if kernel provides generic algo
|
||||
_found=0
|
||||
while read _k _s _v; do
|
||||
[ "$_k" != "name" -a "$_k" != "driver" ] && continue
|
||||
[ "$_v" != "$_module" ] && continue
|
||||
_found=1
|
||||
break
|
||||
done </proc/crypto
|
||||
[ "$_found" = "0" ] && return 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
mv /etc/modprobe.d/fips.conf.bak /etc/modprobe.d/fips.conf
|
||||
|
||||
info "Self testing crypto algorithms"
|
||||
modprobe tcrypt || return 1
|
||||
rmmod tcrypt
|
||||
|
||||
info "Checking integrity of kernel"
|
||||
if [ -e "/run/initramfs/live/vmlinuz0" ]; then
|
||||
do_rhevh_check /run/initramfs/live/vmlinuz0 || return 1
|
||||
elif [ -e "/run/initramfs/live/isolinux/vmlinuz0" ]; then
|
||||
do_rhevh_check /run/initramfs/live/isolinux/vmlinuz0 || return 1
|
||||
else
|
||||
sha512hmac -c "/boot/.vmlinuz-${KERNEL}.hmac" || return 1
|
||||
BOOT_IMAGE="$(getarg BOOT_IMAGE)"
|
||||
BOOT_IMAGE_NAME="${BOOT_IMAGE##*/}"
|
||||
BOOT_IMAGE_PATH="${BOOT_IMAGE%${BOOT_IMAGE_NAME}}"
|
||||
|
||||
if [ -z "$BOOT_IMAGE_NAME" ]; then
|
||||
BOOT_IMAGE_NAME="vmlinuz-${KERNEL}"
|
||||
elif ! [ -e "/boot/${BOOT_IMAGE_PATH}/${BOOT_IMAGE}" ]; then
|
||||
#if /boot is not a separate partition BOOT_IMAGE might start with /boot
|
||||
BOOT_IMAGE_PATH=${BOOT_IMAGE_PATH#"/boot"}
|
||||
#on some achitectures BOOT_IMAGE does not contain path to kernel
|
||||
#so if we can't find anything, let's treat it in the same way as if it was empty
|
||||
if ! [ -e "/boot/${BOOT_IMAGE_PATH}/${BOOT_IMAGE_NAME}" ]; then
|
||||
BOOT_IMAGE_NAME="vmlinuz-${KERNEL}"
|
||||
BOOT_IMAGE_PATH=""
|
||||
fi
|
||||
fi
|
||||
|
||||
BOOT_IMAGE_HMAC="/boot/${BOOT_IMAGE_PATH}.${BOOT_IMAGE_NAME}.hmac"
|
||||
if ! [ -e "${BOOT_IMAGE_HMAC}" ]; then
|
||||
warn "${BOOT_IMAGE_HMAC} does not exist"
|
||||
return 1
|
||||
fi
|
||||
|
||||
sha512hmac -c "${BOOT_IMAGE_HMAC}" || return 1
|
||||
fi
|
||||
|
||||
info "All initrd crypto checks done"
|
||||
|
@@ -11,28 +11,48 @@ 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 _bootfstype
|
||||
|
||||
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
|
||||
|
||||
# with hostonly_default_device fs module for /boot is not installed by default
|
||||
if [[ $hostonly ]] && [[ "$hostonly_default_device" == "no" ]]; then
|
||||
_bootfstype=$(find_mp_fstype /boot)
|
||||
if [[ -n "$_bootfstype" ]]; then
|
||||
hostonly='' instmods $_bootfstype
|
||||
else
|
||||
dwarning "Can't determine fs type for /boot, FIPS check may fail."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
install() {
|
||||
local _dir
|
||||
inst_hook pre-trigger 01 "$moddir/fips-boot.sh"
|
||||
inst_hook pre-mount 01 "$moddir/fips-boot.sh"
|
||||
inst_hook pre-pivot 01 "$moddir/fips-noboot.sh"
|
||||
inst_hook pre-udev 01 "$moddir/fips-load-crypto.sh"
|
||||
inst_script "$moddir/fips.sh" /sbin/fips.sh
|
||||
|
||||
inst_multiple sha512hmac rmmod insmod mount uname umount fipscheck
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -1,2 +1,2 @@
|
||||
#!/bin/sh
|
||||
[ -c /dev/watchdog ] && echo -n 'V' > /dev/watchdog
|
||||
[ -c /dev/watchdog ] && printf 'V' > /dev/watchdog
|
||||
|
@@ -19,24 +19,18 @@ inst_key_val() {
|
||||
unset _value
|
||||
}
|
||||
|
||||
inst_key_val '' /etc/vconsole.conf vconsole.keymap KEYMAP -d KEYTABLE
|
||||
inst_key_val '' /etc/vconsole.conf vconsole.font FONT -d SYSFONT
|
||||
inst_key_val '' /etc/vconsole.conf vconsole.font.map FONT_MAP -d CONTRANS
|
||||
inst_key_val '' /etc/vconsole.conf vconsole.font.unimap FONT_UNIMAP -d UNIMAP
|
||||
inst_key_val 1 /etc/vconsole.conf vconsole.font.unicode UNICODE vconsole.unicode
|
||||
inst_key_val '' /etc/vconsole.conf vconsole.keymap.ext EXT_KEYMAP
|
||||
inst_key_val '' /etc/vconsole.conf rd.vconsole.keymap vconsole.keymap KEYMAP -d KEYTABLE
|
||||
inst_key_val '' /etc/vconsole.conf rd.vconsole.font vconsole.font FONT -d SYSFONT
|
||||
inst_key_val '' /etc/vconsole.conf rd.vconsole.font.map vconsole.font.map FONT_MAP -d CONTRANS
|
||||
inst_key_val '' /etc/vconsole.conf rd.vconsole.font.unimap vconsole.font.unimap FONT_UNIMAP -d UNIMAP
|
||||
inst_key_val 1 /etc/vconsole.conf rd.vconsole.font.unicode vconsole.font.unicode UNICODE vconsole.unicode
|
||||
inst_key_val '' /etc/vconsole.conf rd.vconsole.keymap.ext vconsole.keymap.ext EXT_KEYMAP
|
||||
|
||||
inst_key_val '' /etc/locale.conf locale.LANG LANG
|
||||
inst_key_val '' /etc/locale.conf locale.LC_ALL LC_ALL
|
||||
inst_key_val '' /etc/locale.conf rd.locale.LANG locale.LANG LANG
|
||||
inst_key_val '' /etc/locale.conf rd.locale.LC_ALL locale.LC_ALL LC_ALL
|
||||
|
||||
if [ -f /etc/locale.conf ]; then
|
||||
. /etc/locale.conf
|
||||
export LANG
|
||||
export LC_ALL
|
||||
fi
|
||||
|
||||
if [ -n "$DRACUT_SYSTEMD" ]; then
|
||||
rm -f -- /etc/udev/rules.d/10-console.rules
|
||||
rm -f -- /lib/udev/rules.d/10-console.rules
|
||||
rm -f -- /lib/udev/console_init
|
||||
fi
|
||||
|
@@ -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"
|
||||
|
@@ -1,3 +1,6 @@
|
||||
|
||||
option classless-static-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-static-routes;
|
||||
|
@@ -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 "$@" \
|
||||
@@ -139,23 +76,30 @@ load_ipv6() {
|
||||
}
|
||||
|
||||
do_ipv6auto() {
|
||||
local ret
|
||||
load_ipv6
|
||||
echo 0 > /proc/sys/net/ipv6/conf/$netif/forwarding
|
||||
echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_ra
|
||||
echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_redirects
|
||||
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
|
||||
ret=$?
|
||||
|
||||
[ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
|
||||
|
||||
return 0
|
||||
return $ret
|
||||
}
|
||||
|
||||
# Handle static ip configuration
|
||||
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
|
||||
@@ -176,11 +120,13 @@ do_static() {
|
||||
ip addr add $ip/$mask ${srv:+peer $srv} dev $netif
|
||||
wait_for_ipv6_dad $netif
|
||||
else
|
||||
if ! arping -f -q -D -c 2 -I $netif $ip; then
|
||||
warn "Duplicate address detected for $ip for interface $netif."
|
||||
return 1
|
||||
if [ -z "$srv" ]; then
|
||||
if ! arping -f -q -D -c 2 -I $netif $ip; then
|
||||
warn "Duplicate address detected for $ip for interface $netif."
|
||||
return 1
|
||||
fi
|
||||
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 +136,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 +147,214 @@ 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
|
||||
|
||||
# Set mtu on bond master
|
||||
[ -n "$bondmtu" ] && ip link set mtu $bondmtu dev $bondname
|
||||
|
||||
# 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
|
||||
|
||||
|
||||
@@ -368,18 +377,15 @@ for p in $(getargs ip=); do
|
||||
esac
|
||||
|
||||
# If this option isn't directed at our interface, skip it
|
||||
[ -n "$dev" ] && [ "$dev" != "$netif" ] && \
|
||||
[ "$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
|
||||
|
||||
if [ -n "$dev" ]; then
|
||||
[ "$dev" != "$netif" ] && \
|
||||
[ "$use_bridge" != 'true' ] && \
|
||||
[ "$use_vlan" != 'true' ] && continue
|
||||
else
|
||||
iface_is_enslaved "$netif" && continue
|
||||
fi
|
||||
# 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
|
||||
|
||||
@@ -392,33 +398,42 @@ for p in $(getargs ip=); do
|
||||
do_dhcp -6 ;;
|
||||
auto6)
|
||||
do_ipv6auto ;;
|
||||
either6)
|
||||
do_ipv6auto || do_dhcp -6 ;;
|
||||
*)
|
||||
do_static ;;
|
||||
esac
|
||||
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 +444,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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
@@ -97,7 +102,7 @@ command -v fix_bootif >/dev/null || . /lib/net-lib.sh
|
||||
# Default: We don't know the interface to use, handle all
|
||||
# Fixme: waiting for the interface as well.
|
||||
else
|
||||
cond='ACTION=="add", SUBSYSTEM=="net"'
|
||||
cond='ACTION=="add", SUBSYSTEM=="net", ENV{DEVTYPE}!="wlan|wwan"'
|
||||
# if you change the name of "91-default-net.rules", also change modules.d/80cms/cmssetup.sh
|
||||
echo "$cond, $runcmd" > /etc/udev/rules.d/91-default-net.rules
|
||||
fi
|
||||
|
@@ -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|either6}
|
||||
# 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" -o "$2" = "either6" ]; 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,36 @@ 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
|
||||
[ -n "$(ip -6 addr show dev "$1" scope link)" ] \
|
||||
[ -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
|
||||
[ -n "$(ip -6 addr show dev "$1")" ] \
|
||||
[ -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 +676,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,25 +701,45 @@ hostname() {
|
||||
cat /proc/sys/kernel/hostname
|
||||
}
|
||||
|
||||
iface_has_link() {
|
||||
iface_has_carrier() {
|
||||
local cnt=0
|
||||
local interface="$1" flags=""
|
||||
[ -n "$interface" ] || return 2
|
||||
interface="/sys/class/net/$interface"
|
||||
[ -d "$interface" ] || return 2
|
||||
local timeout="$(getargs rd.net.timeout.carrier=)"
|
||||
timeout=${timeout:-5}
|
||||
timeout=${timeout:-15}
|
||||
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 "$@"
|
||||
}
|
||||
|
||||
iface_is_enslaved() {
|
||||
local _li
|
||||
_li=$(ip -o link show dev $1)
|
||||
strstr "$li" " master " || return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
find_iface_with_link() {
|
||||
local iface_path="" iface=""
|
||||
for iface_path in /sys/class/net/*; do
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Format:
|
||||
# bond=<bondname>[:<bondslaves>:[:<options>]]
|
||||
# bond=<bondname>[:<bondslaves>:[:<options>[:<mtu>]]]
|
||||
#
|
||||
# bondslaves is a comma-separated list of physical (ethernet) interfaces
|
||||
# options is a comma-separated list on bonding options (modinfo bonding for details) in format compatible with initscripts
|
||||
@@ -9,14 +9,8 @@
|
||||
#
|
||||
# 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
|
||||
# if the mtu is specified, it will be set on the bond master
|
||||
#
|
||||
|
||||
# We translate list of slaves to space-separated here to mwke it easier to loop over them in ifup
|
||||
# Ditto for bonding options
|
||||
@@ -28,24 +22,24 @@ parsebond() {
|
||||
v=${v#*:}
|
||||
done
|
||||
|
||||
unset bondname bondslaves bondoptions
|
||||
case $# in
|
||||
0) bondname=bond0; bondslaves="eth0 eth1" ;;
|
||||
1) bondname=$1; bondslaves="eth0 eth1" ;;
|
||||
2) bondname=$1; bondslaves=$(str_replace "$2" "," " ") ;;
|
||||
3) bondname=$1; bondslaves=$(str_replace "$2" "," " "); bondoptions=$(str_replace "$3" "," " ") ;;
|
||||
4) bondname=$1; bondslaves=$(str_replace "$2" "," " "); bondoptions=$(str_replace "$3" "," " "); bondmtu=$4;;
|
||||
*) die "bond= requires zero to four parameters" ;;
|
||||
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=)"
|
||||
# Parse bond for bondname, bondslaves, bondmode, bondoptions and bondmtu
|
||||
for bond in $(getargs bond=); do
|
||||
unset bondname
|
||||
unset bondslaves
|
||||
unset bondoptions
|
||||
unset bondmtu
|
||||
if [ "$bond" != "bond" ]; then
|
||||
parsebond "$bond"
|
||||
fi
|
||||
# Simple default bond
|
||||
if [ -z "$bondname" ]; then
|
||||
@@ -57,5 +51,5 @@ 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
|
||||
echo "bondmtu=\"$bondmtu\"" >> /tmp/bond.${bondname}.info
|
||||
done
|
||||
|
@@ -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
|
||||
|
@@ -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"
|
||||
@@ -79,9 +78,10 @@ for p in $(getargs ip=); do
|
||||
die "Sorry, automatic calculation of netmask is not yet supported"
|
||||
;;
|
||||
auto6);;
|
||||
either6);;
|
||||
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'"
|
||||
;;
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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"
|
||||
|
@@ -9,7 +9,7 @@ check() {
|
||||
require_binaries btrfs || return 1
|
||||
|
||||
[[ $hostonly ]] || [[ $mount_needs ]] && {
|
||||
for fs in ${host_fs_types[@]}; do
|
||||
for fs in "${host_fs_types[@]}"; do
|
||||
[[ "$fs" == "btrfs" ]] && return 0
|
||||
done
|
||||
return 255
|
||||
|
22
modules.d/90dmsquash-live-ntfs/module-setup.sh
Executable file
22
modules.d/90dmsquash-live-ntfs/module-setup.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
command -v
|
||||
|
||||
check() {
|
||||
require_binaries ntfs-3g || return 1
|
||||
return 255
|
||||
}
|
||||
|
||||
depends() {
|
||||
echo dmsquash-live
|
||||
return 0
|
||||
}
|
||||
|
||||
install() {
|
||||
inst_multiple fusermount ulockmgr_server mount.fuse ntfs-3g
|
||||
dracut_need_initqueue
|
||||
}
|
||||
|
||||
installkernel() {
|
||||
hostonly='' instmods fuse
|
||||
}
|
@@ -79,7 +79,20 @@ if [ -f $livedev ]; then
|
||||
esac
|
||||
[ -e /sys/fs/$fstype ] || modprobe $fstype
|
||||
else
|
||||
mount -n -t $fstype -o ${liverw:-ro} $livedev /run/initramfs/live
|
||||
if [ "$(blkid -o value -s TYPE $livedev)" != "ntfs" ]; then
|
||||
mount -n -t $fstype -o ${liverw:-ro} $livedev /run/initramfs/live
|
||||
else
|
||||
# Symlinking /usr/bin/ntfs-3g as /sbin/mount.ntfs seems to boot
|
||||
# at the first glance, but ends with lots and lots of squashfs
|
||||
# errors, because systemd attempts to kill the ntfs-3g process?!
|
||||
if [ -x "/usr/bin/ntfs-3g" ]; then
|
||||
( exec -a @ntfs-3g ntfs-3g -o ${liverw:-ro} $livedev /run/initramfs/live ) | vwarn
|
||||
else
|
||||
die "Failed to mount block device of live image: Missing NTFS support"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$?" != "0" ]; then
|
||||
die "Failed to mount block device of live image"
|
||||
exit 1
|
||||
|
@@ -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() {
|
||||
@@ -45,25 +45,27 @@ installkernel() {
|
||||
instmods yenta_socket scsi_dh_rdac scsi_dh_emc scsi_dh_alua \
|
||||
atkbd i8042 usbhid firewire-ohci pcmcia hv-vmbus \
|
||||
atkbd i8042 usbhid firewire-ohci pcmcia usb_storage \
|
||||
nvme hv-vmbus sdhci_acpi
|
||||
nvme hv-vmbus sdhci_acpi nfit
|
||||
|
||||
instmods \
|
||||
"=drivers/hid" \
|
||||
"=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
|
||||
|
||||
@@ -81,7 +83,7 @@ installkernel() {
|
||||
instmods '=fs'
|
||||
fi
|
||||
else
|
||||
for i in $(host_fs_all); do
|
||||
for i in "${host_fs_types[@]}"; do
|
||||
hostonly='' instmods $i
|
||||
done
|
||||
fi
|
||||
|
@@ -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;
|
||||
@@ -109,9 +109,9 @@ if [ -n "$LVS" ] ; then
|
||||
lvm lvscan --ignorelockingfailure 2>&1 | vinfo
|
||||
for LV in $LVS; do
|
||||
if [ -z "$sysinit" ]; then
|
||||
lvm lvchange --yes -ay --ignorelockingfailure $nopoll --ignoremonitoring $LV 2>&1 | vinfo
|
||||
lvm lvchange --yes -K -ay --ignorelockingfailure $nopoll --ignoremonitoring $LV 2>&1 | vinfo
|
||||
else
|
||||
lvm lvchange --yes -ay $sysinit $LV 2>&1 | vinfo
|
||||
lvm lvchange --yes -K -ay $sysinit $LV 2>&1 | vinfo
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
@@ -42,6 +42,10 @@ cmdline() {
|
||||
done
|
||||
}
|
||||
|
||||
installkernel() {
|
||||
hostonly='' 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
|
||||
|
@@ -2,34 +2,69 @@
|
||||
# -*- 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
|
||||
_md_force_run() {
|
||||
type getargs >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
|
||||
_md_start() {
|
||||
local _udevinfo
|
||||
local _path_s
|
||||
local _path_d
|
||||
local _md="$1"
|
||||
local _offroot="$2"
|
||||
|
||||
_udevinfo="$(udevadm info --query=env --name="${_md}")"
|
||||
strstr "$_udevinfo" "MD_LEVEL=container" && continue
|
||||
strstr "$_udevinfo" "DEVTYPE=partition" && continue
|
||||
|
||||
_path_s="/sys/$(udevadm info -q path -n "${_md}")/md/array_state"
|
||||
[ ! -r "$_path_s" ] && continue
|
||||
|
||||
# inactive ?
|
||||
[ "$(cat "$_path_s")" != "inactive" ] && continue
|
||||
|
||||
mdadm $_offroot -R "${_md}" 2>&1 | vinfo
|
||||
|
||||
# still inactive ?
|
||||
[ "$(cat "$_path_s")" = "inactive" ] && continue
|
||||
|
||||
_path_d="${_path_s%/*}/degraded"
|
||||
[ ! -r "$_path_d" ] && continue
|
||||
> $hookdir/initqueue/work
|
||||
}
|
||||
|
||||
_md_force_run() {
|
||||
local _offroot
|
||||
local _md
|
||||
local _UUID
|
||||
local _MD_UUID=$(getargs rd.md.uuid -d rd_MD_UUID=)
|
||||
[ -n "$_MD_UUID" ] || getargbool 0 rd.auto || return
|
||||
|
||||
_offroot=$(strstr "$(mdadm --help-options 2>&1)" offroot && echo --offroot)
|
||||
# try to force-run anything not running yet
|
||||
for md in /dev/md[0-9_]*; do
|
||||
[ -b "$md" ] || continue
|
||||
_udevinfo="$(udevadm info --query=env --name="$md")"
|
||||
strstr "$_udevinfo" "MD_LEVEL=container" && continue
|
||||
strstr "$_udevinfo" "DEVTYPE=partition" && continue
|
||||
|
||||
_path_s="/sys/$(udevadm info -q path -n "$md")/md/array_state"
|
||||
[ ! -r "$_path_s" ] && continue
|
||||
if [ -n "$_MD_UUID" ]; then
|
||||
for _md in /dev/md[0-9_]*; do
|
||||
[ -b "$_md" ] || continue
|
||||
_UUID=$(
|
||||
/sbin/mdadm -D --export "$_md" \
|
||||
| while read line || [ -n "$line" ]; do
|
||||
str_starts "$line" "MD_UUID=" || continue
|
||||
printf "%s" "${line#MD_UUID=}"
|
||||
done
|
||||
)
|
||||
|
||||
# inactive ?
|
||||
[ "$(cat "$_path_s")" != "inactive" ] && continue
|
||||
[ -z "$_UUID" ] && continue
|
||||
|
||||
mdadm $_offroot -R "$md" 2>&1 | vinfo
|
||||
# check if we should handle this device
|
||||
strstr " $_MD_UUID " " $_UUID " || continue
|
||||
|
||||
# still inactive ?
|
||||
[ "$(cat "$_path_s")" = "inactive" ] && continue
|
||||
|
||||
_path_d="${_path_s%/*}/degraded"
|
||||
[ ! -r "$_path_d" ] && continue
|
||||
done
|
||||
_md_start "${_md}" "${_offroot}"
|
||||
done
|
||||
else
|
||||
# try to force-run anything not running yet
|
||||
for _md in /dev/md[0-9_]*; do
|
||||
[ -b "$_md" ] || continue
|
||||
_md_start "${_md}" "${_offroot}"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
_md_force_run
|
||||
|
@@ -26,6 +26,9 @@ else
|
||||
done < "${f}" > "${f}.new"
|
||||
mv "${f}.new" "$f"
|
||||
done
|
||||
for uuid in $MD_UUID; do
|
||||
wait_for_dev "/dev/disk/by-id/md-uuid-${uuid}"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@@ -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
|
||||
@@ -104,7 +105,7 @@ install() {
|
||||
/etc/multipath.conf \
|
||||
/etc/multipath/*
|
||||
|
||||
[[ $hostonly ]] && {
|
||||
[[ $hostonly ]] && [[ $hostonly_mode = "strict" ]] && {
|
||||
for_each_host_dev_and_slaves_all add_hostonly_mpath_conf
|
||||
[ -n "$_allow" ] && mpathconf $_allow --outfile ${initdir}/etc/multipath.conf
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@ check() {
|
||||
require_binaries mount.cifs || return 1
|
||||
|
||||
[[ $hostonly ]] || [[ $mount_needs ]] && {
|
||||
for fs in ${host_fs_types[@]}; do
|
||||
for fs in "${host_fs_types[@]}"; do
|
||||
[[ "$fs" == "cifs" ]] && return 0
|
||||
done
|
||||
return 255
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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"
|
||||
@@ -89,8 +87,8 @@ elif [ "$netdriver" = "bnx2x" ]; then
|
||||
# If driver is bnx2x, do not use /sys/module/fcoe/parameters/create but fipvlan
|
||||
modprobe 8021q
|
||||
udevadm settle --timeout=30
|
||||
# Sleep for 3 s to allow dcb negotiation
|
||||
sleep 3
|
||||
# Sleep for 13 s to allow dcb negotiation
|
||||
sleep 13
|
||||
fipvlan "$netif" -c -s
|
||||
else
|
||||
vlan="no"
|
||||
|
14
modules.d/95fcoe/lldpad.sh
Normal file
14
modules.d/95fcoe/lldpad.sh
Normal 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
|
@@ -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,76 @@ 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
|
||||
|
||||
# Some Combined Network Adapters(CNAs) implement DCB in firmware.
|
||||
# Do not run software-based DCB or LLDP on CNAs that implement DCB.
|
||||
# If the network interface provides hardware DCB/DCBX capabilities,
|
||||
# DCB_REQUIRED in "/etc/fcoe/cfg-xxx" is expected to set to "no".
|
||||
#
|
||||
# Force "nodcb" if there's any DCB_REQUIRED="no"(child or vlan parent).
|
||||
grep -q "^[[:blank:]]*DCB_REQUIRED=\"no\"" /etc/fcoe/cfg-${i##*/} &>/dev/null
|
||||
[ $? -eq 0 ] && dcb="nodcb"
|
||||
if [ "$p" ] ; then
|
||||
grep -q "^[[:blank:]]*DCB_REQUIRED=\"no\"" /etc/fcoe/cfg-${p} &>/dev/null
|
||||
[ $? -eq 0 ] && 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
|
||||
|
@@ -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)
|
||||
|
@@ -46,8 +46,9 @@ fi
|
||||
handle_firmware()
|
||||
{
|
||||
if ! iscsistart -f; then
|
||||
warn "iscistart: Could not get list of targets from firmware."
|
||||
return 1
|
||||
warn "iscistart: Could not get list of targets from firmware. Skipping."
|
||||
echo 'skipped' > "/tmp/iscsistarted-firmware"
|
||||
return 0
|
||||
fi
|
||||
|
||||
for p in $(getargs rd.iscsi.param -d iscsi_param); do
|
||||
@@ -78,23 +79,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 +110,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 +123,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,34 +183,40 @@ 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 ; }
|
||||
while : ; do
|
||||
status=$(systemctl is-active "$netroot_enc" 2>/dev/null)
|
||||
[ "$status" != "activating" ] && break
|
||||
sleep 1
|
||||
done
|
||||
else
|
||||
systemctl --no-block restart "$netroot_enc" >/dev/null 2>&1 \
|
||||
&& { > $hookdir/initqueue/work ; }
|
||||
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
|
||||
|
@@ -23,12 +23,54 @@ check() {
|
||||
|
||||
[[ $hostonly ]] || [[ $mount_needs ]] && {
|
||||
pushd . >/dev/null
|
||||
for_each_host_dev_and_slaves is_iscsi || return 255
|
||||
for_each_host_dev_and_slaves is_iscsi
|
||||
local _is_iscsi=$?
|
||||
popd >/dev/null
|
||||
[[ $_is_iscsi == 0 ]] || return 255
|
||||
}
|
||||
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 +117,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"
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ check() {
|
||||
require_binaries rpc.statd mount.nfs mount.nfs4 umount || return 1
|
||||
|
||||
[[ $hostonly ]] || [[ $mount_needs ]] && {
|
||||
for fs in ${host_fs_types[@]}; do
|
||||
for fs in "${host_fs_types[@]}"; do
|
||||
[[ "$fs" == "nfs" ]] && return 0
|
||||
[[ "$fs" == "nfs3" ]] && return 0
|
||||
[[ "$fs" == "nfs4" ]] && return 0
|
||||
@@ -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() {
|
||||
|
@@ -32,7 +32,7 @@ cmdline_journal() {
|
||||
|
||||
cmdline() {
|
||||
local dev=/dev/block/$(find_root_block_device)
|
||||
if [ -e $dev ]; then
|
||||
if [ -e $dev ] && [ -n "$root_dev" ] ; then
|
||||
printf " root=%s" "$(shorten_persistent_dev "$(get_persistent_dev "$dev")")"
|
||||
printf " rootflags=%s" "$(find_mp_fsopts /)"
|
||||
printf " rootfstype=%s" "$(find_mp_fstype /)"
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -27,6 +27,7 @@ install() {
|
||||
fi
|
||||
|
||||
inst_rules \
|
||||
40-redhat-cpu-hotplug.rules \
|
||||
40-redhat.rules \
|
||||
50-firmware.rules \
|
||||
50-udev-default.rules \
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
check() {
|
||||
[[ $hostonly ]] || [[ $mount_needs ]] && {
|
||||
for fs in ${host_fs_types[@]}; do
|
||||
for fs in "${host_fs_types[@]}"; do
|
||||
[[ "$fs" == "9p" ]] && return 0
|
||||
done
|
||||
return 255
|
||||
@@ -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
|
||||
}
|
||||
|
@@ -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
|
||||
|
39
modules.d/95virtfs/virtfs-generator.sh
Executable file
39
modules.d/95virtfs/virtfs-generator.sh
Executable 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
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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=/
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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"
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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.
|
||||
|
@@ -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 \
|
||||
\
|
||||
@@ -148,7 +166,7 @@ install() {
|
||||
}
|
||||
|
||||
_mods=$(modules_load_get /usr/lib/modules-load.d)
|
||||
[[ $_mods ]] && instmods $_mods
|
||||
[[ $_mods ]] && hostonly='' instmods $_mods
|
||||
|
||||
if [[ $hostonly ]]; then
|
||||
inst_multiple -o \
|
||||
@@ -163,7 +181,7 @@ install() {
|
||||
/etc/sysctl.conf
|
||||
|
||||
_mods=$(modules_load_get /etc/modules-load.d)
|
||||
[[ $_mods ]] && instmods $_mods
|
||||
[[ $_mods ]] && hostonly='' instmods $_mods
|
||||
fi
|
||||
|
||||
if ! [[ -e "$initdir/etc/machine-id" ]]; then
|
||||
@@ -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"
|
||||
|
@@ -1,39 +1,87 @@
|
||||
#!/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
|
||||
|
||||
generator_wait_for_dev()
|
||||
{
|
||||
local _name
|
||||
local _timeout
|
||||
|
||||
_name="$(str_replace "$1" '/' '\x2f')"
|
||||
_timeout=$(getarg rd.timeout)
|
||||
_timeout=${_timeout:-0}
|
||||
|
||||
[ -e "$hookdir/initqueue/finished/devexists-${_name}.sh" ] && return 0
|
||||
if ! [ -e "$hookdir/initqueue/finished/devexists-${_name}.sh" ]; then
|
||||
|
||||
printf '[ -e "%s" ]\n' $1 \
|
||||
>> "$hookdir/initqueue/finished/devexists-${_name}.sh"
|
||||
{
|
||||
printf '[ -e "%s" ] || ' $1
|
||||
printf 'warn "\"%s\" does not exist"\n' $1
|
||||
} >> "$hookdir/emergency/80-${_name}.sh"
|
||||
printf '[ -e "%s" ]\n' $1 \
|
||||
>> "$hookdir/initqueue/finished/devexists-${_name}.sh"
|
||||
{
|
||||
printf '[ -e "%s" ] || ' $1
|
||||
printf 'warn "\"%s\" does not exist"\n' $1
|
||||
} >> "$hookdir/emergency/80-${_name}.sh"
|
||||
fi
|
||||
|
||||
_name=$(dev_unit_name "$1")
|
||||
if ! [ -L /run/systemd/generator/initrd.target.wants/${_name}.device ]; then
|
||||
[ -d /run/systemd/generator/initrd.target.wants ] || mkdir -p /run/systemd/generator/initrd.target.wants
|
||||
ln -s ../${_name}.device /run/systemd/generator/initrd.target.wants/${_name}.device
|
||||
if ! [ -L "$GENERATOR_DIR"/initrd.target.wants/${_name}.device ]; then
|
||||
[ -d "$GENERATOR_DIR"/initrd.target.wants ] || mkdir -p "$GENERATOR_DIR"/initrd.target.wants
|
||||
ln -s ../${_name}.device "$GENERATOR_DIR"/initrd.target.wants/${_name}.device
|
||||
fi
|
||||
|
||||
if ! [ -f /run/systemd/generator/${_name}.device.d/timeout.conf ]; then
|
||||
mkdir -p /run/systemd/generator/${_name}.device.d
|
||||
if ! [ -f "$GENERATOR_DIR"/${_name}.device.d/timeout.conf ]; then
|
||||
mkdir -p "$GENERATOR_DIR"/${_name}.device.d
|
||||
{
|
||||
echo "[Unit]"
|
||||
echo "JobTimeoutSec=0"
|
||||
} > /run/systemd/generator/${_name}.device.d/timeout.conf
|
||||
echo "JobTimeoutSec=$_timeout"
|
||||
} > "$GENERATOR_DIR"/${_name}.device.d/timeout.conf
|
||||
fi
|
||||
}
|
||||
|
||||
generator_mount_rootfs()
|
||||
{
|
||||
local _type=$2
|
||||
local _flags=$3
|
||||
local _name
|
||||
|
||||
[ -z "$1" ] && return 0
|
||||
|
||||
_name=$(dev_unit_name "$1")
|
||||
[ -d "$GENERATOR_DIR" ] || mkdir -p "$GENERATOR_DIR"
|
||||
if ! [ -f "$GENERATOR_DIR"/sysroot.mount ]; then
|
||||
{
|
||||
echo "[Unit]"
|
||||
echo "Before=initrd-root-fs.target"
|
||||
echo "Requires=systemd-fsck@${_name}.service"
|
||||
echo "After=systemd-fsck@${_name}.service"
|
||||
echo "[Mount]"
|
||||
echo "Where=/sysroot"
|
||||
echo "What=$1"
|
||||
echo "Options=${_flags}"
|
||||
echo "Type=${_type}"
|
||||
} > "$GENERATOR_DIR"/sysroot.mount
|
||||
fi
|
||||
if ! [ -L "$GENERATOR_DIR"/initrd-root-fs.target.requires/sysroot.mount ]; then
|
||||
[ -d "$GENERATOR_DIR"/initrd-root-fs.target.requires ] || mkdir -p "$GENERATOR_DIR"/initrd-root-fs.target.requires
|
||||
ln -s ../sysroot.mount "$GENERATOR_DIR"/initrd-root-fs.target.requires/sysroot.mount
|
||||
fi
|
||||
}
|
||||
|
||||
generator_fsck_after_pre_mount()
|
||||
{
|
||||
local _name
|
||||
|
||||
[ -z "$1" ] && return 0
|
||||
|
||||
_name=$(dev_unit_name "$1")
|
||||
[ -d /run/systemd/generator/systemd-fsck@${_name}.service.d ] || mkdir -p /run/systemd/generator/systemd-fsck@${_name}.service.d
|
||||
if ! [ -f /run/systemd/generator/systemd-fsck@${_name}.service.d/after-pre-mount.conf ]; then
|
||||
{
|
||||
echo "[Unit]"
|
||||
echo "After=dracut-pre-mount.service"
|
||||
} > /run/systemd/generator/systemd-fsck@${_name}.service.d/after-pre-mount.conf
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
root=$(getarg root=)
|
||||
case "$root" in
|
||||
block:LABEL=*|LABEL=*)
|
||||
@@ -60,6 +108,12 @@ case "$root" in
|
||||
rootok=1 ;;
|
||||
esac
|
||||
|
||||
[ "${root%%:*}" = "block" ] && generator_wait_for_dev "${root#block:}"
|
||||
GENERATOR_DIR="$1"
|
||||
|
||||
if [ "$rootok" = "1" ]; then
|
||||
generator_wait_for_dev "${root#block:}" "$RDRETRY"
|
||||
generator_fsck_after_pre_mount "${root#block:}"
|
||||
strstr "$(cat /proc/cmdline)" 'root=' || generator_mount_rootfs "${root#block:}" "$(getarg rootfstype=)" "$(getarg rootflags=)"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
@@ -14,7 +14,7 @@ filtersubvol() {
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
subvol\=*) :;;
|
||||
*) echo -n "${1}," ;;
|
||||
*) printf '%s' "${1}," ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
@@ -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
|
||||
@@ -859,13 +868,32 @@ wait_for_mount()
|
||||
} >> "$hookdir/emergency/90-${_name}.sh"
|
||||
}
|
||||
|
||||
# get a systemd-compatible unit name from a path
|
||||
# (mimicks unit_name_from_path_instance())
|
||||
dev_unit_name()
|
||||
{
|
||||
_name="${1%%/}"
|
||||
_name="${_name##/}"
|
||||
_name="$(str_replace "$_name" '-' '\x2d')"
|
||||
_name="$(str_replace "$_name" '/' '-')"
|
||||
echo "$_name"
|
||||
local dev="$1"
|
||||
|
||||
if command -v systemd-escape >/dev/null; then
|
||||
systemd-escape -p -- "$dev"
|
||||
return
|
||||
fi
|
||||
|
||||
if [ "$dev" = "/" -o -z "$dev" ]; then
|
||||
printf -- "-"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
dev="${1%%/}"
|
||||
dev="${dev##/}"
|
||||
dev="$(str_replace "$dev" '\' '\x5c')"
|
||||
dev="$(str_replace "$dev" '-' '\x2d')"
|
||||
if [ "${dev##.}" != "$dev" ]; then
|
||||
dev="\x2e${dev##.}"
|
||||
fi
|
||||
dev="$(str_replace "$dev" '/' '-')"
|
||||
|
||||
printf -- "%s" "$dev"
|
||||
}
|
||||
|
||||
# wait_for_dev <dev>
|
||||
@@ -878,6 +906,7 @@ wait_for_dev()
|
||||
local _name
|
||||
local _needreload
|
||||
local _noreload
|
||||
local _timeout
|
||||
|
||||
if [ "$1" = "-n" ]; then
|
||||
_noreload=1
|
||||
@@ -904,10 +933,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 +1087,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 +1107,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 +1196,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 +1294,8 @@ show_memstats()
|
||||
iomem)
|
||||
cat /proc/iomem
|
||||
;;
|
||||
komem)
|
||||
tracekomem
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
@@ -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
191
modules.d/99base/memtrace-ko.sh
Executable 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 $?
|
@@ -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
|
||||
@@ -102,13 +103,13 @@ install() {
|
||||
|
||||
. "$moddir/dracut-lib.sh"
|
||||
|
||||
for _dev in ${host_devs[@]}; do
|
||||
for _dev in "${host_devs[@]}"; do
|
||||
[[ "$_dev" == "$root_dev" ]] && continue
|
||||
|
||||
# We only actually wait for real devs - swap is only needed
|
||||
# for resume and udev rules generated when parsing resume=
|
||||
# argument take care of the waiting for us
|
||||
for _dev2 in ${swap_devs[@]}; do
|
||||
for _dev2 in "${swap_devs[@]}"; do
|
||||
[[ "$_dev" == "$_dev2" ]] && continue 2
|
||||
done
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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 \
|
||||
|
@@ -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" \
|
||||
|
@@ -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
|
||||
|
@@ -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" \
|
||||
|
@@ -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" \
|
||||
|
@@ -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**************************"
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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" \
|
||||
|
@@ -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" \
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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" \
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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" \
|
||||
|
@@ -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
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user