Compare commits
65 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 |
14
Makefile
14
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
|
||||
@@ -39,7 +39,7 @@ 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.pc dracut-install skipcpio/skipcpio
|
||||
|
||||
@@ -202,6 +202,16 @@ rpm: dracut-$(VERSION).tar.bz2 syncheck
|
||||
--define "_rpmdir $$PWD" -ba dracut.spec; ) && \
|
||||
( 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 \
|
||||
[ "$${i##*/}" = "module-setup.sh" ] && continue; \
|
||||
|
@@ -593,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
|
||||
@@ -615,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
|
||||
}
|
||||
@@ -633,13 +635,14 @@ check_block_and_slaves_all() {
|
||||
_ret=0
|
||||
fi
|
||||
check_vol_slaves_all "$@" && 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_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
|
||||
}
|
||||
@@ -652,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
|
||||
@@ -668,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
|
||||
@@ -684,43 +687,39 @@ 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="${_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
|
||||
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
|
||||
for i in /dev/mapper/*; do
|
||||
[[ $i == /dev/mapper/control ]] && continue
|
||||
_lv=$(get_maj_min $i)
|
||||
if [[ $_lv = $2 ]]; then
|
||||
_vg=$(lvm lvs --noheadings -o vg_name $i 2>/dev/null)
|
||||
# strip space
|
||||
_vg="${_vg//[[:space:]]/}"
|
||||
if [[ $_vg ]]; then
|
||||
for _pv in $(lvm vgs --noheadings -o pv_name "$_vg" 2>/dev/null)
|
||||
do
|
||||
check_block_and_slaves_all $1 $(get_maj_min $_pv)
|
||||
done
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
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
|
||||
}
|
||||
|
||||
@@ -1241,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
|
||||
@@ -1737,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
|
||||
@@ -1750,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() {
|
||||
@@ -1761,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
|
||||
}
|
||||
|
17
dracut.8.asc
17
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,10 @@ 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).
|
||||
|
||||
|
@@ -449,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.
|
||||
@@ -458,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.
|
||||
+
|
||||
@@ -469,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
|
||||
|
@@ -54,6 +54,10 @@ Space-separated lists have to have a leading and trailing space!
|
||||
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.
|
||||
|
139
dracut.sh
139
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,29 @@ 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.
|
||||
@@ -304,6 +329,7 @@ rearrange_params()
|
||||
--long add: \
|
||||
--long force-add: \
|
||||
--long add-drivers: \
|
||||
--long force-drivers: \
|
||||
--long omit-drivers: \
|
||||
--long modules: \
|
||||
--long omit: \
|
||||
@@ -355,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 \
|
||||
@@ -471,6 +499,7 @@ 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;;
|
||||
@@ -537,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)
|
||||
@@ -545,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" ;;
|
||||
@@ -790,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
|
||||
@@ -827,6 +861,21 @@ 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 DRACUT_TMPDIR="$(mktemp -p "$TMPDIR/" -d -t dracut.XXXXXX)"
|
||||
[ -d "$DRACUT_TMPDIR" ] || {
|
||||
@@ -857,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
|
||||
@@ -875,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.'
|
||||
@@ -921,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 "
|
||||
@@ -937,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%|}"
|
||||
@@ -1039,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
|
||||
|
||||
@@ -1114,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"
|
||||
@@ -1136,10 +1195,23 @@ if [[ $hostonly ]]; then
|
||||
|
||||
# check /proc/modules
|
||||
declare -A host_modules
|
||||
while read m rest; do
|
||||
[ -z "$m" ] && continue
|
||||
host_modules["$m"]=1
|
||||
done </proc/modules
|
||||
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
|
||||
@@ -1162,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
|
||||
@@ -1359,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
|
||||
@@ -1367,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
|
||||
@@ -1424,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
|
||||
@@ -1619,4 +1704,10 @@ else
|
||||
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
|
||||
|
@@ -346,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
|
||||
|
@@ -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
|
||||
|
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" ] && [ "crypto-$_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,7 +11,7 @@ depends() {
|
||||
}
|
||||
|
||||
installkernel() {
|
||||
local _fipsmodules _mod i
|
||||
local _fipsmodules _mod i _bootfstype
|
||||
|
||||
if [[ -f "${srcmods}/modules.fips" ]]; then
|
||||
_fipsmodules="$(cat "${srcmods}/modules.fips")"
|
||||
@@ -36,12 +36,23 @@ installkernel() {
|
||||
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
|
||||
|
@@ -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
|
||||
|
@@ -1,6 +1,6 @@
|
||||
|
||||
option classless-routes code 121 = array of unsigned integer 8;
|
||||
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, classless-routes;
|
||||
root-path, interface-mtu, classless-static-routes;
|
||||
|
@@ -76,6 +76,7 @@ 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
|
||||
@@ -84,10 +85,11 @@ do_ipv6auto() {
|
||||
[ -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
|
||||
@@ -118,9 +120,11 @@ 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 -4 addr flush dev $netif
|
||||
ip addr add $ip/$mask ${srv:+peer $srv} brd + dev $netif
|
||||
@@ -249,6 +253,9 @@ if [ -z "$NO_BOND_MASTER" ]; then
|
||||
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%%=*};
|
||||
@@ -370,10 +377,13 @@ 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
|
||||
|
||||
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 mtu dns1 dns2; do
|
||||
eval '[ "$'$i'" ] && echo '$i'="$'$i'"'
|
||||
@@ -388,6 +398,8 @@ for p in $(getargs ip=); do
|
||||
do_dhcp -6 ;;
|
||||
auto6)
|
||||
do_ipv6auto ;;
|
||||
either6)
|
||||
do_ipv6auto || do_dhcp -6 ;;
|
||||
*)
|
||||
do_static ;;
|
||||
esac
|
||||
|
@@ -102,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
|
||||
|
@@ -445,7 +445,7 @@ ip_to_var() {
|
||||
fi
|
||||
|
||||
if [ $# -eq 1 ]; then
|
||||
# format: ip={dhcp|on|any|dhcp6|auto6}
|
||||
# format: ip={dhcp|on|any|dhcp6|auto6|either6}
|
||||
# or
|
||||
# ip=<ipv4-address> means anaconda-style static config argument cluster
|
||||
autoconf="$1"
|
||||
@@ -472,7 +472,7 @@ ip_to_var() {
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "$2" = "dhcp" -o "$2" = "on" -o "$2" = "any" -o "$2" = "dhcp6" -o "$2" = "auto6" ]; then
|
||||
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"
|
||||
@@ -645,6 +645,7 @@ wait_for_ipv6_dad_link() {
|
||||
timeout=$(($timeout*10))
|
||||
|
||||
while [ $cnt -lt $timeout ]; do
|
||||
[ -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)" ] \
|
||||
@@ -662,6 +663,7 @@ wait_for_ipv6_dad() {
|
||||
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)" ] \
|
||||
@@ -706,7 +708,7 @@ iface_has_carrier() {
|
||||
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"
|
||||
@@ -731,6 +733,13 @@ 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,6 +9,8 @@
|
||||
#
|
||||
# bond without parameters assumes bond=bond0:eth0,eth1:mode=balance-rr
|
||||
#
|
||||
# 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
|
||||
@@ -25,15 +27,17 @@ parsebond() {
|
||||
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
|
||||
}
|
||||
|
||||
# Parse bond for bondname, bondslaves, bondmode and bondoptions
|
||||
# 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
|
||||
@@ -47,4 +51,5 @@ for bond in $(getargs bond=); do
|
||||
echo "bondname=$bondname" > /tmp/bond.${bondname}.info
|
||||
echo "bondslaves=\"$bondslaves\"" >> /tmp/bond.${bondname}.info
|
||||
echo "bondoptions=\"$bondoptions\"" >> /tmp/bond.${bondname}.info
|
||||
echo "bondmtu=\"$bondmtu\"" >> /tmp/bond.${bondname}.info
|
||||
done
|
||||
|
@@ -78,6 +78,7 @@ 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"
|
||||
|
@@ -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
|
||||
|
@@ -45,7 +45,7 @@ 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" \
|
||||
@@ -83,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
|
||||
|
@@ -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
|
||||
|
@@ -43,7 +43,7 @@ cmdline() {
|
||||
}
|
||||
|
||||
installkernel() {
|
||||
instmods dm-snapshot
|
||||
hostonly='' instmods dm-snapshot
|
||||
}
|
||||
|
||||
# called by dracut
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -105,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
|
||||
|
@@ -87,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"
|
||||
|
@@ -51,16 +51,30 @@ cmdline() {
|
||||
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
|
||||
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"
|
||||
dcb="dcb"
|
||||
else
|
||||
dcb="nodcb"
|
||||
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
|
||||
}
|
||||
|
@@ -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
|
||||
@@ -196,6 +197,11 @@ handle_netroot()
|
||||
${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 ; }
|
||||
|
@@ -23,8 +23,10 @@ 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
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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 /)"
|
||||
|
@@ -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
|
||||
|
@@ -166,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 \
|
||||
@@ -181,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
|
||||
|
@@ -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
|
||||
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
|
||||
@@ -10,32 +8,80 @@ generator_wait_for_dev()
|
||||
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"
|
||||
|
||||
_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
|
||||
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
|
||||
|
||||
if ! [ -f /run/systemd/generator/${_name}.device.d/timeout.conf ]; then
|
||||
_timeout=$(getarg rd.device.timeout || printf "0")
|
||||
mkdir -p /run/systemd/generator/${_name}.device.d
|
||||
_name=$(dev_unit_name "$1")
|
||||
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 "$GENERATOR_DIR"/${_name}.device.d/timeout.conf ]; then
|
||||
mkdir -p "$GENERATOR_DIR"/${_name}.device.d
|
||||
{
|
||||
echo "[Unit]"
|
||||
echo "JobTimeoutSec=$_timeout"
|
||||
} > /run/systemd/generator/${_name}.device.d/timeout.conf
|
||||
} > "$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=*)
|
||||
@@ -62,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
|
||||
|
@@ -868,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>
|
||||
|
@@ -103,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
|
||||
|
||||
|
Reference in New Issue
Block a user