Compare commits
410 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b490820a67 | ||
![]() |
3178e5d9e6 | ||
![]() |
7ceaad3400 | ||
![]() |
d8caac65a7 | ||
![]() |
d2846fdcce | ||
![]() |
6414f18c34 | ||
![]() |
77359602a2 | ||
![]() |
e318a113be | ||
![]() |
cba4eac067 | ||
![]() |
6e49e06cfe | ||
![]() |
faa3920f1d | ||
![]() |
44678ee989 | ||
![]() |
386875cc9e | ||
![]() |
ac607d92dc | ||
![]() |
8d32f7965f | ||
![]() |
945b5334ca | ||
![]() |
fa870823fe | ||
![]() |
6b06a771cf | ||
![]() |
89cd64a635 | ||
![]() |
e953f9e688 | ||
![]() |
5b276e8015 | ||
![]() |
0314ef5451 | ||
![]() |
1984bb42e3 | ||
![]() |
417ae3f1ad | ||
![]() |
210431852f | ||
![]() |
82bafb320b | ||
![]() |
a3e2bb4eba | ||
![]() |
6dfff71f85 | ||
![]() |
3860f27881 | ||
![]() |
fa3638a353 | ||
![]() |
cf729a109d | ||
![]() |
7b991e9702 | ||
![]() |
936bd1e05f | ||
![]() |
1e7a5c2617 | ||
![]() |
0aa4e3149f | ||
![]() |
bd49ce86ec | ||
![]() |
75cc5ac016 | ||
![]() |
25c7c10c58 | ||
![]() |
c1b5163c29 | ||
![]() |
a8fb48486c | ||
![]() |
841fc1e3a7 | ||
![]() |
ec3fd83dc1 | ||
![]() |
284c8be768 | ||
![]() |
f3763b75dd | ||
![]() |
9877bf26df | ||
![]() |
20b51b686b | ||
![]() |
d3fd23a1e1 | ||
![]() |
97ff4a0003 | ||
![]() |
3559c0b6cf | ||
![]() |
2822eb855a | ||
![]() |
53c46459df | ||
![]() |
adf1849bf9 | ||
![]() |
197e35b75b | ||
![]() |
ba0b653658 | ||
![]() |
f22abb4b3e | ||
![]() |
f53a0f20fd | ||
![]() |
724674d178 | ||
![]() |
d65cf005bb | ||
![]() |
def98684d4 | ||
![]() |
d1e6cd0f30 | ||
![]() |
d3b8ab7783 | ||
![]() |
f0c92896e7 | ||
![]() |
95dfe9d02b | ||
![]() |
1c5b7848e1 | ||
![]() |
40586a2b7b | ||
![]() |
7ea1b49819 | ||
![]() |
cb9f6af094 | ||
![]() |
faa17f0921 | ||
![]() |
2413fcbc60 | ||
![]() |
a0aeaa381f | ||
![]() |
cfc02869e4 | ||
![]() |
b75196ac27 | ||
![]() |
9a2f5592c5 | ||
![]() |
1d85a6fe6d | ||
![]() |
dd9b5df3b9 | ||
![]() |
afd17a3ec5 | ||
![]() |
dbd8c68b7a | ||
![]() |
a22c502d86 | ||
![]() |
ee2cd169bd | ||
![]() |
9a35a62bf1 | ||
![]() |
93d3f433fe | ||
![]() |
de176906ff | ||
![]() |
b9ec6563e7 | ||
![]() |
76fa8652d2 | ||
![]() |
158fab27b7 | ||
![]() |
81134e54ad | ||
![]() |
77d76bad4d | ||
![]() |
1d71152bd1 | ||
![]() |
754beeddf2 | ||
![]() |
92d595398f | ||
![]() |
85dde6406d | ||
![]() |
7decd80f44 | ||
![]() |
e0459b1e97 | ||
![]() |
64eb996323 | ||
![]() |
991a8728d0 | ||
![]() |
3b4bc498e1 | ||
![]() |
e654485a8e | ||
![]() |
1636712f09 | ||
![]() |
581452062f | ||
![]() |
a2c0b852a0 | ||
![]() |
1cb33f3954 | ||
![]() |
f2c3a039da | ||
![]() |
e1fd8dd119 | ||
![]() |
93950912ea | ||
![]() |
0fa047fcf1 | ||
![]() |
36d52d765e | ||
![]() |
5f99314801 | ||
![]() |
a77208565d | ||
![]() |
a74acc38e2 | ||
![]() |
f52ee9073e | ||
![]() |
9ea87dfdad | ||
![]() |
8485c3205f | ||
![]() |
e92ca555bf | ||
![]() |
ff53445872 | ||
![]() |
dbc92d85f2 | ||
![]() |
90e189b042 | ||
![]() |
8a3fe63a08 | ||
![]() |
0ec43d7a56 | ||
![]() |
3bbd0c7764 | ||
![]() |
00056957bf | ||
![]() |
6bc37a9952 | ||
![]() |
019b3f0277 | ||
![]() |
0147a3be17 | ||
![]() |
6dd298ff9b | ||
![]() |
90689543da | ||
![]() |
7596b72b39 | ||
![]() |
f22f08d857 | ||
![]() |
6efc9e13be | ||
![]() |
39086d914f | ||
![]() |
51b048c3e4 | ||
![]() |
d2ea3cac52 | ||
![]() |
cfe414dce8 | ||
![]() |
c76de095b2 | ||
![]() |
1587cc7724 | ||
![]() |
15097b4ab9 | ||
![]() |
f3516c8db5 | ||
![]() |
3c12f005f8 | ||
![]() |
2cfbfbba06 | ||
![]() |
6410b72af6 | ||
![]() |
2396effc41 | ||
![]() |
0269b775fc | ||
![]() |
dd8d25ba3e | ||
![]() |
1fd259f340 | ||
![]() |
96bfc02133 | ||
![]() |
8cdad31667 | ||
![]() |
0cd9406149 | ||
![]() |
2e1cccc9ca | ||
![]() |
418b762dc2 | ||
![]() |
8e08cf65ab | ||
![]() |
d3b8373f4a | ||
![]() |
655d9cb4a3 | ||
![]() |
386d61d344 | ||
![]() |
c99fbb55e4 | ||
![]() |
cbc8b70f7a | ||
![]() |
b405725794 | ||
![]() |
76766f9fab | ||
![]() |
dfd0775ce1 | ||
![]() |
69c9fb1122 | ||
![]() |
278cc2e163 | ||
![]() |
76904bf6d2 | ||
![]() |
4fa79aedff | ||
![]() |
9db27c4679 | ||
![]() |
531df99049 | ||
![]() |
676a8c4262 | ||
![]() |
584ee33fa0 | ||
![]() |
94b12823ad | ||
![]() |
b3d287ae35 | ||
![]() |
011800434a | ||
![]() |
c1cb0de4d5 | ||
![]() |
bb2981ef4e | ||
![]() |
e88e72e77e | ||
![]() |
6794a14d78 | ||
![]() |
108d50e915 | ||
![]() |
6b08647649 | ||
![]() |
02762f03af | ||
![]() |
b74e7abd6c | ||
![]() |
dd8a1899b7 | ||
![]() |
2e03ba69ee | ||
![]() |
229525f896 | ||
![]() |
5678b583f3 | ||
![]() |
112cd50eba | ||
![]() |
9ee1b78fcb | ||
![]() |
d239bca13f | ||
![]() |
f5e4937240 | ||
![]() |
0f5b9bad74 | ||
![]() |
edcd4c2bd7 | ||
![]() |
89f35f9df1 | ||
![]() |
25e1d28d75 | ||
![]() |
c0f212dbbc | ||
![]() |
ff349b0812 | ||
![]() |
a223be3c54 | ||
![]() |
28b5496083 | ||
![]() |
0a5ac37bc3 | ||
![]() |
ba4b902a70 | ||
![]() |
a0ea3ac575 | ||
![]() |
1444e3e777 | ||
![]() |
f9833db0ca | ||
![]() |
c0d440be71 | ||
![]() |
c1d82f2cac | ||
![]() |
9259945f93 | ||
![]() |
ab6977f0a6 | ||
![]() |
40104e4a2b | ||
![]() |
a10364d4ee | ||
![]() |
18a6ce9d25 | ||
![]() |
6b3248074b | ||
![]() |
d31ba0f55e | ||
![]() |
ead064e33d | ||
![]() |
5018463c5e | ||
![]() |
13e2ceeed9 | ||
![]() |
22f07c112d | ||
![]() |
6ff9d5e086 | ||
![]() |
592dabba90 | ||
![]() |
bf57d7f563 | ||
![]() |
c61cec19fa | ||
![]() |
42720f51f0 | ||
![]() |
412ff7139b | ||
![]() |
d350485721 | ||
![]() |
6d3cc779c6 | ||
![]() |
4ac0cbad25 | ||
![]() |
3bc65506b0 | ||
![]() |
60e4486b53 | ||
![]() |
bea581515c | ||
![]() |
6fa9f8b150 | ||
![]() |
cda0d40758 | ||
![]() |
85d7ac93e9 | ||
![]() |
0ce3429c6b | ||
![]() |
902dc2cb20 | ||
![]() |
1817cb215d | ||
![]() |
cfb4747e57 | ||
![]() |
e45a2dba9d | ||
![]() |
c4634f5bb4 | ||
![]() |
cf3d51ba6a | ||
![]() |
2af86a7080 | ||
![]() |
44e90e5c5a | ||
![]() |
b5b5ff12a8 | ||
![]() |
e2f1c1f88c | ||
![]() |
5a2034943d | ||
![]() |
7e7308158c | ||
![]() |
663ea6df17 | ||
![]() |
3901c9c45a | ||
![]() |
33b00dd5d3 | ||
![]() |
ae35574230 | ||
![]() |
8a886909d0 | ||
![]() |
75cffbd155 | ||
![]() |
a9ebf4e13c | ||
![]() |
3539eec0c1 | ||
![]() |
dc3066da86 | ||
![]() |
c73bba03f8 | ||
![]() |
c3a4119beb | ||
![]() |
e8a848333f | ||
![]() |
8a6939656f | ||
![]() |
a735202636 | ||
![]() |
8c4549ff18 | ||
![]() |
ca77f36f8e | ||
![]() |
f4dad88085 | ||
![]() |
cbea975b98 | ||
![]() |
26c4321fa9 | ||
![]() |
2f25c3f4a5 | ||
![]() |
0828d4c357 | ||
![]() |
70dfe537d2 | ||
![]() |
810270eb00 | ||
![]() |
aee0e16994 | ||
![]() |
d084697710 | ||
![]() |
1d942b8875 | ||
![]() |
f8dd8dcf14 | ||
![]() |
d3898996b0 | ||
![]() |
7cfd77a0f1 | ||
![]() |
e48ff7a5ef | ||
![]() |
a2c1759356 | ||
![]() |
d06ffa49ac | ||
![]() |
63de73ece6 | ||
![]() |
5ee37e0ab4 | ||
![]() |
f35ef174ca | ||
![]() |
46b58d1eef | ||
![]() |
a35aefbf1a | ||
![]() |
1c1f927e29 | ||
![]() |
2a951b1010 | ||
![]() |
c30d8d49cd | ||
![]() |
2df596227c | ||
![]() |
863e5f75a7 | ||
![]() |
b30302eba2 | ||
![]() |
e0c31e098e | ||
![]() |
92f0589585 | ||
![]() |
9426b6be6a | ||
![]() |
711e599ee3 | ||
![]() |
6e42a506b5 | ||
![]() |
179acdbf1e | ||
![]() |
81160d216e | ||
![]() |
94d70b3724 | ||
![]() |
77818e694f | ||
![]() |
52ce3484e3 | ||
![]() |
e7a2d1951e | ||
![]() |
d4974c3452 | ||
![]() |
336f147365 | ||
![]() |
9fd0454107 | ||
![]() |
8d03d1d597 | ||
![]() |
d344f44317 | ||
![]() |
a6688b76a6 | ||
![]() |
1113178730 | ||
![]() |
13c5bb8e63 | ||
![]() |
6b9bc307d7 | ||
![]() |
3626f8270a | ||
![]() |
b01d764b5a | ||
![]() |
3eb019d36b | ||
![]() |
3fef20c9c5 | ||
![]() |
a2a62799f2 | ||
![]() |
1e42363dfd | ||
![]() |
619a609bea | ||
![]() |
60953678c2 | ||
![]() |
6fd000939e | ||
![]() |
08c9da4c2c | ||
![]() |
b0908bcc6f | ||
![]() |
afef8f701f | ||
![]() |
e06063284c | ||
![]() |
90ff109156 | ||
![]() |
13df047b8e | ||
![]() |
ee5bdb2a55 | ||
![]() |
2ad6b48506 | ||
![]() |
fd7c4d2834 | ||
![]() |
d207cf3a74 | ||
![]() |
7085fee2e0 | ||
![]() |
855adf33de | ||
![]() |
f30a0b78b8 | ||
![]() |
bff7ebeb0c | ||
![]() |
6cb85f40fb | ||
![]() |
5c57cf40d8 | ||
![]() |
5fc1eb3820 | ||
![]() |
1e4ba0739b | ||
![]() |
acf43f032a | ||
![]() |
24e0eb7247 | ||
![]() |
7803caa833 | ||
![]() |
919efa1894 | ||
![]() |
459cbc4075 | ||
![]() |
bd087db248 | ||
![]() |
e632ecf64a | ||
![]() |
f180f9f344 | ||
![]() |
b609cf0255 | ||
![]() |
0aa41e0a47 | ||
![]() |
88d3b8bcee | ||
![]() |
eff7f5adf6 | ||
![]() |
73bbcaaacf | ||
![]() |
45e48d41d8 | ||
![]() |
3ff8c64d56 | ||
![]() |
ed3b393b7b | ||
![]() |
aaed7a7abb | ||
![]() |
0b860653be | ||
![]() |
ebede24bd4 | ||
![]() |
871085b8b2 | ||
![]() |
a553865994 | ||
![]() |
a748da9c27 | ||
![]() |
29502af63d | ||
![]() |
1b02a85be8 | ||
![]() |
3e592297cd | ||
![]() |
e20777d90e | ||
![]() |
9ec50d3dbb | ||
![]() |
41594890af | ||
![]() |
6bb1a78b81 | ||
![]() |
97c25fe67d | ||
![]() |
ee7820d04c | ||
![]() |
0df77fb0e9 | ||
![]() |
1b8636aa8e | ||
![]() |
a621fc0be8 | ||
![]() |
eeee01e534 | ||
![]() |
4e558ef5ca | ||
![]() |
95d580507e | ||
![]() |
3d81d725e5 | ||
![]() |
3a6a6b7a05 | ||
![]() |
cf6a399dc8 | ||
![]() |
162cfd6be4 | ||
![]() |
d2f762de55 | ||
![]() |
2403d615f6 | ||
![]() |
f32cc501ae | ||
![]() |
c00d8dc143 | ||
![]() |
2edc0d682c | ||
![]() |
2979071476 | ||
![]() |
98b9ab580a | ||
![]() |
cee6b34456 | ||
![]() |
d44a916dd1 | ||
![]() |
e3e6814eee | ||
![]() |
071cba4de2 | ||
![]() |
c2d781453d | ||
![]() |
3501a9be20 | ||
![]() |
f01253ac3a | ||
![]() |
aafa510eb0 | ||
![]() |
29f9e9ad4b | ||
![]() |
5db3f2daca | ||
![]() |
af39a960a4 | ||
![]() |
2a9b5f1070 | ||
![]() |
e0869cc42d | ||
![]() |
0376e6c0f1 | ||
![]() |
ae7d963f24 | ||
![]() |
bec946f131 | ||
![]() |
05e42bd49b | ||
![]() |
fe57e7f43c | ||
![]() |
e05dff553c | ||
![]() |
7d0a30088e | ||
![]() |
e99d30edf8 | ||
![]() |
23c6493093 | ||
![]() |
95cad9133a | ||
![]() |
3092987a7f | ||
![]() |
6083ccf000 | ||
![]() |
4d85598c4b | ||
![]() |
33d1be3fa2 | ||
![]() |
37646c0f76 | ||
![]() |
8bb18dd465 | ||
![]() |
d0ad543882 | ||
![]() |
c4b4668b38 | ||
![]() |
e484218385 | ||
![]() |
833de7c70a | ||
![]() |
707fb5982c |
@@ -1,2 +1,3 @@
|
||||
(setq sh-basic-offset: 4)
|
||||
(setq indent-tabs-mode nil)
|
||||
((nil . ((setq sh-basic-offset: 4)
|
||||
(setq indent-tabs-mode nil)
|
||||
)))
|
||||
|
20
.gitignore
vendored
20
.gitignore
vendored
@@ -1,19 +1,3 @@
|
||||
/Makefile.inc
|
||||
/dracut.8
|
||||
/dracut-catimages.8
|
||||
/dracut.conf.5
|
||||
/dracut.conf.d/*.conf
|
||||
/dracut-gencmdline.8
|
||||
/dracut.html
|
||||
/dracut.kernel.7
|
||||
/modules.d/99base/switch_root
|
||||
/test/*/test.log
|
||||
test*.img
|
||||
/.buildpath
|
||||
/.project
|
||||
/dracut-version.sh
|
||||
/install/dracut-install
|
||||
/*.rpm
|
||||
/*.[0-9]
|
||||
/modules.d/98systemd/*.service.8
|
||||
/*.sign
|
||||
modules.d/99base/switch_root
|
||||
*~
|
||||
|
21
.mailmap
21
.mailmap
@@ -1,15 +1,6 @@
|
||||
Philippe Seewer <philippe.seewer@bfh.ch> <philippe.seewer-omB+W0Dpw2o@public.gmane.org>
|
||||
Seewer Philippe <philippe.seewer@bfh.ch> <philippe.seewer@bfh.ch>
|
||||
Philippe Seewer <philippe.seewer@bfh.ch> <philippe.seewer@bfh.ch>
|
||||
Victor Lowther <victor.lowther@gmail.com> <victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
|
||||
Harald Hoyer <harald@redhat.com> <harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
|
||||
Harald Hoyer <harald@redhat.com> <harald@eeepc.(none)>
|
||||
Mike Snitzer <snitzer@redhat.com> <msnitzer@redhat.com>
|
||||
Amerigo Wang <amwang@redhat.com> <xiyou.wangcong@gmail.com>
|
||||
Andrey Borzenkov <arvidjaar@gmail.com> <arvidjaar@mail.ru>
|
||||
Dan Horák <dhorak@redhat.com> <dan@danny.cz>
|
||||
John Reiser <jreiser@bitwagon.com> <jreiser@BitWagon.com>
|
||||
Luca Berra <bluca@vodka.it> <bluca@comedia.it>
|
||||
Dave Young <dyoung@redhat.com> dyoung@redhat.com
|
||||
Frederick Grose <fgrose@sugarlabs.org> <fgrose@gmail.com>
|
||||
Frederic Crozat <fcrozat@suse.com> <fcrozat@mandriva.com>
|
||||
Philippe Seewer <philippe.seewer@bfh.ch> <philippe.seewer-omB+W0Dpw2o@public.gmane.org>
|
||||
Seewer Philippe <philippe.seewer@bfh.ch> <philippe.seewer@bfh.ch>
|
||||
Philippe Seewer <philippe.seewer@bfh.ch> <philippe.seewer@bfh.ch>
|
||||
Victor Lowther <victor.lowther@gmail.com> <victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
|
||||
Harald Hoyer <harald@redhat.com> <harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
|
||||
Harald Hoyer <harald@redhat.com> <harald@eeepc.(none)>
|
||||
|
@@ -1,33 +0,0 @@
|
||||
#!/bin/sh
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
if [[ -f /etc/kernel/cmdline ]]; then
|
||||
readarray -t BOOT_OPTIONS < /etc/kernel/cmdline
|
||||
fi
|
||||
|
||||
if ! [[ "${BOOT_OPTIONS[@]}" ]]; then
|
||||
readarray -t BOOT_OPTIONS < /proc/cmdline
|
||||
fi
|
||||
|
||||
unset noimageifnotneeded
|
||||
|
||||
for ((i=0; i < "${#BOOT_OPTIONS[@]}"; i++)); do
|
||||
if [[ ${BOOT_OPTIONS[$i]} == root\=PARTUUID\=* ]]; then
|
||||
noimageifnotneeded="yes"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
ret=0
|
||||
case "$1" in
|
||||
add)
|
||||
dracut ${noimageifnotneeded:+--noimageifnotneeded} "$3"/initrd "$2"
|
||||
ret=$?
|
||||
;;
|
||||
remove)
|
||||
rm -f -- "$3"/initrd
|
||||
ret=$?
|
||||
;;
|
||||
esac
|
||||
exit $ret
|
@@ -1,70 +0,0 @@
|
||||
#!/bin/bash
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
export LANG=C
|
||||
|
||||
KERNEL_VERSION="$1"
|
||||
KERNEL_IMAGE="$2"
|
||||
|
||||
[[ -f /etc/os-release ]] && . /etc/os-release
|
||||
|
||||
if [[ ! -f /etc/machine-id ]] || [[ ! -s /etc/machine-id ]]; then
|
||||
systemd-machine-id-setup
|
||||
fi
|
||||
|
||||
[[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
|
||||
|
||||
[[ $MACHINE_ID ]] || exit 1
|
||||
[[ -f $KERNEL_IMAGE ]] || exit 1
|
||||
|
||||
INITRDFILE="/boot/initramfs-0-rescue-${MACHINE_ID}.img"
|
||||
NEW_KERNEL_IMAGE="${KERNEL_IMAGE%/*}/vmlinuz-0-rescue-${MACHINE_ID}"
|
||||
|
||||
[[ -f $INITRDFILE ]] && [[ -f $NEW_KERNEL_IMAGE ]] && exit 0
|
||||
|
||||
dropindirs_sort()
|
||||
{
|
||||
suffix=$1; shift
|
||||
args=("$@")
|
||||
files=$(
|
||||
while (( $# > 0 )); do
|
||||
for i in ${1}/*${suffix}; do
|
||||
[[ -f $i ]] && echo ${i##*/}
|
||||
done
|
||||
shift
|
||||
done | sort -Vu
|
||||
)
|
||||
|
||||
for f in $files; do
|
||||
for d in "${args[@]}"; do
|
||||
if [[ -f "$d/$f" ]]; then
|
||||
echo "$d/$f"
|
||||
continue 2
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
# source our config dir
|
||||
for f in $(dropindirs_sort ".conf" "/etc/dracut.conf.d" "/usr/lib/dracut/dracut.conf.d"); do
|
||||
[[ -e $f ]] && . "$f"
|
||||
done
|
||||
|
||||
[[ $dracut_rescue_image != "yes" ]] && exit 0
|
||||
|
||||
if [[ ! -f $INITRDFILE ]]; then
|
||||
dracut --no-hostonly -a "rescue" "$INITRDFILE" "$KERNEL_VERSION"
|
||||
((ret+=$?))
|
||||
fi
|
||||
|
||||
if [[ ! -f $NEW_KERNEL_IMAGE ]]; then
|
||||
cp "$KERNEL_IMAGE" "$NEW_KERNEL_IMAGE"
|
||||
((ret+=$?))
|
||||
fi
|
||||
|
||||
new-kernel-pkg --install "$KERNEL_VERSION" --kernel-image "$NEW_KERNEL_IMAGE" --initrdfile "$INITRDFILE" --banner "$NAME $VERSION_ID Rescue $MACHINE_ID"
|
||||
|
||||
((ret+=$?))
|
||||
|
||||
exit $ret
|
@@ -1,103 +0,0 @@
|
||||
#!/bin/bash
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
export LANG=C
|
||||
|
||||
COMMAND="$1"
|
||||
KERNEL_VERSION="$2"
|
||||
BOOT_DIR_ABS="${3%/*}/0-rescue"
|
||||
KERNEL_IMAGE="$4"
|
||||
|
||||
|
||||
dropindirs_sort()
|
||||
{
|
||||
suffix=$1; shift
|
||||
args=("$@")
|
||||
files=$(
|
||||
while (( $# > 0 )); do
|
||||
for i in ${1}/*${suffix}; do
|
||||
[[ -f $i ]] && echo ${i##*/}
|
||||
done
|
||||
shift
|
||||
done | sort -Vu
|
||||
)
|
||||
|
||||
for f in $files; do
|
||||
for d in "${args[@]}"; do
|
||||
if [[ -f "$d/$f" ]]; then
|
||||
echo "$d/$f"
|
||||
continue 2
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
[[ -f /etc/os-release ]] && . /etc/os-release
|
||||
|
||||
if [[ ! -f /etc/machine-id ]] || [[ ! -s /etc/machine-id ]]; then
|
||||
systemd-machine-id-setup
|
||||
fi
|
||||
|
||||
[[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
|
||||
|
||||
if [[ -f /etc/kernel/cmdline ]]; then
|
||||
readarray -t BOOT_OPTIONS < /etc/kernel/cmdline
|
||||
fi
|
||||
if ! [[ "${BOOT_OPTIONS[@]}" ]]; then
|
||||
readarray -t BOOT_OPTIONS < /proc/cmdline
|
||||
fi
|
||||
if ! [[ $BOOT_OPTIONS ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
LOADER_ENTRY="/boot/loader/entries/${MACHINE_ID}-0-rescue.conf"
|
||||
BOOT_DIR="/${MACHINE_ID}/0-rescue"
|
||||
|
||||
ret=0
|
||||
|
||||
case "$COMMAND" in
|
||||
add)
|
||||
for i in "/boot/loader/entries/${MACHINE_ID}-0-rescue.conf"; do
|
||||
[[ -f $i ]] && exit 0
|
||||
done
|
||||
|
||||
# source our config dir
|
||||
for f in $(dropindirs_sort ".conf" "/etc/dracut.conf.d" "/usr/lib/dracut/dracut.conf.d"); do
|
||||
[[ -e $f ]] && . "$f"
|
||||
done
|
||||
|
||||
[[ $dracut_rescue_image != "yes" ]] && exit 0
|
||||
|
||||
[[ -d "$BOOT_DIR_ABS" ]] || mkdir -p "$BOOT_DIR_ABS"
|
||||
|
||||
if ! cp "$KERNEL_IMAGE" "$BOOT_DIR_ABS"/linux; then
|
||||
echo "Can't copy '$KERNEL_IMAGE to '$BOOT_DIR_ABS/linux'!" >&2
|
||||
fi
|
||||
|
||||
dracut --no-hostonly -a "rescue" "$BOOT_DIR_ABS"/initrd "$2"
|
||||
((ret+=$?))
|
||||
|
||||
{
|
||||
echo "title $PRETTY_NAME - Rescue Image"
|
||||
echo "version $KERNEL_VERSION"
|
||||
echo "machine-id $MACHINE_ID"
|
||||
echo "options ${BOOT_OPTIONS[@]} rd.auto=1"
|
||||
echo "linux $BOOT_DIR/linux"
|
||||
echo "initrd $BOOT_DIR/initrd"
|
||||
} > $LOADER_ENTRY
|
||||
((ret+=$?))
|
||||
;;
|
||||
|
||||
remove)
|
||||
exit 0
|
||||
;;
|
||||
|
||||
*)
|
||||
usage
|
||||
ret=1;;
|
||||
esac
|
||||
|
||||
((ret+=$?))
|
||||
|
||||
exit $ret
|
93
AUTHORS
93
AUTHORS
@@ -1,105 +1,32 @@
|
||||
Harald Hoyer <harald@redhat.com>
|
||||
Victor Lowther <victor.lowther@gmail.com>
|
||||
Amadeusz Żołnowski <aidecoe@aidecoe.name>
|
||||
Will Woods <wwoods@redhat.com>
|
||||
Philippe Seewer <philippe.seewer@bfh.ch>
|
||||
Warren Togami <wtogami@redhat.com>
|
||||
Jeremy Katz <katzj@redhat.com>
|
||||
Dave Young <dyoung@redhat.com>
|
||||
David Dillow <dave@thedillows.org>
|
||||
Michal Soltys <soltys@ziu.info>
|
||||
Amerigo Wang <amwang@redhat.com>
|
||||
Colin Guthrie <colin@mageia.org>
|
||||
Andrey Borzenkov <arvidjaar@gmail.com>
|
||||
Peter Jones <pjones@redhat.com>
|
||||
Andreas Thienemann <andreas@bawue.net>
|
||||
Hans de Goede <hdegoede@redhat.com>
|
||||
John Reiser <jreiser@bitwagon.com>
|
||||
Luca Berra <bluca@vodka.it>
|
||||
WANG Chao <chaowang@redhat.com>
|
||||
Daniel Drake <dsd@laptop.org>
|
||||
Dan Horák <dhorak@redhat.com>
|
||||
Baoquan He <bhe@redhat.com>
|
||||
Leho Kraav <leho@kraav.com>
|
||||
Brian C. Lane <bcl@redhat.com>
|
||||
Kamil Rytarowski <n54@gmx.com>
|
||||
Peter Jones <pjones@redhat.com>
|
||||
Luca Berra <bluca@comedia.it>
|
||||
Marc Grimme <grimme@atix.de>
|
||||
Chao Wang <chaowang@redhat.com>
|
||||
Frederic Crozat <fcrozat@suse.com>
|
||||
Jesse Keating <jkeating@redhat.com>
|
||||
Milan Broz <mbroz@redhat.com>
|
||||
Radek Vykydal <rvykydal@redhat.com>
|
||||
Roberto Sassu <roberto.sassu@polito.it>
|
||||
Anton Blanchard <anton@samba.org>
|
||||
Andrey Borzenkov <arvidjaar@mail.ru>
|
||||
Bill Nottingham <notting@redhat.com>
|
||||
Colin Walters <walters@verbum.org>
|
||||
Daniel Drake <dsd@laptop.org>
|
||||
David Cantrell <dcantrell@redhat.com>
|
||||
Dennis Gilmore <dennis@ausil.us>
|
||||
Jon Ander Hernandez <jonan.h@gmail.com>
|
||||
Juan RP <xtraeme@gmail.com>
|
||||
Lance Albertson <lance@osuosl.org>
|
||||
Marian Ganisin <mganisin@redhat.com>
|
||||
Michael Ploujnikov <plouj@somanetworks.com>
|
||||
Peter Rajnoha <prajnoha@redhat.com>
|
||||
Wim Muskee <wimmuskee@gmail.com>
|
||||
Alan Jenkins <alan-jenkins@tuffmail.co.uk>
|
||||
Alan Pevec <apevec@redhat.com>
|
||||
Frederick Grose <fgrose@sugarlabs.org>
|
||||
Ian Dall <ian@beware.dropbear.id.au>
|
||||
James Buren <ryuo@frugalware.org>
|
||||
James Lee <jlee@thestaticvoid.com>
|
||||
Dan Horák <dan@danny.cz>
|
||||
Joey Boggs <jboggs@redhat.com>
|
||||
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
|
||||
Mike Snitzer <snitzer@redhat.com>
|
||||
Przemysław Rudy <prudy1@o2.pl>
|
||||
Stefan Reimer <it@startux.de>
|
||||
Thomas Lange <lange@informatik.uni-koeln.de>
|
||||
Vivek Goyal <vgoyal@redhat.com>
|
||||
Vladislav Bogdanov <bubble@hoster-ok.com>
|
||||
Adam Williamson <awilliam@redhat.com>
|
||||
Alexander Todorov <atodorov@redhat.com>
|
||||
Andy Lutomirski <luto@mit.edu>
|
||||
Anssi Hannula <anssi@mageia.org>
|
||||
Brandon Philips <brandon@ifup.co>
|
||||
Canek Peláez Valdés <caneko@gmail.com>
|
||||
Chris Leech <cleech@redhat.com>
|
||||
Christian Heinz <christian.ch.heinz@gmail.com>
|
||||
Cong Wang <amwang@redhat.com>
|
||||
Daniel Schaal <farbing@web.de>
|
||||
Dave Jones <davej@redhat.com>
|
||||
Dave Young <dave@redhat.com>
|
||||
Dennis Schridde <devurandom@gmx.net>
|
||||
Duane Griffin <duaneg@dghda.com>
|
||||
Glen Gray <slaine@slaine.org>
|
||||
Hermann Gausterer <git-dracut-2012@mrq1.org>
|
||||
James Laska <jlaska@redhat.com>
|
||||
Jan Stodola <jstodola@redhat.com>
|
||||
Jiri Pirko <jiri@resnulli.us>
|
||||
Joe Lawrence <Joe.Lawrence@stratus.com>
|
||||
Kevin Yung <Kevin.Yung@myob.com>
|
||||
Kyle McMartin <kyle@redhat.com>
|
||||
Lars R. Damerow <lars@pixar.com>
|
||||
Lennert Buytenhek <buytenh@wantstofly.org>
|
||||
Lubomir Rintel <lkundrak@v3.sk>
|
||||
Matt <smoothsailing72@hotmail.com>
|
||||
Matt Smith <shadowfax@gmx.com>
|
||||
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
|
||||
Luca Berra <bluca@vodka.it>
|
||||
Michal Schmidt <mschmidt@redhat.com>
|
||||
Mike Gorse <mgorse@suse.com>
|
||||
Mike Snitzer <msnitzer@redhat.com>
|
||||
Mike Snitzer <snitzer@redhat.com>
|
||||
Munehiro Matsuda <haro@kgt.co.jp>
|
||||
Nicolas Chauvet <kwizart@gmail.com>
|
||||
Nikoli <nikoli@lavabit.com>
|
||||
Olivier Blin <dev@blino.org>
|
||||
Paolo Bonzini <pbonzini@redhat.com>
|
||||
Peter Robinson <pbrobinson@fedoraproject.org>
|
||||
Pádraig Brady <P@draigBrady.com>
|
||||
Peter Rajnoha <prajnoha@redhat.com>
|
||||
Quentin Armitage <quentin@armitage.org.uk>
|
||||
Robert Buchholz <rbu@goodpoint.de>
|
||||
Sergey Fionov <fionov@gmail.com>
|
||||
Srinivasa T N <seenutn@linux.vnet.ibm.com>
|
||||
Thilo Bangert <thilo.bangert@gmx.net>
|
||||
Thomas Backlund <tmb@mageia.org>
|
||||
Tomasz Torcz <tomek@pipebreaker.pl>
|
||||
Vadim Kuznetsov <vadimk@gentoo.org>
|
||||
Ville Skyttä <ville.skytta@iki.fi>
|
||||
Yanko Kaneti <yaneti@declera.com>
|
||||
maximilian attems <max@stro.at>
|
||||
|
42
COPYING
42
COPYING
@@ -1,12 +1,12 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
675 Mass Ave, Cambridge, MA 02139, USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
@@ -15,7 +15,7 @@ software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
@@ -55,8 +55,8 @@ patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
@@ -110,7 +110,7 @@ above, provided that you also meet all of these conditions:
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
@@ -168,7 +168,7 @@ access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
@@ -225,7 +225,7 @@ impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
@@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
@@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Appendix: How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
@@ -291,7 +291,7 @@ convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
Copyright (C) 19yy <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -303,16 +303,16 @@ the "copyright" line and a pointer to where the full notice is found.
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
@@ -335,5 +335,5 @@ necessary. Here is a sample; alter the names:
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
|
6
HACKING
6
HACKING
@@ -1,11 +1,11 @@
|
||||
Right now, most of the testing is done using a qemu/kvm guest and
|
||||
generating the initramfs on another box but the support is all present
|
||||
to build for the "running" machine. For the former, you can boot the guest
|
||||
using qemu's -kernel and -initrd options.
|
||||
using qemu's -kernel and -initrd options.
|
||||
|
||||
dracut exists and will build an image. It is command-line equivalent
|
||||
to most mkinitrd implementations and should be pretty straight-forward
|
||||
to use.
|
||||
to use.
|
||||
|
||||
To use, just run dracut with an output file name and, optionally, a
|
||||
kernel version (it defaults to using the current). The appropriate
|
||||
@@ -14,7 +14,7 @@ like to customize the list of modules copied in, edit /etc/dracut.conf
|
||||
and set
|
||||
dracutmodules="foo bar baz"
|
||||
|
||||
Note that dracut calls functional components in modules.d "modules"
|
||||
Note that dracut calls functional components in modules.d "modules"
|
||||
while kernel modules are called "drivers".
|
||||
|
||||
Requirements:
|
||||
|
279
Makefile
279
Makefile
@@ -1,253 +1,116 @@
|
||||
-include dracut-version.sh
|
||||
|
||||
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
|
||||
VERSION=004
|
||||
GITVERSION=$(shell [ -d .git ] && git rev-list --abbrev-commit -n 1 HEAD |cut -b 1-8)
|
||||
|
||||
prefix ?= /usr
|
||||
libdir ?= ${prefix}/lib
|
||||
datadir ?= ${prefix}/share
|
||||
pkglibdir ?= ${libdir}/dracut
|
||||
pkglibdir ?= ${datadir}/dracut
|
||||
sysconfdir ?= ${prefix}/etc
|
||||
bindir ?= ${prefix}/bin
|
||||
sbindir ?= ${prefix}/sbin
|
||||
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
|
||||
|
||||
man5pages = dracut.conf.5
|
||||
.PHONY: install clean archive rpm testimage test all check AUTHORS
|
||||
|
||||
man7pages = dracut.cmdline.7 \
|
||||
dracut.bootup.7 \
|
||||
dracut.modules.7
|
||||
|
||||
man8pages = dracut.8 \
|
||||
dracut-catimages.8 \
|
||||
mkinitrd.8 \
|
||||
modules.d/98systemd/dracut-cmdline.service.8 \
|
||||
modules.d/98systemd/dracut-initqueue.service.8 \
|
||||
modules.d/98systemd/dracut-mount.service.8 \
|
||||
modules.d/98systemd/dracut-shutdown.service.8 \
|
||||
modules.d/98systemd/dracut-pre-mount.service.8 \
|
||||
modules.d/98systemd/dracut-pre-pivot.service.8 \
|
||||
modules.d/98systemd/dracut-pre-trigger.service.8 \
|
||||
modules.d/98systemd/dracut-pre-udev.service.8
|
||||
|
||||
manpages = $(man1pages) $(man5pages) $(man7pages) $(man8pages)
|
||||
|
||||
.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
|
||||
|
||||
DRACUT_INSTALL_OBJECTS = \
|
||||
install/dracut-install.o \
|
||||
install/hashmap.o\
|
||||
install/log.o \
|
||||
install/util.o
|
||||
|
||||
# deps generated with gcc -MM
|
||||
install/dracut-install.o: install/dracut-install.c install/log.h install/macro.h \
|
||||
install/hashmap.h install/util.h
|
||||
install/hashmap.o: install/hashmap.c install/util.h install/macro.h install/log.h \
|
||||
install/hashmap.h
|
||||
install/log.o: install/log.c install/log.h install/macro.h install/util.h
|
||||
install/util.o: install/util.c install/util.h install/macro.h install/log.h
|
||||
|
||||
install/dracut-install: $(DRACUT_INSTALL_OBJECTS)
|
||||
|
||||
dracut-install: install/dracut-install
|
||||
ln -fs $< $@
|
||||
|
||||
SKIPCPIO_OBJECTS= \
|
||||
skipcpio/skipcpio.o
|
||||
|
||||
skipcpio/skipcpio.o: skipcpio/skipcpio.c
|
||||
skipcpio/skipcpio: skipcpio/skipcpio.o
|
||||
|
||||
indent:
|
||||
indent -i8 -nut -br -linux -l120 install/dracut-install.c
|
||||
indent -i8 -nut -br -linux -l120 skipcpio/skipcpio.c
|
||||
|
||||
doc: $(manpages) dracut.html
|
||||
|
||||
ifneq ($(enable_documentation),no)
|
||||
all: doc
|
||||
ifeq (1,${WITH_SWITCH_ROOT})
|
||||
targets = modules.d/99base/switch_root
|
||||
else
|
||||
targets =
|
||||
endif
|
||||
|
||||
%: %.xml
|
||||
xsltproc -o $@ -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
|
||||
all: $(targets) dracut-rhel6.html
|
||||
|
||||
%.xml: %.asc
|
||||
asciidoc -d manpage -b docbook -o $@ $<
|
||||
dracut-rhel6.html: dracut-rhel6.xml
|
||||
xsltproc -o dracut-rhel6.html --xinclude -nonet \
|
||||
--stringparam draft.mode yes \
|
||||
--stringparam html.stylesheet http://docs.redhat.com/docs/en-US/Common_Content/css/default.css \
|
||||
http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl dracut-rhel6.xml
|
||||
|
||||
dracut.8: dracut.usage.asc dracut.8.asc
|
||||
modules.d/99base/switch_root: switch_root.c
|
||||
gcc -D _GNU_SOURCE -D 'PACKAGE_STRING="dracut"' -std=gnu99 -fsigned-char -g -O2 -o modules.d/99base/switch_root switch_root.c
|
||||
|
||||
dracut.html: dracut.asc $(manpages) dracut.css dracut.usage.asc
|
||||
asciidoc -a numbered -d book -b docbook -o dracut.xml dracut.asc
|
||||
xsltproc -o dracut.html --xinclude -nonet \
|
||||
--stringparam custom.css.source dracut.css \
|
||||
--stringparam generate.css.header 1 \
|
||||
http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl dracut.xml
|
||||
rm -f -- dracut.xml
|
||||
|
||||
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
|
||||
install:
|
||||
mkdir -p $(DESTDIR)$(pkglibdir)
|
||||
mkdir -p $(DESTDIR)$(bindir)
|
||||
mkdir -p $(DESTDIR)$(sbindir)
|
||||
mkdir -p $(DESTDIR)$(sysconfdir)
|
||||
mkdir -p $(DESTDIR)$(pkglibdir)/modules.d
|
||||
mkdir -p $(DESTDIR)$(mandir)/man1 $(DESTDIR)$(mandir)/man5 $(DESTDIR)$(mandir)/man7 $(DESTDIR)$(mandir)/man8
|
||||
install -m 0755 dracut.sh $(DESTDIR)$(bindir)/dracut
|
||||
install -m 0755 dracut-catimages.sh $(DESTDIR)$(bindir)/dracut-catimages
|
||||
install -m 0755 mkinitrd-dracut.sh $(DESTDIR)$(bindir)/mkinitrd
|
||||
install -m 0755 lsinitrd.sh $(DESTDIR)$(bindir)/lsinitrd
|
||||
mkdir -p $(DESTDIR)$(mandir)/man{1,5,8}
|
||||
install -m 0755 dracut $(DESTDIR)$(sbindir)/dracut
|
||||
install -m 0755 dracut-gencmdline $(DESTDIR)$(sbindir)/dracut-gencmdline
|
||||
install -m 0755 dracut-catimages $(DESTDIR)$(sbindir)/dracut-catimages
|
||||
install -m 0755 mkinitrd-dracut.sh $(DESTDIR)$(sbindir)/mkinitrd
|
||||
install -m 0755 lsinitrd $(DESTDIR)$(sbindir)/lsinitrd
|
||||
ifeq (1,${WITH_SWITCH_ROOT})
|
||||
install -m 0755 modules.d/99base/switch_root $(DESTDIR)$(sbindir)/switch_root
|
||||
endif
|
||||
install -m 0644 dracut.conf $(DESTDIR)$(sysconfdir)/dracut.conf
|
||||
mkdir -p $(DESTDIR)$(sysconfdir)/dracut.conf.d
|
||||
mkdir -p $(DESTDIR)$(pkglibdir)/dracut.conf.d
|
||||
install -m 0755 dracut-init.sh $(DESTDIR)$(pkglibdir)/dracut-init.sh
|
||||
install -m 0755 dracut-functions.sh $(DESTDIR)$(pkglibdir)/dracut-functions.sh
|
||||
install -m 0755 dracut-version.sh $(DESTDIR)$(pkglibdir)/dracut-version.sh
|
||||
ln -fs dracut-functions.sh $(DESTDIR)$(pkglibdir)/dracut-functions
|
||||
install -m 0755 dracut-logger.sh $(DESTDIR)$(pkglibdir)/dracut-logger.sh
|
||||
install -m 0755 dracut-initramfs-restore.sh $(DESTDIR)$(pkglibdir)/dracut-initramfs-restore
|
||||
install -m 0755 dracut-functions $(DESTDIR)$(pkglibdir)/dracut-functions
|
||||
cp -arx modules.d $(DESTDIR)$(pkglibdir)
|
||||
ifneq ($(enable_documentation),no)
|
||||
for i in $(man1pages); do install -m 0644 $$i $(DESTDIR)$(mandir)/man1/$${i##*/}; done
|
||||
for i in $(man5pages); do install -m 0644 $$i $(DESTDIR)$(mandir)/man5/$${i##*/}; done
|
||||
for i in $(man7pages); do install -m 0644 $$i $(DESTDIR)$(mandir)/man7/$${i##*/}; done
|
||||
for i in $(man8pages); do install -m 0644 $$i $(DESTDIR)$(mandir)/man8/$${i##*/}; done
|
||||
ln -fs dracut.cmdline.7 $(DESTDIR)$(mandir)/man7/dracut.kernel.7
|
||||
install -m 0644 dracut.8 $(DESTDIR)$(mandir)/man8
|
||||
install -m 0644 mkinitrd.8 $(DESTDIR)$(mandir)/man8
|
||||
install -m 0644 lsinitrd.1 $(DESTDIR)$(mandir)/man1
|
||||
install -m 0644 dracut-catimages.8 $(DESTDIR)$(mandir)/man8
|
||||
install -m 0644 dracut-gencmdline.8 $(DESTDIR)$(mandir)/man8
|
||||
install -m 0644 dracut.conf.5 $(DESTDIR)$(mandir)/man5
|
||||
ifeq (1,${WITH_SWITCH_ROOT})
|
||||
rm $(DESTDIR)$(pkglibdir)/modules.d/99base/switch_root
|
||||
endif
|
||||
if [ -n "$(systemdsystemunitdir)" ]; then \
|
||||
mkdir -p $(DESTDIR)$(systemdsystemunitdir); \
|
||||
ln -srf $(DESTDIR)$(pkglibdir)/modules.d/98systemd/dracut-shutdown.service $(DESTDIR)$(systemdsystemunitdir)/dracut-shutdown.service; \
|
||||
mkdir -p $(DESTDIR)$(systemdsystemunitdir)/shutdown.target.wants; \
|
||||
ln -s ../dracut-shutdown.service \
|
||||
$(DESTDIR)$(systemdsystemunitdir)/shutdown.target.wants/dracut-shutdown.service; \
|
||||
mkdir -p $(DESTDIR)$(systemdsystemunitdir)/initrd.target.wants; \
|
||||
for i in \
|
||||
dracut-cmdline.service \
|
||||
dracut-initqueue.service \
|
||||
dracut-mount.service \
|
||||
dracut-pre-mount.service \
|
||||
dracut-pre-pivot.service \
|
||||
dracut-pre-trigger.service \
|
||||
dracut-pre-udev.service \
|
||||
; do \
|
||||
ln -srf $(DESTDIR)$(pkglibdir)/modules.d/98systemd/$$i $(DESTDIR)$(systemdsystemunitdir); \
|
||||
ln -s ../$$i \
|
||||
$(DESTDIR)$(systemdsystemunitdir)/initrd.target.wants/$$i; \
|
||||
done \
|
||||
fi
|
||||
if [ -f install/dracut-install ]; then \
|
||||
install -m 0755 install/dracut-install $(DESTDIR)$(pkglibdir)/dracut-install; \
|
||||
fi
|
||||
if [ -f skipcpio/skipcpio ]; then \
|
||||
install -m 0755 skipcpio/skipcpio $(DESTDIR)$(pkglibdir)/skipcpio; \
|
||||
fi
|
||||
mkdir -p $(DESTDIR)${prefix}/lib/kernel/install.d
|
||||
install -m 0755 50-dracut.install $(DESTDIR)${prefix}/lib/kernel/install.d/50-dracut.install
|
||||
install -m 0755 51-dracut-rescue.install $(DESTDIR)${prefix}/lib/kernel/install.d/51-dracut-rescue.install
|
||||
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
|
||||
|
||||
clean:
|
||||
$(RM) *~
|
||||
$(RM) */*~
|
||||
$(RM) */*/*~
|
||||
$(RM) $(manpages:%=%.xml) dracut.xml
|
||||
$(RM) test-*.img
|
||||
$(RM) dracut-*.rpm dracut-*.tar.bz2
|
||||
$(RM) dracut-version.sh
|
||||
$(RM) dracut-install install/dracut-install $(DRACUT_INSTALL_OBJECTS)
|
||||
$(RM) skipcpio/skipcpio $(SKIPCPIO_OBJECTS)
|
||||
$(RM) $(manpages) dracut.html
|
||||
$(MAKE) -C test clean
|
||||
rm -f *~
|
||||
rm -f modules.d/99base/switch_root
|
||||
rm -f test-*.img
|
||||
rm -f dracut-*.rpm dracut-*.tar.bz2
|
||||
make -C test clean
|
||||
|
||||
archive: dracut-$(VERSION)-$(GITVERSION).tar.bz2
|
||||
|
||||
dist: dracut-$(VERSION).tar.bz2
|
||||
|
||||
dracut-$(VERSION).tar.bz2: doc syncheck
|
||||
@echo "DRACUT_VERSION=$(VERSION)" > dracut-version.sh
|
||||
git archive --format=tar $(VERSION) --prefix=dracut-$(VERSION)/ > dracut-$(VERSION).tar
|
||||
mkdir -p dracut-$(VERSION)
|
||||
for i in $(manpages) dracut.html dracut-version.sh; do [ "$${i%/*}" != "$$i" ] && mkdir -p "dracut-$(VERSION)/$${i%/*}"; cp "$$i" "dracut-$(VERSION)/$$i"; done
|
||||
tar --owner=root --group=root -rf dracut-$(VERSION).tar $$(find dracut-$(VERSION) -type f)
|
||||
rm -fr -- dracut-$(VERSION).tar.bz2 dracut-$(VERSION)
|
||||
bzip2 -9 dracut-$(VERSION).tar
|
||||
rm -f -- dracut-$(VERSION).tar
|
||||
dracut-$(VERSION).tar.bz2:
|
||||
git archive --format=tar $(VERSION) --prefix=dracut-$(VERSION)/ |bzip2 > dracut-$(VERSION).tar.bz2
|
||||
|
||||
rpm: dracut-$(VERSION).tar.bz2 syncheck
|
||||
dracut-$(VERSION).tar.gz:
|
||||
git archive --format=tar $(VERSION) --prefix=dracut-$(VERSION)/ |gzip > dracut-$(VERSION).tar.gz
|
||||
|
||||
dracut-$(VERSION)-$(GITVERSION).tar.bz2:
|
||||
git archive --format=tar HEAD --prefix=dracut-$(VERSION)-$(GITVERSION)/ |bzip2 > dracut-$(VERSION)-$(GITVERSION).tar.bz2
|
||||
|
||||
|
||||
rpm: dracut-$(VERSION).tar.bz2
|
||||
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; \
|
||||
$$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" -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 )
|
||||
( mv "$$rpmbuild"/noarch/*.rpm .; mv "$$rpmbuild"/*.src.rpm .;rm -fr "$$rpmbuild"; ls *.rpm )
|
||||
|
||||
syncheck:
|
||||
@ret=0;for i in dracut-initramfs-restore.sh modules.d/*/*.sh; do \
|
||||
[ "$${i##*/}" = "module-setup.sh" ] && continue; \
|
||||
read line < "$$i"; [ "$${line#*bash*}" != "$$line" ] && continue; \
|
||||
[ $$V ] && echo "posix syntax check: $$i"; bash --posix -n "$$i" ; ret=$$(($$ret+$$?)); \
|
||||
[ $$V ] && echo "checking for [[: $$i"; if grep -Fq '[[ ' "$$i" ; then ret=$$(($$ret+1)); echo "$$i contains [["; fi \
|
||||
@ret=0;for i in modules.d/99base/init modules.d/*/*.sh; do \
|
||||
[ "$${i##*/}" = "caps.sh" ] && continue; \
|
||||
dash -n "$$i" ; ret=$$(($$ret+$$?)); \
|
||||
done;exit $$ret
|
||||
@ret=0;for i in *.sh mkinitrd-dracut.sh modules.d/*/*.sh \
|
||||
modules.d/*/module-setup.sh; do \
|
||||
[ $$V ] && echo "bash syntax check: $$i"; bash -n "$$i" ; ret=$$(($$ret+$$?)); \
|
||||
@ret=0;for i in dracut modules.d/02caps/caps.sh modules.d/*/install modules.d/*/installkernel modules.d/*/check; do \
|
||||
bash -n "$$i" ; ret=$$(($$ret+$$?)); \
|
||||
done;exit $$ret
|
||||
|
||||
check: all syncheck rpm
|
||||
@[ "$$EUID" == "0" ] || { echo "'check' must be run as root! Please use 'sudo'."; exit 1; }
|
||||
@$(MAKE) -C test check
|
||||
check: all syncheck
|
||||
$(MAKE) -C test check
|
||||
|
||||
testimage: all
|
||||
./dracut.sh -l -a debug -f test-$(shell uname -r).img $(shell uname -r)
|
||||
@echo wrote test-$(shell uname -r).img
|
||||
./dracut -l -a debug -f test-$(shell uname -r).img $(shell uname -r)
|
||||
@echo wrote test-$(shell uname -r).img
|
||||
|
||||
testimages: all
|
||||
./dracut.sh -l -a debug --kernel-only -f test-kernel-$(shell uname -r).img $(shell uname -r)
|
||||
@echo wrote test-$(shell uname -r).img
|
||||
./dracut.sh -l -a debug --no-kernel -f test-dracut.img $(shell uname -r)
|
||||
@echo wrote test-dracut.img
|
||||
./dracut -l -a debug --kernel-only -f test-kernel-$(shell uname -r).img $(shell uname -r)
|
||||
@echo wrote test-$(shell uname -r).img
|
||||
./dracut -l -a debug --no-kernel -f test-dracut.img $(shell uname -r)
|
||||
@echo wrote test-dracut.img
|
||||
|
||||
hostimage: all
|
||||
./dracut.sh -H -l -f test-$(shell uname -r).img $(shell uname -r)
|
||||
@echo wrote test-$(shell uname -r).img
|
||||
./dracut -H -l -a debug -f test-$(shell uname -r).img $(shell uname -r)
|
||||
@echo wrote test-$(shell uname -r).img
|
||||
|
||||
AUTHORS:
|
||||
git shortlog --numbered --summary -e |while read a rest; do echo $$rest;done > AUTHORS
|
||||
|
||||
dracut.html.sign: dracut-$(VERSION).tar.bz2
|
||||
gpg-sign-all dracut-$(VERSION).tar.bz2 dracut.html
|
||||
|
||||
upload: dracut.html.sign
|
||||
kup put dracut-$(VERSION).tar.bz2 dracut-$(VERSION).tar.sign /pub/linux/utils/boot/dracut/
|
||||
kup put dracut.html dracut.html.sign /pub/linux/utils/boot/dracut/
|
||||
|
621
NEWS
621
NEWS
@@ -1,552 +1,3 @@
|
||||
dracut-033
|
||||
==========
|
||||
- improved hostonly device recognition
|
||||
- improved hostonly module recognition
|
||||
- add dracut.css for dracut.html
|
||||
- do not install udev rules from /etc in generic mode
|
||||
- fixed LABEL= parsing for swap devices
|
||||
- fixed iBFT network setup
|
||||
- url-lib.sh: handle 0-size files with curl
|
||||
- dracut.asc: document debugging dracut on shutdown
|
||||
- if rd.md=0, use dmraid for imsm and ddf
|
||||
- skip empty dracut modules
|
||||
- removed caching of kernel cmdline
|
||||
- fixed iso-scan, if the loop device driver is a kernel module
|
||||
- bcache: support new blkid
|
||||
- fixed ifup udev rules
|
||||
- ifup with dhcp, if no "ip=" specified for the interface
|
||||
|
||||
dracut-032
|
||||
==========
|
||||
- add parameter --print-cmdline
|
||||
This prints the kernel command line parameters for the current disk
|
||||
layout.
|
||||
$ dracut --print-cmdline
|
||||
rd.luks.uuid=luks-e68c8906-6542-4a26-83c4-91b4dd9f0471
|
||||
rd.lvm.lv=debian/root rd.lvm.lv=debian/usr root=/dev/mapper/debian-root
|
||||
rootflags=rw,relatime,errors=remount-ro,user_xattr,barrier=1,data=ordered
|
||||
rootfstype=ext4
|
||||
- dracut.sh: add --persistent-policy option and persistent_policy conf option
|
||||
--persistent-policy <policy>:
|
||||
Use <policy> to address disks and partitions.
|
||||
<policy> can be any directory name found in /dev/disk.
|
||||
E.g. "by-uuid", "by-label"
|
||||
- dracut now creates the initramfs without udevadm
|
||||
that means the udev database does not have to populated
|
||||
and the initramfs can be built in a chroot with
|
||||
/sys /dev /proc mounted
|
||||
- renamed dracut_install() to inst_multiple() for consistent naming
|
||||
- if $libdirs is unset, fall back to ld.so.cache paths
|
||||
- always assemble /usr device in initramfs
|
||||
- bash module added (disable it, if you really want dash)
|
||||
- continue to boot, if the main loop times out, in systemd mode
|
||||
- removed inst*() shell pure versions, dracut-install binary is in charge now
|
||||
- fixed ifcfg file generation for vlan
|
||||
- do not include adjtime and localtime anymore
|
||||
- fixed generation of zfcp.conf of CMS setups
|
||||
- install vt102 terminfo
|
||||
dracut_install() is still there for backwards compat
|
||||
- do not strip files in FIPS mode
|
||||
- fixed iBFT interface configuration
|
||||
- fs-lib: install fsck and fsck.ext*
|
||||
- shutdown: fixed killall_proc_mountpoint()
|
||||
- network: also wait for ethernet interfaces to setup
|
||||
- fixed checking for FIPS mode
|
||||
|
||||
Contributions from:
|
||||
Harald Hoyer
|
||||
WANG Chao
|
||||
Baoquan He
|
||||
Daniel Schaal
|
||||
Dave Young
|
||||
James Lee
|
||||
Radek Vykydal
|
||||
|
||||
|
||||
dracut-031
|
||||
==========
|
||||
- do not include the resume dracut module in hostonly mode,
|
||||
if no swap is present
|
||||
- don't warn twice about omitted modules
|
||||
- use systemd-cat for logging on systemd systems, if logfile is unset
|
||||
- fixed PARTUUID parsing
|
||||
- support kernel module signing keys
|
||||
- do not install the usrmount dracut module in hostonly mode,
|
||||
if /sbin/init does not live in /usr
|
||||
- add debian udev rule files
|
||||
- add support for bcache
|
||||
- network: handle bootif style interfaces
|
||||
e.g. ip=77-77-6f-6f-64-73:dhcp
|
||||
- add support for kmod static devnodes
|
||||
- add vlan support for iBFT
|
||||
|
||||
Contributions from:
|
||||
Harald Hoyer
|
||||
Amadeusz Żołnowski
|
||||
Brandon Philips
|
||||
Colin Walters
|
||||
James Lee
|
||||
Kyle McMartin
|
||||
Peter Jones
|
||||
|
||||
dracut-030
|
||||
==========
|
||||
- support new persistent network interface names
|
||||
- fix findmnt calls, prevents hang on stale NFS mounts
|
||||
- add systemd.slice and slice.target units
|
||||
- major shell cleanup
|
||||
- support root=PARTLABEL= and root=PARTUUID=
|
||||
- terminfo: only install l/linux v/vt100 and v/vt220
|
||||
- unset all LC_* and LANG, 10% faster
|
||||
- fixed dependency loop for dracut-cmdline.service
|
||||
- do not wait_for_dev for the root devices
|
||||
- do not wait_for_dev for devices, if dracut-initqueue is not needed
|
||||
- support early microcode loading with --early-microcode
|
||||
- dmraid, let dmraid setup its own partitions
|
||||
- sosreport renamed to rdsosreport
|
||||
|
||||
Contributions from:
|
||||
Harald Hoyer
|
||||
Konrad Rzeszutek Wilk
|
||||
WANG Chao
|
||||
|
||||
dracut-029
|
||||
==========
|
||||
- wait for IPv6 autoconfiguration
|
||||
- i18n: make the default font configurable
|
||||
To set the default font for your distribution, add
|
||||
i18n_default_font="latarcyrheb-sun16"
|
||||
to your /lib/dracut/dracut.conf.d/01-dist.conf distribution config.
|
||||
- proper handle "rd.break" in systemd mode before switch-root
|
||||
- systemd: make unit files symlinks
|
||||
- build without dash requirement
|
||||
- add dracut-shutdown.service.8 manpage
|
||||
- handle MACs for "ip="
|
||||
"ip=77-77-6f-6f-64-73:dhcp"
|
||||
- don't explode when mixing BOOTIF and ip=
|
||||
- 90lvm/module-setup.sh: redirect error message of lvs to /dev/null
|
||||
|
||||
Contributions from:
|
||||
Harald Hoyer
|
||||
Will Woods
|
||||
Baoquan He
|
||||
|
||||
dracut-028
|
||||
==========
|
||||
- full integration of crypto devs in systemd logic
|
||||
- support for bridge over team and vlan tagged team
|
||||
- support multiple bonding interfaces
|
||||
- new kernel command line param "rd.action_on_fail"
|
||||
to control the emergency action
|
||||
- support for bridge over a vlan tagged interface
|
||||
- support for "iso-scan/filename" kernel parameter
|
||||
- lsinitrd got some love and does not use "file" anymore
|
||||
- fixed issue with noexec mounted tmp dirs
|
||||
- FIPS mode fixed
|
||||
- dracut_install got some love
|
||||
- fixed some /usr mounting problems
|
||||
- ifcfg dracut module got some love and fixes
|
||||
- default installed font is now latarcyrheb-sun16
|
||||
- new parameters rd.live.dir and rd.live.squashimg
|
||||
- lvm: add tools for thin provisioning
|
||||
- also install non-hwcap libs
|
||||
- setup correct system time and time zone in initrd
|
||||
- s390: fixed cms setup
|
||||
- add systemd-udevd persistent network interface naming
|
||||
|
||||
Contributions from:
|
||||
Harald Hoyer
|
||||
Kamil Rytarowski
|
||||
WANG Chao
|
||||
Baoquan He
|
||||
Adam Williamson
|
||||
Colin Guthrie
|
||||
Dan Horák
|
||||
Dave Young
|
||||
Dennis Gilmore
|
||||
Dennis Schridde
|
||||
|
||||
dracut-027
|
||||
==========
|
||||
- dracut now has bash-completion
|
||||
- require bash version 4
|
||||
- systemd module now requires systemd >= 199
|
||||
- dracut makes use of native systemd initrd units
|
||||
- added hooks for new-kernel-pkg and kernel-install
|
||||
- hostonly is now default for fedora
|
||||
- comply with the BootLoaderSpec paths
|
||||
http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec
|
||||
- added rescue module
|
||||
- host_fs_types is now a hashmap
|
||||
- new dracut argument "--regenerate-all"
|
||||
- new dracut argument "--noimageifnotneeded"
|
||||
- new man page dracut.bootup
|
||||
- install all host filesystem drivers
|
||||
- use -D_FILE_OFFSET_BITS=64 to build dracut-install
|
||||
|
||||
dracut-026
|
||||
==========
|
||||
- introduce /usr/lib/dracut/dracut.conf.d/ drop-in directory
|
||||
|
||||
/usr/lib/dracut/dracut.conf.d/*.conf can be overwritten by the same
|
||||
filenames in /etc/dracut.conf.d.
|
||||
|
||||
Packages should use /usr/lib/dracut/dracut.conf.d rather than
|
||||
/etc/dracut.conf.d for drop-in configuration files.
|
||||
|
||||
/etc/dracut.conf and /etc/dracut.conf.d belong to the system administrator.
|
||||
|
||||
- uses systemd-198 native initrd units
|
||||
- totally rely on the fstab-generator in systemd mode for block devices
|
||||
- dracut systemd now uses dracut.target rather than basic.target
|
||||
- dracut systemd services optimize themselves away
|
||||
- fixed hostonly parameter generation
|
||||
- turn off curl globbing (fixes IPv6)
|
||||
- modify the udev rules on install and not runtime time
|
||||
- enable initramfs building without kernel modules (fixed regression)
|
||||
- in the initqueue/timeout,
|
||||
reset the main loop counter, as we see new udev events or initqueue/work
|
||||
- fixed udev rule installation
|
||||
|
||||
dracut-025
|
||||
==========
|
||||
- do not strip signed kernel modules
|
||||
- add sosreport script and generate /run/initramfs/sosreport.txt
|
||||
- make short uuid specification for allow-discards work
|
||||
- turn off RateLimit for the systemd journal
|
||||
- fixed MAC address assignment
|
||||
- add systemd checkisomd5 service
|
||||
- splitout drm kernel modules from plymouth module
|
||||
- add 'swapoff' to initramfs to fix shutdown/reboot
|
||||
- add team device support
|
||||
- add pre-shutdown hook
|
||||
- kill all processes in shutdown and report remaining ones
|
||||
- "--device" changed to "--add-device" and "add_device=" added for conf files
|
||||
- add memory usage trace to different hook points
|
||||
- cope with optional field #7 in /proc/self/mountinfo
|
||||
- lots of small bugfixes
|
||||
|
||||
dracut-024
|
||||
==========
|
||||
- new dracut option "--device"
|
||||
- new dracut kernel command line options "rd.auto"
|
||||
- new dracut kernel command line options "rd.noverifyssl"
|
||||
- new dracut option "--kernel-cmdline" and "kernel_cmdline" option for default parameters
|
||||
- fixes for systemd and crypto
|
||||
- fix for kexec in shutdown, if not included in initramfs
|
||||
- create the initramfs non-world readable
|
||||
- prelink/preunlink in the initramfs
|
||||
- strip binaries in the initramfs by default now
|
||||
- various FIPS fixes
|
||||
- various dracut-install fixes
|
||||
|
||||
dracut-023
|
||||
==========
|
||||
- resume from hibernate fixes
|
||||
- -N option for --no-hostonly
|
||||
- support for systemd crypto handling
|
||||
- new dracut module "crypt-loop"
|
||||
- deprecate the old kernel command line options
|
||||
- more documentation
|
||||
- honor CFLAGS for dracut-install build
|
||||
- multipath fixes
|
||||
- / is mounted according to rootflags parameter but forced ro at first.
|
||||
Later it is remounted according to /etc/fstab + rootflags parameter
|
||||
and "ro"/"rw".
|
||||
- support for xfs / reiserfs separate journal device
|
||||
- new "ro_mnt" option to force ro mount of / and /usr
|
||||
- root on cifs support
|
||||
- dracut-install: fixed issue for /var/tmp containing a symlink
|
||||
- only lazy resolve with ldd, if the /var/tmp partition is not mounted with "noexec"
|
||||
- i18n: fixed inclusion of "include" keymaps
|
||||
|
||||
dracut-022
|
||||
==========
|
||||
- fixed host-only kernel module bug
|
||||
|
||||
dracut-021
|
||||
==========
|
||||
- fixed systemd in the initramfs (requires systemd >= 187)
|
||||
- dracut-install: massive speedup with /var on the same filesystem with COW copy
|
||||
- dracut-install: moved to /usr/lib/dracut until it becomes a general purpose tool
|
||||
- new options: "rd.usrmount.ro" and "rd.skipfsck"
|
||||
- less mount/umount
|
||||
- apply "ro" on the kernel command line also to /usr
|
||||
- mount according to fstab, if neither "ro" or "rw" is specified
|
||||
- skip fsck for xfs and btrfs. remount is enough
|
||||
- give emergency_shell if /usr mount failed
|
||||
- dracut now uses getopt:
|
||||
* options can be position independent now!!
|
||||
* we can now use --option=<arg>
|
||||
- added option "--kver=<kernel-version>", and the image location can be omitted
|
||||
# dracut --kver 3.5.0-0.rc7.git1.2.fc18.x86_64
|
||||
- dracut.sh: for --include copy also the symbolic links
|
||||
- man pages: lsinitrd and mkinitrd added
|
||||
- network: We do not support renaming in the kernel namespace anymore (as udev does
|
||||
that not anymore). So, if a user wants to use ifname, he has to rename
|
||||
to a custom namespace. "eth[0-9]+" is not allowed anymore. !!!!!
|
||||
- resume: moved the resume process to the initqueue.
|
||||
This should prevent accidently mounting the root file system.
|
||||
- testsuite: add support for: make V=1 TESTS="01 20 40" check
|
||||
$ sudo make V=1 clean check
|
||||
now runs the testsuite in verbose mode
|
||||
|
||||
$ sudo make TESTS="01 20 40" clean check
|
||||
now only runs the 01, 20 and 40 tests.
|
||||
|
||||
dracut-020
|
||||
==========
|
||||
- changed rd.dasd kernel parameter
|
||||
- arm kernel modules added to kernel-modules
|
||||
- make udevdir systemdutildir systemdsystemunitdir global vars
|
||||
your distribution should ship those settings in
|
||||
/etc/dracut.conf.d/01-distro.conf
|
||||
see dracut.conf.d/fedora.conf.example
|
||||
- kernel modules are now only handled with /sys/modules and modules.dep
|
||||
- systemd fixups
|
||||
- mdraid: wait for md devices to be clean, before shutdown
|
||||
- ifup fixed for ipv6
|
||||
- add PARTUUID as root=PARTUUID=<partition uuid> parameter
|
||||
- fixed instmods() return code and set pipefail globally
|
||||
- add 04watchdog dracut module
|
||||
- dracut-shutdown.service: fixed ordering to be before shutdown.target
|
||||
- make use of "ln -r" instead of shell functions, if new coreutils is installed
|
||||
- network: support vlan tagged bonding
|
||||
- new dracut module qemu and qemu-net to install all kernel driver
|
||||
- fs-lib/fs-lib.sh: removed test mounting of btrfs and xfs
|
||||
- no more "mknod" in the initramfs!!
|
||||
- replaced all "tr" calls with "sed"
|
||||
- speedup with lazy kernel module dependency resolving
|
||||
- lots of speedup optimizations and last but not least
|
||||
- dracut-install:
|
||||
- new binary to significanlty speedup the installation process
|
||||
- dracut-functions.sh makes use of it, if installed
|
||||
|
||||
|
||||
dracut-019
|
||||
==========
|
||||
- initqueue/online hook
|
||||
- fixes for ifcfg write out
|
||||
- rootfs-block: avoid remount when options don't change
|
||||
- Debian multiarch support
|
||||
- virtfs root filesystem support
|
||||
- cope with systemd-udevd
|
||||
- mount tmpfs with strictatime
|
||||
- include all kernel/drivers/net/phy drivers
|
||||
- add debug_on() and debug_off() functions
|
||||
- add arguments for source_hook() and source_all()
|
||||
- cleanup hook
|
||||
- plymouth: get consoledev from /sys/class/tty/console/active
|
||||
- experimental systemd dracut module for systemd in the initramfs
|
||||
- install xhci-hcd kernel module
|
||||
- dracut: new "--mount" option
|
||||
- lsinitrd: new option --printsize
|
||||
- ARM storage kernel modules added
|
||||
- s390 cms conf file support
|
||||
- /etc/initrd-release in the initrd
|
||||
- vlan support
|
||||
- full bonding and bridge support
|
||||
- removed scsi_wait_scan kernel module from standard install
|
||||
- support rd.luks.allow-discards and honor options in crypttab
|
||||
- lots of bugfixes
|
||||
|
||||
dracut-018
|
||||
==========
|
||||
- lvm: ignore lvm mirrors
|
||||
- lsinitrd: handle LZMA images
|
||||
- iscsi: add rd.iscsi.param
|
||||
- iscsi: add iscsi interface binding
|
||||
- new module cms to read and handle z-Series cms config files
|
||||
- fixed fstab.sys handling
|
||||
- new dracut option "--tmpdir"
|
||||
- new dracut option "--no-hostonly"
|
||||
- nbd: name based nbd connects
|
||||
- converted manpage and documentation source to asciidoc
|
||||
- write-ifcfg fixes and cleanups
|
||||
- ifup is now done in the initqueue
|
||||
- netroot cleanup
|
||||
- initqueue/online is now for hooks, which require network
|
||||
- no more /tmp/root.info
|
||||
- 98pollcdrom: factored out the ugly cdrom polling in the main loop
|
||||
- simplified rd.luks.uuid testing
|
||||
- removed "egrep" and "ls" calls
|
||||
- speedup kernel module installation
|
||||
- make bzip2 optional
|
||||
- lots of bugfixes
|
||||
|
||||
dracut-017
|
||||
==========
|
||||
- a _lot_ faster than dracut-016 in image creation
|
||||
- systemd service dracut-shutdown.service
|
||||
- livenet fixes
|
||||
- ssh-client module install fix
|
||||
- root=iscsi:... fixed
|
||||
- lots of restructuring and optimizing in dracut-functions.sh
|
||||
- usrmount: honor fs_passno in /etc/fstab
|
||||
- renamed all shell scripts to .sh
|
||||
- new option "--omit-drivers" and config option "omit_drivers"
|
||||
- hostonly mode fixups
|
||||
|
||||
dracut-016
|
||||
==========
|
||||
- fixed lsinitrd
|
||||
- honor binaries in sbin first
|
||||
- fixed usrmount module
|
||||
- added systemd service for shutdown
|
||||
- fixed terminfo on distros with /usr/share/terminfo
|
||||
- reload udev rules after "pre-trigger" hook
|
||||
- improved test suite
|
||||
- new parameter "--omit-drivers" and new conf param omit_drivers
|
||||
- "--offroot" support for mdraid
|
||||
- new libs: net-lib.sh, nfs-lib.sh, url-lib.sh, img-lib.sh
|
||||
full of functions to use in your dracut module
|
||||
|
||||
dracut-015
|
||||
==========
|
||||
- hostonly mode automatically adds command line options for root and /usr
|
||||
- --add-fstab --mount parameters
|
||||
- ssh-client module
|
||||
- --ctty option: add job control
|
||||
- cleanup /run/initramfs
|
||||
- convertfs module
|
||||
- /sbin/ifup can be called directly
|
||||
- support kernel modules compressed with xz
|
||||
- s390 iscsi modules added
|
||||
- terminfo module
|
||||
- lsinitrd can handle concatened images
|
||||
- lsinitrd can sort by size
|
||||
|
||||
dracut-014
|
||||
==========
|
||||
- new dracut arguments:
|
||||
--lvmconf
|
||||
--nolvmconf
|
||||
--fscks [LIST]
|
||||
--nofscks
|
||||
- new .conf options:
|
||||
install_items
|
||||
fscks
|
||||
nofscks
|
||||
- new kernel options:
|
||||
rd.md.ddf
|
||||
rd.md.waitclean
|
||||
plymouth.enable
|
||||
- dracut move from /sbin to /usr/bin
|
||||
- dracut modules dir moved from /usr/share/dracut to /usr/lib/dracut
|
||||
- profiling with "dracut --profile"
|
||||
- new TEST-16-DMSQUASH, test for Fedora LiveCDs
|
||||
- speedup of initramfs creation
|
||||
- ask_for_password fallback to CLI
|
||||
- mdraid completely switched to incremental assembly
|
||||
- no more cdrom polling
|
||||
- "switch_root" breakpoint is now very late
|
||||
- /dev/live is gone
|
||||
- /dev/root is gone
|
||||
- fs-lib dracut module for fscks added
|
||||
- xen dracut module removed
|
||||
- usb mass storage kernel drivers now included
|
||||
- usrmount dracut module added:
|
||||
mount /usr if found in /sysroot/etc/fstab
|
||||
- only include fsck helper needed for hostonly
|
||||
- fcoe: support for bnx2fc
|
||||
- support iSCSI drivers: qla4xxx, cxgb3i, cxgb4i, bnx2i, be2iscsi
|
||||
- fips-aesni dracut module added
|
||||
- add install_items to dracut.conf
|
||||
install_items+=" <file>[ <file> ...] "
|
||||
- speedup internal testsuite
|
||||
- internal testsuite: store temporary data in a temporary dir
|
||||
|
||||
dracut-013
|
||||
==========
|
||||
- speedup of initramfs creation
|
||||
- fixed inst_dir for symbolic links
|
||||
- add unix kernel module
|
||||
|
||||
dracut-012
|
||||
==========
|
||||
- better fsck handling
|
||||
- fixed wait condition for LVM volumes
|
||||
- fix for hardlinks (welcome Debian! :-)
|
||||
- shutdown bugfixes
|
||||
- automatic busybox symlink creation
|
||||
- try to mount /usr, if init points to a path in /usr
|
||||
- btrfs with multiple devices
|
||||
- "--force-add" option for dracut, to force-add dracut modules,
|
||||
without hostonly checks
|
||||
- lsinitrd also display the initramfs size in human readable form
|
||||
- livenet module, to mount live-isos over http
|
||||
- masterkey,ecryptfs,integrity security modules
|
||||
- initqueue/timeout queue e.g. for starting degraded raids
|
||||
- "make rpm" creates an rpm with an increasing release number from any
|
||||
git checkout
|
||||
- support lvm mirrors
|
||||
- start degraded lvm mirrors after a timeout
|
||||
- start degraded md raids after a timeout
|
||||
- getarg() now returns wildcards without file matching to the current fs
|
||||
- lots of bugfixes
|
||||
|
||||
dracut-011
|
||||
==========
|
||||
- use udev-168 features for shutting down udev
|
||||
- introduce "--prefix" to put all initramfs files in e.g "/run/initramfs"
|
||||
- new shutdown script (called by systemd >= 030) to disassemble the root device
|
||||
- lots of bugfixes
|
||||
- new module for gpg-encrypted keys - 91crypt-gpg
|
||||
|
||||
dracut-010
|
||||
==========
|
||||
- lots of bugfixes
|
||||
- plymouth: use /run/plymouth/pid instead of /run/initramfs/plymouth
|
||||
- add "/lib/firmware/updates" to default firmware path
|
||||
|
||||
dracut-009
|
||||
==========
|
||||
- dracut generator
|
||||
- dracut-logger
|
||||
- xz compression
|
||||
- better argument handling
|
||||
|
||||
- initramfs
|
||||
- hooks moved to /lib/dracut/hooks in initramfs
|
||||
- rd.driver.{blacklist|pre|post} accept comma separated driver list
|
||||
- iSCSI: iSCSI Boot Firmware Table (iBFT) support
|
||||
- support for /run
|
||||
- live image: support for generic rootfs.img (instead of ext3fs.img)
|
||||
- caps module
|
||||
- FCoE: EDD support
|
||||
|
||||
dracut-008
|
||||
==========
|
||||
- removed --ignore-kernel-modules option (no longer necessary)
|
||||
- renamed kernel command line arguments to follow the rd. naming scheme
|
||||
- merged check, install, installkernel to module-setup.sh
|
||||
- support for bzip2 and xz compressed initramfs images.
|
||||
- source code beautification
|
||||
- lots of documentation
|
||||
- lsinitrd: "catinitrd" functionality
|
||||
- dracut: --list-modules
|
||||
- lvm: support for dynamic LVM SNAPSHOT root volume
|
||||
- 95fstab-sys: mount all /etc/fstab.sys volumes before switch_root
|
||||
- 96insmodpost dracut module
|
||||
- rd.shell=1 per default
|
||||
- rootfs-block:mount-root.sh add fsck
|
||||
- busybox shell replacements module
|
||||
- honor old "real_init="
|
||||
- 97biosdevname dracut module
|
||||
|
||||
dracut-007
|
||||
==========
|
||||
- module i18n is no longer fedora/red hat specific (Amadeusz Żołnowski)
|
||||
- distribution specific conf file
|
||||
- bootchartd support
|
||||
- debug module now has fsck
|
||||
- use "hardlink", if available, to save some space
|
||||
- /etc/dracut.conf can be overwritten by settings in /etc/dracut.conf.d/*.conf
|
||||
- gentoo splash module
|
||||
- --ignore-kernel-modules option
|
||||
- crypto keys on external devices support
|
||||
- bugfixes
|
||||
|
||||
dracut-006
|
||||
==========
|
||||
- fixed mdraid with IMSM
|
||||
@@ -557,20 +8,13 @@ dracut-006
|
||||
- add btrfsctl scan for btrfs multi-devices (raid)
|
||||
- teach dmsquash live-root to use rootflags
|
||||
- trigger udev with action=add
|
||||
- fixed add_drivers handling
|
||||
- fixed add_drivers handling
|
||||
- add sr_mod
|
||||
- use pigz instead of gzip, if available
|
||||
- boot from LVM mirrors and snapshots
|
||||
- iscsi: add support for multiple netroot=iscsi:
|
||||
- Support old version of module-init-tools
|
||||
- got rid of rdnetdebug
|
||||
- fixed "ip=auto6"
|
||||
- dracut.conf: use "+=" as default for config variables
|
||||
- bugfixes
|
||||
|
||||
dracut-005
|
||||
==========
|
||||
- dcb support to dracut's FCoE support
|
||||
- dcb support to dracut's FCoE support
|
||||
- add readonly overlay support for dmsquash
|
||||
- add keyboard kernel modules
|
||||
- dracut.conf: added add_dracutmodules
|
||||
@@ -578,6 +22,7 @@ dracut-005
|
||||
- add preliminary IPv6 support
|
||||
- bugfixes
|
||||
|
||||
|
||||
dracut-004
|
||||
==========
|
||||
- dracut-lib: read multiple lines from $init/etc/cmdline
|
||||
@@ -608,7 +53,7 @@ dracut-003
|
||||
- add s390 network support
|
||||
- fixed dracut-gencmdline for root=UUID or LABEL
|
||||
- do not destroy assembled raid arrays if mdadm.conf present
|
||||
- mount /dev/shm
|
||||
- mount /dev/shm
|
||||
- let udevd not resolve group and user names
|
||||
- moved network from udev to initqueue
|
||||
- improved debug output: specifying "rdinitdebug" now logs
|
||||
@@ -616,7 +61,7 @@ dracut-003
|
||||
- strip kernel modules which have no x bit set
|
||||
- redirect stdin, stdout, stderr all RW to /dev/console
|
||||
so the user can use "less" to view /init.log and dmesg
|
||||
- add new device mapper udev rules and dmeventd
|
||||
- add new device mapper udev rules and dmeventd
|
||||
- fixed dracut-gencmdline for root=UUID or LABEL
|
||||
- do not destroy assembled raid arrays if mdadm.conf present
|
||||
- mount /dev/shm
|
||||
@@ -661,17 +106,17 @@ dracut-001
|
||||
Supported cmdline formats:
|
||||
fcoe=<networkdevice>:<dcb|nodcb>
|
||||
fcoe=<macaddress>:<dcb|nodcb>
|
||||
|
||||
|
||||
Note currently only nodcb is supported, the dcb option is reserved for
|
||||
future use.
|
||||
|
||||
|
||||
Note letters in the macaddress must be lowercase!
|
||||
|
||||
|
||||
Examples:
|
||||
fcoe=eth0:nodcb
|
||||
fcoe=4A:3F:4C:04:F8:D7:nodcb
|
||||
|
||||
- Syslog support for dracut
|
||||
- Syslog support for dracut
|
||||
This module provides syslog functionality in the initrd.
|
||||
This is especially interesting when complex configuration being
|
||||
used to provide access to the device the rootfs resides on.
|
||||
@@ -698,20 +143,20 @@ dracut-0.8
|
||||
dracut-0.7
|
||||
==========
|
||||
- dracut: strip binaries in initramfs
|
||||
|
||||
|
||||
--strip
|
||||
strip binaries in the initramfs (default)
|
||||
|
||||
|
||||
--nostrip
|
||||
do not strip binaries in the initramfs
|
||||
- dracut-catimages
|
||||
|
||||
|
||||
Usage: ./dracut-catimages [OPTION]... <initramfs> <base image>
|
||||
[<image>...]
|
||||
Creates initial ramdisk image by concatenating several images from the
|
||||
command
|
||||
line and /boot/dracut/
|
||||
|
||||
|
||||
-f, --force Overwrite existing initramfs file.
|
||||
-i, --imagedir Directory with additional images to add
|
||||
(default: /boot/dracut/)
|
||||
@@ -728,44 +173,44 @@ dracut-0.7
|
||||
dracut-0.6
|
||||
==========
|
||||
- dracut: add --kernel-only and --no-kernel arguments
|
||||
|
||||
|
||||
--kernel-only
|
||||
only install kernel drivers and firmware files
|
||||
|
||||
|
||||
--no-kernel
|
||||
do not install kernel drivers and firmware files
|
||||
|
||||
|
||||
All kernel module related install commands moved from "install"
|
||||
to "installkernel".
|
||||
|
||||
|
||||
For "--kernel-only" all installkernel scripts of the specified
|
||||
modules are used, regardless of any checks, so that all modules
|
||||
which might be needed by any dracut generic image are in.
|
||||
|
||||
|
||||
The basic idea is to create two images. One image with the kernel
|
||||
modules and one without. So if the kernel changes, you only have
|
||||
to replace one image.
|
||||
|
||||
|
||||
Grub and the kernel can handle multiple images, so grub entry can
|
||||
look like this:
|
||||
|
||||
|
||||
title Fedora (2.6.29.5-191.fc11.i586)
|
||||
root (hd0,0)
|
||||
kernel /vmlinuz-2.6.29.5-191.fc11.i586 ro rhgb quiet
|
||||
initrd /initrd-20090722.img /initrd-kernel-2.6.29.5-191.fc11.i586.img /initrd-config.img
|
||||
|
||||
|
||||
initrd-20090722.img
|
||||
the image provided by the initrd rpm
|
||||
one old backup version is kept like with the kernel
|
||||
|
||||
|
||||
initrd-kernel-2.6.29.5-191.fc11.i586.img
|
||||
the image provided by the kernel rpm
|
||||
|
||||
|
||||
initrd-config.img
|
||||
optional image with local configuration files
|
||||
|
||||
- dracut: add --kmoddir directory, where to look for kernel modules
|
||||
|
||||
|
||||
-k, --kmoddir [DIR]
|
||||
specify the directory, where to look for kernel modules
|
||||
|
||||
@@ -785,18 +230,18 @@ dracut-0.4
|
||||
- firmware loading support
|
||||
- new internal queue (initqueue)
|
||||
initqueue now loops until /dev/root exists or root is mounted
|
||||
|
||||
|
||||
init now has the following points to inject scripts:
|
||||
|
||||
|
||||
/cmdline/*.sh
|
||||
scripts for command line parsing
|
||||
|
||||
|
||||
/pre-udev/*.sh
|
||||
scripts to run before udev is started
|
||||
|
||||
|
||||
/pre-trigger/*.sh
|
||||
scripts to run before the main udev trigger is pulled
|
||||
|
||||
|
||||
/initqueue/*.sh
|
||||
runs in parallel to the udev trigger
|
||||
Udev events can add scripts here with /sbin/initqueue.
|
||||
@@ -808,12 +253,12 @@ dracut-0.4
|
||||
filesystem was mounted, the user will be dropped to a shell after
|
||||
a timeout.
|
||||
Scripts can remove themselves from the initqueue by "rm $job".
|
||||
|
||||
|
||||
/pre-mount/*.sh
|
||||
scripts to run before the root filesystem is mounted
|
||||
NFS is an exception, because it has no device node to be created
|
||||
and mounts in the udev events
|
||||
|
||||
|
||||
/mount/*.sh
|
||||
scripts to mount the root filesystem
|
||||
NFS is an exception, because it has no device node to be created
|
||||
@@ -821,12 +266,12 @@ dracut-0.4
|
||||
If the udev queue is empty and no root device is found or no root
|
||||
filesystem was mounted, the user will be dropped to a shell after
|
||||
a timeout.
|
||||
|
||||
|
||||
/pre-pivot/*.sh
|
||||
scripts to run before the real init is executed and the initramfs
|
||||
disappears
|
||||
All processes started before should be killed here.
|
||||
|
||||
|
||||
The behaviour of the dmraid module demonstrates how to use the new
|
||||
mechanism. If it detects a device which is part of a raidmember from a
|
||||
udev rule, it installs a job to scan for dmraid devices, if the udev
|
||||
|
21
PKGBUILD
21
PKGBUILD
@@ -1,21 +0,0 @@
|
||||
pkgname=dracut-git
|
||||
pkgver=$(date +%s)
|
||||
pkgrel=$(git log --pretty=format:%h |head -n 1)
|
||||
pkgdesc="Initramfs generation utility"
|
||||
arch=('i686' 'x86_64')
|
||||
url="https://dracut.wiki.kernel.org/"
|
||||
license=('GPL')
|
||||
conflicts=('dracut' 'mkinitcpio')
|
||||
provides=('dracut=9999' 'mkinitcpio=9999')
|
||||
depends=('bash')
|
||||
optdepends=('cryptsetup' 'lvm2')
|
||||
makedepends=('libxslt')
|
||||
backup=(etc/dracut.conf)
|
||||
source=()
|
||||
md5sums=()
|
||||
|
||||
build() {
|
||||
cd ..
|
||||
make sysconfdir=/etc || return 1
|
||||
make DESTDIR="${pkgdir}" sysconfdir=/etc install || return 1
|
||||
}
|
72
README
72
README
@@ -1,9 +1,9 @@
|
||||
dracut
|
||||
Dracut
|
||||
------
|
||||
dracut is a new initramfs infrastructure.
|
||||
Dracut is a new initramfs infrastructure.
|
||||
|
||||
Information about the initial goals and aims can be found at
|
||||
https://fedoraproject.org/wiki/Initrdrewrite
|
||||
Information about the initial goals and aims can be found at
|
||||
https://fedoraproject.org/wiki/Initrdrewrite
|
||||
|
||||
Unlike existing initramfs's, this is an attempt at having as little as
|
||||
possible hard-coded into the initramfs as possible. The initramfs has
|
||||
@@ -19,19 +19,19 @@ we'll grow some hooks for running arbitrary commands in the flow of
|
||||
the script, but it's worth trying to resist the urge as much as we can
|
||||
as hooks are guaranteed to be the path to slow-down.
|
||||
|
||||
Most of the initramfs generation functionality in dracut is provided by a bunch
|
||||
Most of the initrd generation functionality in dracut is provided by a bunch
|
||||
of generator modules that are sourced by the main dracut script to install
|
||||
specific functionality into the initramfs. They live in the modules.d
|
||||
subdirectory, and use functionality provided by dracut-functions to do their
|
||||
specific functionality into the initrd. They live in the modules.d
|
||||
subdirectory, and use functionality provided by dracut-functions to do their
|
||||
work.
|
||||
|
||||
Some general rules for writing modules:
|
||||
* Use one of the inst family of functions to actually install files
|
||||
on to the initramfs. They handle mangling the pathnames and (for binaries,
|
||||
on to the initrd. They handle mangling the pathnames and (for binaries,
|
||||
scripts, and kernel modules) installing dependencies as appropriate so
|
||||
you do not have to.
|
||||
* Scripts that end up on the initramfs should be POSIX compliant. dracut
|
||||
will try to use /bin/dash as /bin/sh for the initramfs if it is available,
|
||||
* Scripts that end up on the initrd should be POSIX compliant. dracut
|
||||
will try to use /bin/dash as /bin/sh for the initrd if it is available,
|
||||
so you should install it on your system -- dash aims for strict POSIX
|
||||
compliance to the extent possible.
|
||||
* Hooks MUST be POSIX compliant -- they are sourced by the init script,
|
||||
@@ -44,49 +44,35 @@ Some general rules for writing modules:
|
||||
* We have some breakpoints for debugging your hooks. If you pass 'rdbreak'
|
||||
as a kernel parameter, the initramfs will drop to a shell just before
|
||||
switching to a new root. You can pass 'rdbreak=hookpoint', and the initramfs
|
||||
will break just before hooks in that hookpoint run.
|
||||
will break just before hooks in that hookpoint run.
|
||||
|
||||
Also, there is an attempt to keep things as distribution-agnostic as
|
||||
possible. Every distribution has their own tool here and it's not
|
||||
something which is really interesting to have separate across them.
|
||||
So contributions to help decrease the distro-dependencies are welcome.
|
||||
|
||||
Currently dracut lives on kernel.org.
|
||||
|
||||
The tarballs can be found here:
|
||||
http://www.kernel.org/pub/linux/utils/boot/dracut/
|
||||
ftp://ftp.kernel.org/pub/linux/utils/boot/dracut/
|
||||
|
||||
Git:
|
||||
git://git.kernel.org/pub/scm/boot/dracut/dracut.git
|
||||
http://git.kernel.org/pub/scm/boot/dracut/dracut.git
|
||||
https://git.kernel.org/pub/scm/boot/dracut/dracut.git
|
||||
|
||||
git://github.com/haraldh/dracut.git
|
||||
|
||||
git://dracut.git.sourceforge.net/gitroot/dracut/dracut
|
||||
|
||||
Git Web:
|
||||
http://git.kernel.org/?p=boot/dracut/dracut.git
|
||||
|
||||
https://haraldh@github.com/haraldh/dracut.git
|
||||
|
||||
http://dracut.git.sourceforge.net/git/gitweb.cgi?p=dracut/dracut
|
||||
|
||||
Git Web RSS Feed:
|
||||
http://git.kernel.org/?p=boot/dracut/dracut.git;a=rss
|
||||
Currently dracut lives on sourceforge.
|
||||
|
||||
Project Page:
|
||||
http://www.kernel.org/pub/linux/utils/boot/dracut/dracut.html
|
||||
https://sourceforge.net/projects/dracut/
|
||||
|
||||
Project Wiki:
|
||||
http://dracut.wiki.kernel.org
|
||||
Drop Harald Hoyer <harald@redhat.com> a mail, if you want to help with
|
||||
the documentation, git access, etc.
|
||||
|
||||
See the TODO file for things which still need to be done and HACKING for
|
||||
some instructions on how to get started. There is also a mailing list
|
||||
that is being used for the discussion -- initramfs@vger.kernel.org.
|
||||
It is a typical vger list, send mail to majordomo@vger.kernel.org with body
|
||||
of 'subscribe initramfs email@host.com'
|
||||
Git Repository:
|
||||
http://dracut.git.sourceforge.net/
|
||||
git://dracut.git.sourceforge.net/gitroot/dracut/dracut
|
||||
|
||||
Trac Instance:
|
||||
http://apps.sourceforge.net/trac/dracut/
|
||||
|
||||
The git tree can be found at
|
||||
git://dracut.git.sourceforge.net/gitroot/dracut/dracut for now. See the TODO
|
||||
file for things which still need to be done and HACKING for some
|
||||
instructions on how to get started. There is also a mailing list that
|
||||
is being used for the discussion -- initramfs@vger.kernel.org. It is
|
||||
a typical vger list, send mail to majordomo@vger.kernel.org with body
|
||||
of 'subscribe initramfs email@host.com'
|
||||
|
||||
|
||||
Licensed under the GPLv2
|
||||
|
@@ -1,7 +1,7 @@
|
||||
To build a generic initramfs, you have to install the following software packages:
|
||||
* device-mapper
|
||||
* cryptsetup-luks
|
||||
* rpcbind nfs-utils
|
||||
* rpcbind nfs-utils
|
||||
* lvm2
|
||||
* iscsi-initiator-utils
|
||||
* nbd
|
||||
|
@@ -1,3 +1,6 @@
|
||||
"dracut --kernel-only" is to build an initrd with only kernel modules and firmware files.
|
||||
"dracut --kernel-only" only executes "installkernel" in the modules subdirectories.
|
||||
dracut-kernel is used to pull in all firmware files to build an initrd with
|
||||
only kernel modules and firmware files.
|
||||
|
||||
dracut --kernel-only only executes "installkernel" in the modules
|
||||
subdirectories.
|
||||
|
||||
|
@@ -1,5 +0,0 @@
|
||||
# dracut RHEL-7 branch
|
||||
|
||||
dracut is an initramfs infrastructure.
|
||||
|
||||
CentOS CI Status: [](https://ci.centos.org/job/dracut-push-rhel-7/)
|
@@ -1,10 +1,10 @@
|
||||
Most of the functionality that dracut implements are actually implemented
|
||||
by dracut modules. dracut modules live in modules.d, and have the following
|
||||
by dracut modules. Dracut modules live in modules.d, and have the following
|
||||
structure:
|
||||
|
||||
dracut_install_dir/modules.d/
|
||||
00modname/
|
||||
module-setup.sh
|
||||
install
|
||||
check
|
||||
<other files as needed by the hook>
|
||||
|
||||
@@ -12,55 +12,45 @@ dracut_install_dir/modules.d/
|
||||
The numeric code must be present and in the range of 00 - 99.
|
||||
Modules with lower numbers are installed first. This is important
|
||||
because the dracut install functions (which install files onto
|
||||
the initrd) refuse to overwrite already installed files. This makes
|
||||
it easy for an earlier module to override the functionality of a
|
||||
the initrd) refuse to overwrite already installed files. This makes
|
||||
it easy for an earlier module to override the functionality of a
|
||||
later module, so that you can have a distro or system specific
|
||||
module override or modify the functionality of a generic module
|
||||
without having to patch the more generic module.
|
||||
|
||||
module-setup.sh:
|
||||
dracut sources this script to install the functionality that a
|
||||
install: dracut sources this script to install the functionality that a
|
||||
module implements onto the initrd. For the most part, this amounts
|
||||
to copying files from the host system onto the initrd in a controlled
|
||||
manner.
|
||||
|
||||
install():
|
||||
This function of module-setup.sh is called to install all
|
||||
non-kernel files. dracut supplies several install functions that are
|
||||
manner. dracut supplies several install functions that are
|
||||
specialized for different file types. Browse through dracut-functions
|
||||
fore more details. dracut also provides a $moddir variable if you
|
||||
need to install a file from the module directory, such as an initrd
|
||||
hook, a udev rule, or a specialized executable.
|
||||
|
||||
installkernel():
|
||||
This function of module-setup.sh is called to install all
|
||||
kernel related files.
|
||||
|
||||
|
||||
check():
|
||||
dracut calls this function to check and see if a module can be installed
|
||||
check: Dracut calls this program to check and see if a module can be installed
|
||||
on the initrd.
|
||||
|
||||
|
||||
When called without options, check should check to make sure that
|
||||
any files it needs to install into the initrd from the host system
|
||||
are present. It should exit with a 0 if they are, and a 1 if they are
|
||||
not.
|
||||
|
||||
When called with $hostonly set, it should perform the same check
|
||||
that it would without it set, and it should also check to see if the
|
||||
When called with -h, it should perform the same check that it would
|
||||
without any options, and it should also check to see if the
|
||||
functionality the module implements is being used on the host system.
|
||||
For example, if this module handles installing support for LUKS
|
||||
encrypted volumes, it should return 0 if all the tools to handle
|
||||
encrpted volumes are available and the host system has the root
|
||||
partition on an encrypted volume, 1 otherwise.
|
||||
|
||||
depends():
|
||||
This function should output a list of dracut modules
|
||||
When called with -d, it should output a list of dracut modules
|
||||
that it relies upon. An example would be the nfs and iscsi modules,
|
||||
which rely on the network module to detect and configure network
|
||||
interfaces.
|
||||
|
||||
Any other files in the module will not be touched by dracut directly.
|
||||
Check may take additional options in the future.
|
||||
|
||||
Any other files in the module will not be touched by dracut directly.
|
||||
|
||||
You are encouraged to provide a README that describes what the module is for.
|
||||
|
||||
@@ -70,42 +60,39 @@ HOOKS
|
||||
|
||||
init has the following hook points to inject scripts:
|
||||
|
||||
/lib/dracut/hooks/cmdline/*.sh
|
||||
/cmdline/*.sh
|
||||
scripts for command line parsing
|
||||
|
||||
/lib/dracut/hooks/pre-udev/*.sh
|
||||
/pre-udev/*.sh
|
||||
scripts to run before udev is started
|
||||
|
||||
/lib/dracut/hooks/pre-trigger/*.sh
|
||||
/pre-trigger/*.sh
|
||||
scripts to run before the main udev trigger is pulled
|
||||
|
||||
/lib/dracut/hooks/initqueue/*.sh
|
||||
/initqueue/*.sh
|
||||
runs in parallel to the udev trigger
|
||||
Udev events can add scripts here with /sbin/initqueue.
|
||||
If /sbin/initqueue is called with the "--onetime" option, the script
|
||||
will be removed after it was run.
|
||||
If /lib/dracut/hooks/initqueue/work is created and udev >= 143 then
|
||||
this loop can process the jobs in parallel to the udevtrigger.
|
||||
If /initqueue/work is created and udev >= 143 then this loop can
|
||||
process the jobs in parallel to the udevtrigger.
|
||||
If the udev queue is empty and no root device is found or no root
|
||||
filesystem was mounted, the user will be dropped to a shell after
|
||||
a timeout.
|
||||
Scripts can remove themselves from the initqueue by "rm $job".
|
||||
|
||||
/lib/dracut/hooks/pre-mount/*.sh
|
||||
/pre-mount/*.sh
|
||||
scripts to run before the root filesystem is mounted
|
||||
Network filesystems like NFS that do not use device files are an
|
||||
Network filesystems like NFS that do not use device files are an
|
||||
exception. Root can be mounted already at this point.
|
||||
|
||||
/lib/dracut/hooks/mount/*.sh
|
||||
/mount/*.sh
|
||||
scripts to mount the root filesystem
|
||||
If the udev queue is empty and no root device is found or no root
|
||||
filesystem was mounted, the user will be dropped to a shell after
|
||||
a timeout.
|
||||
|
||||
/lib/dracut/hooks/pre-pivot/*.sh
|
||||
scripts to run before latter initramfs cleanups
|
||||
|
||||
/lib/dracut/hooks/cleanup/*.sh
|
||||
/pre-pivot/*.sh
|
||||
scripts to run before the real init is executed and the initramfs
|
||||
disappears
|
||||
All processes started before should be killed here.
|
||||
|
@@ -1,32 +0,0 @@
|
||||
For the testsuite to work, you will have to install at least the following software packages:
|
||||
dash \
|
||||
bridge-utils \
|
||||
asciidoc \
|
||||
mdadm \
|
||||
lvm2 \
|
||||
cryptsetup \
|
||||
nfs-utils \
|
||||
nbd \
|
||||
dhcp-server \
|
||||
scsi-target-utils \
|
||||
iscsi-initiator-utils
|
||||
|
||||
TEST-04-FULL-SYSTEMD: systemd >= 187
|
||||
|
||||
How to run the testsuite:
|
||||
|
||||
$ sudo make clean check
|
||||
|
||||
in verbose mode:
|
||||
$ sudo make V=1 clean check
|
||||
|
||||
only specific test:
|
||||
$ sudo make TESTS="01 20 40" clean check
|
||||
only runs the 01, 20 and 40 tests.
|
||||
|
||||
debug a specific test case:
|
||||
$ cd TEST-01-BASIC
|
||||
$ sudo make clean setup run
|
||||
... change some kernel parameters ...
|
||||
$ sudo make run
|
||||
to run the test without doing the setup
|
44
TODO
44
TODO
@@ -1,44 +1,2 @@
|
||||
Current TODO list, broken into things which are relevant for the
|
||||
initramfs itself (/init et al) vs the generator.
|
||||
A lot of things are/should be marked with "FIXME" in the code.
|
||||
|
||||
Items are ordered in priority.
|
||||
|
||||
INITRAMFS TODO
|
||||
|
||||
- use info and warn prefix
|
||||
- generate systemd unit dracut-initramfs-restore in /run/systemd dynamically
|
||||
- put "root=" parsing hooks in separate hook dir
|
||||
- call "root=" parsing hooks after getting new rootpath from dhcp
|
||||
- put mount hook in main initqueue loop / careful about resume!
|
||||
- the hard-coded list of udev rules that we care about is kind of lame.
|
||||
- panic fallback
|
||||
- bridging/bonding without "netroot=" https://bugzilla.redhat.com/show_bug.cgi?id=822750
|
||||
- progress indication for fsck https://bugzilla.redhat.com/show_bug.cgi?id=827118
|
||||
- domain, searchdomain https://bugzilla.redhat.com/show_bug.cgi?id=840778
|
||||
- disable write-ifcfg https://bugzilla.redhat.com/show_bug.cgi?id=840784
|
||||
- check for /var to be mounted in convertfs https://bugzilla.redhat.com/show_bug.cgi?id=848172
|
||||
- probably fix "--include" https://bugzilla.redhat.com/show_bug.cgi?id=849338
|
||||
|
||||
GENERATOR TODO
|
||||
|
||||
- remove wait for swap devs, if no "resume=" is given on the kernel command line
|
||||
- add presets (predefined set of modules)
|
||||
- add interpreter/plugin-scripts to be sourced at the beginning or end (can use dracut-functions)
|
||||
- add mechanism for module specific command line options
|
||||
- pkg-config integration, to make it easy for other packages to use us.
|
||||
- default module specification could use some work
|
||||
- udev rule copying, as mentioned above, is a bit too hard-coded
|
||||
|
||||
- dracut-install parse LD_SHOW_AUXV="" AT_PLATFORM for lib install
|
||||
|
||||
CODE TODO
|
||||
|
||||
- document more functions
|
||||
- make function vars local, and prefix with "_"
|
||||
|
||||
Future Enhancement Requests
|
||||
|
||||
- run ssh server to enter crypto password or perform debugging (supported by debian)
|
||||
- https://bugzilla.redhat.com/show_bug.cgi?id=524727 - dracut + encrypted root + networking
|
||||
See https://sourceforge.net/apps/trac/dracut/wiki/TODO
|
||||
|
||||
|
78
configure
vendored
78
configure
vendored
@@ -1,78 +0,0 @@
|
||||
#!/bin/bash
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
# We don't support srcdir != builddir
|
||||
echo \#buildapi-variable-no-builddir >/dev/null
|
||||
|
||||
prefix=/usr
|
||||
|
||||
enable_documentation=yes
|
||||
|
||||
# Little helper function for reading args from the commandline.
|
||||
# it automatically handles -a b and -a=b variants, and returns 1 if
|
||||
# we need to shift $3.
|
||||
read_arg() {
|
||||
# $1 = arg name
|
||||
# $2 = arg value
|
||||
# $3 = arg parameter
|
||||
local rematch='^[^=]*=(.*)$'
|
||||
if [[ $2 =~ $rematch ]]; then
|
||||
read "$1" <<< "${BASH_REMATCH[1]}"
|
||||
else
|
||||
read "$1" <<< "$3"
|
||||
# There is no way to shift our callers args, so
|
||||
# return 1 to indicate they should do it instead.
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
while (($# > 0)); do
|
||||
case "${1%%=*}" in
|
||||
--prefix) read_arg prefix "$@" || shift;;
|
||||
--libdir) read_arg libdir "$@" || shift;;
|
||||
--datadir) read_arg datadir "$@" || shift;;
|
||||
--sysconfdir) read_arg sysconfdir "$@" || shift;;
|
||||
--sbindir) read_arg sbindir "$@" || shift;;
|
||||
--mandir) read_arg mandir "$@" || shift;;
|
||||
--disable-documentation) enable_documentation=no;;
|
||||
--program-prefix) read_arg programprefix "$@" || shift;;
|
||||
--exec-prefix) read_arg execprefix "$@" || shift;;
|
||||
--bindir) read_arg bindir "$@" || shift;;
|
||||
--includedir) read_arg includedir "$@" || shift;;
|
||||
--libexecdir) read_arg libexecdir "$@" || shift;;
|
||||
--localstatedir) read_arg localstatedir "$@" || shift;;
|
||||
--sharedstatedir) read_arg sharedstatedir "$@" || shift;;
|
||||
--infodir) read_arg infodir "$@" || shift;;
|
||||
--systemdsystemunitdir) read_arg systemdsystemunitdir "$@" || shift;;
|
||||
--bashcompletiondir) read_arg bashcompletiondir "$@" || shift;;
|
||||
*) echo "Ignoring unknown option '$1'";;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
cat > Makefile.inc.$$ <<EOF
|
||||
prefix ?= ${prefix}
|
||||
libdir ?= ${libdir:-${prefix}/lib}
|
||||
datadir ?= ${datadir:-${prefix}/share}
|
||||
sysconfdir ?= ${sysconfdir:-${prefix}/etc}
|
||||
sbindir ?= ${sbindir:-${prefix}/sbin}
|
||||
mandir ?= ${mandir:-${prefix}/share/man}
|
||||
enable_documentation ?= ${enable_documentation:-yes}
|
||||
bindir ?= ${bindir:-${prefix}/bin}
|
||||
EOF
|
||||
|
||||
{
|
||||
[[ $programprefix ]] && echo "programprefix ?= ${programprefix}"
|
||||
[[ $execprefix ]] && echo "execprefix ?= ${execprefix}"
|
||||
[[ $includedir ]] && echo "includedir ?= ${includedir}"
|
||||
[[ $libexecdir ]] && echo "libexecdir ?= ${libexecdir}"
|
||||
[[ $localstatedir ]] && echo "localstatedir ?= ${localstatedir}"
|
||||
[[ $sharedstatedir ]] && echo "sharedstatedir ?= ${sharedstatedir}"
|
||||
[[ $infodir ]] && echo "infodir ?= ${infodir}"
|
||||
[[ $systemdsystemunitdir ]] && echo "systemdsystemunitdir ?= ${systemdsystemunitdir}"
|
||||
[[ $bashcompletiondir ]] && echo "bashcompletiondir ?= ${bashcompletiondir}"
|
||||
} >> Makefile.inc.$$
|
||||
|
||||
mv Makefile.inc.$$ Makefile.inc
|
53
debian/changelog
vendored
Normal file
53
debian/changelog
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
dracut (2.26) unstable; urgency=low
|
||||
|
||||
[ Harald Hoyer ]
|
||||
* multipath: install udev rules and helper tools
|
||||
* NEWS update
|
||||
* multipath: install xdr utils
|
||||
* multipath: install multipath kernel module
|
||||
* specfile update
|
||||
* dracut.8: fixed formatting for rootfs and mount options
|
||||
* dracut: check more return codes, check for permissions and use
|
||||
derror
|
||||
* dracut: create initramfs-$(kernelversion).img by default
|
||||
* Makefile: add WITH_SWITCH_ROOT
|
||||
* fips: search different lib paths
|
||||
* kernel-modules: add firewire-ohci to hardcoded modules list
|
||||
* 90dm: install more device mapper kernel modules
|
||||
* specfile update
|
||||
|
||||
[ Peter Jones ]
|
||||
* Use glob for libdir when installing multipath libraries.
|
||||
* Add #!/bin/bash for consistency.
|
||||
* Make sure and get all the multipath related modules.
|
||||
* Bring up multipath devices that are configured in multipath.conf.
|
||||
* Fix missing shell variables.
|
||||
* This has to be executable.
|
||||
* Handle modules with hyphens in their names properly.
|
||||
|
||||
[ Harald Hoyer ]
|
||||
* lvm: scan without monitor
|
||||
|
||||
[ Yanko Kaneti ]
|
||||
* Wildcards need dracut_install
|
||||
|
||||
[ Harald Hoyer ]
|
||||
* lvm/dmraid: make LIBDIR depend on the binary
|
||||
* nfs: install passwd entries for nobody and nfsnobody
|
||||
* nfs: add rd_NFS_DOMAIN parameter to set the NFSv4 domain name
|
||||
* dracut-functions: inst_simple(): do not bail out if target is a dir
|
||||
and exists
|
||||
* dm: install dmsetup
|
||||
* multipath: corrected initqueue parameter
|
||||
* rootfs-block/mount-root: remount root with /etc/fstab filesystem
|
||||
options
|
||||
* test: set PATH
|
||||
|
||||
-- Philippe Seewer <philippe.seewer@.bfh.ch> Fri, 27 Nov 2009 10:58:26 +0100
|
||||
|
||||
dracut (2.21) unstable; urgency=low
|
||||
[ Harald Hoyer ]
|
||||
* fix rd_DASD argument handling (bug #531720)
|
||||
* Resolves: rhbz#531720
|
||||
|
||||
-- Philippe Seewer <philippe.seewer@.bfh.ch> Fri, 06 Nov 2009 15:52:00 +0100
|
1
debian/compat
vendored
Normal file
1
debian/compat
vendored
Normal file
@@ -0,0 +1 @@
|
||||
5
|
40
debian/control
vendored
Normal file
40
debian/control
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
Source: dracut
|
||||
Section: utils
|
||||
Priority: optional
|
||||
Maintainer: Philippe Seewer <philippe.seewer@bfh.ch>
|
||||
Build-Depends: debhelper (>= 5.0), cdbs
|
||||
Standards-Version: 3.8.3
|
||||
Vcs-Browser: http://dracut.git.sourceforge.net/git/gitweb-index.cgi
|
||||
Vcs-Git: git://dracut.git.sourceforge.net/gitroot/dracut/dracut
|
||||
|
||||
Package: dracut
|
||||
Architecture: all
|
||||
Recommends: cryptsetup, dmsetup, dmraid, lvm2, mdadm
|
||||
Depends: cpio, module-init-tools, udev, ${misc:Depends}
|
||||
Provides: linux-initramfs-tool
|
||||
Description: A new initramfs infrastructure
|
||||
Unlike existing initramfs's, this is an attempt at having as little as
|
||||
possible hard-coded into the initramfs as possible. The initramfs has
|
||||
(basically) one purpose in life -- getting the rootfs mounted so that
|
||||
we can transition to the real rootfs. This is all driven off of
|
||||
device availability. Therefore, instead of scripts hard-coded to do
|
||||
various things, we depend on udev to create device nodes for us and
|
||||
then when we have the rootfs's device node, we mount and carry on.
|
||||
Having the root on MD, LVM2, LUKS is supported as well as NFS, iSCSI,
|
||||
NBD and FCOE with dracut-network.
|
||||
|
||||
Package: dracut-network
|
||||
Architecture: all
|
||||
Recommends: nfs-common, open-iscsi, nbd-client
|
||||
Depends: dracut, iputils-arping, dhcp3-client, ${misc:Depends}
|
||||
Description: A new initramfs infrastucture
|
||||
Unlike existing initramfs's, this is an attempt at having as little as
|
||||
possible hard-coded into the initramfs as possible. The initramfs has
|
||||
(basically) one purpose in life -- getting the rootfs mounted so that
|
||||
we can transition to the real rootfs. This is all driven off of
|
||||
device availability. Therefore, instead of scripts hard-coded to do
|
||||
various things, we depend on udev to create device nodes for us and
|
||||
then when we have the rootfs's device node, we mount and carry on.
|
||||
Having the root on MD, LVM2, LUKS is supported as well as NFS, iSCSI,
|
||||
NBD and FCOE with dracut-network.
|
||||
|
39
debian/copyright
vendored
Normal file
39
debian/copyright
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
This package was debianized by Philippe Seewer <philippe.seewer@bfh.ch> on
|
||||
Fri Nov 20 15:45:00 +0100
|
||||
|
||||
Sources can be downloaded from:
|
||||
|
||||
https://sourceforge.net/projects/dracut/
|
||||
|
||||
Upstream Maintainer:
|
||||
Harald Hoyer <harald@redhat.com>
|
||||
|
||||
Updstream Authors:
|
||||
Victor Lowther <victor.lowther@gmail.com>
|
||||
Warren Togami <wtogami@redhat.com>
|
||||
Jeremy Katz <katzj@redhat.com>
|
||||
Philippe Seewer <philippe.seewer@bfh.ch>
|
||||
David Dillow <dave@thedillows.org>
|
||||
Andreas Thienemann <andreas@bawue.net>
|
||||
Hans de Goede <hdegoede@redhat.com>
|
||||
Marc Grimme <grimme@atix.de>
|
||||
Bill Nottingham <notting@redhat.com>
|
||||
Daniel Drake <dsd@laptop.org>
|
||||
Lance Albertson <lance@osuosl.org>
|
||||
Michael Ploujnikov <plouj@somanetworks.com>
|
||||
Peter Jones <pjones@redhat.com>
|
||||
Dave Jones <davej@redhat.com>
|
||||
Michal Schmidt <mschmidt@redhat.com>
|
||||
Peter Rajnoha <prajnoha@redhat.com>
|
||||
Quentin Armitage <quentin@armitage.org.uk>
|
||||
Sergey Fionov <fionov@gmail.com>
|
||||
Thilo Bangert <thilo.bangert@gmx.net>
|
||||
|
||||
Copyright:
|
||||
Copyright 2009 Harald Hoyer <harald@redhat.com>
|
||||
|
||||
|
||||
License: GPLv2
|
||||
|
||||
On Debian systems, the complete text of the GNU General Public
|
||||
License version 2 can be found in `/usr/share/common-licenses/GPL-2'.
|
5
debian/dracut-net.dirs
vendored
Normal file
5
debian/dracut-net.dirs
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
usr/share/dracut/modules.d/40network
|
||||
usr/share/dracut/modules.d/95fcoe
|
||||
usr/share/dracut/modules.d/95iscsi
|
||||
usr/share/dracut/modules.d/95nbd
|
||||
usr/share/dracut/modules.d/95nfs
|
5
debian/dracut-net.install
vendored
Normal file
5
debian/dracut-net.install
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
modules.d/40network usr/share/dracut/modules.d
|
||||
modules.d/95fcoe usr/share/dracut/modules.d
|
||||
modules.d/95iscsi usr/share/dracut/modules.d
|
||||
modules.d/95nbd usr/share/dracut/modules.d
|
||||
modules.d/95nfs usr/share/dracut/modules.d
|
22
debian/dracut.dirs
vendored
Normal file
22
debian/dracut.dirs
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
usr/share/dracut
|
||||
usr/share/dracut/modules.d/00dash
|
||||
usr/share/dracut/modules.d/01fips
|
||||
usr/share/dracut/modules.d/90crypt
|
||||
usr/share/dracut/modules.d/90dm
|
||||
usr/share/dracut/modules.d/90dmraid
|
||||
usr/share/dracut/modules.d/90kernel-modules
|
||||
usr/share/dracut/modules.d/90lvm
|
||||
usr/share/dracut/modules.d/90mdraid
|
||||
usr/share/dracut/modules.d/90multipath
|
||||
usr/share/dracut/modules.d/95dasd
|
||||
usr/share/dracut/modules.d/95dasd_mod
|
||||
usr/share/dracut/modules.d/95debug
|
||||
usr/share/dracut/modules.d/95resume
|
||||
usr/share/dracut/modules.d/95rootfs-block
|
||||
usr/share/dracut/modules.d/95terminfo
|
||||
usr/share/dracut/modules.d/95udev-rules
|
||||
usr/share/dracut/modules.d/95zfcp
|
||||
usr/share/dracut/modules.d/95znet
|
||||
usr/share/dracut/modules.d/98syslog
|
||||
usr/share/dracut/modules.d/99base
|
||||
/var/lib/dracut
|
4
debian/dracut.docs
vendored
Normal file
4
debian/dracut.docs
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
HACKING
|
||||
README.generic
|
||||
README.kernel
|
||||
README.modules
|
25
debian/dracut.install
vendored
Normal file
25
debian/dracut.install
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
dracut usr/sbin
|
||||
dracut-catimages usr/sbin
|
||||
dracut-update-initramfs usr/sbin
|
||||
dracut-functions usr/share/dracut
|
||||
dracut.conf etc
|
||||
modules.d/00dash usr/share/dracut/modules.d
|
||||
modules.d/01fips usr/share/dracut/modules.d
|
||||
modules.d/90crypt usr/share/dracut/modules.d
|
||||
modules.d/90dm usr/share/dracut/modules.d
|
||||
modules.d/90dmraid usr/share/dracut/modules.d
|
||||
modules.d/90kernel-modules usr/share/dracut/modules.d
|
||||
modules.d/90lvm usr/share/dracut/modules.d
|
||||
modules.d/90mdraid usr/share/dracut/modules.d
|
||||
modules.d/90multipath usr/share/dracut/modules.d
|
||||
modules.d/95dasd usr/share/dracut/modules.d
|
||||
modules.d/95dasd_mod usr/share/dracut/modules.d
|
||||
modules.d/95debug usr/share/dracut/modules.d
|
||||
modules.d/95resume usr/share/dracut/modules.d
|
||||
modules.d/95rootfs-block usr/share/dracut/modules.d
|
||||
modules.d/95terminfo usr/share/dracut/modules.d
|
||||
modules.d/95udev-rules usr/share/dracut/modules.d
|
||||
modules.d/95zfcp usr/share/dracut/modules.d
|
||||
modules.d/95znet usr/share/dracut/modules.d
|
||||
modules.d/98syslog usr/share/dracut/modules.d
|
||||
modules.d/99base usr/share/dracut/modules.d
|
2
debian/dracut.manpages
vendored
Normal file
2
debian/dracut.manpages
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
dracut.8
|
||||
dracut.conf.5
|
8
debian/dracut.postinst
vendored
Normal file
8
debian/dracut.postinst
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
# Regenerate initramfs when we're `installed`
|
||||
DPKG_MAINTSCRIPT_PACKAGE='' dracut-update-initramfs -u
|
||||
|
||||
#DEBHELPER#
|
1
debian/dracut.triggers
vendored
Normal file
1
debian/dracut.triggers
vendored
Normal file
@@ -0,0 +1 @@
|
||||
interest update-initramfs
|
3
debian/rules
vendored
Executable file
3
debian/rules
vendored
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/make -f
|
||||
|
||||
include /usr/share/cdbs/1/rules/debhelper.mk
|
346
dracut
Executable file
346
dracut
Executable file
@@ -0,0 +1,346 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Generator script for a dracut initramfs
|
||||
# Tries to retain some degree of compatibility with the command line
|
||||
# of the various mkinitrd implementations out there
|
||||
#
|
||||
|
||||
# Copyright 2005-2009 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
# store for logging
|
||||
dracut_args="$@"
|
||||
|
||||
usage() {
|
||||
# 80x25 linebreak here ^
|
||||
echo "Usage: $0 [OPTION]... <initramfs> <kernel-version>
|
||||
Creates initial ramdisk images for preloading modules
|
||||
|
||||
-f, --force Overwrite existing initramfs file.
|
||||
-m, --modules [LIST] Specify a space-separated list of dracut modules to
|
||||
call when building the initramfs. Modules are located
|
||||
in /usr/share/dracut/modules.d.
|
||||
-o, --omit [LIST] Omit a space-separated list of dracut modules.
|
||||
-a, --add [LIST] Add a space-separated list of dracut modules.
|
||||
-d, --drivers [LIST] Specify a space-separated list of kernel modules to
|
||||
exclusively include in the initramfs.
|
||||
--add-drivers [LIST] Specify a space-separated list of kernel
|
||||
modules to add to the initramfs.
|
||||
--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
|
||||
modules to exclusively include in the generic
|
||||
initramfs.
|
||||
-k, --kmoddir [DIR] Specify the directory, where to look for kernel
|
||||
modules
|
||||
--fwdir [DIR] Specify additional directories, where to look for
|
||||
firmwares, separated by :
|
||||
--kernel-only Only install kernel drivers and firmware files
|
||||
--no-kernel Do not install kernel drivers and firmware files
|
||||
--strip Strip binaries in the initramfs (default)
|
||||
--nostrip Do not strip binaries in the initramfs
|
||||
--mdadmconf Include local /etc/mdadm.conf
|
||||
--nomdadmconf Do not include local /etc/mdadm.conf
|
||||
--lvmconf Include local /etc/lvm/lvm.conf
|
||||
--nolvmconf Do not include local /etc/lvm/lvm.conf
|
||||
-h, --help This message
|
||||
--debug Output debug information of the build process
|
||||
-v, --verbose Verbose output during the build process
|
||||
-c, --conf [FILE] Specify configuration file to use.
|
||||
Default: /etc/dracut.conf
|
||||
-l, --local Local mode. Use modules from the current working
|
||||
directory instead of the system-wide installed in
|
||||
/usr/share/dracut/modules.d.
|
||||
Useful when running dracut from a git checkout.
|
||||
-H, --hostonly Host-Only mode: Install only what is needed for
|
||||
booting the local host instead of a generic host.
|
||||
-i, --include [SOURCE] [TARGET]
|
||||
Include the files in the SOURCE directory into the
|
||||
Target directory in the final initramfs.
|
||||
-I, --install [LIST] Install the space separated list of files into the
|
||||
initramfs.
|
||||
"
|
||||
}
|
||||
|
||||
while (($# > 0)); do
|
||||
case $1 in
|
||||
-f|--force) force=yes;;
|
||||
-m|--modules) dracutmodules_l="$2"; shift;;
|
||||
-o|--omit) omit_dracutmodules_l="$2"; shift;;
|
||||
-a|--add) add_dracutmodules_l="$2"; shift;;
|
||||
-d|--drivers) drivers_l="$2"; shift;;
|
||||
--add-drivers) add_drivers_l="$2"; shift;;
|
||||
--omit-drivers) omit_drivers_l+="$2"; shift;;
|
||||
--filesystems) filesystems_l="$2"; shift;;
|
||||
-k|--kmoddir) drivers_dir_l="$2"; shift;;
|
||||
--fwdir) fw_dir_l="$2"; shift;;
|
||||
--kernel-only) kernel_only="yes"; no_kernel="no";;
|
||||
--no-kernel) kernel_only="no"; no_kernel="yes";;
|
||||
--strip) do_strip_l="yes";;
|
||||
--nostrip) do_strip_l="no";;
|
||||
--mdadmconf) mdadmconf_l="yes";;
|
||||
--nomdadmconf) mdadmconf_l="no";;
|
||||
--lvmconf) lvmconf_l="yes";;
|
||||
--nolvmconf) lvmconf_l="no";;
|
||||
-h|--help) usage; exit 1 ;;
|
||||
--debug) debug="yes";;
|
||||
-v|--verbose) beverbose="yes";;
|
||||
-c|--conf) conffile="$2"; shift;;
|
||||
--confdir) confdir="$2"; shift;;
|
||||
-l|--local) allowlocal="yes" ;;
|
||||
-H|--hostonly) hostonly_l="yes" ;;
|
||||
-i|--include) include_src="$2"; include_target="$3"; shift 2;;
|
||||
-I|--install) install_items="$2"; shift;;
|
||||
-*) printf "\nUnknown option: %s\n\n" "$1" >&2; usage; exit 1;;
|
||||
*) break ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
||||
export PATH
|
||||
unset LD_LIBRARY_PATH
|
||||
unset GREP_OPTIONS
|
||||
|
||||
[[ $debug ]] && {
|
||||
export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): ';
|
||||
set -x
|
||||
}
|
||||
|
||||
[[ $dracutbasedir ]] || dracutbasedir=/usr/share/dracut
|
||||
|
||||
[[ $allowlocal && -f "$(readlink -f $(dirname $0))/dracut-functions" ]] && dracutbasedir="$(dirname $0)"
|
||||
|
||||
# if we were not passed a config file, try the default one
|
||||
if [[ ! -f $conffile ]]; then
|
||||
[[ $allowlocal ]] || conffile="/etc/dracut.conf"
|
||||
[[ $allowlocal ]] && conffile="$dracutbasedir/dracut.conf"
|
||||
fi
|
||||
|
||||
if [[ ! -d $confdir ]]; then
|
||||
[[ $allowlocal ]] || confdir="/etc/dracut.conf.d"
|
||||
[[ $allowlocal ]] && confdir="$dracutbasedir/dracut.conf.d"
|
||||
fi
|
||||
|
||||
# source our config dir
|
||||
if [ "$confdir" ] && [ -d "$confdir" ]; then
|
||||
for f in "$confdir"/*.conf; do
|
||||
[ -e "$f" ] && . "$f"
|
||||
done
|
||||
fi
|
||||
|
||||
# source our config file
|
||||
[[ -f $conffile ]] && . "$conffile"
|
||||
|
||||
# these optins add to the stuff in the config file
|
||||
[[ $add_dracutmodules_l ]] && add_dracutmodules+=" $add_dracutmodules_l"
|
||||
[[ $add_drivers_l ]] && add_drivers+=" $add_drivers_l"
|
||||
[[ $omit_drivers_l ]] && omit_drivers+=" $omit_drivers_l"
|
||||
|
||||
# these options override the stuff in the config file
|
||||
[[ $dracutmodules_l ]] && dracutmodules=$dracutmodules_l
|
||||
[[ $omit_dracutmodules_l ]] && omit_dracutmodules=$omit_dracutmodules_l
|
||||
[[ $drivers_l ]] && drivers=$drivers_l
|
||||
[[ $filesystems_l ]] && filesystems=$filesystems_l
|
||||
[[ $drivers_dir_l ]] && drivers_dir=$drivers_dir_l
|
||||
[[ $fw_dir_l ]] && fw_dir=$fw_dir_l
|
||||
[[ $do_strip_l ]] && do_strip=$do_strip_l
|
||||
[[ $hostonly_l ]] && hostonly=$hostonly_l
|
||||
[[ $mdadmconf_l ]] && mdadmconf=$mdadmconf_l
|
||||
[[ $lvmconf_l ]] && lvmconf=$lvmconf_l
|
||||
[[ $dracutbasedir ]] || dracutbasedir=/usr/share/dracut
|
||||
[[ $fw_dir ]] || fw_dir=/lib/firmware
|
||||
[[ $do_strip ]] || do_strip=yes
|
||||
# eliminate IFS hackery when messing with fw_dir
|
||||
fw_dir=${fw_dir//:/ }
|
||||
|
||||
[[ $hostonly = yes ]] && hostonly="-h"
|
||||
[[ $hostonly != "-h" ]] && unset hostonly
|
||||
|
||||
if [[ -f $dracutbasedir/dracut-functions ]]; then
|
||||
. $dracutbasedir/dracut-functions
|
||||
else
|
||||
echo "Cannot find $dracutbasedir/dracut-functions. Are you running from a git checkout?"
|
||||
echo "Try passing -l as an argument to $0"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dracutfunctions=$dracutbasedir/dracut-functions
|
||||
export dracutfunctions
|
||||
|
||||
dinfo "Executing $0 $dracut_args"
|
||||
|
||||
omit_drivers_corrected=""
|
||||
for d in $omit_drivers; do
|
||||
strstr " $drivers $add_drivers " " $d " && continue
|
||||
omit_drivers_corrected+="$d|"
|
||||
done
|
||||
omit_drivers="${omit_drivers_corrected%|}"
|
||||
unset omit_drivers_corrected
|
||||
|
||||
# This is kinda legacy -- eventually it should go away.
|
||||
case $dracutmodules in
|
||||
""|auto) dracutmodules="all" ;;
|
||||
esac
|
||||
|
||||
[[ $2 ]] && kernel=$2 || kernel=$(uname -r)
|
||||
[[ $1 ]] && outfile=$1 || outfile="/boot/initramfs-$kernel.img"
|
||||
abs_outfile=$(readlink -f "$outfile") && outfile="$abs_outfile"
|
||||
|
||||
srcmods="/lib/modules/$kernel/"
|
||||
[[ $drivers_dir ]] && srcmods="$drivers_dir"
|
||||
export srcmods
|
||||
|
||||
if [[ -f $outfile && ! $force ]]; then
|
||||
derror "Will not override existing initramfs ($outfile) without --force"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
outdir=$(dirname "$outfile")
|
||||
if ! [[ -d "$outdir" ]]; then
|
||||
derror "Can't write $outfile: Directory $outdir does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! [[ -w "$outdir" ]]; then
|
||||
derror "No permission to write $outdir."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -f "$outfile" ]] && ! [[ -w "$outfile" ]]; then
|
||||
derror "No permission to write $outfile."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
hookdirs="cmdline pre-udev pre-trigger netroot pre-mount pre-pivot mount emergency initqueue initqueue-finished initqueue-settled initqueue-timeout
|
||||
"
|
||||
|
||||
[[ -n "$TMPDIR" ]] && ! [[ -w "$TMPDIR" ]] && unset TMPDIR
|
||||
readonly initdir=$(mktemp -d -t initramfs.XXXXXX)
|
||||
|
||||
trap 'ret=$?;rm -rf "$initdir";exit $ret;' EXIT # clean up after ourselves no matter how we die.
|
||||
trap 'exit 1;' SIGINT # clean up after ourselves no matter how we die.
|
||||
|
||||
# Need to be able to have non-root users read stuff (rpcbind etc)
|
||||
chmod 755 "$initdir"
|
||||
|
||||
export initdir hookdirs dracutbasedir dracutmodules drivers \
|
||||
fw_dir drivers_dir debug beverbose no_kernel kernel_only \
|
||||
add_drivers omit_drivers mdadmconf lvmconf filesystems
|
||||
|
||||
if [[ $kernel_only != yes ]]; then
|
||||
# Create some directory structure first
|
||||
for d in bin sbin usr/bin usr/sbin usr/lib etc proc sys sysroot tmp dev/pts var/log var/run $hookdirs; do
|
||||
inst_dir "/$d"
|
||||
done
|
||||
fi
|
||||
|
||||
# check all our modules to see if they should be sourced.
|
||||
# This builds a list of modules that we will install next.
|
||||
check_modules
|
||||
modules_loaded=" "
|
||||
# source our modules.
|
||||
for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
|
||||
_d_mod=${moddir##*/}; _d_mod=${_d_mod#[0-9][0-9]}
|
||||
if strstr "$mods_to_load" " $_d_mod "; then
|
||||
if [[ $kernel_only = yes ]]; then
|
||||
[[ -x $moddir/installkernel ]] && . "$moddir/installkernel"
|
||||
else
|
||||
[[ -x "$moddir/install" ]] && . "$moddir/install"
|
||||
if [[ $no_kernel != yes && -x $moddir/installkernel ]]; then
|
||||
. "$moddir/installkernel"
|
||||
fi
|
||||
fi
|
||||
modules_loaded+="$_d_mod "
|
||||
mods_to_load=${mods_to_load// $_d_mod /}
|
||||
fi
|
||||
done
|
||||
unset moddir
|
||||
|
||||
## final stuff that has to happen
|
||||
|
||||
# generate module dependencies for the initrd
|
||||
if [[ -d $initdir/lib/modules/$kernel ]]; then
|
||||
if ! depmod -a -b "$initdir" $kernel; then
|
||||
derror "\"depmod -a $kernel\" failed."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $include_src && $include_target ]]; then
|
||||
if [[ -f $include_src ]]; then
|
||||
inst $include_src $include_target
|
||||
else
|
||||
mkdir -p "$initdir$include_target"
|
||||
cp -a -t "$initdir$include_target" "$include_src"/*
|
||||
fi
|
||||
fi
|
||||
|
||||
for item in $install_items; do
|
||||
dracut_install "$item"
|
||||
done
|
||||
unset item
|
||||
|
||||
# make sure that library links are correct and up to date
|
||||
cp -ar /etc/ld.so.conf* "$initdir"/etc
|
||||
ldconfig -r "$initdir" || [[ $(id -u) != "0" ]] && dinfo "ldconfig might need uid=0 (root) for chroot()"
|
||||
|
||||
[[ $beverbose = yes ]] && (du -c "$initdir" | sort -n)
|
||||
|
||||
# strip binaries
|
||||
if [[ $do_strip = yes ]] ; then
|
||||
for p in strip grep find; do
|
||||
if ! which $p >/dev/null 2>&1; then
|
||||
dwarn "Could not find '$p'. Not stripping binaries in the initramfs."
|
||||
do_strip=no
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ $do_strip = yes ]] ; then
|
||||
for f in $(find "$initdir" -type f \( -perm -0100 -or -perm -0010 -or -perm -0001 -or -path '*/lib/modules/*.ko' \) ); do
|
||||
# do not strip files with a .hmac file,
|
||||
# because that would alter the checksum
|
||||
if ! [[ -f "${f%/*}/.${f##*/}.hmac" ]]; then
|
||||
dinfo "Stripping '$f'"
|
||||
strip -g "$f" 2>/dev/null|| :
|
||||
else
|
||||
dinfo "Not stripping '$f', because it has a hmac checksum file."
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if strstr "$modules_loaded" " fips " && command -v prelink >/dev/null; then
|
||||
for i in $initdir/bin/* \
|
||||
$initdir/bin/* \
|
||||
$initdir/usr/bin/* \
|
||||
$initdir/usr/sbin/*; do
|
||||
[ -x $i ] && prelink -u $i &>/dev/null
|
||||
done
|
||||
fi
|
||||
|
||||
type pigz &>/dev/null && gzip=pigz || gzip=gzip
|
||||
if ! ( set -o pipefail; umask 077; cd "$initdir"; find . |cpio -R root:root -H newc -o --quiet| \
|
||||
$gzip -9 > "$outfile"; ); then
|
||||
derror "dracut: creation of $outfile failed"
|
||||
rm -f "$outfile"
|
||||
exit 1
|
||||
fi
|
||||
dinfo "Wrote $outfile"
|
||||
dinfo $(ls -l "$outfile")
|
||||
|
||||
exit 0
|
||||
|
@@ -1,79 +0,0 @@
|
||||
#
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
#
|
||||
# Copyright 2013 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
__contains_word () {
|
||||
local word=$1; shift
|
||||
for w in $*; do [[ $w = $word ]] && return 0; done
|
||||
return 1
|
||||
}
|
||||
|
||||
_dracut() {
|
||||
local field_vals= cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
local -A OPTS=(
|
||||
[STANDALONE]='-f -v -q -l -H -h -M -N
|
||||
--ro-mnt --force --kernel-only --no-kernel --strip --nostrip
|
||||
--hardlink --nohardlink --noprefix --mdadmconf --nomdadmconf
|
||||
--lvmconf --nolvmconf --debug --profile --verbose --quiet
|
||||
--local --hostonly --no-hostonly --fstab --help --bzip2 --lzma
|
||||
--xz --no-compress --gzip --list-modules --show-modules --keep
|
||||
--printsize --regenerate-all --noimageifnotneeded --early-microcode
|
||||
--no-early-microcode --print-cmdline --prelink --noprelink'
|
||||
|
||||
[ARG]='-a -m -o -d -I -k -c -L --kver --add --force-add --add-drivers
|
||||
--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 --install-optional'
|
||||
)
|
||||
|
||||
if __contains_word "$prev" ${OPTS[ARG]}; then
|
||||
case $prev in
|
||||
--kmoddir|-k|--fwdir|--confdir|--tmpdir)
|
||||
comps=$(compgen -d -- "$cur")
|
||||
compopt -o filenames
|
||||
;;
|
||||
-c|--conf|--sshkey|--add-fstab|--add-device|-I|--install|--install-optional)
|
||||
comps=$(compgen -f -- "$cur")
|
||||
compopt -o filenames
|
||||
;;
|
||||
-a|-m|-o|--add|--modules|--omit)
|
||||
comps=$(dracut --list-modules 2>/dev/null)
|
||||
;;
|
||||
--persistent-policy)
|
||||
comps=$(cd /dev/disk/; echo *)
|
||||
;;
|
||||
--kver)
|
||||
comps=$(cd /lib/modules; echo [0-9]*)
|
||||
;;
|
||||
*)
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ $cur = -* ]]; then
|
||||
COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
complete -F _dracut dracut
|
@@ -1,7 +1,5 @@
|
||||
#!/bin/bash --norc
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
#
|
||||
|
||||
# Copyright 2009 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
@@ -33,13 +31,12 @@ derror() {
|
||||
|
||||
usage() {
|
||||
# 80x25 linebreak here ^
|
||||
cat << EOF
|
||||
Usage: $0 [OPTION]... <initramfs> <base image> [<image>...]
|
||||
echo "Usage: $0 [OPTION]... <initramfs> <base image> [<image>...]
|
||||
Creates initial ramdisk image by concatenating several images from the command
|
||||
line and /boot/dracut/
|
||||
|
||||
-f, --force Overwrite existing initramfs file.
|
||||
-i, --imagedir Directory with additional images to add
|
||||
-i, --imagedir Directory with additional images to add
|
||||
(default: /boot/dracut/)
|
||||
-o, --overlaydir Overlay directory, which contains files that
|
||||
will be used to create an additional image
|
||||
@@ -48,7 +45,7 @@ line and /boot/dracut/
|
||||
-h, --help This message
|
||||
--debug Output debug information of the build process
|
||||
-v, --verbose Verbose output during the build process
|
||||
EOF
|
||||
"
|
||||
}
|
||||
|
||||
|
||||
@@ -57,16 +54,16 @@ overlay=/var/lib/dracut/overlay
|
||||
|
||||
while (($# > 0)); do
|
||||
case $1 in
|
||||
-f|--force) force=yes;;
|
||||
-i|--imagedir) imagedir=$2;shift;;
|
||||
-o|--overlaydir) overlay=$2;shift;;
|
||||
--nooverlay) no_overlay=yes;shift;;
|
||||
--noimagedir) no_imagedir=yes;shift;;
|
||||
-h|--help) usage; exit 1 ;;
|
||||
--debug) debug="yes";;
|
||||
-v|--verbose) beverbose="yes";;
|
||||
-*) printf "\nUnknown option: %s\n\n" "$1" >&2; usage; exit 1;;
|
||||
*) break ;;
|
||||
-f|--force) force=yes;;
|
||||
-i|--imagedir) imagedir=$2;shift;;
|
||||
-o|--overlaydir) overlay=$2;shift;;
|
||||
--nooverlay) no_overlay=yes;shift;;
|
||||
--noimagedir) no_imagedir=yes;shift;;
|
||||
-h|--help) usage; exit 1 ;;
|
||||
--debug) debug="yes";;
|
||||
-v|--verbose) beverbose="yes";;
|
||||
-*) printf "\nUnknown option: %s\n\n" "$1" >&2; usage; exit 1;;
|
||||
*) break ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
@@ -111,18 +108,18 @@ fi
|
||||
|
||||
if [[ ! $no_imagedir ]]; then
|
||||
for i in "$imagedir/"*.img; do
|
||||
[[ -f $i ]] && images+=("$i")
|
||||
[[ -f $i ]] && images+=("$i")
|
||||
done
|
||||
fi
|
||||
|
||||
images+=($@)
|
||||
|
||||
dinfo "Using base image $baseimage"
|
||||
cat -- "$baseimage" > "$outfile"
|
||||
cat "$baseimage" > "$outfile"
|
||||
|
||||
for i in "${images[@]}"; do
|
||||
for i in "${images[@]}"; do
|
||||
dinfo "Appending $i"
|
||||
cat -- "$i" >> "$outfile"
|
||||
cat "$i" >> "$outfile"
|
||||
done
|
||||
|
||||
dinfo "Created $outfile"
|
52
dracut-catimages.8
Normal file
52
dracut-catimages.8
Normal file
@@ -0,0 +1,52 @@
|
||||
.TH DRACUT-CATIMAGES 8 "June 2009" "Linux"
|
||||
.SH NAME
|
||||
dracut-catimages \- creates initial ramdisk image by concatenating images
|
||||
.SH SYNOPSIS
|
||||
\fBdracut-catimages\fR [\fIOPTION\fR]... \fI<initramfs base image>\fR \fI[<image>...]\fR
|
||||
|
||||
.SH DESCRIPTION
|
||||
.B dracut-catimages
|
||||
creates an initial ramdisk image by concatenating several images from the command
|
||||
line and /boot/dracut/*.img
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.BR \-f ", " \-\-force
|
||||
overwrite existing initramfs file.
|
||||
.TP
|
||||
.BR \-i ", " \-\-imagedir
|
||||
Directory with additional images to add (default: /boot/dracut/)
|
||||
.TP
|
||||
.BR \-o ", " \-\-overlaydir
|
||||
Overlay directory, which contains additional files that will be used to create an additional image
|
||||
.TP
|
||||
.BR \-\-nooverlay
|
||||
Do not use the overlay directory
|
||||
.TP
|
||||
.BR \-\-noimagedir
|
||||
Do not use the additional image directory
|
||||
.TP
|
||||
.BR \-h ", " \-\-help
|
||||
display help text and exit.
|
||||
.TP
|
||||
.B \-\-debug
|
||||
output debug information of the build process
|
||||
.TP
|
||||
.BR \-v ", " \-\-verbose
|
||||
verbose output during the build process
|
||||
|
||||
.SH FILES
|
||||
.TP
|
||||
.B /boot/dracut/*.img
|
||||
.TP
|
||||
.B
|
||||
.SH AUTHORS
|
||||
.nf
|
||||
Harald Hoyer <harald@redhat.com>
|
||||
.fi
|
||||
.SH AVAILABILITY
|
||||
The dracut-catimages command is part of the dracut package and is available from
|
||||
http://sourceforge.net/apps/trac/dracut/wiki
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR dracut (8)
|
@@ -1,59 +0,0 @@
|
||||
DRACUT-CATIMAGES(8)
|
||||
===================
|
||||
:doctype: manpage
|
||||
:man source: dracut
|
||||
:man manual: dracut
|
||||
|
||||
NAME
|
||||
----
|
||||
dracut-catimages - creates initial ramdisk image by concatenating images
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
**dracut-catimages** [_OPTION_...] _<initramfs base image>_ [_<image>_...]
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
dracut-catimages creates an initial ramdisk image by concatenating several
|
||||
images from the command line and /boot/dracut/*.img
|
||||
|
||||
OPTIONS
|
||||
-------
|
||||
**-f, --force**::
|
||||
overwrite existing initramfs file.
|
||||
|
||||
**-i, --imagedir**::
|
||||
Directory with additional images to add (default: /boot/dracut/)
|
||||
|
||||
**-o, --overlaydir**::
|
||||
Overlay directory, which contains additional files that will be used to
|
||||
create an additional image
|
||||
|
||||
**--nooverlay**:: Do not use the overlay directory
|
||||
|
||||
**--noimagedir**:: Do not use the additional image directory
|
||||
|
||||
**-h, --help**:: display help text and exit.
|
||||
|
||||
**--debug**:: output debug information of the build process
|
||||
|
||||
**-v, --verbose**:: verbose output during the build process
|
||||
|
||||
FILES
|
||||
-----
|
||||
_/boot/dracut/*.img_::
|
||||
images to work with
|
||||
|
||||
AUTHORS
|
||||
-------
|
||||
Harald Hoyer
|
||||
|
||||
AVAILABILITY
|
||||
------------
|
||||
The dracut-catimages command is part of the dracut package and is available from
|
||||
link:$$https://dracut.wiki.kernel.org$$[https://dracut.wiki.kernel.org]
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
*dracut*(8)
|
||||
|
661
dracut-functions
Executable file
661
dracut-functions
Executable file
@@ -0,0 +1,661 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# functions used by dracut and other tools.
|
||||
#
|
||||
# Copyright 2005-2009 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
IF_RTLD=""
|
||||
IF_dynamic=""
|
||||
|
||||
# Generic substring function. If $2 is in $1, return 0.
|
||||
strstr() { [[ $1 =~ $2 ]]; }
|
||||
|
||||
# Log initrd creation.
|
||||
if ! [[ $dracutlogfile ]]; then
|
||||
[[ $dracutbasedir = /usr/share/dracut ]] && \
|
||||
dracutlogfile=/var/log/dracut.log || \
|
||||
dracutlogfile=$HOME/dracut.log
|
||||
if [[ -w ${dracutlogfile%/*} ]]; then
|
||||
>>"$dracutlogfile"
|
||||
fi
|
||||
fi
|
||||
|
||||
dwarning() {
|
||||
echo "W: $@" >&2
|
||||
[[ -w $dracutlogfile ]] && echo $(date) "Warn:" $@ >>"$dracutlogfile"
|
||||
}
|
||||
|
||||
dinfo() {
|
||||
[[ $beverbose ]] && echo "I: $@" >&2
|
||||
[[ -w $dracutlogfile ]] && echo $(date) "Info:" $@ >>"$dracutlogfile"
|
||||
}
|
||||
|
||||
derror() {
|
||||
echo "E: $@" >&2
|
||||
[[ -w $dracutlogfile ]] && echo $(date) "Err:" $@ >>"$dracutlogfile"
|
||||
}
|
||||
|
||||
|
||||
|
||||
# normalize_path <path>
|
||||
# Prints the normalized path, where it removes any duplicated
|
||||
# and trailing slashes.
|
||||
# Example:
|
||||
# $ normalize_path ///test/test//
|
||||
# /test/test
|
||||
normalize_path() {
|
||||
shopt -q -s extglob
|
||||
set -- "${1//+(\/)//}"
|
||||
shopt -q -u extglob
|
||||
echo "${1%/}"
|
||||
}
|
||||
|
||||
# convert_abs_rel <from> <to>
|
||||
# Prints the relative path, when creating a symlink to <to> from <from>.
|
||||
# Example:
|
||||
# $ convert_abs_rel /usr/bin/test /bin/test-2
|
||||
# ../../bin/test-2
|
||||
# $ ln -s $(convert_abs_rel /usr/bin/test /bin/test-2) /usr/bin/test
|
||||
convert_abs_rel() {
|
||||
local __current __absolute __abssize __cursize __newpath
|
||||
local -i __i __level
|
||||
|
||||
set -- "$(normalize_path "$1")" "$(normalize_path "$2")"
|
||||
|
||||
# corner case #1 - self looping link
|
||||
[[ "$1" == "$2" ]] && { echo "${1##*/}"; return; }
|
||||
|
||||
# corner case #2 - own dir link
|
||||
[[ "${1%/*}" == "$2" ]] && { echo "."; return; }
|
||||
|
||||
IFS="/" __current=($1)
|
||||
IFS="/" __absolute=($2)
|
||||
|
||||
__abssize=${#__absolute[@]}
|
||||
__cursize=${#__current[@]}
|
||||
|
||||
while [[ ${__absolute[__level]} == ${__current[__level]} ]]
|
||||
do
|
||||
(( __level++ ))
|
||||
if (( __level > __abssize || __level > __cursize ))
|
||||
then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
for ((__i = __level; __i < __cursize-1; __i++))
|
||||
do
|
||||
if ((__i > __level))
|
||||
then
|
||||
__newpath=$__newpath"/"
|
||||
fi
|
||||
__newpath=$__newpath".."
|
||||
done
|
||||
|
||||
for ((__i = __level; __i < __abssize; __i++))
|
||||
do
|
||||
if [[ -n $__newpath ]]
|
||||
then
|
||||
__newpath=$__newpath"/"
|
||||
fi
|
||||
__newpath=$__newpath${__absolute[__i]}
|
||||
done
|
||||
|
||||
echo "$__newpath"
|
||||
}
|
||||
|
||||
# returns OK if $1 contains $2 at the beginning
|
||||
str_starts() {
|
||||
[ "${1#$2*}" != "$1" ]
|
||||
}
|
||||
|
||||
ln_r() {
|
||||
local _source=$1
|
||||
local _dest=$2
|
||||
|
||||
if ! str_starts "$_source" "/"; then
|
||||
ln -sfn "$_source" "${initdir}/${_dest}"
|
||||
else
|
||||
[[ -d "${_dest%/*}" ]] && _dest=$(readlink -f "${_dest%/*}")/${_dest##*/}
|
||||
ln -sfn $(convert_abs_rel "${_dest}" "${_source}") "${initdir}/${_dest}"
|
||||
fi
|
||||
}
|
||||
|
||||
get_fs_env() {
|
||||
if [[ -x /lib/udev/vol_id ]]; then
|
||||
eval $(/lib/udev/vol_id --export $1)
|
||||
elif find_binary blkid >/dev/null; then
|
||||
eval $(blkid -o udev $1)
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
get_fs_type() (
|
||||
get_fs_env $1 || return
|
||||
echo $ID_FS_TYPE
|
||||
)
|
||||
|
||||
get_fs_uuid() (
|
||||
get_fs_env $1 || return
|
||||
echo $ID_FS_UUID
|
||||
)
|
||||
|
||||
# finds the major:minor of the block device backing the root filesystem.
|
||||
find_block_device() {
|
||||
local rootdev blkdev fs type opts misc
|
||||
while read blkdev fs type opts misc; do
|
||||
[[ $blkdev = rootfs ]] && continue # skip rootfs entry
|
||||
[[ $fs = $1 ]] && { rootdev=$blkdev; break; } # we have a winner!
|
||||
done < /proc/mounts
|
||||
[[ -b $rootdev ]] || return 1 # oops, not a block device.
|
||||
# get major/minor for the device
|
||||
ls -nLl "$rootdev" | \
|
||||
(read x x x x maj min x; maj=${maj//,/}; echo $maj:$min)
|
||||
}
|
||||
|
||||
find_root_block_device() { find_block_device /; }
|
||||
|
||||
# Walk all the slave relationships for a given block device.
|
||||
# Stop when our helper function returns success
|
||||
# $1 = function to call on every found block device
|
||||
# $2 = block device in major:minor format
|
||||
check_block_and_slaves() {
|
||||
local x
|
||||
[[ -b /dev/block/$2 ]] || return 1 # Not a block device? So sorry.
|
||||
"$1" $2 && return
|
||||
check_vol_slaves "$@" && return 0
|
||||
if [[ -f "/sys/dev/block/$2/../dev" ]]; then
|
||||
check_block_and_slaves $1 $(cat "/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 $(cat "$x") && return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
get_numeric_dev() {
|
||||
ls -lH "$1" | { read a b c d maj min rest; printf "%d:%d" ${maj%%,} $min;}
|
||||
}
|
||||
|
||||
# ugly workaround for the lvm design
|
||||
# There is no volume group device,
|
||||
# so, there are no slave devices for volume groups.
|
||||
# Logical volumes only have the slave devices they really live on,
|
||||
# but you cannot create the logical volume without the volume group.
|
||||
# And the volume group might be bigger than the devices the LV needs.
|
||||
check_vol_slaves() {
|
||||
for i in /dev/mapper/*; do
|
||||
lv=$(get_numeric_dev $i)
|
||||
if [[ $lv = $2 ]]; then
|
||||
vg=$(lvm lvs --noheadings -o vg_name $i 2>/dev/null)
|
||||
# strip space
|
||||
vg=$(echo $vg)
|
||||
if [[ $vg ]]; then
|
||||
for pv in $(lvm vgs --noheadings -o pv_name "$vg" 2>/dev/null); \
|
||||
do
|
||||
check_block_and_slaves $1 $(get_numeric_dev $pv) \
|
||||
&& return 0
|
||||
done
|
||||
fi
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# Install a directory, keeping symlinks as on the original system.
|
||||
# Example: if /lib points to /lib64 on the host, "inst_dir /lib/file"
|
||||
# will create ${initdir}/lib64, ${initdir}/lib64/file,
|
||||
# and a symlink ${initdir}/lib -> lib64.
|
||||
inst_dir() {
|
||||
[[ -e ${initdir}/"$1" ]] && return 0 # already there
|
||||
|
||||
local _dir="$1" _part="${1%/*}" _file
|
||||
while [[ "$_part" != "${_part%/*}" ]] && ! [[ -e "${initdir}/${_part}" ]]; do
|
||||
_dir="$_part $_dir"
|
||||
_part=${_part%/*}
|
||||
done
|
||||
|
||||
# iterate over parent directories
|
||||
for _file in $_dir; do
|
||||
[[ -e "${initdir}/$_file" ]] && continue
|
||||
if [[ -L $_file ]]; then
|
||||
inst_symlink "$_file"
|
||||
else
|
||||
# create directory
|
||||
mkdir -m 0755 -p "${initdir}/$_file" || return 1
|
||||
[[ -e "$_file" ]] && chmod --reference="$_file" "${initdir}/$_file"
|
||||
chmod u+w "${initdir}/$_file"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# $1 = file to copy to ramdisk
|
||||
# $2 (optional) Name for the file on the ramdisk
|
||||
# Location of the image dir is assumed to be $initdir
|
||||
# We never overwrite the target if it exists.
|
||||
inst_simple() {
|
||||
local src target
|
||||
[[ -f $1 ]] || return 1
|
||||
src=$1 target="${2:-$1}"
|
||||
if ! [[ -d ${initdir}$target ]]; then
|
||||
[[ -e ${initdir}$target ]] && return 0
|
||||
inst_dir "${target%/*}"
|
||||
fi
|
||||
# install checksum files also
|
||||
if [[ -e "${src%/*}/.${src##*/}.hmac" ]]; then
|
||||
inst "${src%/*}/.${src##*/}.hmac" "${target%/*}/.${target##*/}.hmac"
|
||||
fi
|
||||
dinfo "Installing $src"
|
||||
cp -pfL "$src" "${initdir}$target"
|
||||
}
|
||||
|
||||
# Same as above, but specialized to handle dynamic libraries.
|
||||
# It handles making symlinks according to how the original library
|
||||
# is referenced.
|
||||
inst_library() {
|
||||
local src=$1 dest=${2:-$1}
|
||||
[[ -e $initdir$dest ]] && return 0
|
||||
if [[ -L $src ]]; then
|
||||
# install checksum files also
|
||||
if [[ -e "${src%/*}/.${src##*/}.hmac" ]]; then
|
||||
inst "${src%/*}/.${src##*/}.hmac" "${dest%/*}/.${dest##*/}.hmac"
|
||||
fi
|
||||
reallib=$(readlink -f "$src")
|
||||
lib=${src##*/}
|
||||
inst_simple "$reallib" "$reallib"
|
||||
inst_dir "${dest%/*}"
|
||||
ln_r "$reallib" "$dest"
|
||||
else
|
||||
inst_simple "$src" "$dest"
|
||||
fi
|
||||
}
|
||||
|
||||
# find a binary. If we were not passed the full path directly,
|
||||
# search in the usual places to find the binary.
|
||||
find_binary() {
|
||||
local binpath="/bin /sbin /usr/bin /usr/sbin" p
|
||||
[[ -z ${1##/*} && -x $1 ]] && { echo $1; return 0; }
|
||||
for p in $binpath; do
|
||||
[[ -x $p/$1 ]] && { echo "$p/$1"; return 0; }
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# Same as above, but specialized to install binary executables.
|
||||
# Install binary executable, and all shared library dependencies, if any.
|
||||
inst_binary() {
|
||||
local bin target
|
||||
bin=$(find_binary "$1") || return 1
|
||||
target=${2:-$bin}
|
||||
inst_symlink $bin $target && return 0
|
||||
local LDSO NAME IO FILE ADDR I1 n f TLIBDIR
|
||||
[[ -e $initdir$target ]] && return 0
|
||||
# I love bash!
|
||||
LC_ALL=C ldd $bin 2>/dev/null | while read line; do
|
||||
[[ $line = 'not a dynamic executable' ]] && return 1
|
||||
if [[ $line =~ not\ found ]]; then
|
||||
derror "Missing a shared library required by $bin."
|
||||
derror "Run \"ldd $bin\" to find out what it is."
|
||||
derror "dracut cannot create an initrd."
|
||||
exit 1
|
||||
fi
|
||||
so_regex='([^ ]*/lib[^/]*/[^ ]*\.so[^ ]*)'
|
||||
[[ $line =~ $so_regex ]] || continue
|
||||
FILE=${BASH_REMATCH[1]}
|
||||
[[ -e ${initdir}$FILE ]] && continue
|
||||
# see if we are loading an optimized version of a shared lib.
|
||||
lib_regex='^(/lib[^/]*).*'
|
||||
if [[ $FILE =~ $lib_regex ]]; then
|
||||
TLIBDIR=${BASH_REMATCH[1]}
|
||||
BASE=${FILE##*/}
|
||||
# prefer nosegneg libs, then unoptimized ones.
|
||||
for f in "$TLIBDIR/i686/nosegneg" "$TLIBDIR"; do
|
||||
[[ -e $f/$BASE ]] || continue
|
||||
FILE=$f/$BASE
|
||||
break
|
||||
done
|
||||
inst_library "$FILE" "$TLIBDIR/$BASE"
|
||||
IF_dynamic=yes
|
||||
continue
|
||||
fi
|
||||
inst_library "$FILE"
|
||||
done
|
||||
inst_simple "$bin" "$target"
|
||||
}
|
||||
|
||||
# same as above, except for shell scripts.
|
||||
# If your shell script does not start with shebang, it is not a shell script.
|
||||
inst_script() {
|
||||
[[ -f $1 ]] || return 1
|
||||
local line
|
||||
read -r -n 80 line <"$1"
|
||||
# If debug is set, clean unprintable chars to prevent messing up the term
|
||||
[[ $debug ]] && line=$(echo -n "$line" | tr -c -d '[:print:][:space:]')
|
||||
shebang_regex='(#! *)(/[^ ]+).*'
|
||||
[[ $line =~ $shebang_regex ]] || return 1
|
||||
inst "${BASH_REMATCH[2]}" && inst_simple "$@"
|
||||
}
|
||||
|
||||
# same as above, but specialized for symlinks
|
||||
inst_symlink() {
|
||||
local _src=$1 _target=${2:-$1} _realsrc
|
||||
strstr "$1" "/" || return 1
|
||||
[[ -L $1 ]] || return 1
|
||||
[[ -L $initdir/$_target ]] && return 0
|
||||
_realsrc=$(readlink -f "$_src")
|
||||
[[ ${_realsrc#/} = ${_realsrc} ]] && _realsrc="${_src%/*}/${_realsrc}"
|
||||
if ! [[ -e $initdir/$_realsrc ]]; then
|
||||
if [[ -d $_realsrc ]]; then
|
||||
inst_dir "$_realsrc"
|
||||
else
|
||||
inst "$_realsrc"
|
||||
fi
|
||||
fi
|
||||
[[ ! -e $initdir/${_target%/*} ]] && inst_dir "${_target%/*}"
|
||||
|
||||
ln_r "${_realsrc}" "${_target}"
|
||||
}
|
||||
|
||||
# find a udev rule in the usual places.
|
||||
find_rule() {
|
||||
[[ -f $1 ]] && { echo "$1"; return 0; }
|
||||
for r in . /lib/udev/rules.d /etc/udev/rules.d $dracutbasedir/rules.d; do
|
||||
[[ -f $r/$1 ]] && { echo "$r/$1"; return 0; }
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# udev rules always get installed in the same place, so
|
||||
# create a function to install them to make life simpler.
|
||||
inst_rules() {
|
||||
local target=/etc/udev/rules.d
|
||||
inst_dir "/lib/udev/rules.d"
|
||||
inst_dir "$target"
|
||||
for rule in "$@"; do
|
||||
rule=$(find_rule "$rule") && \
|
||||
inst_simple "$rule" "$target/${rule##*/}"
|
||||
done
|
||||
}
|
||||
|
||||
# general purpose installation function
|
||||
# Same args as above.
|
||||
inst() {
|
||||
case $# in
|
||||
1) ;;
|
||||
2)
|
||||
[[ -z $initdir ]] && [[ -d $2 ]] && export initdir=$2
|
||||
[[ $initdir = $2 ]] && set $1
|
||||
;;
|
||||
3)
|
||||
[[ -z $initdir ]] && export initdir=$2
|
||||
set $1 $3
|
||||
;;
|
||||
*)
|
||||
derror "inst only takes 1 or 2 or 3 arguments"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
for x in inst_symlink inst_script inst_binary inst_simple; do
|
||||
$x "$@" && return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# install function specialized for hooks
|
||||
# $1 = type of hook, $2 = hook priority (lower runs first), $3 = hook
|
||||
# All hooks should be POSIX/SuS compliant, they will be sourced by init.
|
||||
inst_hook() {
|
||||
if ! [[ -f $3 ]]; then
|
||||
derror "Cannot install a hook ($3) that does not exist."
|
||||
derror "Aborting initrd creation."
|
||||
exit 1
|
||||
elif ! strstr "$hookdirs" "$1"; then
|
||||
derror "No such hook type $1. Aborting initrd creation."
|
||||
exit 1
|
||||
fi
|
||||
inst_simple "$3" "/${1}/${2}${3##*/}"
|
||||
}
|
||||
|
||||
dracut_install() {
|
||||
if [[ $1 = '-o' ]]; then
|
||||
local optional=yes
|
||||
shift
|
||||
fi
|
||||
while (($# > 0)); do
|
||||
if ! inst "$1" ; then
|
||||
if [[ $optional = yes ]]; then
|
||||
dinfo "Skipping program $1 as it cannot be found and is flagged to be optional"
|
||||
else
|
||||
derror "Failed to install $1"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
check_module_deps() {
|
||||
local moddir dep ret
|
||||
# if we are already set to be loaded, we do not have to be checked again.
|
||||
strstr "$mods_to_load" " $1 " && return
|
||||
# turn a module name into a directory, if we can.
|
||||
moddir=$(echo ${dracutbasedir}/modules.d/??${1})
|
||||
[[ -d $moddir && -x $moddir/install ]] || return 1
|
||||
# if we do not have a check script, we are unconditionally included
|
||||
if [[ -x $moddir/check ]]; then
|
||||
"$moddir/check"
|
||||
ret=$?
|
||||
# a return value of 255 = load module only as a dependency.
|
||||
((ret==0||ret==255)) || return 1
|
||||
for dep in $("$moddir/check" -d); do
|
||||
check_module_deps "$dep" && continue
|
||||
dwarning "Dependency $mod failed."
|
||||
return 1
|
||||
done
|
||||
fi
|
||||
mods_to_load+=" $1 "
|
||||
}
|
||||
|
||||
should_source_module() {
|
||||
local dep
|
||||
if [[ $kernel_only = yes ]]; then
|
||||
[[ -x $1/installkernel ]] && return 0
|
||||
return 1
|
||||
fi
|
||||
[[ -x $1/install ]] || [[ -x $1/installkernel ]] || return 1
|
||||
[[ -x $1/check ]] || return 0
|
||||
"$1/check" $hostonly || return 1
|
||||
for dep in $("$1/check" -d); do
|
||||
check_module_deps "$dep" && continue
|
||||
dwarning "Cannot load dracut module \"$mod\", dependencies failed."
|
||||
return 1
|
||||
done
|
||||
}
|
||||
|
||||
check_modules() {
|
||||
local modcheck;
|
||||
local mod;
|
||||
for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
|
||||
local mod=${moddir##*/}; mod=${mod#[0-9][0-9]}
|
||||
# If we are already scheduled to be loaded, no need to check again.
|
||||
strstr "$mods_to_load" " $mod " && continue
|
||||
# This should never happen, but...
|
||||
[[ -d $moddir ]] || continue
|
||||
[[ $dracutmodules != all ]] && ! strstr "$dracutmodules" "$mod" && \
|
||||
continue
|
||||
strstr "$omit_dracutmodules" "$mod" && continue
|
||||
if ! strstr "$add_dracutmodules" "$mod"; then
|
||||
should_source_module "$moddir" || continue
|
||||
fi
|
||||
mods_to_load+=" $mod "
|
||||
done
|
||||
|
||||
modcheck=$add_dracutmodules
|
||||
[[ $dracutmodules != all ]] && modcheck="$m $dracutmodules"
|
||||
for mod in $modcheck; do
|
||||
strstr "$mods_to_load" "$mod" && continue
|
||||
strstr "$omit_dracutmodules" "$mod" && continue
|
||||
dwarning "Dracut module \"$mod\" cannot be found."
|
||||
done
|
||||
}
|
||||
|
||||
# Install a single kernel module along with any firmware it may require.
|
||||
# $1 = full path to kernel module to install
|
||||
install_kmod_with_fw() {
|
||||
local modname=${1##*/} fwdir found
|
||||
modname=${modname%.ko*}
|
||||
# no need to go further if the module is already installed
|
||||
[[ -e "${initdir}/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" ]] && return 0
|
||||
|
||||
if [[ $omit_drivers ]]; then
|
||||
local _kmod=${1##*/}
|
||||
_kmod=${_kmod%.ko}
|
||||
_kmod=${_kmod/-/_}
|
||||
if [[ "$_kmod" =~ $omit_drivers ]]; then
|
||||
dinfo "Omitting driver $_kmod"
|
||||
return 1
|
||||
fi
|
||||
if [[ "${1##*/lib/modules/$kernel/}" =~ $omit_drivers ]]; then
|
||||
dinfo "Omitting driver $_kmod"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
inst_simple "$1" "/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" || \
|
||||
return $?
|
||||
|
||||
for fw in $(modinfo -k $kernel -F firmware $1 2>/dev/null); do
|
||||
found=''
|
||||
for fwdir in $fw_dir; do
|
||||
if [[ -d $fwdir && -f $fwdir/$fw ]]; then
|
||||
inst_simple "$fwdir/$fw" "/lib/firmware/$fw"
|
||||
found=yes
|
||||
fi
|
||||
done
|
||||
if [[ $found != yes ]]; then
|
||||
dinfo "Possible missing firmware \"${fw}\" for kernel module \"${mod}.ko\""
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
# Do something with all the dependencies of a kernel module.
|
||||
# Note that kernel modules depend on themselves using the technique we use
|
||||
# $1 = function to call for each dependency we find
|
||||
# It will be passed the full path to the found kernel module
|
||||
# $2 = module to get dependencies for
|
||||
# rest of args = arguments to modprobe
|
||||
for_each_kmod_dep() {
|
||||
local func=$1 kmod=$2 cmd modpapth options
|
||||
shift 2
|
||||
modprobe "$@" --ignore-install --show-depends $kmod 2>/dev/null | ( \
|
||||
local found=0;
|
||||
while read cmd modpath options; do
|
||||
[[ $cmd = insmod ]] || continue
|
||||
$func ${modpath} || exit $?
|
||||
found=1
|
||||
done; [[ $found -eq 0 ]] && exit 1; exit 0;)
|
||||
return $?
|
||||
}
|
||||
|
||||
# filter kernel modules to install certain modules that meet specific
|
||||
# requirements.
|
||||
# $1 = function to call with module name to filter.
|
||||
# This function will be passed the full path to the module to test.
|
||||
# The behaviour of this function can vary depending on whether $hostonly is set.
|
||||
# If it is, we will only look at modules that are already in memory.
|
||||
# If it is not, we will look at all kernel modules
|
||||
# This function returns the full filenames of modules that match $1
|
||||
filter_kernel_modules () (
|
||||
if ! [[ $hostonly ]]; then
|
||||
filtercmd='find "$srcmods/kernel/drivers" "$srcmods/updates" "$srcmods/extra" "$srcmods/weak-updates" -name "*.ko" -o -name "*.ko.gz" 2>/dev/null'
|
||||
else
|
||||
filtercmd='cut -d " " -f 1 </proc/modules|xargs modinfo -F filename -k $kernel'
|
||||
fi
|
||||
for modname in $(eval $filtercmd); do
|
||||
case $modname in
|
||||
*.ko)
|
||||
"$1" "$modname" && echo "$modname"
|
||||
;;
|
||||
*.ko.gz)
|
||||
gzip -dc "$modname" > $initdir/$$.ko
|
||||
$1 $initdir/$$.ko && echo "$modname"
|
||||
rm -f $initdir/$$.ko
|
||||
;;
|
||||
esac
|
||||
done
|
||||
)
|
||||
|
||||
# install kernel modules along with all their dependencies.
|
||||
instmods() {
|
||||
[[ $no_kernel = yes ]] && return
|
||||
local mod mpargs modpath modname cmd
|
||||
local ret=0
|
||||
while (($# > 0)); do
|
||||
mod=${1%.ko*}
|
||||
case $mod in
|
||||
=*) # This introduces 2 incompatible meanings for =* arguments
|
||||
# to instmods. We need to decide which one to keep.
|
||||
if [[ $mod = =ata && -f $srcmods/modules.block ]] ; then
|
||||
instmods $mpargs $(egrep 'ata|ahci' "${srcmods}/modules.block")
|
||||
elif [ -f $srcmods/modules.${mod#=} ]; then
|
||||
instmods $mpargs $(cat ${srcmods}/modules.${mod#=} )
|
||||
else
|
||||
instmods $mpargs $(find "$srcmods" -path "*/${mod#=}/*")
|
||||
fi
|
||||
;;
|
||||
--*)
|
||||
mod=${mod##*/}
|
||||
mpargs+=" $mod";;
|
||||
i2o_scsi)
|
||||
# Must never run this diagnostic-only module
|
||||
shift; continue;
|
||||
;;
|
||||
*)
|
||||
# if we are already installed, skip this module and go on
|
||||
# to the next one.
|
||||
[[ -f $initdir/$1 ]] && { shift; continue; }
|
||||
|
||||
mod=${mod##*/}
|
||||
|
||||
if [[ $omit_drivers ]] && [[ "$1" =~ $omit_drivers ]]; then
|
||||
dinfo "Omitting driver ${mod##$srcmods}"
|
||||
shift; continue;
|
||||
fi
|
||||
|
||||
# If we are building a host-specific initramfs and this
|
||||
# module is not already loaded, move on to the next one.
|
||||
[[ $hostonly ]] && ! grep -q "${mod//-/_}" /proc/modules && \
|
||||
! echo $add_drivers | grep -qe "\<${mod}\>" && {
|
||||
shift; continue;
|
||||
}
|
||||
# ok, load the module, all its dependencies, and any firmware
|
||||
# it may require
|
||||
for_each_kmod_dep install_kmod_with_fw $mod \
|
||||
--set-version $kernel -d ${srcmods%%/lib/modules/*}/
|
||||
ret=$((ret+$?))
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
return $ret
|
||||
}
|
||||
|
||||
# vim:ts=8:sw=4:sts=4:et
|
1783
dracut-functions.sh
1783
dracut-functions.sh
File diff suppressed because it is too large
Load Diff
715
dracut-gencmdline
Executable file
715
dracut-gencmdline
Executable file
@@ -0,0 +1,715 @@
|
||||
#!/bin/bash --norc
|
||||
#
|
||||
# Copyright 2005-2009 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# code taken from mkinitrd
|
||||
#
|
||||
#. /usr/libexec/initrd-functions
|
||||
|
||||
IF_verbose=""
|
||||
function set_verbose() {
|
||||
case $1 in
|
||||
1|true|yes|on)
|
||||
IF_verbose="-v"
|
||||
;;
|
||||
0|false|no|off)
|
||||
IF_verbose=""
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function is_verbose() {
|
||||
[ -n "$IF_verbose" ] && return 0
|
||||
return 1
|
||||
}
|
||||
|
||||
function get_verbose() {
|
||||
echo "$IF_verbose"
|
||||
is_verbose
|
||||
}
|
||||
|
||||
|
||||
function get_numeric_dev() {
|
||||
(
|
||||
fmt="%d:%d"
|
||||
if [ "$1" == "hex" ]; then
|
||||
fmt="%x:%x"
|
||||
fi
|
||||
ls -lH "$2" | awk '{ sub(/,/, "", $5); printf("'"$fmt"'", $5, $6); }'
|
||||
) 2>/dev/null
|
||||
}
|
||||
|
||||
|
||||
function error() {
|
||||
echo "$@" >&2
|
||||
}
|
||||
|
||||
function vecho() {
|
||||
is_verbose && echo "$@"
|
||||
}
|
||||
|
||||
# module dep finding and installation functions
|
||||
moduledep() {
|
||||
MPARGS=""
|
||||
if [ "$1" == "--ignore-install" ]; then
|
||||
MPARGS="$MPARGS --ignore-install"
|
||||
shift
|
||||
fi
|
||||
vecho -n "Looking for deps of module $1"
|
||||
deps=""
|
||||
deps=$(modprobe $MPARGS --set-version $kernel --show-depends $1 2>/dev/null| awk '/^insmod / { print gensub(".*/","","g",$2) }' | while read foo ; do [ "${foo%%.ko}" != "$1" ] && echo -n "${foo%%.ko} " ; done)
|
||||
[ -n "$deps" ] && vecho ": $deps" || vecho
|
||||
}
|
||||
|
||||
export MALLOC_PERTURB_=204
|
||||
|
||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH
|
||||
export PATH
|
||||
|
||||
# Set the umask. For iscsi, the initrd can contain plaintext
|
||||
# password (chap secret), so only allow read by owner.
|
||||
umask 077
|
||||
|
||||
VERSION=6.0.87
|
||||
|
||||
PROBE="yes"
|
||||
MODULES=""
|
||||
GRAPHICSMODS=""
|
||||
PREMODS=""
|
||||
DMRAIDS=""
|
||||
ncryptodevs=0
|
||||
ncryptoparts=0
|
||||
ncryptolvs=0
|
||||
ncryptoraids=0
|
||||
root=""
|
||||
scsi_wait_scan="no"
|
||||
|
||||
NET_LIST=""
|
||||
LD_SO_CONF=/etc/ld.so.conf
|
||||
LD_SO_CONF_D=/etc/ld.so.conf.d/
|
||||
|
||||
[ -e /etc/sysconfig/mkinitrd ] && . /etc/sysconfig/mkinitrd
|
||||
|
||||
CONFMODS="$MODULES"
|
||||
MODULES=""
|
||||
ARCH=$(uname -m | sed -e 's/s390x/s390/')
|
||||
|
||||
compress=1
|
||||
allowmissing=""
|
||||
target=""
|
||||
kernel=""
|
||||
force=""
|
||||
img_vers=""
|
||||
builtins=""
|
||||
modulefile=/etc/modules.conf
|
||||
[ "$ARCH" != "s390" ] && withusb=1
|
||||
rc=0
|
||||
nolvm=""
|
||||
nodmraid=""
|
||||
|
||||
IMAGESIZE=8000
|
||||
PRESCSIMODS=""
|
||||
fstab="/etc/fstab"
|
||||
|
||||
vg_list=""
|
||||
net_list="$NET_LIST"
|
||||
|
||||
usage () {
|
||||
if [ "$1" == "-n" ]; then
|
||||
cmd=echo
|
||||
else
|
||||
cmd=error
|
||||
fi
|
||||
|
||||
$cmd "usage: `basename $0` [--version] [--help] [-v] [-f]"
|
||||
|
||||
if [ "$1" == "-n" ]; then
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
qpushd() {
|
||||
pushd "$1" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
qpopd() {
|
||||
popd >/dev/null 2>&1
|
||||
}
|
||||
|
||||
|
||||
freadlink() {
|
||||
readlink -f "$1"
|
||||
}
|
||||
|
||||
resolve_device_name() {
|
||||
if [ -z "${1##UUID=*}" ]; then
|
||||
real=$(freadlink /dev/disk/by-uuid/${1##UUID=})
|
||||
[ -b $real ] && { echo $real; return; }
|
||||
fi
|
||||
if [ -z "${1##LABEL=*}" ]; then
|
||||
real=$(freadlink /dev/disk/by-label/${1##LABEL=})
|
||||
[ -b $real ] && { echo $real; return; }
|
||||
fi
|
||||
echo "$1"
|
||||
}
|
||||
|
||||
finddevnoinsys() {
|
||||
majmin="$1"
|
||||
if [ -n "$majmin" ]; then
|
||||
dev=$(for x in /sys/block/* ; do find $x/ -name dev ; done | while read device ; do \
|
||||
echo "$majmin" | cmp -s $device && echo $device ; done)
|
||||
if [ -n "$dev" ]; then
|
||||
dev=${dev%%/dev}
|
||||
dev=${dev%%/}
|
||||
echo "$dev"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
finddevicedriverinsys () {
|
||||
if is_iscsi $PWD; then
|
||||
handleiscsi "$PWD"
|
||||
return
|
||||
fi
|
||||
while [ "$PWD" != "/sys/devices" ]; do
|
||||
deps=
|
||||
if [ -f modalias ]; then
|
||||
MODALIAS=$(cat modalias)
|
||||
if [ "${MODALIAS::7}" == "scsi:t-" ]; then
|
||||
scsi_wait_scan=yes
|
||||
fi
|
||||
moduledep $MODALIAS
|
||||
unset MODALIAS
|
||||
fi
|
||||
|
||||
cd ..
|
||||
done
|
||||
}
|
||||
|
||||
findstoragedriverinsys () {
|
||||
local sysfs=$(freadlink "$1")
|
||||
|
||||
# if its a partition look at the device holding the partition
|
||||
if [ -f "$sysfs/start" ]; then
|
||||
sysfs=$(freadlink ${sysfs%/*})
|
||||
fi
|
||||
|
||||
if [[ ! "$sysfs" =~ ^/sys/.*block/.*$ ]]; then
|
||||
#error "WARNING: $sysfs is a not a block sysfs path, skipping"
|
||||
return
|
||||
fi
|
||||
|
||||
case " $handleddevices " in
|
||||
*" $sysfs "*)
|
||||
return ;;
|
||||
*) handleddevices="$handleddevices $sysfs" ;;
|
||||
esac
|
||||
|
||||
if [[ "$sysfs" =~ ^/sys/.*block/md[0-9]+$ ]]; then
|
||||
local raid=${sysfs##*/}
|
||||
vecho "Found MDRAID component $raid"
|
||||
handleraid $raid
|
||||
fi
|
||||
if [[ "$sysfs" =~ ^/sys/.*block/dm-[0-9]+$ ]]; then
|
||||
vecho "Found DeviceMapper component ${sysfs##*/}"
|
||||
handledm $(cat $sysfs/dev |cut -d : -f 1) $(cat $sysfs/dev |cut -d : -f 2)
|
||||
fi
|
||||
|
||||
for slave in $(ls -d "$sysfs"/slaves/* 2>/dev/null) ; do
|
||||
findstoragedriverinsys "$slave"
|
||||
done
|
||||
|
||||
if [ -L "$sysfs/device" ]; then
|
||||
qpushd $(freadlink "$sysfs/device")
|
||||
finddevicedriverinsys
|
||||
qpopd
|
||||
fi
|
||||
}
|
||||
|
||||
findstoragedriver () {
|
||||
local device="$1"
|
||||
|
||||
if [ ! -b "$device" ]; then
|
||||
#error "WARNING: $device is a not a block device, skipping"
|
||||
return
|
||||
fi
|
||||
|
||||
local majmin=$(get_numeric_dev dec "$device")
|
||||
local sysfs=$(finddevnoinsys "$majmin")
|
||||
|
||||
if [ -z "$sysfs" ]; then
|
||||
#error "WARNING: $device major:minor $majmin not found, skipping"
|
||||
return
|
||||
fi
|
||||
|
||||
vecho "Looking for driver for $device in $sysfs"
|
||||
findstoragedriverinsys "$sysfs"
|
||||
}
|
||||
|
||||
iscsi_get_rec_val() {
|
||||
|
||||
# The open-iscsi 742 release changed to using flat files in
|
||||
# /var/lib/iscsi.
|
||||
|
||||
result=$(grep "^${2} = " "$1" | sed -e s'/.* = //')
|
||||
}
|
||||
|
||||
iscsi_set_parameters() {
|
||||
path=$1
|
||||
vecho setting iscsi parameters
|
||||
|
||||
tmpfile=$(mktemp)
|
||||
|
||||
# Check once before getting explicit values, so we can output a decent
|
||||
# error message.
|
||||
/sbin/iscsiadm --show -m session -r $path > $tmpfile
|
||||
if [ ! -s $tmpfile ]; then
|
||||
echo Unable to find iscsi record for $path
|
||||
exit 1
|
||||
fi
|
||||
|
||||
nit_name=$(grep "^InitiatorName=" /etc/iscsi/initiatorname.iscsi | \
|
||||
sed -e "s/^InitiatorName=//")
|
||||
|
||||
iscsi_get_rec_val $tmpfile "node.name"
|
||||
tgt_name=${result}
|
||||
iscsi_get_rec_val $tmpfile "node.tpgt"
|
||||
tpgt=${result}
|
||||
# iscsistart wants node.conn[0].address / port
|
||||
iscsi_get_rec_val $tmpfile 'node.conn\[0\].address'
|
||||
tgt_ipaddr=${result}
|
||||
iscsi_get_rec_val $tmpfile 'node.conn\[0\].port'
|
||||
tgt_port=${result}
|
||||
|
||||
# Note: we get chap secrets (passwords) in plaintext, and also store
|
||||
# them in the initrd.
|
||||
|
||||
iscsi_get_rec_val $tmpfile "node.session.auth.username"
|
||||
chap=${result}
|
||||
if [ -n "${chap}" -a "${chap}" != "<empty>" ]; then
|
||||
chap="-u ${chap}"
|
||||
iscsi_get_rec_val $tmpfile "node.session.auth.password"
|
||||
chap_pw="-w ${result}"
|
||||
else
|
||||
chap=""
|
||||
fi
|
||||
|
||||
iscsi_get_rec_val $tmpfile "node.session.auth.username_in"
|
||||
chap_in=${result}
|
||||
if [ -n "${chap_in}" -a "${chap_in}" != "<empty>" ]; then
|
||||
chap_in="-U ${chap_in}"
|
||||
iscsi_get_rec_val $tmpfile "node.session.auth.password_in"
|
||||
chap_in_pw="-W ${result}"
|
||||
else
|
||||
chap_in=""
|
||||
fi
|
||||
|
||||
rm $tmpfile
|
||||
}
|
||||
|
||||
emit_iscsi () {
|
||||
if [ -n "${iscsi_devs}" ]; then
|
||||
for dev in ${iscsi_devs}; do
|
||||
iscsi_set_parameters $dev
|
||||
# recid is not really used, just use 0 for it
|
||||
echo "/bin/iscsistart -t ${tgt_name} -i ${nit_name} \
|
||||
-g ${tpgt} -a ${tgt_ipaddr} ${chap} ${chap_pw} \
|
||||
${chap_in} ${chap_in_pw}"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
is_iscsi() {
|
||||
path=$1
|
||||
if echo $path | grep -q "/platform/host[0-9]*/session[0-9]*/target[0-9]*:[0-9]*:[0-9]*/[0-9]*:[0-9]*:[0-9]*:[0-9]*"; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
handledm() {
|
||||
major=$1
|
||||
minor=$2
|
||||
while read dmstart dmend dmtype r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 ; do
|
||||
case "$dmtype" in
|
||||
crypt)
|
||||
# this device is encrypted; find the slave device and see
|
||||
# whether the encryption is LUKS; if not, bail.
|
||||
slavedev=$(finddevnoinsys $r3)
|
||||
# get the basename, then s,!,/, in case it's a cciss device
|
||||
slavedev=$(echo ${slavedev##*/} | tr '!' '/')
|
||||
cryptsetup isLuks "/dev/$slavedev" 2>/dev/null || continue
|
||||
find_base_dm_mods
|
||||
dmname=$(dmsetup info -j $major -m $minor -c --noheadings -o name)
|
||||
# do the device resolution dance to get /dev/mapper/foo
|
||||
# since 'lvm lvs' doesn't like dm-X device nodes
|
||||
if [[ "$slavedev" =~ ^dm- ]]; then
|
||||
majmin=$(get_numeric_dev dec "/dev/$slavedev")
|
||||
for dmdev in /dev/mapper/* ; do
|
||||
dmnum=$(get_numeric_dev dev $dmdev)
|
||||
if [ $dmnum = $majmin ]; then
|
||||
slavedev=${dmdev#/dev/}
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# determine if $slavedev is an LV
|
||||
# if so, add the device to latecryptodevs
|
||||
# if not, add the device to cryptodevs
|
||||
local vg=$(lvshow /dev/$slavedev)
|
||||
if [ -n "$vg" ]; then
|
||||
eval cryptolv${ncryptolvs}='"'/dev/$slavedev $dmname'"'
|
||||
let ncryptolvs++
|
||||
elif grep -q "^$slavedev :" /proc/mdstat ; then
|
||||
eval cryptoraid${ncryptoraids}='"'/dev/$slavedev $dmname'"'
|
||||
let ncryptoraids++
|
||||
else
|
||||
eval cryptoparts${ncryptoparts}='"'/dev/$slavedev $dmname'"'
|
||||
let ncryptoparts++
|
||||
fi
|
||||
|
||||
let ncryptodevs++
|
||||
findstoragedriver "/dev/$slavedev"
|
||||
;;
|
||||
esac
|
||||
done << EOF
|
||||
$(dmsetup table -j $major -m $minor 2>/dev/null)
|
||||
EOF
|
||||
local name=$(dmsetup info --noheadings -c -j $major -m $minor -o name)
|
||||
local vg=$(lvshow "/dev/mapper/$name")
|
||||
local raids=$(/sbin/dmraid -s -craidname 2>/dev/null | grep -vi "no raid disks")
|
||||
if [ -n "$vg" ]; then
|
||||
vg=`echo $vg` # strip whitespace
|
||||
case " $vg_list " in
|
||||
*" $vg "*) ;;
|
||||
*) vg_list="$vg_list $vg"
|
||||
[ -z "$nolvm" ] && find_base_dm_mods
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
for raid in $raids ; do
|
||||
if [ "$raid" == "$name" ]; then
|
||||
case " $DMRAIDS " in
|
||||
*" $raid "*) ;;
|
||||
*) DMRAIDS="$DMRAIDS $raid"
|
||||
[ -z "$nodmraid" ] && find_base_dm_mods
|
||||
;;
|
||||
esac
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
handleiscsi() {
|
||||
vecho "Found iscsi component $1"
|
||||
|
||||
# We call iscsi_set_parameters once here to figure out what network to
|
||||
# use (it sets tgt_ipaddr), and once again to emit iscsi values,
|
||||
# not very efficient.
|
||||
iscsi_set_parameters $1
|
||||
iscsi_devs="$iscsi_devs $1"
|
||||
netdev=$(/sbin/ip route get to $tgt_ipaddr | \
|
||||
sed 's|.*dev \(.*\).*|\1|g' | awk '{ print $1; exit }')
|
||||
addnetdev $netdev
|
||||
}
|
||||
|
||||
handleraid() {
|
||||
local start=0
|
||||
|
||||
if [ -n "$noraid" -o ! -f /proc/mdstat ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
levels=$(awk "/^$1[ ]*:/ { print\$4 }" /proc/mdstat)
|
||||
|
||||
for level in $levels ; do
|
||||
case $level in
|
||||
linear)
|
||||
start=1
|
||||
;;
|
||||
multipath)
|
||||
start=1
|
||||
;;
|
||||
raid[01] | raid10)
|
||||
start=1
|
||||
;;
|
||||
raid[456])
|
||||
start=1
|
||||
;;
|
||||
*)
|
||||
error "raid level $level (in /proc/mdstat) not recognized"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [ "$start" = 1 ]; then
|
||||
raiddevices="$raiddevices $1"
|
||||
fi
|
||||
return $start
|
||||
}
|
||||
|
||||
lvshow() {
|
||||
lvm lvs --ignorelockingfailure --noheadings -o vg_name \
|
||||
$1 2>/dev/null | egrep -v '^ *(WARNING:|Volume Groups with)'
|
||||
}
|
||||
|
||||
vgdisplay() {
|
||||
lvm vgdisplay --ignorelockingfailure -v $1 2>/dev/null |
|
||||
sed -n 's/PV Name//p'
|
||||
}
|
||||
|
||||
dmmods_found="n"
|
||||
find_base_dm_mods()
|
||||
{
|
||||
[ "$dmmods_found" == "n" ] || return
|
||||
dmmods_found="y"
|
||||
}
|
||||
|
||||
savedargs=$*
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
--fstab*)
|
||||
if [ "$1" != "${1##--fstab=}" ]; then
|
||||
fstab=${1##--fstab=}
|
||||
else
|
||||
fstab=$2
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
|
||||
|
||||
-v|--verbose)
|
||||
set_verbose true
|
||||
;;
|
||||
--net-dev*)
|
||||
if [ "$1" != "${1##--net-dev=}" ]; then
|
||||
net_list="$net_list ${1##--net-dev=}"
|
||||
else
|
||||
net_list="$net_list $2"
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
--rootdev*)
|
||||
if [ "$1" != "${1##--rootdev=}" ]; then
|
||||
rootdev="${1##--rootdev=}"
|
||||
else
|
||||
rootdev="$2"
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
--thawdev*)
|
||||
if [ "$1" != "${1##--thawdev=}" ]; then
|
||||
thawdev="${1##--thawdev=}"
|
||||
else
|
||||
thawdev="$2"
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
--rootfs*)
|
||||
if [ "$1" != "${1##--rootfs=}" ]; then
|
||||
rootfs="${1##--rootfs=}"
|
||||
else
|
||||
rootfs="$2"
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
--rootopts*)
|
||||
if [ "$1" != "${1##--rootopts=}" ]; then
|
||||
rootopts="${1##--rootopts=}"
|
||||
else
|
||||
rootopts="$2"
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
--root*)
|
||||
if [ "$1" != "${1##--root=}" ]; then
|
||||
root="${1##--root=}"
|
||||
else
|
||||
root="$2"
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
--loopdev*)
|
||||
if [ "$1" != "${1##--loopdev=}" ]; then
|
||||
loopdev="${1##--loopdev=}"
|
||||
else
|
||||
loopdev="$2"
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
--loopfs*)
|
||||
if [ "$1" != "${1##--loopfs=}" ]; then
|
||||
loopfs="${1##--loopfs=}"
|
||||
else
|
||||
loopfs="$2"
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
--loopopts*)
|
||||
if [ "$1" != "${1##--loopopts=}" ]; then
|
||||
loopopts="${1##--loopopts=}"
|
||||
else
|
||||
loopopts="$2"
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
--looppath*)
|
||||
if [ "$1" != "${1##--looppath=}" ]; then
|
||||
looppath="${1##--looppath=}"
|
||||
else
|
||||
looppath="$2"
|
||||
shift
|
||||
fi
|
||||
;;
|
||||
--help)
|
||||
usage -n
|
||||
;;
|
||||
*)
|
||||
if [ -z "$target" ]; then
|
||||
target=$1
|
||||
elif [ -z "$kernel" ]; then
|
||||
kernel=$1
|
||||
else
|
||||
usage
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
shift
|
||||
done
|
||||
|
||||
[ -z "$rootfs" ] && rootfs=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $3; }}' $fstab)
|
||||
[ -z "$rootopts" ] && rootopts=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $4; }}' $fstab)
|
||||
[ -z "$rootopts" ] && rootopts="defaults"
|
||||
|
||||
|
||||
[ -z "$rootdev" ] && rootdev=$(awk '/^[ \t]*[^#]/ { if ($2 == "/") { print $1; }}' $fstab)
|
||||
# check if it's nfsroot
|
||||
physdev=""
|
||||
if [ "$rootfs" == "nfs" ]; then
|
||||
if [ "x$net_list" == "x" ]; then
|
||||
handlenfs $rootdev
|
||||
fi
|
||||
else
|
||||
# check if it's root by label
|
||||
rdev=$rootdev
|
||||
rdev=$(resolve_device_name "$rdev")
|
||||
rootopts=$(echo $rootopts | sed -e 's/^r[ow],//' -e 's/,_netdev//' -e 's/_netdev//' -e 's/,r[ow],$//' -e 's/,r[ow],/,/' -e 's/^r[ow]$/defaults/' -e 's/$/,ro/')
|
||||
findstoragedriver "$rdev"
|
||||
fi
|
||||
|
||||
# find the first swap dev which would get used for swsusp
|
||||
[ -z "$thawdev" ] && thawdev=$(awk '/^[ \t]*[^#]/ { if ($3 == "swap") { print $1; exit }}' $fstab)
|
||||
swsuspdev="$thawdev"
|
||||
if [ -n "$swsuspdev" ]; then
|
||||
swsuspdev=$(resolve_device_name "$swsuspdev")
|
||||
findstoragedriver "$swsuspdev"
|
||||
fi
|
||||
|
||||
|
||||
cemit()
|
||||
{
|
||||
cat
|
||||
}
|
||||
|
||||
emit()
|
||||
{
|
||||
NONL=""
|
||||
if [ "$1" == "-n" ]; then
|
||||
NONL="-n"
|
||||
shift
|
||||
fi
|
||||
echo $NONL "$@"
|
||||
}
|
||||
|
||||
emitdmraids()
|
||||
{
|
||||
if [ -z "$nodmraid" -a -n "$DMRAIDS" ]; then
|
||||
for raid in $DMRAIDS; do
|
||||
echo -n "rd_DM_UUID=$raid "
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# HACK: module loading + device creation isn't necessarily synchronous...
|
||||
# this will make sure that we have all of our devices before trying
|
||||
# things like RAID or LVM
|
||||
emitdmraids
|
||||
|
||||
emitcrypto()
|
||||
{
|
||||
local luksuuid=$(grep "^$2 " /etc/crypttab 2>/dev/null| awk '{ print $2 }')
|
||||
if [ -z "$luksuuid" ]; then
|
||||
luksuuid="$2"
|
||||
fi
|
||||
luksuuid=${luksuuid##UUID=}
|
||||
echo -n "rd_LUKS_UUID=$luksuuid "
|
||||
}
|
||||
|
||||
if [ -n "$raiddevices" ]; then
|
||||
for dev in $raiddevices; do
|
||||
uid=$(udevadm info --query=env --name /dev/${dev}|grep MD_UUID)
|
||||
uid=${uid##MD_UUID=}
|
||||
[ -n "$uid" ] && echo -n "rd_MD_UUID=$uid "
|
||||
done
|
||||
else
|
||||
echo -n "rd_NO_MD "
|
||||
fi
|
||||
|
||||
if [ -z "$nolvm" -a -n "$vg_list" ]; then
|
||||
for vg in $vg_list; do
|
||||
echo -n "rd_LVM_VG=$vg "
|
||||
done
|
||||
else
|
||||
echo -n "rd_NO_LVM "
|
||||
fi
|
||||
|
||||
cryptdevs="$(echo ${!cryptoraid@} ${!cryptopart@} ${!cryptolv@})"
|
||||
|
||||
if [ -z "$cryptdevs" ]; then
|
||||
echo -n "rd_NO_LUKS "
|
||||
else
|
||||
for cryptdev in ${!cryptoraid@} ${!cryptopart@} ${!cryptolv@} ; do
|
||||
emitcrypto `eval echo '$'$cryptdev`
|
||||
done
|
||||
fi
|
||||
|
||||
# output local keyboard/18n settings
|
||||
[ -e /etc/sysconfig/keyboard ] && . /etc/sysconfig/keyboard
|
||||
[ -e /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n
|
||||
|
||||
for i in KEYTABLE SYSFONT SYSFONTACM UNIMAP LANG; do
|
||||
val=$(eval echo \$$i)
|
||||
[[ $val ]] && echo -n "$i=$val "
|
||||
done
|
||||
|
||||
if [ -n "$KEYBOARDTYPE" -a "$KEYBOARDTYPE" != "pc" ]; then
|
||||
echo -n "KEYBOARDTYPE=$KEYBOARDTYPE "
|
||||
fi
|
||||
|
||||
if [ -n "$rootdev" ]; then
|
||||
echo -n "root=$rootdev "
|
||||
fi
|
||||
|
||||
echo
|
||||
# vim:ts=8:sw=4:sts=4:et
|
20
dracut-gencmdline.8
Normal file
20
dracut-gencmdline.8
Normal file
@@ -0,0 +1,20 @@
|
||||
.TH DRACUT-GENCMDLINE 8 "June 2009" "Linux"
|
||||
.SH NAME
|
||||
dracut-gencmdline \- generates kernel command line parameters for the dracut generated initramfs
|
||||
.SH SYNOPSIS
|
||||
.BR dracut-gencmdline
|
||||
|
||||
.SH DESCRIPTION
|
||||
.B dracut-gencmdline
|
||||
generates kernel command line parameters for the dracut generated initramfs, which are very specific to the host system.
|
||||
|
||||
.SH AUTHORS
|
||||
.nf
|
||||
Harald Hoyer <harald@redhat.com>
|
||||
.fi
|
||||
.SH AVAILABILITY
|
||||
The dracut-gencmdline command is part of the dracut package and is available from
|
||||
http://sourceforge.net/apps/trac/dracut/wiki
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR dracut (8)
|
@@ -1,34 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# functions used by dracut and other tools.
|
||||
#
|
||||
# Copyright 2005-2009 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
export LC_MESSAGES=C
|
||||
|
||||
if [[ $DRACUT_KERNEL_LAZY ]] && ! [[ $DRACUT_KERNEL_LAZY_HASHDIR ]]; then
|
||||
if ! [[ -d "$initdir/.kernelmodseen" ]]; then
|
||||
mkdir -p "$initdir/.kernelmodseen"
|
||||
fi
|
||||
DRACUT_KERNEL_LAZY_HASHDIR="$initdir/.kernelmodseen"
|
||||
fi
|
||||
|
||||
if [[ $initdir ]] && ! [[ -d $initdir ]]; then
|
||||
mkdir -p "$initdir"
|
||||
fi
|
||||
|
||||
[[ $dracutbasedir ]] || export dracutbasedir=${BASH_SOURCE%/*}
|
||||
. $dracutbasedir/dracut-functions.sh
|
@@ -1,36 +0,0 @@
|
||||
#!/bin/bash
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
set -e
|
||||
|
||||
KERNEL_VERSION="$(uname -r)"
|
||||
|
||||
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
|
||||
SKIP="$dracutbasedir/skipcpio"
|
||||
[[ -x $SKIP ]] || SKIP=cat
|
||||
|
||||
[[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
|
||||
|
||||
if [[ $MACHINE_ID ]] && [[ -d /boot/${MACHINE_ID} || -L /boot/${MACHINE_ID} ]] ; then
|
||||
IMG="/boot/${MACHINE_ID}/${KERNEL_VERSION}/initrd"
|
||||
fi
|
||||
[[ -f $IMG ]] || IMG="/boot/initramfs-${KERNEL_VERSION}.img"
|
||||
|
||||
cd /run/initramfs
|
||||
|
||||
[ -f .need_shutdown -a -f "$IMG" ] || exit 1
|
||||
if $SKIP "$IMG" | zcat | cpio -id --no-absolute-filenames --quiet >/dev/null; then
|
||||
rm -f -- .need_shutdown
|
||||
elif $SKIP "$IMG" | xzcat | cpio -id --no-absolute-filenames --quiet >/dev/null; then
|
||||
rm -f -- .need_shutdown
|
||||
elif $SKIP "$IMG" | lz4 -d -c | cpio -id --no-absolute-filenames --quiet >/dev/null; then
|
||||
rm -f -- .need_shutdown
|
||||
else
|
||||
# something failed, so we clean up
|
||||
echo "Unpacking of $IMG to /run/initramfs failed" >&2
|
||||
rm -f -- /run/initramfs/shutdown
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
443
dracut-logger.sh
443
dracut-logger.sh
@@ -1,443 +0,0 @@
|
||||
#!/bin/bash
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 et filetype=sh
|
||||
#
|
||||
# logging faciality module for dracut both at build- and boot-time
|
||||
#
|
||||
# Copyright 2010 Amadeusz Żołnowski <aidecoe@aidecoe.name>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
__DRACUT_LOGGER__=1
|
||||
|
||||
|
||||
## @brief Logging facility module for dracut both at build- and boot-time.
|
||||
#
|
||||
# @section intro Introduction
|
||||
#
|
||||
# The logger takes a bit from Log4j philosophy. There are defined 6 logging
|
||||
# levels:
|
||||
# - TRACE (6)
|
||||
# The TRACE Level designates finer-grained informational events than the
|
||||
# DEBUG.
|
||||
# - DEBUG (5)
|
||||
# The DEBUG Level designates fine-grained informational events that are most
|
||||
# useful to debug an application.
|
||||
# - INFO (4)
|
||||
# The INFO level designates informational messages that highlight the
|
||||
# progress of the application at coarse-grained level.
|
||||
# - WARN (3)
|
||||
# The WARN level designates potentially harmful situations.
|
||||
# - ERROR (2)
|
||||
# The ERROR level designates error events that might still allow the
|
||||
# application to continue running.
|
||||
# - FATAL (1)
|
||||
# The FATAL level designates very severe error events that will presumably
|
||||
# lead the application to abort.
|
||||
# Descriptions are borrowed from Log4j documentation:
|
||||
# http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Level.html
|
||||
#
|
||||
# @section usage Usage
|
||||
#
|
||||
# First of all you have to start with dlog_init() function which initializes
|
||||
# required variables. Don't call any other logging function before that one!
|
||||
# If you're ready with this, you can use following functions which corresponds
|
||||
# clearly to levels listed in @ref intro Introduction. Here they are:
|
||||
# - dtrace()
|
||||
# - ddebug()
|
||||
# - dinfo()
|
||||
# - dwarn()
|
||||
# - derror()
|
||||
# - dfatal()
|
||||
# They take all arguments given as a single message to be logged. See dlog()
|
||||
# function for details how it works. Note that you shouldn't use dlog() by
|
||||
# yourself. It's wrapped with above functions.
|
||||
#
|
||||
# @see dlog_init() dlog()
|
||||
#
|
||||
# @section conf Configuration
|
||||
#
|
||||
# Logging is controlled by following global variables:
|
||||
# - @var stdloglvl - logging level to standard error (console output)
|
||||
# - @var sysloglvl - logging level to syslog (by logger command)
|
||||
# - @var fileloglvl - logging level to file
|
||||
# - @var kmsgloglvl - logging level to /dev/kmsg (only for boot-time)
|
||||
# - @var logfile - log file which is used when @var fileloglvl is higher
|
||||
# than 0
|
||||
# and two global variables: @var maxloglvl and @var syslogfacility which <b>must
|
||||
# not</b> be overwritten. Both are set by dlog_init(). @var maxloglvl holds
|
||||
# maximum logging level of those three and indicates that dlog_init() was run.
|
||||
# @var syslogfacility is set either to 'user' (when building initramfs) or
|
||||
# 'daemon' (when booting).
|
||||
#
|
||||
# Logging level set by the variable means that messages from this logging level
|
||||
# and above (FATAL is the highest) will be shown. Logging levels may be set
|
||||
# independently for each destination (stderr, syslog, file, kmsg).
|
||||
#
|
||||
# @see dlog_init()
|
||||
|
||||
|
||||
## @brief Initializes dracut Logger.
|
||||
#
|
||||
# @retval 1 if something has gone wrong
|
||||
# @retval 0 on success.
|
||||
#
|
||||
# @note This function need to be called before any other from this file.
|
||||
#
|
||||
# If any of the variables is not set, this function set it to default:
|
||||
# - @var stdloglvl = 4 (info)
|
||||
# - @var sysloglvl = 0 (no logging)
|
||||
# - @var fileloglvl is set to 4 when @var logfile is set too, otherwise it's
|
||||
# - @var kmsgloglvl = 0 (no logging)
|
||||
# set to 0
|
||||
#
|
||||
# @warning Function sets global variables @var maxloglvl and @syslogfacility.
|
||||
# See file doc comment for details.
|
||||
dlog_init() {
|
||||
local __oldumask
|
||||
local ret=0; local errmsg
|
||||
[ -z "$stdloglvl" ] && stdloglvl=4
|
||||
[ -z "$sysloglvl" ] && sysloglvl=0
|
||||
[ -z "$kmsgloglvl" ] && kmsgloglvl=0
|
||||
# Skip initialization if it's already done.
|
||||
[ -n "$maxloglvl" ] && return 0
|
||||
|
||||
if [ -z "$fileloglvl" ]; then
|
||||
[ -w "$logfile" ] && fileloglvl=4 || fileloglvl=0
|
||||
elif (( $fileloglvl > 0 )); then
|
||||
if [[ $logfile ]]; then
|
||||
__oldumask=$(umask)
|
||||
umask 0377
|
||||
! [ -e "$logfile" ] && >"$logfile"
|
||||
umask $__oldumask
|
||||
if [ -w "$logfile" -a -f "$logfile" ]; then
|
||||
# Mark new run in the log file
|
||||
echo >>"$logfile"
|
||||
if command -v date >/dev/null; then
|
||||
echo "=== $(date) ===" >>"$logfile"
|
||||
else
|
||||
echo "===============================================" >>"$logfile"
|
||||
fi
|
||||
echo >>"$logfile"
|
||||
else
|
||||
# We cannot log to file, so turn this facility off.
|
||||
fileloglvl=0
|
||||
ret=1
|
||||
errmsg="'$logfile' is not a writable file"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if (( $UID != 0 )); then
|
||||
kmsgloglvl=0
|
||||
sysloglvl=0
|
||||
fi
|
||||
|
||||
if (( $sysloglvl > 0 )); then
|
||||
if [[ -d /run/systemd/journal ]] \
|
||||
&& 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 _systemdcatfile="$DRACUT_TMPDIR/systemd-cat"
|
||||
mkfifo "$_systemdcatfile"
|
||||
readonly _dlogfd=15
|
||||
systemd-cat -t 'dracut' --level-prefix=true <"$_systemdcatfile" &
|
||||
exec 15>"$_systemdcatfile"
|
||||
elif ! [ -S /dev/log -a -w /dev/log ] || ! command -v logger >/dev/null; then
|
||||
# We cannot log to syslog, so turn this facility off.
|
||||
kmsgloglvl=$sysloglvl
|
||||
sysloglvl=0
|
||||
ret=1
|
||||
errmsg="No '/dev/log' or 'logger' included for syslog logging"
|
||||
fi
|
||||
fi
|
||||
|
||||
if (($sysloglvl > 0)) || (($kmsgloglvl > 0 )); then
|
||||
if [ -n "$dracutbasedir" ]; then
|
||||
readonly syslogfacility=user
|
||||
else
|
||||
readonly syslogfacility=daemon
|
||||
fi
|
||||
export syslogfacility
|
||||
fi
|
||||
|
||||
local lvl; local maxloglvl_l=0
|
||||
for lvl in $stdloglvl $sysloglvl $fileloglvl $kmsgloglvl; do
|
||||
(( $lvl > $maxloglvl_l )) && maxloglvl_l=$lvl
|
||||
done
|
||||
readonly maxloglvl=$maxloglvl_l
|
||||
export maxloglvl
|
||||
|
||||
|
||||
if (($stdloglvl < 6)) && (($kmsgloglvl < 6)) && (($fileloglvl < 6)) && (($sysloglvl < 6)); then
|
||||
unset dtrace
|
||||
dtrace() { :; };
|
||||
fi
|
||||
|
||||
if (($stdloglvl < 5)) && (($kmsgloglvl < 5)) && (($fileloglvl < 5)) && (($sysloglvl < 5)); then
|
||||
unset ddebug
|
||||
ddebug() { :; };
|
||||
fi
|
||||
|
||||
if (($stdloglvl < 4)) && (($kmsgloglvl < 4)) && (($fileloglvl < 4)) && (($sysloglvl < 4)); then
|
||||
unset dinfo
|
||||
dinfo() { :; };
|
||||
fi
|
||||
|
||||
if (($stdloglvl < 3)) && (($kmsgloglvl < 3)) && (($fileloglvl < 3)) && (($sysloglvl < 3)); then
|
||||
unset dwarn
|
||||
dwarn() { :; };
|
||||
unset dwarning
|
||||
dwarning() { :; };
|
||||
fi
|
||||
|
||||
if (($stdloglvl < 2)) && (($kmsgloglvl < 2)) && (($fileloglvl < 2)) && (($sysloglvl < 2)); then
|
||||
unset derror
|
||||
derror() { :; };
|
||||
fi
|
||||
|
||||
if (($stdloglvl < 1)) && (($kmsgloglvl < 1)) && (($fileloglvl < 1)) && (($sysloglvl < 1)); then
|
||||
unset dfatal
|
||||
dfatal() { :; };
|
||||
fi
|
||||
|
||||
[ -n "$errmsg" ] && derror "$errmsg"
|
||||
|
||||
return $ret
|
||||
}
|
||||
|
||||
## @brief Converts numeric logging level to the first letter of level name.
|
||||
#
|
||||
# @param lvl Numeric logging level in range from 1 to 6.
|
||||
# @retval 1 if @a lvl is out of range.
|
||||
# @retval 0 if @a lvl is correct.
|
||||
# @result Echoes first letter of level name.
|
||||
_lvl2char() {
|
||||
case "$1" in
|
||||
1) echo F;;
|
||||
2) echo E;;
|
||||
3) echo W;;
|
||||
4) echo I;;
|
||||
5) echo D;;
|
||||
6) echo T;;
|
||||
*) return 1;;
|
||||
esac
|
||||
}
|
||||
|
||||
## @brief Converts numeric level to logger priority defined by POSIX.2.
|
||||
#
|
||||
# @param lvl Numeric logging level in range from 1 to 6.
|
||||
# @retval 1 if @a lvl is out of range.
|
||||
# @retval 0 if @a lvl is correct.
|
||||
# @result Echoes logger priority.
|
||||
_lvl2syspri() {
|
||||
printf $syslogfacility.
|
||||
case "$1" in
|
||||
1) echo crit;;
|
||||
2) echo error;;
|
||||
3) echo warning;;
|
||||
4) echo info;;
|
||||
5) echo debug;;
|
||||
6) echo debug;;
|
||||
*) return 1;;
|
||||
esac
|
||||
}
|
||||
|
||||
## @brief Converts dracut-logger numeric level to syslog log level
|
||||
#
|
||||
# @param lvl Numeric logging level in range from 1 to 6.
|
||||
# @retval 1 if @a lvl is out of range.
|
||||
# @retval 0 if @a lvl is correct.
|
||||
# @result Echoes kernel console numeric log level
|
||||
#
|
||||
# Conversion is done as follows:
|
||||
#
|
||||
# <tt>
|
||||
# FATAL(1) -> LOG_EMERG (0)
|
||||
# none -> LOG_ALERT (1)
|
||||
# none -> LOG_CRIT (2)
|
||||
# ERROR(2) -> LOG_ERR (3)
|
||||
# WARN(3) -> LOG_WARNING (4)
|
||||
# none -> LOG_NOTICE (5)
|
||||
# INFO(4) -> LOG_INFO (6)
|
||||
# DEBUG(5) -> LOG_DEBUG (7)
|
||||
# TRACE(6) /
|
||||
# </tt>
|
||||
#
|
||||
# @see /usr/include/sys/syslog.h
|
||||
_dlvl2syslvl() {
|
||||
local lvl
|
||||
|
||||
case "$1" in
|
||||
1) lvl=0;;
|
||||
2) lvl=3;;
|
||||
3) lvl=4;;
|
||||
4) lvl=6;;
|
||||
5) lvl=7;;
|
||||
6) lvl=7;;
|
||||
*) return 1;;
|
||||
esac
|
||||
|
||||
[ "$syslogfacility" = user ] && echo $((8+$lvl)) || echo $((24+$lvl))
|
||||
}
|
||||
|
||||
## @brief Prints to stderr and/or writes to file, to syslog and/or /dev/kmsg
|
||||
# given message with given level (priority).
|
||||
#
|
||||
# @param lvl Numeric logging level.
|
||||
# @param msg Message.
|
||||
# @retval 0 It's always returned, even if logging failed.
|
||||
#
|
||||
# @note This function is not supposed to be called manually. Please use
|
||||
# dtrace(), ddebug(), or others instead which wrap this one.
|
||||
#
|
||||
# This is core logging function which logs given message to standard error, file
|
||||
# and/or syslog (with POSIX shell command <tt>logger</tt>) and/or to /dev/kmsg.
|
||||
# The format is following:
|
||||
#
|
||||
# <tt>X: some message</tt>
|
||||
#
|
||||
# where @c X is the first letter of logging level. See module description for
|
||||
# details on that.
|
||||
#
|
||||
# Message to syslog is sent with tag @c dracut. Priorities are mapped as
|
||||
# following:
|
||||
# - @c FATAL to @c crit
|
||||
# - @c ERROR to @c error
|
||||
# - @c WARN to @c warning
|
||||
# - @c INFO to @c info
|
||||
# - @c DEBUG and @c TRACE both to @c debug
|
||||
_do_dlog() {
|
||||
local lvl="$1"; shift
|
||||
local lvlc=$(_lvl2char "$lvl") || return 0
|
||||
local msg="$*"
|
||||
local lmsg="$lvlc: $*"
|
||||
|
||||
(( $lvl <= $stdloglvl )) && echo "$msg" >&2
|
||||
|
||||
if (( $lvl <= $sysloglvl )); then
|
||||
if [[ "$_dlogfd" ]]; then
|
||||
printf -- "<%s>%s\n" "$(($(_dlvl2syslvl $lvl) & 7))" "$msg" >&$_dlogfd
|
||||
else
|
||||
logger -t "dracut[$$]" -p $(_lvl2syspri $lvl) -- "$msg"
|
||||
fi
|
||||
fi
|
||||
|
||||
if (( $lvl <= $fileloglvl )) && [[ -w "$logfile" ]] && [[ -f "$logfile" ]]; then
|
||||
echo "$lmsg" >>"$logfile"
|
||||
fi
|
||||
|
||||
(( $lvl <= $kmsgloglvl )) && \
|
||||
echo "<$(_dlvl2syslvl $lvl)>dracut[$$] $msg" >/dev/kmsg
|
||||
}
|
||||
|
||||
## @brief Internal helper function for _do_dlog()
|
||||
#
|
||||
# @param lvl Numeric logging level.
|
||||
# @param msg Message.
|
||||
# @retval 0 It's always returned, even if logging failed.
|
||||
#
|
||||
# @note This function is not supposed to be called manually. Please use
|
||||
# dtrace(), ddebug(), or others instead which wrap this one.
|
||||
#
|
||||
# This function calls _do_dlog() either with parameter msg, or if
|
||||
# none is given, it will read standard input and will use every line as
|
||||
# a message.
|
||||
#
|
||||
# This enables:
|
||||
# dwarn "This is a warning"
|
||||
# echo "This is a warning" | dwarn
|
||||
dlog() {
|
||||
[ -z "$maxloglvl" ] && return 0
|
||||
(( $1 <= $maxloglvl )) || return 0
|
||||
|
||||
if (( $# > 1 )); then
|
||||
_do_dlog "$@"
|
||||
else
|
||||
while read line || [ -n "$line" ]; do
|
||||
_do_dlog "$1" "$line"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
## @brief Logs message at TRACE level (6)
|
||||
#
|
||||
# @param msg Message.
|
||||
# @retval 0 It's always returned, even if logging failed.
|
||||
dtrace() {
|
||||
set +x
|
||||
dlog 6 "$@"
|
||||
[ -n "$debug" ] && set -x || :
|
||||
}
|
||||
|
||||
## @brief Logs message at DEBUG level (5)
|
||||
#
|
||||
# @param msg Message.
|
||||
# @retval 0 It's always returned, even if logging failed.
|
||||
ddebug() {
|
||||
set +x
|
||||
dlog 5 "$@"
|
||||
[ -n "$debug" ] && set -x || :
|
||||
}
|
||||
|
||||
## @brief Logs message at INFO level (4)
|
||||
#
|
||||
# @param msg Message.
|
||||
# @retval 0 It's always returned, even if logging failed.
|
||||
dinfo() {
|
||||
set +x
|
||||
dlog 4 "$@"
|
||||
[ -n "$debug" ] && set -x || :
|
||||
}
|
||||
|
||||
## @brief Logs message at WARN level (3)
|
||||
#
|
||||
# @param msg Message.
|
||||
# @retval 0 It's always returned, even if logging failed.
|
||||
dwarn() {
|
||||
set +x
|
||||
dlog 3 "$@"
|
||||
[ -n "$debug" ] && set -x || :
|
||||
}
|
||||
|
||||
## @brief It's an alias to dwarn() function.
|
||||
#
|
||||
# @param msg Message.
|
||||
# @retval 0 It's always returned, even if logging failed.
|
||||
dwarning() {
|
||||
set +x
|
||||
dwarn "$@"
|
||||
[ -n "$debug" ] && set -x || :
|
||||
}
|
||||
|
||||
## @brief Logs message at ERROR level (2)
|
||||
#
|
||||
# @param msg Message.
|
||||
# @retval 0 It's always returned, even if logging failed.
|
||||
derror() {
|
||||
set +x
|
||||
dlog 2 "$@"
|
||||
[ -n "$debug" ] && set -x || :
|
||||
}
|
||||
|
||||
## @brief Logs message at FATAL level (1)
|
||||
#
|
||||
# @param msg Message.
|
||||
# @retval 0 It's always returned, even if logging failed.
|
||||
dfatal() {
|
||||
set +x
|
||||
dlog 1 "$@"
|
||||
[ -n "$debug" ] && set -x || :
|
||||
}
|
1764
dracut-rhel6.xml
Normal file
1764
dracut-rhel6.xml
Normal file
File diff suppressed because it is too large
Load Diff
558
dracut-update-initramfs
Executable file
558
dracut-update-initramfs
Executable file
@@ -0,0 +1,558 @@
|
||||
#!/bin/sh
|
||||
|
||||
STATEDIR=/var/lib/dracut
|
||||
BOOTDIR=/boot
|
||||
CONF=/etc/dracut.conf
|
||||
KPKGCONF=/etc/kernel-img.conf
|
||||
USETRIGGERS=true
|
||||
mode=""
|
||||
version=""
|
||||
|
||||
set -e
|
||||
|
||||
if $USETRIGGERS \
|
||||
&& [ x"$DPKG_MAINTSCRIPT_PACKAGE" != x ] \
|
||||
&& [ $# = 1 ] \
|
||||
&& [ x"$1" = x-u ] \
|
||||
&& dpkg-trigger --check-supported 2>/dev/null
|
||||
then
|
||||
if dpkg-trigger --no-await update-initramfs; then
|
||||
echo "dracut-update-initramfs: deferring update (trigger activated)"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
usage()
|
||||
{
|
||||
if [ -n "${1}" ]; then
|
||||
printf "${@}\n\n" >&2
|
||||
fi
|
||||
cat >&2 << EOF
|
||||
Usage: ${0} [OPTION]...
|
||||
|
||||
Options:
|
||||
-k [version] Specify kernel version or 'all'
|
||||
-c Create a new initramfs
|
||||
-u Update an existing initramfs
|
||||
-d Remove an existing initramfs
|
||||
-t Take over a custom initramfs with this one
|
||||
-b Set alternate boot directory
|
||||
-v Be verbose
|
||||
-h This message
|
||||
|
||||
EOF
|
||||
exit 1
|
||||
}
|
||||
|
||||
# chroot check
|
||||
chrooted()
|
||||
{
|
||||
# borrowed from udev's postinst
|
||||
if [ "$(stat -c %d/%i /)" = "$(stat -Lc %d/%i /proc/1/root 2>/dev/null)" ]; then
|
||||
# the devicenumber/inode pair of / is the same as that of
|
||||
# /sbin/init's root, so we're *not* in a chroot and hence
|
||||
# return false.
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
mild_panic()
|
||||
{
|
||||
if [ -n "${1}" ]; then
|
||||
printf "${@}\n" >&2
|
||||
fi
|
||||
exit 0
|
||||
}
|
||||
|
||||
panic()
|
||||
{
|
||||
if [ -n "${1}" ]; then
|
||||
printf "${@}\n" >&2
|
||||
fi
|
||||
exit 1
|
||||
}
|
||||
|
||||
verbose()
|
||||
{
|
||||
if [ "${verbose}" = 1 ]; then
|
||||
printf "${@}\n"
|
||||
fi
|
||||
}
|
||||
|
||||
version_exists()
|
||||
{
|
||||
[ -e "${STATEDIR}/${1}" ] && [ -e "${initramfs}" ]
|
||||
return $?
|
||||
}
|
||||
|
||||
set_initramfs()
|
||||
{
|
||||
initramfs="${BOOTDIR}/dracut.img-${version}"
|
||||
}
|
||||
|
||||
|
||||
# backup initramfs while running
|
||||
backup_initramfs()
|
||||
{
|
||||
[ ! -r "${initramfs}" ] && return 0
|
||||
initramfs_bak="${initramfs}.dpkg-bak"
|
||||
[ -r "${initramfs_bak}" ] && rm -f "${initramfs_bak}"
|
||||
ln -f "${initramfs}" "${initramfs_bak}" \
|
||||
|| cp -a "${initramfs}" "${initramfs_bak}"
|
||||
verbose "Keeping ${initramfs_bak}"
|
||||
}
|
||||
|
||||
# keep booted initramfs
|
||||
backup_booted_initramfs()
|
||||
{
|
||||
initramfs_bak="${initramfs}.dpkg-bak"
|
||||
|
||||
# first time run thus no backup
|
||||
[ ! -r "${initramfs_bak}" ] && return 0
|
||||
|
||||
# chroot with no /proc
|
||||
[ ! -r /proc/uptime ] && rm -f "${initramfs_bak}" && return 0
|
||||
|
||||
# no kept backup wanted
|
||||
[ "${backup_initramfs}" = "no" ] && rm -f "${initramfs_bak}" && return 0
|
||||
|
||||
# no backup yet
|
||||
if [ ! -r "${initramfs}.bak" ]; then
|
||||
mv -f ${initramfs_bak} "${initramfs}.bak"
|
||||
verbose "Backup ${initramfs}.bak"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# keep booted initramfs
|
||||
uptime_days=$(awk '{printf "%d", $1 / 3600 / 24}' /proc/uptime)
|
||||
if [ -n "$uptime_days" ]; then
|
||||
boot_initramfs=$(find "${initramfs}.bak" -mtime +${uptime_days})
|
||||
fi
|
||||
if [ -n "${boot_initramfs}" ]; then
|
||||
mv -f "${initramfs_bak}" "${initramfs}.bak"
|
||||
verbose "Backup ${initramfs}.bak"
|
||||
return 0
|
||||
fi
|
||||
verbose "Removing current backup ${initramfs_bak}"
|
||||
rm -f ${initramfs_bak}
|
||||
}
|
||||
|
||||
# nuke generated copy
|
||||
remove_initramfs()
|
||||
{
|
||||
[ -z "${initramfs_bak}" ] && return 0
|
||||
rm -f "${initramfs_bak}"
|
||||
verbose "Removing ${initramfs_bak}"
|
||||
}
|
||||
|
||||
|
||||
generate_initramfs()
|
||||
{
|
||||
echo "dracut-update-initramfs: Generating ${initramfs}"
|
||||
OPTS=""
|
||||
if [ "${verbose}" = 1 ]; then
|
||||
OPTS="-v ${OPTS}"
|
||||
fi
|
||||
##WORK HERE!
|
||||
if dracut ${OPTS} "${initramfs}.new" "${version}"; then
|
||||
mv -f "${initramfs}.new" "${initramfs}"
|
||||
set_sha1
|
||||
else
|
||||
mkinitramfs_return="$?"
|
||||
remove_initramfs
|
||||
rm -f "${initramfs}.new"
|
||||
if [ "$mkinitramfs_return" = "2" ]; then
|
||||
# minversion wasn't met, exit 0
|
||||
exit 0
|
||||
fi
|
||||
echo "update-initramfs: failed for ${initramfs}"
|
||||
exit $mkinitramfs_return
|
||||
fi
|
||||
}
|
||||
|
||||
# lilo call
|
||||
run_lilo()
|
||||
{
|
||||
# show lilo errors on failure
|
||||
if ! lilo -t > /dev/null 2>&1 ; then
|
||||
echo "ERROR lilo fails for new ${initramfs}:"
|
||||
echo
|
||||
lilo -t
|
||||
fi
|
||||
lilo
|
||||
}
|
||||
|
||||
# check if lilo is on mbr
|
||||
mbr_check()
|
||||
{
|
||||
# try to discover grub|grub2 and be happy
|
||||
[ -r /boot/grub/grub.cfg ] \
|
||||
&& groot=$(awk '/^set root=/{print substr($2, 7, 3); exit}' \
|
||||
/boot/grub/grub.cfg)
|
||||
[ -r /boot/grub/menu.lst ] \
|
||||
&& groot=$(awk '/^root/{print substr($2, 2, 3); exit}' \
|
||||
/boot/grub/menu.lst)
|
||||
[ -e /boot/grub/device.map ] && [ -n "${groot}" ] \
|
||||
&& dev=$(awk "/${groot}/{ print \$NF}" /boot/grub/device.map)
|
||||
[ -n "${dev}" ] && [ -r ${dev} ] \
|
||||
&& dd if="${dev}" bs=512 skip=0 count=1 2> /dev/null \
|
||||
| grep -q GRUB && return 0
|
||||
|
||||
# check out lilo.conf for validity
|
||||
boot=$(awk -F = '/^boot=/{ print $2}' /etc/lilo.conf)
|
||||
[ -z "${boot}" ] && return 0
|
||||
case ${boot} in
|
||||
/dev/md/*)
|
||||
if [ -r /proc/mdstat ]; then
|
||||
MD=${boot#/dev/md/}
|
||||
boot="/dev/$(awk "/^md${MD}/{print substr(\$5, 1, 3)}" \
|
||||
/proc/mdstat)"
|
||||
fi
|
||||
;;
|
||||
/dev/md*)
|
||||
if [ -r /proc/mdstat ]; then
|
||||
MD=${boot#/dev/}
|
||||
boot="/dev/$(awk "/^${MD}/{print substr(\$5, 1, 3)}" \
|
||||
/proc/mdstat)"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
[ ! -r "${boot}" ] && return 0
|
||||
dd if="${boot}" bs=512 skip=0 count=1 2> /dev/null | grep -q LILO \
|
||||
&& run_lilo && return 0
|
||||
|
||||
# no idea which bootloader is used
|
||||
echo
|
||||
echo "WARNING: grub and lilo installed."
|
||||
echo "If you use grub as bootloader everything is fine."
|
||||
echo "If you use lilo as bootloader you must run lilo!"
|
||||
echo
|
||||
}
|
||||
|
||||
# Invoke bootloader
|
||||
run_bootloader()
|
||||
{
|
||||
# if both lilo and grub around, figure out if lilo needs to be run
|
||||
if ( command -v update-grub >/dev/null 2>&1 \
|
||||
|| [ -e /boot/grub/menu.lst ] || [ -e /boot/grub/grub.cfg ] ) \
|
||||
&& ( [ -e /etc/lilo.conf ] && command -v lilo >/dev/null 2>&1 ); then
|
||||
[ -r "${KPKGCONF}" ] && \
|
||||
do_b=$(awk '/^do_bootloader/{print $3}' "${KPKGCONF}")
|
||||
if [ "${do_b}" = "yes" ] || [ "${do_b}" = "Yes" ] \
|
||||
|| [ "${do_b}" = "YES" ]; then
|
||||
run_lilo
|
||||
return 0
|
||||
elif [ "${do_b}" = "no" ] || [ "${do_b}" = "No" ] \
|
||||
|| [ "${do_b}" = "NO" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# do_bootloader unconfigured
|
||||
mbr_check
|
||||
return 0
|
||||
fi
|
||||
if [ -r /etc/lilo.conf ] && command -v lilo >/dev/null 2>&1; then
|
||||
run_lilo
|
||||
return 0
|
||||
fi
|
||||
if command -v elilo >/dev/null 2>&1; then
|
||||
elilo
|
||||
return 0
|
||||
fi
|
||||
if [ -r /etc/zipl.conf ]; then
|
||||
zipl
|
||||
fi
|
||||
if flash-kernel --supported >/dev/null 2>&1; then
|
||||
flash-kernel ${version}
|
||||
fi
|
||||
}
|
||||
|
||||
compare_sha1()
|
||||
{
|
||||
sha1sum "${initramfs}" | diff "${STATEDIR}/${version}" - >/dev/null 2>&1
|
||||
return $?
|
||||
}
|
||||
|
||||
# Note that this must overwrite so that updates work.
|
||||
set_sha1()
|
||||
{
|
||||
sha1sum "${initramfs}" > "${STATEDIR}/${version}"
|
||||
}
|
||||
|
||||
delete_sha1()
|
||||
{
|
||||
rm -f "${STATEDIR}/${version}"
|
||||
}
|
||||
|
||||
# ro /boot is not modified
|
||||
ro_boot_check()
|
||||
{
|
||||
# check irrelevant inside of a chroot
|
||||
if [ ! -r /proc/mounts ] || chrooted; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
boot_opts=$(awk '/boot/{if ((match($4, /^ro/) || match($4, /,ro/)) \
|
||||
&& $2 == "/boot") print "ro"}' /proc/mounts)
|
||||
if [ -n "${boot_opts}" ]; then
|
||||
echo "WARNING: /boot is ro mounted."
|
||||
echo "update-initramfs: Not updating ${initramfs}"
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
get_sorted_versions()
|
||||
{
|
||||
version_list=""
|
||||
|
||||
for gsv_x in "${STATEDIR}"/*; do
|
||||
gsv_x="$(basename "${gsv_x}")"
|
||||
if [ "${gsv_x}" = '*' ]; then
|
||||
return 0
|
||||
fi
|
||||
worklist=""
|
||||
for gsv_i in $version_list; do
|
||||
if dpkg --compare-versions "${gsv_x}" '>' "${gsv_i}"; then
|
||||
worklist="${worklist} ${gsv_x} ${gsv_i}"
|
||||
gsv_x=""
|
||||
else
|
||||
worklist="${worklist} ${gsv_i}"
|
||||
fi
|
||||
done
|
||||
if [ "${gsv_x}" != "" ]; then
|
||||
worklist="${worklist} ${gsv_x}"
|
||||
fi
|
||||
version_list="${worklist}"
|
||||
done
|
||||
|
||||
verbose "Available versions: ${version_list}"
|
||||
}
|
||||
|
||||
set_current_version()
|
||||
{
|
||||
if [ -f /boot/dracut.img-`uname -r` ]; then
|
||||
version=`uname -r`
|
||||
fi
|
||||
}
|
||||
|
||||
set_linked_version()
|
||||
{
|
||||
if [ -e /initrd.img ] && [ -L /initrd.img ]; then
|
||||
linktarget="$(basename "$(readlink /initrd.img)")"
|
||||
fi
|
||||
|
||||
if [ -e /boot/initrd.img ] && [ -L /boot/initrd.img ]; then
|
||||
linktarget="$(basename "$(readlink /boot/initrd.img)")"
|
||||
fi
|
||||
|
||||
if [ -z "${linktarget}" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
version="${linktarget##*img-}"
|
||||
}
|
||||
|
||||
set_highest_version()
|
||||
{
|
||||
get_sorted_versions
|
||||
set -- ${version_list}
|
||||
version=${1}
|
||||
}
|
||||
|
||||
create()
|
||||
{
|
||||
if [ -z "${version}" ]; then
|
||||
usage "Create mode requires a version argument"
|
||||
fi
|
||||
|
||||
set_initramfs
|
||||
|
||||
if [ "${takeover}" = 0 ]; then
|
||||
if version_exists "${version}"; then
|
||||
panic "Cannot create version ${version}: already exists"
|
||||
fi
|
||||
|
||||
if [ -e "${initramfs}" ]; then
|
||||
panic "${initramfs} already exists, cannot create."
|
||||
fi
|
||||
fi
|
||||
|
||||
generate_initramfs
|
||||
}
|
||||
|
||||
update()
|
||||
{
|
||||
if [ "${update_initramfs}" = "no" ]; then
|
||||
echo "update-initramfs: Not updating initramfs."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "${version}" ]; then
|
||||
set_highest_version
|
||||
fi
|
||||
|
||||
if [ -z "${version}" ]; then
|
||||
set_linked_version
|
||||
fi
|
||||
|
||||
if [ -z "${version}" ]; then
|
||||
set_current_version
|
||||
fi
|
||||
|
||||
if [ -z "${version}" ]; then
|
||||
verbose "Nothing to do, exiting."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
set_initramfs
|
||||
|
||||
ro_boot_check
|
||||
|
||||
altered_check
|
||||
|
||||
backup_initramfs
|
||||
|
||||
generate_initramfs
|
||||
|
||||
run_bootloader
|
||||
|
||||
backup_booted_initramfs
|
||||
}
|
||||
|
||||
delete()
|
||||
{
|
||||
if [ -z "${version}" ]; then
|
||||
usage "Delete mode requires a version argument"
|
||||
fi
|
||||
|
||||
set_initramfs
|
||||
|
||||
if [ ! -e "${initramfs}" ]; then
|
||||
panic "Cannot delete ${initramfs}, doesn't exist."
|
||||
fi
|
||||
|
||||
if ! version_exists "${version}"; then
|
||||
panic "Cannot delete version ${version}: Not created by this utility."
|
||||
fi
|
||||
|
||||
altered_check
|
||||
|
||||
echo "update-initramfs: Deleting ${initramfs}"
|
||||
|
||||
delete_sha1
|
||||
|
||||
rm -f "${initramfs}"
|
||||
}
|
||||
|
||||
# Check for update mode on existing and modified initramfs
|
||||
altered_check()
|
||||
{
|
||||
# No check on takeover
|
||||
[ "${takeover}" = 1 ] && return 0
|
||||
if [ ! -e "${initramfs}" ]; then
|
||||
mild_panic "${initramfs} does not exist. Cannot update."
|
||||
fi
|
||||
if ! compare_sha1; then
|
||||
echo "update-initramfs: ${initramfs} has been altered." >&2
|
||||
mild_panic "update-initramfs: Cannot update. Override with -t option."
|
||||
fi
|
||||
}
|
||||
|
||||
# Defaults
|
||||
verbose=0
|
||||
yes=0
|
||||
# We default to takeover=1 in Ubuntu, but not Debian
|
||||
takeover=0
|
||||
|
||||
##
|
||||
|
||||
while getopts "k:cudyvtb:h?" flag; do
|
||||
case "${flag}" in
|
||||
k)
|
||||
version="${OPTARG}"
|
||||
;;
|
||||
c)
|
||||
mode="c"
|
||||
;;
|
||||
d)
|
||||
mode="d"
|
||||
;;
|
||||
u)
|
||||
mode="u"
|
||||
;;
|
||||
v)
|
||||
verbose="1"
|
||||
;;
|
||||
y)
|
||||
yes="1"
|
||||
;;
|
||||
t)
|
||||
takeover="1"
|
||||
;;
|
||||
b)
|
||||
BOOTDIR="${OPTARG}"
|
||||
if [ ! -d "${BOOTDIR}" ]; then
|
||||
echo "Error: ${BOOTDIR} is not a directory."
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
h|?)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $((${OPTIND} - 1))
|
||||
|
||||
if [ $# -ne 0 ]; then
|
||||
echo "Invalid argument for option -k."
|
||||
usage
|
||||
fi
|
||||
|
||||
# Validate arguments
|
||||
if [ -z "${mode}" ]; then
|
||||
usage "You must specify at least one of -c, -u, or -d."
|
||||
fi
|
||||
|
||||
if [ "${version}" = "all" ] \
|
||||
|| ( [ "${update_initramfs}" = "all" ] && [ -z "${version}" ] ); then
|
||||
: FIXME check for --yes, and if not ask are you sure
|
||||
get_sorted_versions
|
||||
if [ -z "${version_list}" ]; then
|
||||
verbose "Nothing to do, exiting."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
OPTS="-b ${BOOTDIR}"
|
||||
if [ "${verbose}" = "1" ]; then
|
||||
OPTS="${OPTS} -v"
|
||||
fi
|
||||
if [ "${takeover}" = "1" ]; then
|
||||
OPTS="${OPTS} -t"
|
||||
fi
|
||||
if [ "${yes}" = "1" ]; then
|
||||
OPTS="${OPTS} -y"
|
||||
fi
|
||||
for u_version in ${version_list}; do
|
||||
# Don't stop if one version doesn't work.
|
||||
set +e
|
||||
verbose "Execute: ${0} -${mode} -k \"${u_version}\" ${OPTS}"
|
||||
"${0}" -${mode} -k "${u_version}" ${OPTS}
|
||||
set -e
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
||||
case "${mode}" in
|
||||
c)
|
||||
create
|
||||
;;
|
||||
d)
|
||||
delete
|
||||
;;
|
||||
u)
|
||||
update
|
||||
;;
|
||||
esac
|
511
dracut.8
Normal file
511
dracut.8
Normal file
@@ -0,0 +1,511 @@
|
||||
.TH DRACUT 8 "June 2009" "Linux"
|
||||
.SH NAME
|
||||
dracut \- create initial ramdisk images for preloading modules
|
||||
.SH SYNOPSIS
|
||||
\fBdracut\fR [\fIOPTION\fR]... \fI<image>\fR \fI<kernel-version>\fR
|
||||
|
||||
.SH DESCRIPTION
|
||||
.B dracut
|
||||
creates an initial image used by the kernel for
|
||||
preloading the block device modules (such as IDE, SCSI or RAID)
|
||||
which are needed to access the root filesystem.
|
||||
|
||||
.SS Options
|
||||
.TP
|
||||
.BR \-f ", " \-\-force
|
||||
overwrite existing initramfs file.
|
||||
.TP
|
||||
.BR \-m ", " \-\-modules " \fILIST\fR"
|
||||
specify a space-separated list of dracut modules to call
|
||||
when building the initramfs.
|
||||
Modules are located in
|
||||
.IR /usr/share/dracut/modules.d .
|
||||
.TP
|
||||
.BR \-o ", " \-\-omit " \fILIST\fR"
|
||||
omit a space-separated list of dracut modules.
|
||||
.TP
|
||||
.BR \-a ", " \-\-add " \fILIST\fR"
|
||||
add a space-separated list of dracut modules.
|
||||
.TP
|
||||
.BR \-d ", " \-\-drivers " \fILIST\fR"
|
||||
specify a space-separated list of kernel modules to exclusively include
|
||||
in the initramfs.
|
||||
The kernel modules have to be specified without the ".ko" suffix.
|
||||
.TP
|
||||
.BR \-\-add-drivers " \fILIST\fR"
|
||||
specify a space-separated list of kernel modules to add to the initramfs.
|
||||
The kernel modules have to be specified without the ".ko" suffix.
|
||||
.TP
|
||||
.BR \-\-omit-drivers " \fILIST\fR"
|
||||
specify a space-separated list of kernel modules to omit from the initramfs.
|
||||
The kernel modules have to be specified without the ".ko" suffix.
|
||||
Regular expressions are also allowed like ".*/fs/ocfs/.*".
|
||||
|
||||
If [LIST] has multiple arguments, then you have to put these in quotes.
|
||||
|
||||
example:
|
||||
# dracut --omit "module1 module2" ...
|
||||
.TP
|
||||
.BR \-\-filesystems " \fILIST\fR"
|
||||
specify a space-separated list of kernel filesystem modules to exclusively
|
||||
include in the generic initramfs.
|
||||
.TP
|
||||
.BR \-k ", " \-\-kmoddir " \fI{DIR}\fR
|
||||
specify the directory, where to look for kernel modules
|
||||
.TP
|
||||
.BR " \-\-fwdir " \fI{DIR}\fR
|
||||
specify additional directory, where to look for firmwares
|
||||
.TP
|
||||
.BR \-\-kernel-only
|
||||
only install kernel drivers and firmware files
|
||||
.TP
|
||||
.BR \-\-no-kernel
|
||||
do not install kernel drivers and firmware files
|
||||
.TP
|
||||
.BR \-\-mdadmconf
|
||||
include local /etc/mdadm.conf
|
||||
.TP
|
||||
.BR \-\-nomdadmconf
|
||||
do not include local /etc/mdadm.conf
|
||||
.TP
|
||||
.BR \-\-strip
|
||||
strip binaries in the initramfs (default)
|
||||
.TP
|
||||
.BR \-\-nostrip
|
||||
do not strip binaries in the initramfs
|
||||
.TP
|
||||
.BR \-h ", " \-\-help
|
||||
display help text and exit.
|
||||
.TP
|
||||
.B \-\-debug
|
||||
output debug information of the build process
|
||||
.TP
|
||||
.BR \-v ", " \-\-verbose
|
||||
verbose output during the build process
|
||||
.TP
|
||||
.BR \-c ", " \-\-conf " \fIFILE\fR"
|
||||
specify configuration file to use.
|
||||
Default:
|
||||
.IR /etc/dracut.conf
|
||||
.TP
|
||||
.BR \-\-confdir " \fIDIR\fR"
|
||||
specify configuration directory to use.
|
||||
Default:
|
||||
.IR /etc/dracut.conf.d
|
||||
.TP
|
||||
.BR \-l ", " \-\-local
|
||||
local mode. Use modules from the current working
|
||||
directory instead of the system-wide installed in
|
||||
.IR /usr/share/dracut/modules.d .
|
||||
Useful when running dracut from a git checkout.
|
||||
.TP
|
||||
.BR \-H ", " \-\-hostonly
|
||||
Host-Only mode: Install only what is needed for
|
||||
booting the local host instead of a generic host.
|
||||
.TP
|
||||
.BR \-i ", " \-\-include " \fISOURCE\fR" "" " \fITARGET\fR"
|
||||
include the files in the SOURCE directory into the
|
||||
target directory in the final initramfs.
|
||||
.TP
|
||||
.BR \-I ", " \-\-install " \fILIST\fR"
|
||||
install the space separated list of files into the initramfs.
|
||||
|
||||
.SH "KERNEL COMMAND LINE"
|
||||
The root filesystem used by the kernel is specified in the boot configuration
|
||||
file, as always. The traditional \fBroot=/dev/hda1\fR style device
|
||||
specification is allowed. If a label is used, as in \fBroot=LABEL=rootPart\fR
|
||||
the initrd will search all available devices for an ext2 or ext3 filesystem
|
||||
with the appropriate label, and mount that device as the root filesystem.
|
||||
\fBroot=UUID=uuidnumber\fR will mount the partition with that UUID as the
|
||||
root filesystem.
|
||||
|
||||
.SS Standard
|
||||
.TP
|
||||
.BR init= "<path to real init>"
|
||||
.TP
|
||||
.BR root= "<path to blockdevice>"
|
||||
specify blockdevice to use as root filesystem.
|
||||
e.g.
|
||||
root=/dev/sda1
|
||||
root=/dev/disk/by-path/pci-0000:00:1f.1-scsi-0:0:1:0-part1
|
||||
.TP
|
||||
.BR rootfstype= "<filesystem type>"
|
||||
"auto" if not specified, e.g. rootfstype=ext3
|
||||
.TP
|
||||
.BR rootflags= "<mount options>"
|
||||
specify additional mount options for the root filesystem. If not set, /etc/fstab
|
||||
of the real root will be parsed for special mount options and mounted
|
||||
accordingly.
|
||||
.TP
|
||||
\fBrootfallback=\fR\fI<path to blockdevice>\fR
|
||||
specify the block device to use as the root filesystem, if the normal root cannot be found\&. This can only be a simple block device with a simple file system, for which the filesystem driver is either compiled in, or added manually to the initramfs\&. This parameter can be specified multiple times\&.
|
||||
.TP
|
||||
.B rd_NO_FSTAB
|
||||
do not honor special mount options for the root filesystem found in
|
||||
/etc/fstab of the real root.
|
||||
|
||||
.SS Misc
|
||||
.TP
|
||||
.BR hostname= "<hostname>"
|
||||
set the initial hostname
|
||||
.TP
|
||||
.BR rdblacklist= "<drivername>"
|
||||
do not load kernel module <drivername>
|
||||
This parameter can be specified multiple times.
|
||||
.TP
|
||||
.BR rdloaddriver= "<drivername>"
|
||||
force loading kernel module <drivername>
|
||||
This parameter can be specified multiple times.
|
||||
.TP
|
||||
.BR rd_retry= "<seconds>"
|
||||
wait <seconds> until dracut tries to force assemble LVM or RAID volumes. If the root device is not found within <seconds>*2 then dracut fails and either drops to a shell, if rdshell is on the kernel command line, or exits with 1, which normally causes a kernel panic.
|
||||
|
||||
Default: rd_retry=40
|
||||
|
||||
.SS Debug
|
||||
.TP
|
||||
.B rdinfo
|
||||
print informational output though "quiet" is set
|
||||
.TP
|
||||
.B rdshell
|
||||
allow dropping to a shell, if root mounting fails
|
||||
.TP
|
||||
.B rdinitdebug
|
||||
set -x for the dracut shell and logs to dmesg, console and /init.log
|
||||
.TP
|
||||
.B rdbreak
|
||||
drop to a shell at the end
|
||||
.TP
|
||||
.ad l
|
||||
.BR rdbreak= \%{cmdline\:|pre-udev\:|pre-trigger\:|initqueue\:|pre-mount\:|mount\:|pre-pivot}
|
||||
.ad
|
||||
drop to a shell on defined breakpoint
|
||||
.TP
|
||||
.B rdudevinfo
|
||||
set udev to loglevel info
|
||||
.TP
|
||||
.B rdudevdebug
|
||||
set udev to loglevel debug
|
||||
|
||||
.SS I18N
|
||||
e.g.
|
||||
LANG=en_US.UTF-8
|
||||
SYSFONT=latarcyrheb-sun16
|
||||
KEYTABLE=de-latin1-nodeadkeys
|
||||
.TP
|
||||
.BR KEYBOARDTYPE= sun|pc
|
||||
will be written to /etc/sysconfig/keyboard in the initramfs
|
||||
.TP
|
||||
.BR KEYTABLE= "<keytable filename>"
|
||||
will be written to /etc/sysconfig/keyboard in the initramfs
|
||||
.TP
|
||||
.BR SYSFONT= "Console font"
|
||||
will be written to /etc/sysconfig/i18n in the initramfs
|
||||
.TP
|
||||
.BR SYSFONTACM= "Unicode font map"
|
||||
will be written to /etc/sysconfig/i18n in the initramfs
|
||||
.TP
|
||||
.BR UNIMAP= "Unicode font map"
|
||||
will be written to /etc/sysconfig/i18n in the initramfs
|
||||
.TP
|
||||
.BR LANG= <locale>
|
||||
will be written to /etc/sysconfig/i18n in the initramfs
|
||||
|
||||
.SS LVM
|
||||
.TP
|
||||
.BR rd_NO_LVM
|
||||
disable LVM detection
|
||||
.TP
|
||||
.BR rd_LVM_VG= "<volume group name>"
|
||||
only activate the volume groups with the given name
|
||||
rd_LVM_VG can be specified multiple times on the kernel command line.
|
||||
.TP
|
||||
.BR rd_LVM_LV= "<logical volume name>"
|
||||
only activate the logical volumes with the given name
|
||||
rd_LVM_LV can be specified multiple times on the kernel command line.
|
||||
.TP
|
||||
.BR rd_NO_LVMCONF
|
||||
remove any /etc/lvm/lvm.conf, which may exist in the initramfs
|
||||
|
||||
.SS "crypto LUKS"
|
||||
.TP
|
||||
.BR rd_NO_LUKS
|
||||
disable crypto LUKS detection
|
||||
.TP
|
||||
.BR rd_LUKS_UUID= "<luks uuid>"
|
||||
only activate the LUKS partitions with the given UUID
|
||||
Any "luks-" of the LUKS UUID is removed before comparing to <luks uuid>.
|
||||
The comparisons also matches, if <luks uuid> is only the beginning of the
|
||||
LUKS UUID, so you don't have to specify the full UUID.
|
||||
This parameter can be specified multiple times.
|
||||
.TP
|
||||
.BR rd_NO_CRYPTTAB
|
||||
do not check, if LUKS partition is in /etc/crypttab
|
||||
|
||||
.SS MD
|
||||
.TP
|
||||
.BR rd_NO_MD
|
||||
disable MD RAID detection
|
||||
.TP
|
||||
.BR rd_NO_MDIMSM
|
||||
no MD RAID for imsm/isw raids, use dmraid instead
|
||||
.TP
|
||||
.BR rd_NO_MDADMCONF
|
||||
ignore mdadm.conf included in initramfs
|
||||
.TP
|
||||
.BR rd_MD_UUID= "<md uuid>"
|
||||
only activate the raid sets with the given UUID.
|
||||
This parameter can be specified multiple times.
|
||||
|
||||
.SS DMRAID
|
||||
.TP
|
||||
.BR rd_NO_DM
|
||||
disable DM RAID detection
|
||||
.TP
|
||||
.BR rd_DM_UUID= "<dmraid uuid>"
|
||||
only activate the raid sets with the given UUID.
|
||||
This parameter can be specified multiple times.
|
||||
|
||||
.SS MULTIPATH
|
||||
.TP
|
||||
.BR rd_NO_MULTIPATH
|
||||
disable multipath in the initramfs
|
||||
|
||||
.SS FIPS
|
||||
.TP
|
||||
.BR fips=1
|
||||
enable FIPS
|
||||
.TP
|
||||
.BR boot=<boot device>
|
||||
specify the device, where /boot is located
|
||||
e.g.
|
||||
boot=/dev/sda1
|
||||
boot=/dev/disk/by-path/pci-0000:00:1f.1-scsi-0:0:1:0-part1
|
||||
boot=UUID=<uuid>
|
||||
boot=LABEL=<label>
|
||||
|
||||
If the root device is encrypted, the /boot partition must reside on a seperate partition and has to be specified.
|
||||
|
||||
.SS Network
|
||||
.TP
|
||||
.BR ip= {dhcp|on|any|dhcp6|auto6|ibft}
|
||||
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.
|
||||
.sp
|
||||
\fBauto6\fR: IPv6 autoconfiguration
|
||||
.sp
|
||||
\fBdhcp6\fR: IPv6 DHCP
|
||||
.sp
|
||||
\fBibft\fR: iBFT autoconfiguration
|
||||
|
||||
.TP
|
||||
.BR ip= <interface>:{dhcp|on|any|dhcp6|auto6}
|
||||
dhcp|on|any|dhcp6: get ip from dhcp server on a specific interface
|
||||
auto6: do IPv6 autoconfiguration
|
||||
This parameter can be specified multiple times.
|
||||
|
||||
.TP
|
||||
.ad l
|
||||
.BR ip= "\%<client-IP>\::[<server-id>]\::<gateway-IP>\::<netmask>\::<client\%hostname>\::<interface>\::{none|off}"
|
||||
.ad
|
||||
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.
|
||||
.TP
|
||||
.BR ifname= <interface>:<MAC>
|
||||
Assign network device name <interface> (ie eth0) to the NIC with MAC <MAC>.
|
||||
Note that if you use this option you \fBmust\fR specify an ifname= argument
|
||||
for all interfaces used in ip= or fcoe= arguments
|
||||
This parameter can be specified multiple times.
|
||||
.TP
|
||||
.BR bootdev= <interface>
|
||||
specify network interface to use routing and netroot information from.
|
||||
Required if multiple ip= lines are used.
|
||||
.TP
|
||||
.BR nameserver= "<IP> [nameserver=<IP> ...]"
|
||||
specify nameserver(s) to use
|
||||
.TP
|
||||
.BR vlan= "<vlanname>:<phydevice>"
|
||||
Setup vlan device named <vlanname> on <phydeivce>.
|
||||
We support the four styles of vlan names: VLAN_PLUS_VID (vlan0005), VLAN_PLUS_VID_NO_PAD (vlan5),
|
||||
DEV_PLUS_VID (eth0.0005), DEV_PLUS_VID_NO_PAD (eth0.5)
|
||||
This parameter can be specified multiple times.
|
||||
.TP
|
||||
.BR bridge= "<bridgename>:<ethnames>"
|
||||
Setup bridge <bridgename> with <ethnames>\&. <ethnames> is a comma\-separated list of physical (ethernet) interfaces\&. Bridge without parameters assumes bridge=br0:eth0
|
||||
.TP
|
||||
.BR bond= "<bondname>[:<bondslaves>:[:<options>]]"
|
||||
Setup bonding device <bondname> on top of <bondslaves>\&. <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\&. If <options> includes multi\-valued arp_ip_target option, then its values should be separated by semicolon\&. Bond without parameters assumes bond=bond0:eth0,eth1:mode=balance\-rr
|
||||
.TP
|
||||
.BR biosdevname={0|1]}
|
||||
turn off/on biosdevname network interface renaming
|
||||
.SS NFS
|
||||
.TP
|
||||
.BR root= "[<server-ip>:]<root-dir>[:<nfs-options>]"
|
||||
mount nfs share from <server-ip>:/<root-dir>, if no server-ip is given,
|
||||
use dhcp next_server. if server-ip is an IPv6 address it has to be put in brackets, e.g. [2001:DB8::1].
|
||||
NFS options can be appended with the prefix ":" or "," and are seperated by ",".
|
||||
.TP
|
||||
.BR root= "nfs:[<server-ip>:]<root-dir>[:<nfs-options>]"
|
||||
.TP
|
||||
.BR root= "nfs4:[<server-ip>:]<root-dir>[:<nfs-options>]"
|
||||
.TP
|
||||
.BR root= dhcp|dhcp6
|
||||
root=dhcp alone directs initrd to look at the DHCP root-path where NFS
|
||||
options can be specified.
|
||||
root-path=<server-ip>:<root-dir>[,<nfs-options>]
|
||||
root-path=nfs:<server-ip>:<root-dir>[,<nfs-options>]
|
||||
root-path=nfs4:<server-ip>:<root-dir>[,<nfs-options>]
|
||||
.TP
|
||||
.BR root= /dev/nfs " nfsroot=" "[<server-ip>:]<root-dir>[,<nfs-options>]"
|
||||
\fBDeprecated!\fR kernel Documentation/filesystems/nfsroot.txt defines
|
||||
this method.
|
||||
This is supported by dracut but not recommended.
|
||||
.TP
|
||||
.BR rd_NFS_DOMAIN= "<NFSv4 domain name>"
|
||||
Set the NFSv4 domain name. Will overwrite the settings in /etc/idmap.conf.
|
||||
|
||||
.SS iSCSI
|
||||
.TP
|
||||
.ad l
|
||||
.BR root= "\%iscsi:[username:password\:[:reverse:password]@]\:[<servername>]\::[<protocol>]\::[<port>]\:[:[<iscsi_iface_name>]:[<netdev_name>]]\::[<LUN>]\::<targetname>"
|
||||
.ad
|
||||
protocol defaults to "6", LUN defaults to "0".
|
||||
|
||||
If the "servername" field is provided by BOOTP or DHCP, then that
|
||||
field is used in conjunction with other associated fields to contact
|
||||
the boot server in the Boot stage (Section 7). However, if the
|
||||
"servername" field is not provided, then the "targetname" field is
|
||||
then used in the Discovery Service stage in conjunction with other
|
||||
associated fields.
|
||||
|
||||
http://tools.ietf.org/html/rfc4173
|
||||
|
||||
.TP
|
||||
.ad l
|
||||
.BR root= "\%iscsi:[username:password\:[:reverse:password]@]\:[<servername>]\::[<protocol>]\::[<port>]\:[:[<iscsi_iface_name>]:[<netdev_name>]]\::[<LUN>]\::<targetname>"
|
||||
.ad
|
||||
e.g. root=iscsi:192.168.50.1::::iqn.2009-06.dracut:target0
|
||||
|
||||
.ad l
|
||||
If servername is an IPv6 address, it has to be put in brackets.
|
||||
e.g.
|
||||
root=iscsi:[2001:DB8::1]::::iqn.2009-06.dracut:target0
|
||||
.TP
|
||||
.ad l
|
||||
.BR root= ??? " netroot=" "\%iscsi:[username:password[:reverse:password]@]\:[<servername>]\::[<protocol>]\::[<port>]\:[:[<iscsi_iface_name>]:[<netdev_name>]]\::[<LUN>]\::<targetname> ..."
|
||||
.ad
|
||||
multiple netroot options allow setting up multiple iscsi disks
|
||||
e.g.
|
||||
root=UUID=12424547
|
||||
netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target0
|
||||
netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target1
|
||||
|
||||
.ad l
|
||||
If servername is an IPv6 address, it has to be put in brackets.
|
||||
e.g.
|
||||
netroot=iscsi:[2001:DB8::1]::::iqn.2009-06.dracut:target0
|
||||
.TP
|
||||
.ad l
|
||||
.BR \%root= \%??? " \%iscsi_initiator=" \%<initiator> " \%iscsi_target_name=" "<target name>" " \%iscsi_target_ip=" "<target ip>" " \%iscsi_target_port=" "<target port>" " \%iscsi_target_group=" "<target group>" " \%iscsi_username=" "<username>" " \%iscsi_password=" <password> " \%iscsi_in_username=" "<in username>" " \%iscsi_in_password=" "<in password>"
|
||||
.ad
|
||||
manually specify all iscsistart parameter (see \fIiscsistart\ --help\fR)
|
||||
|
||||
.TP
|
||||
.BR root= ??? " netroot=iscsi iscsi_firmware"
|
||||
will read the iscsi parameter from the BIOS firmware
|
||||
|
||||
.TP
|
||||
.BR iscsi_param= <param>
|
||||
<param> will be passed as "--param <param>" to iscsistart.
|
||||
This parameter can be specified multiple times.
|
||||
e.g.:
|
||||
"netroot=iscsi iscsi_firmware iscsi_param=node.session.timeo.replacement_timeout=30"
|
||||
will result in
|
||||
iscsistart -b --param node.session.timeo.replacement_timeout=30
|
||||
|
||||
.SS FCoE
|
||||
.TP
|
||||
.BR fcoe=<edd|interface|MAC>:<dcb|nodcb>
|
||||
Try to connect to a FCoE SAN through the NIC specified by <interface> or <MAC> or EDD settings.
|
||||
This parameter can be specified multiple times.
|
||||
|
||||
.SS NBD
|
||||
.TP
|
||||
.BR root= nbd:<server>:<port>[:<fstype>][:<mountopts>]
|
||||
mount nbd share from <server>
|
||||
.TP
|
||||
.BR root= dhcp
|
||||
with dhcp root-path=nbd:<server>:<port>[:<fstype>][:<mountopts>]
|
||||
root=dhcp alone directs initrd to look at the DHCP root-path where NBD
|
||||
options can be specified.
|
||||
This syntax is only usable in cases where you are directly mounting the volume
|
||||
as the rootfs.
|
||||
|
||||
|
||||
.SS DASD
|
||||
.TP
|
||||
.BR rd_DASD_MOD= ....
|
||||
same syntax as the kernel module parameter (s390 only)
|
||||
|
||||
.TP
|
||||
.ad l
|
||||
.BR rd_DASD= "\%<dasd adaptor device bus ID>\:[,readonly=X]\:[,use_diag=X]\:[,erplog=X]\:[,failfast=X]"
|
||||
.ad
|
||||
activate DASD device with the given adaptor device bus ID and setting the sysfs attributes
|
||||
to the specified values
|
||||
This parameter can be specified multiple times.
|
||||
|
||||
.SS ZFCP
|
||||
.TP
|
||||
.BR rd_ZFCP= "<zfcp adaptor device bus ID>,\:<WWPN>,\:<FCPLUN>"
|
||||
rd_ZFCP can be specified multiple times on the kernel command line.
|
||||
|
||||
example: rd_ZFCP=0.0.4000,0x5005076300C213e9,0x5022000000000000
|
||||
.TP
|
||||
.BR rd_NO_ZFCPCONF
|
||||
ignore zfcp.conf included in the initramfs
|
||||
|
||||
.SS ZNET
|
||||
.TP
|
||||
.BR rd_ZNET= "<nettype>,<subchannels>,<options>"
|
||||
rd_ZNET can be specified multiple times on the kernel command line. Examples:
|
||||
rd_ZNET=qeth,0.0.0600,0.0.0601,0.0.0602,layer2=1,portname=foo
|
||||
rd_ZNET=ctc,0.0.0600,0.0.0601,0.0.0602,protocol=bar
|
||||
|
||||
.SS "Plymouth Boot Splash"
|
||||
.TP
|
||||
.BR rd_NO_PLYMOUTH
|
||||
do not start plymouth. This will not work with encrypted partitions.
|
||||
|
||||
.SH FILES
|
||||
.TP
|
||||
.B /var/log/dracut.log
|
||||
.TP
|
||||
.B /etc/dracut.conf
|
||||
see \fBdracut.conf\fR(5)
|
||||
.SS "Configuration in the Initramfs"
|
||||
.TP
|
||||
.B /etc/conf.d/
|
||||
Any files found in /etc/conf.d/ will be sourced in the initramfs to
|
||||
set initial values. Command line options will override these values
|
||||
set in the configuration files.
|
||||
.TP
|
||||
.B /etc/cmdline
|
||||
Can contain additional command line options.
|
||||
|
||||
.SH AUTHORS
|
||||
.nf
|
||||
Harald Hoyer <harald@redhat.com>
|
||||
Victor Lowther <victor.lowther@gmail.com>
|
||||
Warren Togami <wtogami@redhat.com>
|
||||
Jeremy Katz <katzj@redhat.com>
|
||||
Philippe Seewer <philippe.seewer@bfh.ch>
|
||||
David Dillow <dave@thedillows.org>
|
||||
.fi
|
||||
.SH AVAILABILITY
|
||||
The dracut command is part of the dracut package and is available from
|
||||
http://sourceforge.net/apps/trac/dracut/wiki
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR dracut.conf (5)
|
529
dracut.8.asc
529
dracut.8.asc
@@ -1,529 +0,0 @@
|
||||
DRACUT(8)
|
||||
=========
|
||||
:doctype: manpage
|
||||
:man source: dracut
|
||||
:man manual: dracut
|
||||
|
||||
NAME
|
||||
----
|
||||
dracut - low-level tool for generating an initramfs image
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
*dracut* [__OPTION...__] [__<image>__ [__<kernel version>__]]
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
||||
Create an initramfs <image> for the kernel with the version <kernel version>.
|
||||
If <kernel version> is omitted, then the version of the actual running
|
||||
kernel is used. If <image> is omitted or empty, then the default location
|
||||
/boot/initramfs-<kernel version>.img is used.
|
||||
|
||||
dracut creates an initial image used by the kernel for preloading the block
|
||||
device modules (such as IDE, SCSI or RAID) which are needed to access the root
|
||||
filesystem, mounting the root filesystem and booting into the real system.
|
||||
|
||||
At boot time, the kernel unpacks that archive into RAM disk, mounts and uses it
|
||||
as initial root file system. All finding of the root device happens in this
|
||||
early userspace.
|
||||
|
||||
For a complete list of kernel command line options see *dracut.cmdline*(7).
|
||||
|
||||
If you are dropped to an emergency shell, while booting your initramfs,
|
||||
the file _/run/initramfs/rdsosreport.txt_ is created, which can be safed to a
|
||||
(to be mounted by hand) partition (usually /boot) or a USB stick.
|
||||
Additional debugging info can be produced by adding **rd.debug** to the kernel
|
||||
command line. _/run/initramfs/rdsosreport.txt_ contains all logs and the output
|
||||
of some tools. It should be attached to any report about dracut problems.
|
||||
|
||||
USAGE
|
||||
-----
|
||||
|
||||
include::dracut.usage.asc[]
|
||||
|
||||
OPTIONS
|
||||
-------
|
||||
**--kver** _<kernel version>_::
|
||||
set the kernel version. This enables to specify the kernel version, without
|
||||
specifying the location of the initramfs image. For example:
|
||||
----
|
||||
# dracut --kver 3.5.0-0.rc7.git1.2.fc18.x86_64
|
||||
----
|
||||
|
||||
**-f, --force**::
|
||||
overwrite existing initramfs file.
|
||||
|
||||
**-m, --modules** _<list of 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_. This
|
||||
parameter can be specified multiple times.
|
||||
+
|
||||
[NOTE]
|
||||
===============================
|
||||
If [LIST] has multiple arguments, then you have to put these in quotes. For
|
||||
example:
|
||||
----
|
||||
# dracut --modules "module1 module2" ...
|
||||
----
|
||||
===============================
|
||||
|
||||
**-o, --omit** _<list of dracut modules>_::
|
||||
omit a space-separated list of dracut modules. This parameter can be
|
||||
specified multiple times.
|
||||
+
|
||||
[NOTE]
|
||||
===============================
|
||||
If [LIST] has multiple arguments, then you have to put these in quotes. For
|
||||
example:
|
||||
----
|
||||
# dracut --omit "module1 module2" ...
|
||||
----
|
||||
===============================
|
||||
|
||||
**-a, --add** _<list of dracut modules>_::
|
||||
add a space-separated list of dracut modules to the default set of modules.
|
||||
This parameter can be specified multiple times.
|
||||
+
|
||||
[NOTE]
|
||||
===============================
|
||||
If [LIST] has multiple arguments, then you have to put these in quotes. For
|
||||
example:
|
||||
----
|
||||
# dracut --add "module1 module2" ...
|
||||
----
|
||||
===============================
|
||||
|
||||
**--force-add** _<list of dracut modules>_::
|
||||
force to add a space-separated list of dracut modules to the default set of
|
||||
modules, when -H is specified. This parameter can be specified multiple
|
||||
times.
|
||||
+
|
||||
[NOTE]
|
||||
===============================
|
||||
If [LIST] has multiple arguments, then you have to put these in quotes. For
|
||||
example:
|
||||
----
|
||||
# dracut --force-add "module1 module2" ...
|
||||
----
|
||||
===============================
|
||||
|
||||
**-d, --drivers** _<list of kernel modules>_::
|
||||
specify a space-separated list of kernel modules to exclusively include
|
||||
in the initramfs. The kernel modules have to be specified without the ".ko"
|
||||
suffix. This parameter can be specified multiple times.
|
||||
+
|
||||
[NOTE]
|
||||
===============================
|
||||
If [LIST] has multiple arguments, then you have to put these in quotes. For
|
||||
example:
|
||||
----
|
||||
# dracut --drivers "kmodule1 kmodule2" ...
|
||||
----
|
||||
===============================
|
||||
|
||||
**--add-drivers** _<list of kernel modules>_::
|
||||
specify a space-separated list of kernel modules to add to the initramfs.
|
||||
The kernel modules have to be specified without the ".ko" suffix. This
|
||||
parameter can be specified multiple times.
|
||||
+
|
||||
[NOTE]
|
||||
===============================
|
||||
If [LIST] has multiple arguments, then you have to put these in quotes. For
|
||||
example:
|
||||
----
|
||||
# dracut --add-drivers "kmodule1 kmodule2" ...
|
||||
----
|
||||
===============================
|
||||
|
||||
**--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.
|
||||
The kernel modules have to be specified without the ".ko" suffix. This
|
||||
parameter can be specified multiple times.
|
||||
+
|
||||
[NOTE]
|
||||
===============================
|
||||
If [LIST] has multiple arguments, then you have to put these in quotes. For
|
||||
example:
|
||||
----
|
||||
# dracut --omit-drivers "kmodule1 kmodule2" ...
|
||||
----
|
||||
===============================
|
||||
|
||||
**--filesystems** _<list of filesystems>_::
|
||||
specify a space-separated list of kernel filesystem modules to exclusively
|
||||
include in the generic initramfs. This parameter can be specified multiple
|
||||
times.
|
||||
+
|
||||
[NOTE]
|
||||
===============================
|
||||
If [LIST] has multiple arguments, then you have to put these in quotes. For
|
||||
example:
|
||||
----
|
||||
# dracut --filesystems "filesystem1 filesystem2" ...
|
||||
----
|
||||
===============================
|
||||
|
||||
**-k, --kmoddir** _<kernel directory>_::
|
||||
specify the directory, where to look for kernel modules
|
||||
|
||||
**--fwdir** _<dir>[:<dir>...]++_::
|
||||
specify additional directories, where to look for firmwares. This parameter
|
||||
can be specified multiple times.
|
||||
|
||||
**--kernel-cmdline <parameters>**::
|
||||
specify default kernel command line parameters
|
||||
|
||||
|
||||
**--kernel-only**::
|
||||
only install kernel drivers and firmware files
|
||||
|
||||
**--no-kernel**::
|
||||
do not install kernel drivers and firmware files
|
||||
|
||||
**--early-microcode**::
|
||||
Combine early microcode with ramdisk
|
||||
|
||||
**--no-early-microcode**::
|
||||
Do not combine early microcode with ramdisk
|
||||
|
||||
**--print-cmdline**::
|
||||
print the kernel command line for the current disk layout
|
||||
|
||||
**--mdadmconf**::
|
||||
include local _/etc/mdadm.conf_
|
||||
|
||||
**--nomdadmconf**::
|
||||
do not include local _/etc/mdadm.conf_
|
||||
|
||||
**--lvmconf**::
|
||||
include local _/etc/lvm/lvm.conf_
|
||||
|
||||
**--nolvmconf**::
|
||||
do not include local _/etc/lvm/lvm.conf_
|
||||
|
||||
**--fscks** [LIST]::
|
||||
add a space-separated list of fsck tools, in addition to _dracut.conf_'s
|
||||
specification; the installation is opportunistic (non-existing tools are
|
||||
ignored)
|
||||
+
|
||||
[NOTE]
|
||||
===============================
|
||||
If [LIST] has multiple arguments, then you have to put these in quotes. For
|
||||
example:
|
||||
----
|
||||
# dracut --fscks "fsck.foo barfsck" ...
|
||||
----
|
||||
===============================
|
||||
|
||||
**--nofscks**::
|
||||
inhibit installation of any fsck tools
|
||||
|
||||
**--strip**::
|
||||
strip binaries in the initramfs (default)
|
||||
|
||||
**--nostrip**::
|
||||
do not strip binaries in the initramfs
|
||||
|
||||
**--prelink**::
|
||||
prelink binaries in the initramfs (default)
|
||||
|
||||
**--noprelink**::
|
||||
do not prelink binaries in the initramfs
|
||||
|
||||
**--hardlink**::
|
||||
hardlink files in the initramfs (default)
|
||||
|
||||
**--nohardlink**::
|
||||
do not hardlink files in the initramfs
|
||||
|
||||
**--prefix** _<dir>_::
|
||||
prefix initramfs files with the specified directory
|
||||
|
||||
**--noprefix**::
|
||||
do not prefix initramfs files (default)
|
||||
|
||||
**-h, --help**::
|
||||
display help text and exit.
|
||||
|
||||
**--debug**::
|
||||
output debug information of the build process
|
||||
|
||||
**-v, --verbose**::
|
||||
increase verbosity level (default is info(4))
|
||||
|
||||
**-q, --quiet**:: decrease verbosity level (default is info(4))
|
||||
|
||||
**-c, --conf** _<dracut configuration file>_::
|
||||
specify configuration file to use.
|
||||
+
|
||||
Default:
|
||||
_/etc/dracut.conf_
|
||||
|
||||
**--confdir** _<configuration directory>_::
|
||||
specify configuration directory to use.
|
||||
+
|
||||
Default:
|
||||
_/etc/dracut.conf.d_
|
||||
|
||||
**--tmpdir** _<temporary directory>_::
|
||||
specify temporary directory to use.
|
||||
+
|
||||
Default:
|
||||
_/var/tmp_
|
||||
|
||||
**--sshkey** _<sshkey file>_:: ssh key file used with ssh-client module.
|
||||
|
||||
**--logfile** _<logfile>_:: logfile to use; overrides any setting from
|
||||
the configuration files.
|
||||
+
|
||||
Default:
|
||||
_/var/log/dracut.log_
|
||||
|
||||
**-l, --local**::
|
||||
activates the local mode. dracut will use modules from the current working
|
||||
directory instead of the system-wide installed modules in
|
||||
_/usr/lib/dracut/modules.d_.
|
||||
This is useful when running dracut from a git checkout.
|
||||
|
||||
**-H, --hostonly**::
|
||||
Host-Only mode: Install only what is needed for booting the local host
|
||||
instead of a generic host and generate host-specific configuration.
|
||||
+
|
||||
[WARNING]
|
||||
====
|
||||
If chrooted to another root other than the real root device, use "--fstab" and
|
||||
provide a valid _/etc/fstab_.
|
||||
====
|
||||
|
||||
**-N, --no-hostonly**::
|
||||
Disable Host-Only mode
|
||||
|
||||
**--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.
|
||||
E.g. "by-uuid", "by-label"
|
||||
|
||||
**--fstab**::
|
||||
Use _/etc/fstab_ instead of _/proc/self/mountinfo_.
|
||||
|
||||
**--add-fstab** _<filename>_::
|
||||
Add entries of _<filename>_ to the initramfs /etc/fstab.
|
||||
|
||||
**--mount** "_<device>_ _<mountpoint>_ _<filesystem type>_ [_<filesystem options>_ [_<dump frequency>_ [_<fsck order>_]]]"::
|
||||
Mount _<device>_ on _<mountpoint>_ with _<filesystem type>_ in the
|
||||
initramfs. _<filesystem options>_, _<dump options>_ and _<fsck order>_ can
|
||||
be specified, see fstab manpage for the details.
|
||||
The default _<filesystem options>_ is "defaults".
|
||||
The default _<dump frequency>_ is "0".
|
||||
the default _<fsck order>_ is "2".
|
||||
|
||||
**--add-device** _<device>_ ::
|
||||
Bring up _<device>_ in initramfs, _<device>_ should be the device name.
|
||||
This can be useful in hostonly mode for resume support when your swap is on
|
||||
LVM or an encrypted partition.
|
||||
[NB --device can be used for compatibility with earlier releases]
|
||||
|
||||
**-i, --include** _<SOURCE>_ _<TARGET>_::
|
||||
include the files in the SOURCE directory into the
|
||||
TARGET directory in the final initramfs. If SOURCE is a file, it will be
|
||||
installed to TARGET in the final initramfs. This parameter can be specified
|
||||
multiple times.
|
||||
|
||||
**-I, --install** _<file list>_::
|
||||
install the space separated list of files into the initramfs.
|
||||
+
|
||||
[NOTE]
|
||||
===============================
|
||||
If [LIST] has multiple arguments, then you have to put these in quotes. For
|
||||
example:
|
||||
----
|
||||
# dracut --install "/bin/foo /sbin/bar" ...
|
||||
----
|
||||
===============================
|
||||
|
||||
**--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
|
||||
"--compress=gzip -9"
|
||||
|
||||
**--bzip2**::
|
||||
Compress the generated initramfs using bzip2.
|
||||
+
|
||||
[WARNING]
|
||||
====
|
||||
Make sure your kernel has bzip2 decompression support compiled in, otherwise you
|
||||
will not be able to boot. Equivalent to "--compress=bzip2"
|
||||
====
|
||||
|
||||
**--lzma**::
|
||||
Compress the generated initramfs using lzma.
|
||||
+
|
||||
[WARNING]
|
||||
====
|
||||
Make sure your kernel has lzma decompression support compiled in, otherwise you
|
||||
will not be able to boot. Equivalent to "lzma --compress=lzma -9"
|
||||
====
|
||||
|
||||
**--xz**::
|
||||
Compress the generated initramfs using xz.
|
||||
+
|
||||
[WARNING]
|
||||
====
|
||||
Make sure your kernel has xz decompression support compiled in, otherwise you
|
||||
will not be able to boot. Equivalent to
|
||||
"lzma --compress=xz --check=crc32 --lzma2=dict=1MiB"
|
||||
====
|
||||
|
||||
**--lzo**::
|
||||
Compress the generated initramfs using lzop.
|
||||
[WARNING]
|
||||
====
|
||||
Make sure your kernel has lzo decompression support compiled in, otherwise you
|
||||
will not be able to boot.
|
||||
====
|
||||
|
||||
**--lz4**::
|
||||
Compress the generated initramfs using lz4.
|
||||
[WARNING]
|
||||
====
|
||||
Make sure your kernel has lz4 decompression support compiled in, otherwise you
|
||||
will not be able to boot.
|
||||
====
|
||||
|
||||
**--compress** _<compressor>_::
|
||||
Compress the generated initramfs using the passed compression program. If
|
||||
you pass it just the name of a compression program, it will call that
|
||||
program with known-working arguments. If you pass a quoted string with
|
||||
arguments, it will be called with exactly those arguments. Depending on what
|
||||
you pass, this may result in an initramfs that the kernel cannot decompress.
|
||||
|
||||
**--no-compress**::
|
||||
Do not compress the generated initramfs. This will override any other
|
||||
compression options.
|
||||
|
||||
**--list-modules**::
|
||||
List all available dracut modules.
|
||||
|
||||
**-M, --show-modules**::
|
||||
Print included module's name to standard output during build.
|
||||
|
||||
**--keep**::
|
||||
Keep the initramfs temporary directory for debugging purposes.
|
||||
|
||||
**--printsize**::
|
||||
Print out the module install size
|
||||
|
||||
**--profile**:
|
||||
Output profile information of the build process
|
||||
|
||||
**--ro-mnt**:
|
||||
Mount / and /usr read-only by default.
|
||||
|
||||
**-L, --stdlog** _<level>_::
|
||||
[0-6] Specify logging level (to standard error)
|
||||
----
|
||||
0 - suppress any messages
|
||||
1 - only fatal errors
|
||||
2 - all errors
|
||||
3 - warnings
|
||||
4 - info
|
||||
5 - debug info (here starts lots of output)
|
||||
6 - trace info (and even more)
|
||||
----
|
||||
|
||||
**--regenerate-all**::
|
||||
Regenerate all initramfs images at the default location with the kernel
|
||||
versions found on the system. Additional parameters are passed through.
|
||||
|
||||
FILES
|
||||
-----
|
||||
_/var/log/dracut.log_::
|
||||
logfile of initramfs image creation
|
||||
|
||||
_/tmp/dracut.log_::
|
||||
logfile of initramfs image creation, if _/var/log/dracut.log_ is not
|
||||
writable
|
||||
|
||||
_/etc/dracut.conf_::
|
||||
see dracut.conf5
|
||||
|
||||
_/etc/dracut.conf.d/*.conf_::
|
||||
see dracut.conf5
|
||||
|
||||
_/usr/lib/dracut/dracut.conf.d/*.conf_::
|
||||
see dracut.conf5
|
||||
|
||||
Configuration in the initramfs
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
_/etc/conf.d/_::
|
||||
Any files found in _/etc/conf.d/_ will be sourced in the initramfs to
|
||||
set initial values. Command line options will override these values
|
||||
set in the configuration files.
|
||||
|
||||
_/etc/cmdline_::
|
||||
Can contain additional command line options. Deprecated, better use
|
||||
/etc/cmdline.d/*.conf.
|
||||
|
||||
_/etc/cmdline.d/*.conf_::
|
||||
Can contain additional command line options.
|
||||
|
||||
AVAILABILITY
|
||||
------------
|
||||
The dracut command is part of the dracut package and is available from
|
||||
link:$$https://dracut.wiki.kernel.org$$[https://dracut.wiki.kernel.org]
|
||||
|
||||
AUTHORS
|
||||
-------
|
||||
Harald Hoyer
|
||||
|
||||
Victor Lowther
|
||||
|
||||
Philippe Seewer
|
||||
|
||||
Warren Togami
|
||||
|
||||
Amadeusz Żołnowski
|
||||
|
||||
Jeremy Katz
|
||||
|
||||
David Dillow
|
||||
|
||||
Will Woods
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
*dracut.cmdline*(7) *dracut.conf*(5)
|
185
dracut.asc
185
dracut.asc
@@ -1,185 +0,0 @@
|
||||
dracut
|
||||
======
|
||||
Harald Hoyer <harald@redhat.com>
|
||||
v3.0, October 2013
|
||||
|
||||
:language: bash
|
||||
|
||||
= Introduction
|
||||
This section is a modified version of
|
||||
http://en.wikipedia.org/wiki/Initrd which is licensed under the
|
||||
Creative Commons Attribution/Share-Alike License.
|
||||
|
||||
== Definition
|
||||
An _initial ramdisk_ is a temporary file system used in the boot process of the
|
||||
Linux kernel. _initrd_ and _initramfs_ refer to slightly different schemes for
|
||||
loading this file system into memory. Both are commonly used to make
|
||||
preparations before the real root file system can be mounted.
|
||||
|
||||
== Rationale
|
||||
Many Linux distributions ship a single, generic kernel image that is intended to
|
||||
boot as wide a variety of hardware as possible. The device drivers for this
|
||||
generic kernel image are included as loadable modules, as it is not possible to
|
||||
statically compile them all into the one kernel without making it too large to
|
||||
boot from computers with limited memory or from lower-capacity media like floppy
|
||||
disks.
|
||||
|
||||
This then raises the problem of detecting and loading the modules necessary to
|
||||
mount the root file system at boot time (or, for that matter, deducing where or
|
||||
what the root file system is).
|
||||
|
||||
To further complicate matters, the root file system may be on a software RAID
|
||||
volume, LVM, NFS (on diskless workstations), or on an encrypted partition. All
|
||||
of these require special preparations to mount.
|
||||
|
||||
Another complication is kernel support for hibernation, which suspends the
|
||||
computer to disk by dumping an image of the entire system to a swap partition or
|
||||
a regular file, then powering off. On next boot, this image has to be made
|
||||
accessible before it can be loaded back into memory.
|
||||
|
||||
To avoid having to hardcode handling for so many special cases into the kernel,
|
||||
an initial boot stage with a temporary root file system
|
||||
—now dubbed early user space— is used. This root file system would contain
|
||||
user-space helpers that would do the hardware detection, module loading and
|
||||
device discovery necessary to get the real root file system mounted.
|
||||
|
||||
== Implementation
|
||||
An image of this initial root file system (along with the kernel image) must be
|
||||
stored somewhere accessible by the Linux bootloader or the boot firmware of the
|
||||
computer. This can be:
|
||||
|
||||
* The root file system itself
|
||||
* A boot image on an optical disc
|
||||
* A small ext2/ext3 or FAT-formatted partition on a local disk
|
||||
(a _boot partition_)
|
||||
* A TFTP server (on systems that can boot from Ethernet)
|
||||
|
||||
The bootloader will load the kernel and initial root file system image into
|
||||
memory and then start the kernel, passing in the memory address of the image.
|
||||
|
||||
Depending on which algorithms were compiled statically into it, the kernel can
|
||||
currently unpack initrd/initramfs images compressed with gzip, bzip2 and LZMA.
|
||||
|
||||
== Mount preparations
|
||||
dracut can generate a customized initrams image which contains only whatever is
|
||||
necessary to boot some particular computer, such as ATA, SCSI and filesystem
|
||||
kernel modules (host-only mode).
|
||||
|
||||
dracut can also generate a more generic initramfs image (default mode).
|
||||
|
||||
dracut's initramfs starts only with the device name of the root file system (or
|
||||
its UUID) and must discover everything else at boot time. A complex cascade of
|
||||
tasks must be performed to get the root file system mounted:
|
||||
|
||||
* Any hardware drivers that the boot process depends on must be loaded. All
|
||||
kernel modules for common storage devices are packed onto the initramfs and then
|
||||
udev pulls in modules matching the computer's detected hardware.
|
||||
|
||||
* On systems which display a boot rd.splash screen, the video hardware must be
|
||||
initialized and a user-space helper started to paint animations onto the display
|
||||
in lockstep with the boot process.
|
||||
|
||||
* If the root file system is on NFS, dracut does then:
|
||||
** Bring up the primary network interface.
|
||||
** Invoke a DHCP client, with which it can obtain a DHCP lease.
|
||||
** Extract the name of the NFS share and the address of the NFS server from the
|
||||
lease.
|
||||
** Mount the NFS share.
|
||||
|
||||
* If the root file system appears to be on a software RAID device, there is no
|
||||
way of knowing which devices the RAID volume spans; the standard MD utilities
|
||||
must be invoked to scan all available block devices with a raid signature and
|
||||
bring the required ones online.
|
||||
|
||||
* If the root file system appears to be on a logical volume, the LVM utilities
|
||||
must be invoked to scan for and activate the volume group containing it.
|
||||
|
||||
* If the root file system is on an encrypted block device:
|
||||
** Invoke a helper script to prompt the user to type in a passphrase and/or
|
||||
insert a hardware token (such as a smart card or a USB security dongle).
|
||||
|
||||
* Create a decryption target with the device mapper.
|
||||
|
||||
dracut uses udev, an event-driven hotplug agent, which invokes helper programs
|
||||
as hardware devices, disk partitions and storage volumes matching certain rules
|
||||
come online. This allows discovery to run in parallel, and to progressively
|
||||
cascade into arbitrary nestings of LVM, RAID or encryption to get at the root
|
||||
file system.
|
||||
|
||||
When the root file system finally becomes visible:
|
||||
|
||||
* Any maintenance tasks which cannot run on a mounted root file system
|
||||
are done.
|
||||
* The root file system is mounted read-only.
|
||||
* Any processes which must continue running (such as the rd.splash screen helper
|
||||
and its command FIFO) are hoisted into the newly-mounted root file system.
|
||||
|
||||
The final root file system cannot simply be mounted over /, since that would
|
||||
make the scripts and tools on the initial root file system inaccessible for any
|
||||
final cleanup tasks. On an initramfs, the initial root file system cannot be
|
||||
rotated away. Instead, it is simply emptied and the final root file system
|
||||
mounted over the top.
|
||||
|
||||
If the systemd module is used in the initramfs, the ordering of the services
|
||||
started looks like <<dracutbootup7>>.
|
||||
|
||||
== Dracut on shutdown
|
||||
|
||||
On a systemd driven system, the dracut initramfs is also used for the shutdown
|
||||
procedure.
|
||||
|
||||
The following steps are executed during a shutdown:
|
||||
|
||||
* systemd switches to the shutdown.target
|
||||
* systemd starts
|
||||
/lib/systemd/system/shutdown.target.wants/dracut-shutdown.service
|
||||
* dracut-shutdown.service executes /usr/lib/dracut/dracut-initramfs-restore
|
||||
which unpacks the initramfs to /run/initramfs
|
||||
* systemd finishes shutdown.target
|
||||
* systemd kills all processes
|
||||
* systemd tries to unmount everything and mounts the remaining read-only
|
||||
* systemd checks, if there is a /run/initramfs/shutdown executable
|
||||
* if yes, it does a pivot_root to /run/initramfs and executes ./shutdown.
|
||||
The old root is then mounted on /oldroot.
|
||||
/usr/lib/dracut/modules.d/99shutdown/shutdown.sh is the shutdown executable.
|
||||
* shutdown will try to umount every /oldroot mount and calls the various
|
||||
shutdown hooks from the dracut modules
|
||||
|
||||
This ensures, that all devices are disassembled and unmounted cleanly.
|
||||
|
||||
= User Manual
|
||||
|
||||
:leveloffset: 1
|
||||
include::dracut.8.asc[]
|
||||
|
||||
:leveloffset: 1
|
||||
[[dracutconf5]]
|
||||
include::dracut.conf.5.asc[]
|
||||
|
||||
[[dracutcmdline7]]
|
||||
include::dracut.cmdline.7.asc[]
|
||||
|
||||
[[lsinitrd1]]
|
||||
include::lsinitrd.1.asc[]
|
||||
|
||||
[[mkinitrd8]]
|
||||
include::mkinitrd.8.asc[]
|
||||
|
||||
= Developer Manual
|
||||
|
||||
:leveloffset: 1
|
||||
[[dracutmodules7]]
|
||||
include::dracut.modules.7.asc[]
|
||||
|
||||
[[dracutbootup7]]
|
||||
include::dracut.bootup.7.asc[]
|
||||
|
||||
:leveloffset: 0
|
||||
[appendix]
|
||||
License
|
||||
-------
|
||||
This work is licensed under the Creative Commons Attribution/Share-Alike
|
||||
License. To view a copy of this license, visit
|
||||
http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
|
||||
Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
|
||||
|
@@ -1,123 +0,0 @@
|
||||
DRACUT.BOOTUP(7)
|
||||
================
|
||||
:doctype: manpage
|
||||
:man source: dracut
|
||||
:man manual: dracut
|
||||
|
||||
NAME
|
||||
----
|
||||
dracut.bootup - boot ordering in the initramfs
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
||||
This flow chart illustrates the ordering of the services, if systemd is used in
|
||||
the dracut initramfs.
|
||||
----
|
||||
|
||||
systemd-journal.socket
|
||||
|
|
||||
v
|
||||
dracut-cmdline.service
|
||||
|
|
||||
v
|
||||
dracut-pre-udev.service
|
||||
|
|
||||
v
|
||||
systemd-udevd.service
|
||||
|
|
||||
v
|
||||
local-fs-pre.target dracut-pre-trigger.service
|
||||
| |
|
||||
v v
|
||||
(various mounts) (various swap systemd-udev-trigger.service
|
||||
| devices...) | (various low-level (various low-level
|
||||
| | | services: seed, API VFS mounts:
|
||||
v v v tmpfiles, random mqueue, configfs,
|
||||
local-fs.target swap.target dracut-initqueue.service sysctl, ...) debugfs, ...)
|
||||
| | | | |
|
||||
\_______________|____________________ | ___________________|____________________/
|
||||
\|/
|
||||
v
|
||||
sysinit.target
|
||||
|
|
||||
_________________/|\___________________
|
||||
/ | \
|
||||
| | |
|
||||
v | v
|
||||
(various | rescue.service
|
||||
sockets...) | |
|
||||
| | v
|
||||
v | rescue.target
|
||||
sockets.target |
|
||||
| |
|
||||
\_________________ | emergency.service
|
||||
\| |
|
||||
v v
|
||||
basic.target emergency.target
|
||||
|
|
||||
______________________/|
|
||||
/ |
|
||||
| v
|
||||
| dracut-pre-mount.service
|
||||
| |
|
||||
| v
|
||||
| sysroot.mount
|
||||
| |
|
||||
| v
|
||||
| initrd-root-fs.target
|
||||
(custom initrd services) |
|
||||
| v
|
||||
| dracut-mount.service
|
||||
| |
|
||||
| v
|
||||
| initrd-parse-etc.service
|
||||
| |
|
||||
| v
|
||||
| (sysroot-usr.mount and
|
||||
| various mounts marked
|
||||
| with fstab option
|
||||
| x-initrd.mount)
|
||||
| |
|
||||
| v
|
||||
| initrd-fs.target
|
||||
\______________________ |
|
||||
\|
|
||||
v
|
||||
initrd.target
|
||||
|
|
||||
v
|
||||
dracut-pre-pivot.service
|
||||
|
|
||||
v
|
||||
initrd-cleanup.service
|
||||
isolates to
|
||||
initrd-switch-root.target
|
||||
|
|
||||
v
|
||||
______________________/|
|
||||
/ |
|
||||
| initrd-udevadm-cleanup-db.service
|
||||
| |
|
||||
(custom initrd services) |
|
||||
| |
|
||||
\______________________ |
|
||||
\|
|
||||
v
|
||||
initrd-switch-root.target
|
||||
|
|
||||
v
|
||||
initrd-switch-root.service
|
||||
|
|
||||
v
|
||||
switch-root
|
||||
----
|
||||
|
||||
|
||||
AUTHOR
|
||||
------
|
||||
Harald Hoyer
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
*dracut*(8) *bootup*(7)
|
1076
dracut.cmdline.7.asc
1076
dracut.cmdline.7.asc
File diff suppressed because it is too large
Load Diff
35
dracut.conf
35
dracut.conf
@@ -1,21 +1,12 @@
|
||||
# PUT YOUR CONFIG HERE OR IN separate files named *.conf
|
||||
# in /etc/dracut.conf.d
|
||||
# SEE man dracut.conf(5)
|
||||
|
||||
# Sample dracut config file
|
||||
|
||||
#logfile=/var/log/dracut.log
|
||||
#fileloglvl=6
|
||||
|
||||
# Exact list of dracut modules to use. Modules not listed here are not going
|
||||
# to be included. If you only want to add some optional modules use
|
||||
# add_dracutmodules option instead.
|
||||
# Specific list of dracut modules to use
|
||||
#dracutmodules+=""
|
||||
|
||||
# dracut modules to omit
|
||||
# Dracut modules to omit
|
||||
#omit_dracutmodules+=""
|
||||
|
||||
# dracut modules to add to the default
|
||||
# Dracut modules to add to the default
|
||||
#add_dracutmodules+=""
|
||||
|
||||
# additional kernel modules to the default
|
||||
@@ -29,23 +20,7 @@
|
||||
#
|
||||
|
||||
# install local /etc/mdadm.conf
|
||||
#mdadmconf="no"
|
||||
mdadmconf="yes"
|
||||
|
||||
# install local /etc/lvm/lvm.conf
|
||||
#lvmconf="no"
|
||||
|
||||
# A list of fsck tools to install. If it's not specified, module's hardcoded
|
||||
# default is used, currently: "umount mount /sbin/fsck* xfs_db xfs_check
|
||||
# xfs_repair e2fsck jfs_fsck reiserfsck btrfsck". The installation is
|
||||
# opportunistic, so non-existing tools are just ignored.
|
||||
#fscks=""
|
||||
|
||||
# inhibit installation of any fsck tools
|
||||
#nofscks="yes"
|
||||
|
||||
# mount / and /usr read-only by default
|
||||
#ro_mnt="no"
|
||||
|
||||
# set the directory for temporary files
|
||||
# default: /var/tmp
|
||||
#tmpdir=/tmp
|
||||
lvmconf="yes"
|
||||
|
78
dracut.conf.5
Normal file
78
dracut.conf.5
Normal file
@@ -0,0 +1,78 @@
|
||||
.TH DRACUT.CONF 5 "NOV 2009" "Linux"
|
||||
.SH NAME
|
||||
dracut.conf \- configuration file for dracut
|
||||
|
||||
.SH SYNOPSIS
|
||||
\fB/etc/dracut.conf\fR
|
||||
|
||||
.SH DESCRIPTION
|
||||
.B dracut.conf
|
||||
is loaded during the initialisation phase of dracut.
|
||||
Command line parameter will overwrite any values set here.
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.BR dracutmodules+= \%"\ [LIST]\ "
|
||||
Specify a space-separated list of dracut modules to
|
||||
call when building the initramfs. Modules are located
|
||||
in /usr/share/dracut/modules.d.
|
||||
.TP
|
||||
.BR omit_dracutmodules+= \%"\ [LIST]\ "
|
||||
Omit a space-separated list of dracut modules.
|
||||
.TP
|
||||
.BR add_dracutmodules+= \%"\ [LIST]\ "
|
||||
Add a space-separated list of dracut modules.
|
||||
.TP
|
||||
.BR drivers+= \%"\ [LIST]\ "
|
||||
Specify a space-separated list of kernel modules to
|
||||
exclusively include in the initramfs.
|
||||
The kernel modules have to be specified without the ".ko" suffix.
|
||||
.TP
|
||||
.BR add_drivers+= \%"\ [LIST]\ "
|
||||
Specify a space-separated list of kernel
|
||||
modules to add to the initramfs.
|
||||
The kernel modules have to be specified without the ".ko" suffix.
|
||||
.TP
|
||||
.BR omit_drivers+= \%"\ [LIST]\ "
|
||||
Specify a space-separated list of kernel
|
||||
modules to omit from the initramfs.
|
||||
The kernel modules have to be specified without the ".ko" suffix.
|
||||
Regular expressions are also allowed like ".*/fs/foo/.* .*/fs/bar/.*".
|
||||
.TP
|
||||
.BR filesystems+= \%"\ [LIST]\ "
|
||||
Specify a space-separated list of kernel filesystem
|
||||
modules to exclusively include in the generic
|
||||
initramfs.
|
||||
.TP
|
||||
.BR drivers_dir= \%"<dir>"
|
||||
Specify the directory, where to look for kernel modules
|
||||
.TP
|
||||
.BR fw_dir+= \%":<dir>[:<dir>\ ...]"
|
||||
Specify additional directories, where to look for firmwares, separated by :
|
||||
.TP
|
||||
.BR do_strip= \%"yes|no"
|
||||
Strip binaries in the initramfs (default=yes)
|
||||
.TP
|
||||
.BR hostonly= \%"yes|no"
|
||||
Host-Only mode: Install only what is needed for booting
|
||||
the local host instead of a generic host.
|
||||
.TP
|
||||
.BR mdadmconf= \%"yes|no"
|
||||
Include local /etc/mdadm.conf (default=yes)
|
||||
.TP
|
||||
.BR lvmconf= \%"yes|no"
|
||||
Include local /etc/lvm/lvm.conf (default=yes)
|
||||
.TP
|
||||
.BR kernel_only= \%"yes|no"
|
||||
Only install kernel drivers and firmware files. (default=no)
|
||||
.TP
|
||||
.BR no_kernel= \%"yes|no"
|
||||
Do not install kernel drivers and firmware files (default=no)
|
||||
.TP
|
||||
\fBinstall_items+=\fR"\ \&\fI<file>\fR[ \fI<file>\fR\ \&\&...]\ \&"
|
||||
|
||||
Specify additional files to include in the initramfs, separated by spaces.
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR dracut (8)
|
||||
|
@@ -1,212 +0,0 @@
|
||||
DRACUT.CONF(5)
|
||||
==============
|
||||
:doctype: manpage
|
||||
:man source: dracut
|
||||
:man manual: dracut
|
||||
|
||||
NAME
|
||||
----
|
||||
dracut.conf - configuration file(s) for dracut
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
_/etc/dracut.conf_ _/etc/dracut.conf.d/*.conf_
|
||||
_/usr/lib/dracut/dracut.conf.d/*.conf_
|
||||
|
||||
Description
|
||||
-----------
|
||||
_dracut.conf_ is loaded during the initialisation phase of dracut. Command line
|
||||
parameter will overwrite any values set here.
|
||||
|
||||
_*.conf_ files are read from /usr/lib/dracut/dracut.conf.d and
|
||||
/etc/dracut.conf.d. Files with the same name in /etc/dracut.conf.d will replace
|
||||
files in /usr/lib/dracut/dracut.conf.d.
|
||||
The files are then read in alphanumerical order and will overwrite parameters
|
||||
set in _/etc/dracut.conf_. Each line specifies an attribute and a value. A '#'
|
||||
indicates the beginning of a comment; following characters, up to the end of the
|
||||
line are not interpreted.
|
||||
|
||||
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_.
|
||||
|
||||
*omit_dracutmodules+=*" __<dracut modules>__ "::
|
||||
Omit a space-separated list of dracut modules.
|
||||
|
||||
*add_dracutmodules+=*" __<dracut modules>__ "::
|
||||
Add a space-separated list of dracut modules.
|
||||
|
||||
*drivers+=*" __<kernel modules>__ "::
|
||||
Specify a space-separated list of kernel modules to exclusively include in
|
||||
the initramfs. The kernel modules have to be specified without the ".ko"
|
||||
suffix.
|
||||
|
||||
*add_drivers+=*" __<kernel modules>__ "::
|
||||
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.
|
||||
|
||||
*filesystems+=*" __<filesystem names>__ "::
|
||||
Specify a space-separated list of kernel filesystem modules to exclusively
|
||||
include in the generic initramfs.
|
||||
|
||||
*drivers_dir=*"__<kernel modules directory>__"::
|
||||
Specify the directory, where to look for kernel modules
|
||||
|
||||
*fw_dir+=*" :__<dir>__[:__<dir>__ ...] "::
|
||||
Specify additional directories, where to look for firmwares, separated by :
|
||||
|
||||
*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)
|
||||
|
||||
*do_prelink=*"__{yes|no}__"::
|
||||
Prelink binaries in the initramfs (default=yes)
|
||||
|
||||
*hostonly=*"__{yes|no}__"::
|
||||
Host-Only mode: Install only what is needed for booting the local host
|
||||
instead of a generic host and generate host-specific configuration.
|
||||
|
||||
*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.
|
||||
E.g. "by-uuid", "by-label"
|
||||
|
||||
*tmpdir=*"__<temporary directory>__"::
|
||||
Specify temporary directory to use.
|
||||
|
||||
[WARNING]
|
||||
====
|
||||
If chrooted to another root other than the real root device, use --fstab and
|
||||
provide a valid _/etc/fstab_.
|
||||
====
|
||||
|
||||
*use_fstab=*"__{yes|no}__"::
|
||||
Use _/etc/fstab_ instead of _/proc/self/mountinfo_.
|
||||
|
||||
*add_fstab+=*" __<filename>__ "::
|
||||
Add entries of __<filename>__ to the initramfs /etc/fstab.
|
||||
|
||||
*add_device+=*" __<device>__ "::
|
||||
Bring up _<device>_ in initramfs, _<device>_ should be the device name.
|
||||
This can be useful in hostonly mode for resume support when your swap is on
|
||||
LVM an encrypted partition.
|
||||
|
||||
*mdadmconf=*"__{yes|no}__"::
|
||||
Include local _/etc/mdadm.conf_ (default=yes)
|
||||
|
||||
*lvmconf=*"__{yes|no}__"::
|
||||
Include local _/etc/lvm/lvm.conf_ (default=yes)
|
||||
|
||||
*fscks=*" __<fsck tools>__ "::
|
||||
Add a space-separated list of fsck tools. If nothing is specified, the
|
||||
default is: "umount mount /sbin/fsck* xfs_db xfs_check xfs_repair e2fsck
|
||||
jfs_fsck reiserfsck btrfsck". The installation is opportunistic
|
||||
(non-existing tools are ignored).
|
||||
|
||||
*nofscks=*"__{yes|no}__"::
|
||||
If specified, inhibit installation of any fsck tools.
|
||||
|
||||
*ro_mnt=*"__{yes|no}__"::
|
||||
Mount _/_ and _/usr_ read-only by default.
|
||||
|
||||
*kernel_cmdline=*"__parameters__"::
|
||||
Specify default kernel command line parameters
|
||||
|
||||
*kernel_only=*"__{yes|no}__"::
|
||||
Only install kernel drivers and firmware files. (default=no)
|
||||
|
||||
*no_kernel=*"__{yes|no}__"::
|
||||
Do not install kernel drivers and firmware files (default=no)
|
||||
|
||||
*acpi_override=*"__{yes|no}__"::
|
||||
[WARNING] ONLY USE THIS IF YOU KNOW WHAT YOU ARE DOING! +
|
||||
Override BIOS provided ACPI tables. For further documentation read
|
||||
Documentation/acpi/initrd_table_override.txt in the kernel sources.
|
||||
Search for ACPI table files (must have .aml suffix) in acpi_table_dir=
|
||||
directory (see below) and add them to a separate uncompressed cpio
|
||||
archive. This cpio archive gets glued (concatenated, uncompressed one
|
||||
must be the first one) to the compressed cpio archive. The first,
|
||||
uncompressed cpio archive is for data which the kernel must be able
|
||||
to access very early (and cannot make use of uncompress alogrithms yet)
|
||||
like microcode or ACPI tables (default=no).
|
||||
|
||||
*acpi_table_dir=*"__<dir>__"::
|
||||
Directory to search for ACPI tables if acpi_override= is set to yes.
|
||||
|
||||
*early_microcode=*"{yes|no}"::
|
||||
Combine early microcode with ramdisk (default=no)
|
||||
|
||||
*stdloglvl*="__\{0-6\}__"::
|
||||
Set logging to standard error level.
|
||||
|
||||
*sysloglvl*="__\{0-6\}__"::
|
||||
Set logging to syslog level.
|
||||
|
||||
*fileloglvl=*"__\{0-6\}__"::
|
||||
Set logging to file level.
|
||||
|
||||
*logfile=*"__<file>__"::
|
||||
Path to log file.
|
||||
|
||||
*show_modules=*"__{yes|no}__"::
|
||||
Print the name of the included modules to standard output during build.
|
||||
|
||||
*i18n_vars="__<variable mapping>__"::
|
||||
Distribution specific variable mapping.
|
||||
See dracut/modules.d/10i18n/README for a detailed description.
|
||||
|
||||
*i18n_default_font=*"__<fontname>__"::
|
||||
The font <fontname> to install, if not specified otherwise.
|
||||
Default is "LatArCyrHeb-16".
|
||||
|
||||
*i18n_install_all=*"__{yes|no}__"::
|
||||
Install everything regardless of generic or hostonly mode.
|
||||
|
||||
Files
|
||||
-----
|
||||
_/etc/dracut.conf_::
|
||||
Old configuration file. You better use your own file in
|
||||
_/etc/dracut.conf.d/_.
|
||||
|
||||
_/etc/dracut.conf.d/_::
|
||||
Any _/etc/dracut.conf.d/*.conf_ file can overwrite the values in
|
||||
_/etc/dracut.conf_. The configuration files are read in alphanumerical
|
||||
order.
|
||||
|
||||
AUTHOR
|
||||
------
|
||||
Harald Hoyer
|
||||
|
||||
See Also
|
||||
--------
|
||||
*dracut*(8) *dracut.cmdline*(7)
|
||||
|
@@ -1,17 +0,0 @@
|
||||
# dracut config file customized for RedHat/Fedora.
|
||||
|
||||
# i18n
|
||||
i18n_vars="/etc/sysconfig/keyboard:KEYTABLE-KEYMAP /etc/sysconfig/i18n:SYSFONT-FONT,FONTACM-FONT_MAP,FONT_UNIMAP"
|
||||
i18n_default_font="latarcyrheb-sun16"
|
||||
i18n_install_all="yes"
|
||||
stdloglvl=3
|
||||
sysloglvl=5
|
||||
install_optional_items+=" vi /etc/virc ps grep cat rm "
|
||||
prefix="/"
|
||||
systemdutildir=/usr/lib/systemd
|
||||
systemdsystemunitdir=/usr/lib/systemd/system
|
||||
systemdsystemconfdir=/etc/systemd/system
|
||||
udevdir=/usr/lib/udev
|
||||
hostonly="yes"
|
||||
hostonly_cmdline="no"
|
||||
early_microcode="yes"
|
@@ -1,3 +0,0 @@
|
||||
# turn on fips module
|
||||
|
||||
add_dracutmodules+=" fips "
|
@@ -1,5 +0,0 @@
|
||||
# /etc/dracut.conf.d/gentoo-systemd.conf
|
||||
|
||||
# Paths of systemd dirs on Gentoo
|
||||
systemdutildir=/usr/lib/systemd
|
||||
systemdsystemunitdir=/usr/lib/systemd/system
|
@@ -1,15 +0,0 @@
|
||||
# /etc/dracut.conf.d/gentoo.conf
|
||||
# dracut config file customized for Gentoo Base System release 2
|
||||
|
||||
udevdir=/lib/udev
|
||||
ro_mnt=yes
|
||||
|
||||
#
|
||||
# Modules
|
||||
#
|
||||
|
||||
# i18n
|
||||
i18n_vars="/etc/conf.d/keymaps:keymap-KEYMAP,extended_keymaps-EXT_KEYMAPS /etc/conf.d/consolefont:consolefont-FONT,consoletranslation-FONT_MAP /etc/rc.conf:unicode-UNICODE"
|
||||
i18n_default_font="LatArCyrHeb-16"
|
||||
|
||||
omit_drivers+=" i2o_scsi"
|
@@ -1,3 +0,0 @@
|
||||
i18n_vars="/etc/sysconfig/language:RC_LANG-LANG,RC_LC_ALL-LC_ALL /etc/sysconfig/console:CONSOLE_UNICODEMAP-FONT_UNIMAP,CONSOLE_FONT-FONT,CONSOLE_SCREENMAP-FONT_MAP /etc/sysconfig/keyboard:KEYTABLE-KEYMAP"
|
||||
omit_drivers+=" i2o_scsi"
|
||||
|
1120
dracut.css
1120
dracut.css
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,9 @@
|
||||
/var/log/dracut.log {
|
||||
missingok
|
||||
notifempty
|
||||
size 30k
|
||||
compress
|
||||
delaycompress
|
||||
copytruncate
|
||||
size 1M
|
||||
create 0600 root root
|
||||
}
|
||||
|
@@ -1,299 +0,0 @@
|
||||
DRACUT.MODULES(7)
|
||||
=================
|
||||
:doctype: manpage
|
||||
:man source: dracut
|
||||
:man manual: dracut
|
||||
|
||||
NAME
|
||||
----
|
||||
dracut.modules - dracut modules
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
|
||||
dracut uses a modular system to build and extend the initramfs image. All
|
||||
modules are located in _/usr/lib/dracut/modules.d_ or in _<git-src>/modules.d_.
|
||||
The most basic dracut module is _99base_. In _99base_ the initial shell script
|
||||
init is defined, which gets run by the kernel after initramfs loading. Although
|
||||
you can replace init with your own version of _99base_, this is not encouraged.
|
||||
Instead you should use, if possible, the hooks of dracut. All hooks, and the
|
||||
point of time in which they are executed, are described in <<stages>>.
|
||||
|
||||
The main script, which creates the initramfs is dracut itsself. It parses all
|
||||
arguments and sets up the directory, in which everything is installed. It then
|
||||
executes all check, install, installkernel scripts found in the modules, which
|
||||
are to be processed. After everything is installed, the install directory is
|
||||
archived and compressed to the final initramfs image. All helper functions used
|
||||
by check, install and installkernel are found in in the file _dracut-functions_.
|
||||
These shell functions are available to all module installer (install,
|
||||
installkernel) scripts, without the need to source _dracut-functions_.
|
||||
|
||||
A module can check the preconditions for install and installkernel with the
|
||||
check script. Also dependencies can be expressed with check. If a module passed
|
||||
check, install and installkernel will be called to install all of the necessary
|
||||
files for the module. To split between kernel and non-kernel parts of the
|
||||
installation, all kernel module related parts have to be in installkernel. All
|
||||
other files found in a module directory are module specific and mostly are hook
|
||||
scripts and udev rules.
|
||||
|
||||
|
||||
[[stages]]
|
||||
== Boot Process Stages
|
||||
|
||||
dracut modules can insert custom script at various points, to control the boot
|
||||
process.
|
||||
These hooks are plain directories containing shell scripts ending with ".sh",
|
||||
which are sourced by init.
|
||||
Common used functions are in _dracut-lib.sh_, which can be sourced by any script.
|
||||
|
||||
=== Hook: cmdline
|
||||
|
||||
The _cmdline_ hook is a place to insert scripts to parse the kernel command line
|
||||
and prepare the later actions, like setting up udev rules and configuration
|
||||
files.
|
||||
|
||||
In this hook the most important environment variable is defined: root. The
|
||||
second one is rootok, which indicates, that a module claimed to be able to parse
|
||||
the root defined. So for example, **root=**__iscsi:....__ will be claimed by the
|
||||
iscsi dracut module, which then sets rootok.
|
||||
|
||||
=== Hook: pre-udev
|
||||
|
||||
This hook is executed right after the cmdline hook and a check if root and
|
||||
rootok were set. Here modules can take action with the final root, and before
|
||||
udev has been run.
|
||||
|
||||
=== Start Udev
|
||||
|
||||
Now udev is started and the logging for udev is setup.
|
||||
|
||||
=== Hook: pre-trigger
|
||||
|
||||
In this hook, you can set udev environment variables with **udevadm control
|
||||
--property=KEY=_value_** or control the further execution of udev with
|
||||
udevadm.
|
||||
|
||||
=== Trigger Udev
|
||||
|
||||
udev is triggered by calling udevadm trigger, which sends add events for all
|
||||
devices and subsystems.
|
||||
|
||||
=== Main Loop
|
||||
|
||||
In the main loop of dracut loops until udev has settled and
|
||||
all scripts in _initqueue/finished_ returned true.
|
||||
In this loop there are three hooks, where scripts can be inserted
|
||||
by calling /sbin/initqueue.
|
||||
|
||||
==== Initqueue
|
||||
|
||||
This hook gets executed every time a script is inserted here, regardless of the
|
||||
udev state.
|
||||
|
||||
==== Initqueue settled
|
||||
|
||||
This hooks (initqueue/settled) gets executed every time udev has settled.
|
||||
|
||||
==== Initqueue timeout
|
||||
|
||||
This hooks (initqueue/timeout) gets executed, when the main loop counter becomes
|
||||
half of the rd.retry counter.
|
||||
|
||||
==== Initqueue finished
|
||||
|
||||
This hook (initqueue/finished) is called after udev has settled and
|
||||
if all scripts herein return 0 the main loop will be ended.
|
||||
Abritary scripts can be added here, to loop in the
|
||||
initqueue until something happens, which a dracut module wants to wait for.
|
||||
|
||||
=== Hook: pre-mount
|
||||
|
||||
Before the root device is mounted all scripts in the hook pre-mount are
|
||||
executed. In some cases (e.g. NFS) the real root device is already mounted,
|
||||
though.
|
||||
|
||||
=== Hook: mount
|
||||
|
||||
This hook is mainly to mount the real root device.
|
||||
|
||||
=== Hook: pre-pivot
|
||||
|
||||
This hook is called before cleanup hook, This is a good place for
|
||||
actions other than cleanups which need to be called before pivot.
|
||||
|
||||
=== Hook: cleanup
|
||||
|
||||
This hook is the last hook and is called before init finally switches root to
|
||||
the real root device. This is a good place to clean up and kill processes not
|
||||
needed anymore.
|
||||
|
||||
|
||||
=== Cleanup and switch_root
|
||||
|
||||
Init (or systemd) kills all udev processes, cleans up the environment,
|
||||
sets up the arguments for the real init process and finally calls switch_root.
|
||||
switch_root removes the whole filesystem hierarchy of the initramfs,
|
||||
chroot()s to the real root device and calls /sbin/init with the specified
|
||||
arguments.
|
||||
|
||||
To ensure all files in the initramfs hierarchy can be removed, all processes
|
||||
still running from the initramfs should not have any open file descriptors left.
|
||||
|
||||
== Network Infrastructure
|
||||
|
||||
FIXME
|
||||
|
||||
== Writing a Module
|
||||
|
||||
A simple example module is _96insmodpost_, which modprobes a kernel module after
|
||||
udev has settled and the basic device drivers have been loaded.
|
||||
|
||||
All module installation information is in the file module-setup.sh.
|
||||
|
||||
First we create a check() function, which just exits with 0 indicating that this
|
||||
module should be included by default.
|
||||
|
||||
check():
|
||||
----
|
||||
return 0
|
||||
----
|
||||
|
||||
The we create the install() function, which installs a cmdline hook with
|
||||
priority number 20 called _parse-insmodpost.sh_. It also installs the
|
||||
_insmodpost.sh_ script in _/sbin_.
|
||||
|
||||
install():
|
||||
----
|
||||
inst_hook cmdline 20 "$moddir/parse-insmodpost.sh"
|
||||
inst_simple "$moddir/insmodpost.sh" /sbin/insmodpost.sh
|
||||
----
|
||||
|
||||
The _pase-instmodpost.sh_ parses the kernel command line for a argument
|
||||
rd.driver.post, blacklists the module from being autoloaded and installs the
|
||||
hook _insmodpost.sh_ in the _initqueue/settled_.
|
||||
|
||||
_parse-insmodpost.sh_:
|
||||
----
|
||||
for p in $(getargs rd.driver.post=); do
|
||||
echo "blacklist $p" >> /etc/modprobe.d/initramfsblacklist.conf
|
||||
_do_insmodpost=1
|
||||
done
|
||||
|
||||
[ -n "$_do_insmodpost" ] && /sbin/initqueue --settled --unique --onetime /sbin/insmodpost.sh
|
||||
unset _do_insmodpost
|
||||
|
||||
----
|
||||
|
||||
_insmodpost.sh_, which is called in the _initqueue/settled_ hook will just
|
||||
modprobe the kernel modules specified in all rd.driver.post kernel command line
|
||||
parameters. It runs after udev has settled and is only called once (--onetime).
|
||||
|
||||
_insmodpost.sh_:
|
||||
----
|
||||
. /lib/dracut-lib.sh
|
||||
|
||||
for p in $(getargs rd.driver.post=); do
|
||||
modprobe $p
|
||||
done
|
||||
|
||||
----
|
||||
|
||||
|
||||
=== module-setup.sh: check()
|
||||
|
||||
_check()_ is called by dracut to evaluate the inclusion of a dracut module in
|
||||
the initramfs.
|
||||
|
||||
$hostonly:: If the $hostonly variable is set, then the module check() function
|
||||
should be in "hostonly" mode, which means, that the check() should only return
|
||||
0, if the module is really needed to boot this specific host.
|
||||
|
||||
check() should return with:
|
||||
|
||||
0:: Include the dracut module in the initramfs.
|
||||
|
||||
1:: Do not include the dracut module. The requirements are not fullfilled
|
||||
(missing tools, etc.)
|
||||
|
||||
255:: Only include the dracut module, if another module requires it or if
|
||||
explicitly specified in the config file or on the argument list.
|
||||
|
||||
|
||||
=== module-setup.sh: depends()
|
||||
|
||||
The function depends() should echo all other dracut module names the module
|
||||
depends on.
|
||||
|
||||
=== module-setup.sh: cmdline()
|
||||
|
||||
This function should print the kernel command line options needed to boot the
|
||||
current machine setup. It should start with a space and should not print a
|
||||
newline.
|
||||
|
||||
=== module-setup.sh: install()
|
||||
|
||||
The install() function is called to install everything non-kernel related.
|
||||
To install binaries, scripts, and other files, you can use the functions
|
||||
mentioned in <<creation>>.
|
||||
|
||||
To address a file in the current module directory, use the variable "$moddir".
|
||||
|
||||
=== module-setup.sh: installkernel()
|
||||
|
||||
In installkernel() all kernel related files should be installed. You can use all
|
||||
of the functions mentioned in <<creation>> to install files.
|
||||
|
||||
=== [[creation]]Creation Functions
|
||||
|
||||
==== inst_multiple [-o] <file> [ <file> ...]
|
||||
|
||||
installs multiple binaries and files. If executables are specified without a
|
||||
path, dracut will search the path PATH=/usr/sbin:/sbin:/usr/bin:/bin for the
|
||||
binary. If the option "-o" is given as the first parameter, a missing file does
|
||||
not lead to an error.
|
||||
|
||||
==== inst <src> [<dst>]
|
||||
|
||||
installs _one_ file <src> either to the same place in the initramfs or to an
|
||||
optional <dst>.
|
||||
|
||||
==== inst_hook <hookdir> <prio> <src>
|
||||
|
||||
installs an executable/script <src> in the dracut hook <hookdir> with priority
|
||||
<prio>.
|
||||
|
||||
==== inst_rules <udevrule> [ <udevrule> ...]
|
||||
|
||||
installs one ore more udev rules. Non-existant udev rules are reported, but do
|
||||
not let dracut fail.
|
||||
|
||||
==== instmods <kernelmodule> [ <kernelmodule> ... ]
|
||||
|
||||
instmods should be used only in the installkernel() function.
|
||||
|
||||
instmods installs one or more kernel modules in the initramfs. <kernelmodule>
|
||||
can also be a whole subsystem, if prefixed with a "=", like "=drivers/net/team".
|
||||
|
||||
instmods will not install the kernel module, if $hostonly is set and the kernel
|
||||
module is not currently needed by any /sys/*...*/uevent MODALIAS.
|
||||
To install a kernel module regardless of the hostonly mode use the form:
|
||||
----
|
||||
hostonly='' instmods <kernelmodule>
|
||||
----
|
||||
|
||||
=== Initramfs Functions
|
||||
|
||||
FIXME
|
||||
|
||||
|
||||
=== Network Modules
|
||||
|
||||
FIXME
|
||||
|
||||
AUTHOR
|
||||
------
|
||||
Harald Hoyer
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
*dracut*(8)
|
474
dracut.spec
474
dracut.spec
@@ -1,61 +1,29 @@
|
||||
%define dracutlibdir %{_prefix}/lib/dracut
|
||||
|
||||
# Variables must be defined
|
||||
%define with_nbd 1
|
||||
%define with_switch_root 1
|
||||
%define with_nbd 1
|
||||
|
||||
# switchroot provided by util-linux-ng in F-12+
|
||||
%if 0%{?fedora} > 11 || 0%{?rhel} >= 6
|
||||
%define with_switch_root 0
|
||||
%endif
|
||||
# nbd in Fedora only
|
||||
%if 0%{?rhel} >= 6
|
||||
%define with_nbd 0
|
||||
%endif
|
||||
|
||||
Name: dracut
|
||||
Version: xxx
|
||||
Release: xxx
|
||||
|
||||
Version: 004
|
||||
Release: 1%{?dist}
|
||||
Summary: Initramfs generator using udev
|
||||
%if 0%{?fedora} || 0%{?rhel}
|
||||
Group: System Environment/Base
|
||||
%endif
|
||||
%if 0%{?suse_version}
|
||||
Group: System/Base
|
||||
%endif
|
||||
License: GPLv2+
|
||||
URL: http://apps.sourceforge.net/trac/dracut/wiki
|
||||
|
||||
# The entire source code is GPLv2+
|
||||
# except install/* which is LGPLv2+
|
||||
License: GPLv2+ and LGPLv2+
|
||||
|
||||
URL: https://dracut.wiki.kernel.org/
|
||||
|
||||
# Source can be generated by
|
||||
# http://git.kernel.org/?p=boot/dracut/dracut.git;a=snapshot;h=%{version};sf=tgz
|
||||
Source0: http://www.kernel.org/pub/linux/utils/boot/dracut/dracut-%{version}.tar.bz2
|
||||
|
||||
BuildRequires: bash git
|
||||
|
||||
%if 0%{?fedora} || 0%{?rhel}
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
BuildRequires: pkgconfig
|
||||
%endif
|
||||
%if 0%{?fedora}
|
||||
BuildRequires: bash-completion
|
||||
BuildRequires: pkgconfig
|
||||
%endif
|
||||
|
||||
%if 0%{?suse_version}
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
%endif
|
||||
|
||||
%if 0%{?fedora} || 0%{?rhel}
|
||||
BuildRequires: docbook-style-xsl docbook-dtds libxslt
|
||||
%endif
|
||||
|
||||
%if 0%{?suse_version}
|
||||
-BuildRequires: docbook-xsl-stylesheets libxslt
|
||||
%endif
|
||||
|
||||
BuildRequires: asciidoc
|
||||
|
||||
%if 0%{?fedora} > 12 || 0%{?rhel}
|
||||
%if 0%{?fedora} > 12 || 0%{?rhel} >= 6
|
||||
# no "provides", because dracut does not offer
|
||||
# all functionality of the obsoleted packages
|
||||
Obsoletes: mkinitrd <= 6.0.93
|
||||
@@ -64,129 +32,114 @@ Obsoletes: nash <= 6.0.93
|
||||
Obsoletes: libbdevid-python <= 6.0.93
|
||||
%endif
|
||||
|
||||
%if 0%{?fedora} > 16 || 0%{?rhel} > 6
|
||||
BuildRequires: systemd-units
|
||||
%endif
|
||||
|
||||
%if 0%{?suse_version} > 9999
|
||||
Obsoletes: mkinitrd < 2.6.1
|
||||
Provides: mkinitrd = 2.6.1
|
||||
%endif
|
||||
|
||||
Obsoletes: dracut-kernel < 005
|
||||
Provides: dracut-kernel = %{version}-%{release}
|
||||
|
||||
Obsoletes: dracut <= 029
|
||||
Obsoletes: dracut-norescue
|
||||
Provides: dracut-norescue
|
||||
|
||||
Requires: bash >= 4
|
||||
Requires: bash
|
||||
Requires: bzip2
|
||||
Requires: coreutils
|
||||
Requires: cpio
|
||||
Requires: dash
|
||||
Requires: filesystem >= 2.1.0
|
||||
Requires: findutils
|
||||
Requires: grep
|
||||
Requires: hardlink
|
||||
Requires: gzip xz
|
||||
Requires: kmod
|
||||
Requires: gzip
|
||||
Requires: initscripts >= 8.63-1
|
||||
Requires: kbd
|
||||
Requires: mktemp >= 1.5-5
|
||||
Requires: module-init-tools >= 3.7-9
|
||||
Requires: mount
|
||||
Requires: plymouth >= 0.8.0-0.2009.29.09.19.1
|
||||
Requires: plymouth-scripts
|
||||
Requires: sed
|
||||
Requires: kpartx
|
||||
Requires: tar
|
||||
Requires: udev
|
||||
Requires: util-linux-ng >= 2.16
|
||||
Requires: which
|
||||
Requires: file
|
||||
|
||||
%if 0%{?fedora} || 0%{?rhel} > 6
|
||||
Requires: util-linux >= 2.21
|
||||
Requires: systemd >= 219
|
||||
Requires: procps-ng
|
||||
Conflicts: grubby < 8.23
|
||||
%else
|
||||
Requires: udev > 166
|
||||
Requires: util-linux-ng >= 2.21
|
||||
%if ! 0%{?with_switch_root}
|
||||
Requires: util-linux-ng >= 2.16
|
||||
BuildArch: noarch
|
||||
%endif
|
||||
|
||||
%if 0%{?fedora} || 0%{?rhel} > 6
|
||||
Conflicts: initscripts < 8.63-1
|
||||
Conflicts: plymouth < 0.8.0-0.2009.29.09.19.1
|
||||
%endif
|
||||
|
||||
Conflicts: mdadm < 3.2.6-14
|
||||
BuildRequires: docbook-style-xsl docbook-dtds libxslt
|
||||
BuildRequires: dash bash git
|
||||
|
||||
%description
|
||||
dracut contains tools to create a bootable initramfs for 2.6 Linux kernels.
|
||||
Unlike existing implementations, dracut does hard-code as little as possible
|
||||
into the initramfs. dracut contains various modules which are driven by the
|
||||
event-based udev. Having root on MD, DM, LVM2, LUKS is supported as well as
|
||||
NFS, iSCSI, NBD, FCoE with the dracut-network package.
|
||||
dracut is a new, event-driven initramfs infrastructure based around udev.
|
||||
|
||||
%package network
|
||||
Summary: dracut modules to build a dracut initramfs with network support
|
||||
Summary: Dracut modules to build a dracut initramfs with network support
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
Requires: iputils
|
||||
Requires: iproute
|
||||
Requires: dhclient
|
||||
Obsoletes: dracut-generic < 008
|
||||
Provides: dracut-generic = %{version}-%{release}
|
||||
Requires: dhclient rpcbind nfs-utils
|
||||
Requires: iscsi-initiator-utils
|
||||
%if %{with_nbd}
|
||||
Requires: nbd
|
||||
%endif
|
||||
Requires: net-tools iproute
|
||||
Requires: bridge-utils
|
||||
|
||||
%description network
|
||||
This package requires everything which is needed to build a generic
|
||||
all purpose initramfs with network support with dracut.
|
||||
|
||||
%if 0%{?fedora} || 0%{?rhel} >= 6 || 0%{?suse_version}
|
||||
%package fips
|
||||
Summary: dracut modules to build a dracut initramfs with an integrity check
|
||||
Summary: Dracut modules to build a dracut initramfs with an integrity check
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
Requires: hmaccalc
|
||||
Requires: hmaccalc fipscheck
|
||||
%if 0%{?rhel} > 5
|
||||
# For Alpha 3, we want nss instead of nss-softokn
|
||||
Requires: nss
|
||||
%else
|
||||
Requires: nss-softokn
|
||||
%endif
|
||||
Requires: nss-softokn-freebl
|
||||
Requires: nss-softokn-freebl >= 3.14.3-22.el6_6
|
||||
|
||||
%description fips
|
||||
This package requires everything which is needed to build an
|
||||
initramfs with dracut, which does an integrity check.
|
||||
%endif
|
||||
all purpose initramfs with dracut, which does an integrity check.
|
||||
|
||||
%package fips-aesni
|
||||
Summary: dracut modules to build a dracut initramfs with an integrity check with aesni-intel
|
||||
Summary: Dracut modules to build a dracut initramfs with an integrity check with aesni-intel
|
||||
Requires: %{name}-fips = %{version}-%{release}
|
||||
|
||||
%description fips-aesni
|
||||
This package requires everything which is needed to build an
|
||||
initramfs with dracut, which does an integrity check and adds the aesni-intel kernel module.
|
||||
all purpose initramfs with dracut, which does an integrity check
|
||||
and adds the aesni-intel kernel module.
|
||||
|
||||
%package caps
|
||||
Summary: dracut modules to build a dracut initramfs which drops capabilities
|
||||
Summary: Dracut modules to build a dracut initramfs which drops capabilities
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
Requires: libcap
|
||||
|
||||
%description caps
|
||||
This package requires everything which is needed to build an
|
||||
initramfs with dracut, which drops capabilities.
|
||||
all purpose initramfs with dracut, which drops capabilities.
|
||||
|
||||
%package config-generic
|
||||
Summary: dracut configuration to turn off hostonly image generation
|
||||
%package generic
|
||||
Summary: Metapackage to build a generic initramfs with dracut
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
Obsoletes: dracut-nohostonly
|
||||
Provides: dracut-nohostonly
|
||||
Requires: %{name}-network = %{version}-%{release}
|
||||
|
||||
%description config-generic
|
||||
This package provides the configuration to turn off the host specific initramfs
|
||||
generation with dracut and generates a generic image by default.
|
||||
%description generic
|
||||
This package requires everything which is needed to build a generic
|
||||
all purpose initramfs with dracut.
|
||||
|
||||
%package config-rescue
|
||||
Summary: dracut configuration to turn on rescue image generation
|
||||
|
||||
%package kernel
|
||||
Summary: Metapackage to build generic initramfs with dracut with only kernel modules
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
Obsoletes: dracut <= 029
|
||||
|
||||
%description config-rescue
|
||||
This package provides the configuration to turn on the rescue initramfs
|
||||
generation with dracut.
|
||||
%description kernel
|
||||
This package requires everything which is needed to build a initramfs with all
|
||||
kernel modules and firmware files needed by dracut modules.
|
||||
|
||||
%package tools
|
||||
Summary: dracut tools to build the local initramfs
|
||||
Summary: Dracut tools to build the local initramfs
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
Requires: coreutils cryptsetup-luks device-mapper
|
||||
Requires: diffutils dmraid findutils gawk grep lvm2
|
||||
Requires: module-init-tools sed
|
||||
Requires: cpio gzip
|
||||
|
||||
%description tools
|
||||
This package contains tools to assemble the local initrd and host configuration.
|
||||
@@ -203,259 +156,140 @@ git commit -a -q -m "%{version} baseline."
|
||||
|
||||
# Apply all the patches.
|
||||
git am -p1 %{patches}
|
||||
git tag %{version}
|
||||
%endif
|
||||
|
||||
chmod 0755 modules.d/*/check
|
||||
# make rpmlint happy
|
||||
chmod 0755 modules.d/*/install
|
||||
chmod 0755 modules.d/*/installkernel
|
||||
chmod 0755 modules.d/*/*.sh
|
||||
|
||||
%build
|
||||
%configure --systemdsystemunitdir=%{_unitdir} --bashcompletiondir=$(pkg-config --variable=completionsdir bash-completion) --libdir=%{_prefix}/lib
|
||||
|
||||
make %{?_smp_mflags}
|
||||
make WITH_SWITCH_ROOT=0%{?with_switch_root}
|
||||
|
||||
%install
|
||||
%if 0%{?fedora} || 0%{?rhel}
|
||||
rm -rf -- $RPM_BUILD_ROOT
|
||||
%endif
|
||||
make %{?_smp_mflags} install \
|
||||
DESTDIR=$RPM_BUILD_ROOT \
|
||||
libdir=%{_prefix}/lib
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
make install DESTDIR=$RPM_BUILD_ROOT sbindir=/sbin \
|
||||
sysconfdir=/etc mandir=%{_mandir} WITH_SWITCH_ROOT=0%{?with_switch_root}
|
||||
|
||||
echo "DRACUT_VERSION=%{version}-%{release}" > $RPM_BUILD_ROOT/%{dracutlibdir}/dracut-version.sh
|
||||
|
||||
%if 0%{?fedora} == 0 && 0%{?rhel} == 0 && 0%{?suse_version} == 0
|
||||
rm -fr -- $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/01fips
|
||||
rm -fr -- $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/02fips-aesni
|
||||
%endif
|
||||
|
||||
%if %{defined _unitdir}
|
||||
# for systemd, better use systemd-bootchart
|
||||
rm -fr -- $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/00bootchart
|
||||
%endif
|
||||
|
||||
# we do not support dash in the initramfs
|
||||
rm -fr -- $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/00dash
|
||||
|
||||
# remove gentoo specific modules
|
||||
rm -fr -- $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/50gensplash
|
||||
|
||||
%if %{defined _unitdir}
|
||||
# with systemd IMA and selinux modules do not make sense
|
||||
rm -fr -- $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/96securityfs
|
||||
rm -fr -- $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/97masterkey
|
||||
rm -fr -- $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/98integrity
|
||||
%endif
|
||||
echo %{name}-%{version}-%{release} > $RPM_BUILD_ROOT/%{_datadir}/dracut/modules.d/10rpmversion/dracut-version
|
||||
rm $RPM_BUILD_ROOT/%{_datadir}/dracut/modules.d/01fips/check
|
||||
rm $RPM_BUILD_ROOT/%{_datadir}/dracut/modules.d/02fips-aesni/check
|
||||
|
||||
mkdir -p $RPM_BUILD_ROOT/boot/dracut
|
||||
mkdir -p $RPM_BUILD_ROOT/var/lib/dracut/overlay
|
||||
mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/log
|
||||
touch $RPM_BUILD_ROOT%{_localstatedir}/log/dracut.log
|
||||
mkdir -p $RPM_BUILD_ROOT%{_sharedstatedir}/initramfs
|
||||
|
||||
%if 0%{?fedora} || 0%{?rhel} || 0%{?suse_version}
|
||||
install -m 0644 dracut.conf.d/fedora.conf.example $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/01-dist.conf
|
||||
install -m 0644 dracut.conf.d/fips.conf.example $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/40-fips.conf
|
||||
%if 0%{?fedora} <= 12 && 0%{?rhel} < 6
|
||||
rm $RPM_BUILD_ROOT/sbin/mkinitrd
|
||||
rm $RPM_BUILD_ROOT/sbin/lsinitrd
|
||||
%endif
|
||||
|
||||
%if 0%{?suse_version}
|
||||
install -m 0644 dracut.conf.d/suse.conf.example $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/01-dist.conf
|
||||
%endif
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d
|
||||
install -m 0644 dracut.logrotate $RPM_BUILD_ROOT/etc/logrotate.d/dracut
|
||||
|
||||
%if 0%{?fedora} <= 12 && 0%{?rhel} < 6 && 0%{?suse_version} <= 9999
|
||||
rm -f -- $RPM_BUILD_ROOT%{_bindir}/mkinitrd
|
||||
rm -f -- $RPM_BUILD_ROOT%{_bindir}/lsinitrd
|
||||
%endif
|
||||
|
||||
%if 0%{?fedora} || 0%{?rhel} > 6
|
||||
# FIXME: remove after F19
|
||||
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/kernel/postinst.d
|
||||
install -m 0755 51-dracut-rescue-postinst.sh $RPM_BUILD_ROOT%{_sysconfdir}/kernel/postinst.d/51-dracut-rescue-postinst.sh
|
||||
|
||||
echo 'hostonly="no"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/02-generic-image.conf
|
||||
echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/02-rescue.conf
|
||||
%endif
|
||||
|
||||
%if 0%{?fedora} || 0%{?rhel} || 0%{?suse_version}
|
||||
echo 'do_strip=no' > $RPM_BUILD_ROOT/etc/dracut.conf.d/02-fips.conf
|
||||
> $RPM_BUILD_ROOT/etc/system-fips
|
||||
%endif
|
||||
|
||||
# create compat symlink
|
||||
mkdir -p $RPM_BUILD_ROOT%{_sbindir}
|
||||
ln -sr $RPM_BUILD_ROOT%{_bindir}/dracut $RPM_BUILD_ROOT%{_sbindir}/dracut
|
||||
|
||||
%clean
|
||||
rm -rf -- $RPM_BUILD_ROOT
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,0755)
|
||||
%doc README HACKING TODO COPYING AUTHORS NEWS dracut.html dracut.png dracut.svg
|
||||
%{_bindir}/dracut
|
||||
# compat symlink
|
||||
%{_sbindir}/dracut
|
||||
%{_datadir}/bash-completion/completions/dracut
|
||||
%{_datadir}/bash-completion/completions/lsinitrd
|
||||
%if 0%{?fedora} > 12 || 0%{?rhel} >= 6 || 0%{?suse_version} > 9999
|
||||
%{_bindir}/mkinitrd
|
||||
%{_bindir}/lsinitrd
|
||||
%doc README HACKING TODO COPYING AUTHORS NEWS dracut-rhel6.html
|
||||
/sbin/dracut
|
||||
%if 0%{?with_switch_root}
|
||||
/sbin/switch_root
|
||||
%endif
|
||||
%dir %{dracutlibdir}
|
||||
%dir %{dracutlibdir}/modules.d
|
||||
%{dracutlibdir}/dracut-init.sh
|
||||
%{dracutlibdir}/dracut-functions.sh
|
||||
%{dracutlibdir}/dracut-functions
|
||||
%{dracutlibdir}/dracut-version.sh
|
||||
%{dracutlibdir}/dracut-logger.sh
|
||||
%{dracutlibdir}/dracut-initramfs-restore
|
||||
%{dracutlibdir}/dracut-install
|
||||
%{dracutlibdir}/skipcpio
|
||||
%config(noreplace) %{_sysconfdir}/dracut.conf
|
||||
%if 0%{?fedora} || 0%{?suse_version} || 0%{?rhel}
|
||||
%{dracutlibdir}/dracut.conf.d/01-dist.conf
|
||||
%if 0%{?fedora} > 12 || 0%{?rhel} >= 6
|
||||
/sbin/mkinitrd
|
||||
/sbin/lsinitrd
|
||||
%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
|
||||
%{_mandir}/man8/mkinitrd.8*
|
||||
%dir %{_datadir}/dracut
|
||||
%{_datadir}/dracut/dracut-functions
|
||||
%config(noreplace) /etc/dracut.conf
|
||||
%dir /etc/dracut.conf.d
|
||||
%config(noreplace) /etc/logrotate.d/dracut
|
||||
%{_mandir}/man1/lsinitrd.1*
|
||||
%endif
|
||||
%{_mandir}/man7/dracut.kernel.7*
|
||||
%{_mandir}/man7/dracut.cmdline.7*
|
||||
%{_mandir}/man7/dracut.modules.7*
|
||||
%{_mandir}/man7/dracut.bootup.7*
|
||||
%{_mandir}/man8/mkinitrd.8*
|
||||
%{_mandir}/man8/dracut.8*
|
||||
%{_mandir}/man5/dracut.conf.5*
|
||||
%if %{defined _unitdir}
|
||||
%{dracutlibdir}/modules.d/00systemd-bootchart
|
||||
%else
|
||||
%{dracutlibdir}/modules.d/00bootchart
|
||||
%endif
|
||||
%{dracutlibdir}/modules.d/00bash
|
||||
%{dracutlibdir}/modules.d/03modsign
|
||||
%{dracutlibdir}/modules.d/03rescue
|
||||
%{dracutlibdir}/modules.d/04watchdog
|
||||
%{dracutlibdir}/modules.d/05busybox
|
||||
%{dracutlibdir}/modules.d/10i18n
|
||||
%{dracutlibdir}/modules.d/30convertfs
|
||||
%{dracutlibdir}/modules.d/45url-lib
|
||||
%{dracutlibdir}/modules.d/50drm
|
||||
%{dracutlibdir}/modules.d/50plymouth
|
||||
%{dracutlibdir}/modules.d/80cms
|
||||
%{dracutlibdir}/modules.d/90bcache
|
||||
%{dracutlibdir}/modules.d/90btrfs
|
||||
%{dracutlibdir}/modules.d/90crypt
|
||||
%{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
|
||||
%{dracutlibdir}/modules.d/90multipath
|
||||
%{dracutlibdir}/modules.d/90qemu
|
||||
%{dracutlibdir}/modules.d/91crypt-gpg
|
||||
%{dracutlibdir}/modules.d/91crypt-loop
|
||||
%{dracutlibdir}/modules.d/95debug
|
||||
%{dracutlibdir}/modules.d/95resume
|
||||
%{dracutlibdir}/modules.d/95rootfs-block
|
||||
%{dracutlibdir}/modules.d/95dasd
|
||||
%{dracutlibdir}/modules.d/95dasd_mod
|
||||
%{dracutlibdir}/modules.d/95fstab-sys
|
||||
%{dracutlibdir}/modules.d/95zfcp
|
||||
%{dracutlibdir}/modules.d/95terminfo
|
||||
%{dracutlibdir}/modules.d/95udev-rules
|
||||
%{dracutlibdir}/modules.d/95virtfs
|
||||
%if %{undefined _unitdir}
|
||||
%{dracutlibdir}/modules.d/96securityfs
|
||||
%{dracutlibdir}/modules.d/97masterkey
|
||||
%{dracutlibdir}/modules.d/98integrity
|
||||
%endif
|
||||
%{dracutlibdir}/modules.d/97biosdevname
|
||||
%{dracutlibdir}/modules.d/98ecryptfs
|
||||
%{dracutlibdir}/modules.d/98pollcdrom
|
||||
%{dracutlibdir}/modules.d/98selinux
|
||||
%{dracutlibdir}/modules.d/98syslog
|
||||
%{dracutlibdir}/modules.d/98systemd
|
||||
%{dracutlibdir}/modules.d/98usrmount
|
||||
%{dracutlibdir}/modules.d/99base
|
||||
%{dracutlibdir}/modules.d/99fs-lib
|
||||
%{dracutlibdir}/modules.d/99img-lib
|
||||
%{dracutlibdir}/modules.d/99shutdown
|
||||
%{_datadir}/dracut/modules.d/00dash
|
||||
%{_datadir}/dracut/modules.d/10redhat-i18n
|
||||
%{_datadir}/dracut/modules.d/10rpmversion
|
||||
%{_datadir}/dracut/modules.d/50plymouth
|
||||
%{_datadir}/dracut/modules.d/60xen
|
||||
%{_datadir}/dracut/modules.d/90btrfs
|
||||
%{_datadir}/dracut/modules.d/90crypt
|
||||
%{_datadir}/dracut/modules.d/90dm
|
||||
%{_datadir}/dracut/modules.d/90dmraid
|
||||
%{_datadir}/dracut/modules.d/90dmsquash-live
|
||||
%{_datadir}/dracut/modules.d/90kernel-modules
|
||||
%{_datadir}/dracut/modules.d/90lvm
|
||||
%{_datadir}/dracut/modules.d/90mdraid
|
||||
%{_datadir}/dracut/modules.d/90multipath
|
||||
%{_datadir}/dracut/modules.d/95debug
|
||||
%{_datadir}/dracut/modules.d/95fstab-sys
|
||||
%{_datadir}/dracut/modules.d/95resume
|
||||
%{_datadir}/dracut/modules.d/95rootfs-block
|
||||
%{_datadir}/dracut/modules.d/95dasd
|
||||
%{_datadir}/dracut/modules.d/95dasd_mod
|
||||
%{_datadir}/dracut/modules.d/95zfcp
|
||||
%{_datadir}/dracut/modules.d/95znet
|
||||
%{_datadir}/dracut/modules.d/95terminfo
|
||||
%{_datadir}/dracut/modules.d/95udev-rules
|
||||
%{_datadir}/dracut/modules.d/95uswsusp
|
||||
%{_datadir}/dracut/modules.d/96insmodpost
|
||||
%{_datadir}/dracut/modules.d/97biosdevname
|
||||
%{_datadir}/dracut/modules.d/98syslog
|
||||
%{_datadir}/dracut/modules.d/99base
|
||||
%attr(0644,root,root) %ghost %config(missingok,noreplace) %{_localstatedir}/log/dracut.log
|
||||
%dir %{_sharedstatedir}/initramfs
|
||||
%if %{defined _unitdir}
|
||||
%{_unitdir}/dracut-shutdown.service
|
||||
%{_unitdir}/shutdown.target.wants/dracut-shutdown.service
|
||||
%{_unitdir}/dracut-cmdline.service
|
||||
%{_unitdir}/dracut-initqueue.service
|
||||
%{_unitdir}/dracut-mount.service
|
||||
%{_unitdir}/dracut-pre-mount.service
|
||||
%{_unitdir}/dracut-pre-pivot.service
|
||||
%{_unitdir}/dracut-pre-trigger.service
|
||||
%{_unitdir}/dracut-pre-udev.service
|
||||
%{_unitdir}/initrd.target.wants/dracut-cmdline.service
|
||||
%{_unitdir}/initrd.target.wants/dracut-initqueue.service
|
||||
%{_unitdir}/initrd.target.wants/dracut-mount.service
|
||||
%{_unitdir}/initrd.target.wants/dracut-pre-mount.service
|
||||
%{_unitdir}/initrd.target.wants/dracut-pre-pivot.service
|
||||
%{_unitdir}/initrd.target.wants/dracut-pre-trigger.service
|
||||
%{_unitdir}/initrd.target.wants/dracut-pre-udev.service
|
||||
|
||||
%endif
|
||||
%if 0%{?fedora} || 0%{?rhel} > 6
|
||||
%{_prefix}/lib/kernel/install.d/50-dracut.install
|
||||
%endif
|
||||
|
||||
%files network
|
||||
%defattr(-,root,root,0755)
|
||||
%{dracutlibdir}/modules.d/40network
|
||||
%{dracutlibdir}/modules.d/95fcoe
|
||||
%{dracutlibdir}/modules.d/95iscsi
|
||||
%{dracutlibdir}/modules.d/90livenet
|
||||
%{dracutlibdir}/modules.d/90qemu-net
|
||||
%{dracutlibdir}/modules.d/95cifs
|
||||
%{dracutlibdir}/modules.d/95nbd
|
||||
%{dracutlibdir}/modules.d/95nfs
|
||||
%{dracutlibdir}/modules.d/95ssh-client
|
||||
%{dracutlibdir}/modules.d/45ifcfg
|
||||
%{dracutlibdir}/modules.d/95znet
|
||||
%{dracutlibdir}/modules.d/95fcoe-uefi
|
||||
%{dracutlibdir}/modules.d/99uefi-lib
|
||||
%doc README HACKING TODO COPYING AUTHORS NEWS
|
||||
%{_datadir}/dracut/modules.d/40network
|
||||
%{_datadir}/dracut/modules.d/95fcoe
|
||||
%{_datadir}/dracut/modules.d/95iscsi
|
||||
%{_datadir}/dracut/modules.d/95nbd
|
||||
%{_datadir}/dracut/modules.d/95nfs
|
||||
%{_datadir}/dracut/modules.d/45ifcfg
|
||||
|
||||
%if 0%{?fedora} || 0%{?rhel} || 0%{?suse_version}
|
||||
%files fips
|
||||
%defattr(-,root,root,0755)
|
||||
%{dracutlibdir}/modules.d/01fips
|
||||
%{dracutlibdir}/dracut.conf.d/40-fips.conf
|
||||
%doc COPYING
|
||||
%{_datadir}/dracut/modules.d/01fips
|
||||
%config(noreplace) /etc/dracut.conf.d/02-fips.conf
|
||||
%config(missingok) /etc/system-fips
|
||||
%endif
|
||||
|
||||
%files fips-aesni
|
||||
%defattr(-,root,root,0755)
|
||||
%doc COPYING
|
||||
%{dracutlibdir}/modules.d/02fips-aesni
|
||||
%{_datadir}/dracut/modules.d/02fips-aesni
|
||||
|
||||
%files caps
|
||||
%defattr(-,root,root,0755)
|
||||
%{dracutlibdir}/modules.d/02caps
|
||||
%doc COPYING
|
||||
%{_datadir}/dracut/modules.d/02caps
|
||||
|
||||
%files kernel
|
||||
%defattr(-,root,root,0755)
|
||||
%doc README.kernel
|
||||
|
||||
%files generic
|
||||
%defattr(-,root,root,0755)
|
||||
%doc README.generic
|
||||
|
||||
%files tools
|
||||
%defattr(-,root,root,0755)
|
||||
%doc COPYING NEWS
|
||||
%{_mandir}/man8/dracut-gencmdline.8*
|
||||
%{_mandir}/man8/dracut-catimages.8*
|
||||
%{_bindir}/dracut-catimages
|
||||
/sbin/dracut-gencmdline
|
||||
/sbin/dracut-catimages
|
||||
%dir /boot/dracut
|
||||
%dir /var/lib/dracut
|
||||
%dir /var/lib/dracut/overlay
|
||||
|
||||
%files config-generic
|
||||
%defattr(-,root,root,0755)
|
||||
%{dracutlibdir}/dracut.conf.d/02-generic-image.conf
|
||||
|
||||
%files config-rescue
|
||||
%defattr(-,root,root,0755)
|
||||
%{dracutlibdir}/dracut.conf.d/02-rescue.conf
|
||||
%if 0%{?fedora} || 0%{?rhel} > 6
|
||||
%{_prefix}/lib/kernel/install.d/51-dracut-rescue.install
|
||||
%{_sysconfdir}/kernel/postinst.d/51-dracut-rescue-postinst.sh
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
|
509
dracut.usage.asc
509
dracut.usage.asc
@@ -1,509 +0,0 @@
|
||||
To create a initramfs image, the most simple command is:
|
||||
----
|
||||
# dracut
|
||||
----
|
||||
|
||||
This will generate a general purpose initramfs image, with all possible
|
||||
functionality resulting of the combination of the installed dracut modules and
|
||||
system tools. The image is /boot/initramfs-_++<kernel version>++_.img and
|
||||
contains the kernel modules of the currently active kernel with version
|
||||
_++<kernel version>++_.
|
||||
|
||||
If the initramfs image already exists, dracut will display an error message, and
|
||||
to overwrite the existing image, you have to use the --force option.
|
||||
----
|
||||
# dracut --force
|
||||
----
|
||||
|
||||
If you want to specify another filename for the resulting image you would issue
|
||||
a command like:
|
||||
----
|
||||
# dracut foobar.img
|
||||
----
|
||||
|
||||
To generate an image for a specific kernel version, the command would be:
|
||||
----
|
||||
# dracut foobar.img 2.6.40-1.rc5.f20
|
||||
----
|
||||
|
||||
A shortcut to generate the image at the default location for a specific kernel
|
||||
version is:
|
||||
----
|
||||
# dracut --kver 2.6.40-1.rc5.f20
|
||||
----
|
||||
|
||||
If you want to create lighter, smaller initramfs images, you may want to specify
|
||||
the --hostonly or -H option. Using this option, the resulting image will
|
||||
contain only those dracut modules, kernel modules and filesystems, which are
|
||||
needed to boot this specific machine. This has the drawback, that you can't put
|
||||
the disk on another controller or machine, and that you can't switch to another
|
||||
root filesystem, without recreating the initramfs image.
|
||||
|
||||
[NOTE]
|
||||
===============================
|
||||
On RHEL-7 the hostonly mode is the default mode. Generic "non-hostonly" images
|
||||
are created, if the dracut-config-generic rpm is installed. The rescue kernel
|
||||
entry in the bootloader menu is also a generic image.
|
||||
===============================
|
||||
|
||||
=== Inspecting the Contents
|
||||
To see the contents of the image created by dracut, you can use the lsinitrd
|
||||
tool.
|
||||
----
|
||||
# lsinitrd | less
|
||||
----
|
||||
|
||||
To display the contents of a file in the initramfs also use the lsinitrd tool:
|
||||
----
|
||||
# lsinitrd -f /etc/ld.so.conf
|
||||
include ld.so.conf.d/*.conf
|
||||
----
|
||||
|
||||
=== Adding dracut Modules
|
||||
Some dracut modules are turned off by default and have to be activated manually.
|
||||
You can do this by adding the dracut modules to the configuration file
|
||||
_/etc/dracut.conf_ or _/etc/dracut.conf.d/myconf.conf_. See *dracut.conf*(5).
|
||||
You can also add dracut modules on the command line
|
||||
by using the -a or --add option:
|
||||
----
|
||||
# dracut --add bootchart initramfs-bootchart.img
|
||||
----
|
||||
|
||||
To see a list of available dracut modules, use the --list-modules option:
|
||||
----
|
||||
# dracut --list-modules
|
||||
----
|
||||
|
||||
=== Omitting dracut Modules
|
||||
Sometimes you don't want a dracut module to be included for reasons of speed,
|
||||
size or functionality. To do this, either specify the omit_dracutmodules
|
||||
variable in the _dracut.conf_ or _/etc/dracut.conf.d/myconf.conf_ configuration
|
||||
file (see *dracut.conf*(5)), or use the -o or --omit option
|
||||
on the command line:
|
||||
----
|
||||
# dracut -o "multipath lvm" no-multipath-lvm.img
|
||||
----
|
||||
|
||||
=== Adding Kernel Modules
|
||||
If you need a special kernel module in the initramfs, which is not
|
||||
automatically picked up by dracut, you have the use the --add-drivers option
|
||||
on the command line or the drivers vaiable in the _/etc/dracut.conf_
|
||||
or _/etc/dracut.conf.d/myconf.conf_ configuration file (see *dracut.conf*(5)):
|
||||
----
|
||||
# dracut --add-drivers mymod initramfs-with-mymod.img
|
||||
----
|
||||
|
||||
=== Boot parameters
|
||||
An initramfs generated without the "hostonly" mode, does not contain any system
|
||||
configuration files (except for some special exceptions), so the configuration
|
||||
has to be done on the kernel command line. With this flexibility, you can easily
|
||||
boot from a changed root partition, without the need to recompile the initramfs
|
||||
image. So, you could completly change your root partition (move it inside a md
|
||||
raid with encryption and LVM on top), as long as you specify the correct
|
||||
filesystem LABEL or UUID on the kernel command line for your root device, dracut
|
||||
will find it and boot from it.
|
||||
|
||||
The kernel command line usually can be configured in _/boot/grub2/grub.cfg_
|
||||
(or _/boot/efi/EFI/redhat/grub.cfg_ for EFI systems), if
|
||||
grub2 is your bootloader and it also can be edited in the real boot process in
|
||||
the grub menu.
|
||||
|
||||
The kernel command line can also be provided by the dhcp server with the
|
||||
root-path option. See <<NetworkBoot>>.
|
||||
|
||||
For a full reference of all kernel command line parameters,
|
||||
see *dracut.cmdline*(5).
|
||||
|
||||
To get a quick start for the suitable kernel command line on your system,
|
||||
use the __--print-cmdline__ option:
|
||||
----
|
||||
# dracut --print-cmdline
|
||||
root=UUID=8b8b6f91-95c7-4da2-831b-171e12179081 rootflags=rw,relatime,discard,data=ordered rootfstype=ext4
|
||||
----
|
||||
|
||||
==== Specifying the root Device
|
||||
This is the only option dracut really needs to boot from your root partition.
|
||||
Because your root partition can live in various environments, there are a lot of
|
||||
formats for the root= option. The most basic one is root=_++<path to device
|
||||
node>++_:
|
||||
----
|
||||
root=/dev/sda2
|
||||
----
|
||||
|
||||
Because device node names can change, dependent on the drive ordering, you are
|
||||
encouraged to use the filesystem identifier (UUID) or filesystem label (LABEL)
|
||||
to specify your root partition:
|
||||
----
|
||||
root=UUID=19e9dda3-5a38-484d-a9b0-fa6b067d0331
|
||||
----
|
||||
|
||||
or
|
||||
|
||||
----
|
||||
root=LABEL=myrootpartitionlabel
|
||||
----
|
||||
|
||||
To see all UUIDs or LABELs on your system, do:
|
||||
----
|
||||
# ls -l /dev/disk/by-uuid
|
||||
----
|
||||
|
||||
or
|
||||
|
||||
----
|
||||
# ls -l /dev/disk/by-label
|
||||
----
|
||||
|
||||
If your root partition is on the network see <<NetworkBoot>>.
|
||||
|
||||
==== Keyboard Settings
|
||||
If you have to input passwords for encrypted disk volumes, you might want to set
|
||||
the keyboard layout and specify a display font.
|
||||
|
||||
A typical german kernel command would contain:
|
||||
----
|
||||
rd.vconsole.font=latarcyrheb-sun16 rd.vconsole.keymap=de-latin1-nodeadkeys rd.locale.LANG=de_DE.UTF-8
|
||||
----
|
||||
|
||||
Setting these options can override the setting stored on your system, if you use
|
||||
a modern init system, like systemd.
|
||||
|
||||
==== Blacklisting Kernel Modules
|
||||
Sometimes it is required to prevent the automatic kernel module loading of a
|
||||
specific kernel module. To do this, just add rd.blacklist=_++<kernel module
|
||||
name>++_, with _++<kernel module name>++_ not containing the _.ko_
|
||||
suffix, to the kernel command line. For example:
|
||||
----
|
||||
rd.driver.blacklist=mptsas rd.driver.blacklist=nouveau
|
||||
----
|
||||
|
||||
The option can be specified multiple times on the kernel command line.
|
||||
|
||||
==== Speeding up the Boot Process
|
||||
If you want to speed up the boot process, you can specify as much information
|
||||
for dracut on the kernel command as possible. For example, you can tell dracut,
|
||||
that you root partition is not on a LVM volume or not on a raid partition, or
|
||||
that it lives inside a specific crypto LUKS encrypted volume. By default, dracut
|
||||
searches everywhere. A typical dracut kernel command line for a plain primary or
|
||||
logical partition would contain:
|
||||
----
|
||||
rd.luks=0 rd.lvm=0 rd.md=0 rd.dm=0
|
||||
----
|
||||
|
||||
This turns off every automatic assembly of LVM, MD raids, DM raids and
|
||||
crypto LUKS.
|
||||
|
||||
Of course, you could also omit the dracut modules in the initramfs creation
|
||||
process, but then you would lose the posibility to turn it on on demand.
|
||||
|
||||
|
||||
[[Injecting]]
|
||||
=== Injecting custom Files
|
||||
To add your own files to the initramfs image, you have several possibilities.
|
||||
|
||||
The --include option let you specify a source path and a target path.
|
||||
For example
|
||||
----
|
||||
# dracut --include cmdline-preset /etc/cmdline.d/mycmdline.conf initramfs-cmdline-pre.img
|
||||
----
|
||||
will create an initramfs image, where the file cmdline-preset will be copied
|
||||
inside the initramfs to _/etc/cmdline.d/mycmdline.conf_. --include can only
|
||||
be specified once.
|
||||
|
||||
|
||||
----
|
||||
# mkdir -p rd.live.overlay/etc/cmdline.d
|
||||
# mkdir -p rd.live.overlay/etc/conf.d
|
||||
# echo "ip=dhcp" >> rd.live.overlay/etc/cmdline.d/mycmdline.conf
|
||||
# echo export FOO=testtest >> rd.live.overlay/etc/conf.d/testvar.conf
|
||||
# echo export BAR=testtest >> rd.live.overlay/etc/conf.d/testvar.conf
|
||||
# tree rd.live.overlay/
|
||||
rd.live.overlay/
|
||||
`-- etc
|
||||
|-- cmdline.d
|
||||
| `-- mycmdline.conf
|
||||
`-- conf.d
|
||||
`-- testvar.conf
|
||||
|
||||
# dracut --include rd.live.overlay / initramfs-rd.live.overlay.img
|
||||
----
|
||||
|
||||
This will put the contents of the rd.live.overlay directory into the root of the
|
||||
initramfs image.
|
||||
|
||||
The --install option let you specify several files, which will get installed in
|
||||
the initramfs image at the same location, as they are present on initramfs
|
||||
creation time.
|
||||
|
||||
|
||||
----
|
||||
# dracut --install 'strace fsck.ext3 ssh' initramfs-dbg.img
|
||||
----
|
||||
|
||||
This will create an initramfs with the strace, fsck.ext3 and ssh executables,
|
||||
together with the libraries needed to start those. The --install option can be
|
||||
specified multiple times.
|
||||
|
||||
|
||||
[[NetworkBoot]]
|
||||
=== Network Boot
|
||||
|
||||
If your root partition is on a network drive, you have to have the network
|
||||
dracut modules installed to create a network aware initramfs image.
|
||||
|
||||
On a Red Hat Enterprise Linux or Fedora system, this means, you have to install
|
||||
the _dracut-network_ rpm package:
|
||||
|
||||
|
||||
----
|
||||
# yum install dracut-network
|
||||
----
|
||||
|
||||
The resulting initramfs image can be served by a boot manager residing on your
|
||||
local hard drive or it can be served by a PXE/TFTP server.
|
||||
|
||||
How to setup your PXE/TFTP server can be found in the
|
||||
http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/[Red
|
||||
Hat Enterprise Linux Storage Administration Guide].
|
||||
|
||||
If you specify ip=dhcp on the kernel command line, then dracut asks a dhcp
|
||||
server about the ip adress for the machine. The dhcp server can also serve an
|
||||
additional root-path, which will set the root device for dracut. With this
|
||||
mechanism, you have static configuration on your client machine and a
|
||||
centralized boot configuration on your TFTP/DHCP server. If you can't pass a
|
||||
kernel command line, then you can inject _/etc/cmdline.d/mycmdline.conf_, with a
|
||||
method described in <<Injecting>>.
|
||||
|
||||
==== Reducing the Image Size
|
||||
|
||||
To reduce the size of the initramfs, you should create it with by ommitting all
|
||||
dracut modules, which you know, you don't need to boot the machine.
|
||||
|
||||
You can also specify the exact dracut and kernel modules to produce a very tiny
|
||||
initramfs image.
|
||||
|
||||
For example for a NFS image, you would do:
|
||||
|
||||
|
||||
----
|
||||
# dracut -m "nfs network base" initramfs-nfs-only.img
|
||||
----
|
||||
|
||||
Then you would boot from this image with your target machine and reduce the size
|
||||
once more by creating it on the target machine with the --host-only option:
|
||||
|
||||
|
||||
----
|
||||
# dracut -m "nfs network base" --host-only initramfs-nfs-host-only.img
|
||||
----
|
||||
|
||||
This will reduce the size of the initramfs image significantly.
|
||||
|
||||
|
||||
== Troubleshooting
|
||||
|
||||
If the boot process does not succeed, you have several options to debug the
|
||||
situation. Some of the basic operations are covered here. For more information
|
||||
you should also visit:
|
||||
http://fedoraproject.org/wiki/How_to_debug_Dracut_problems
|
||||
|
||||
|
||||
[[identifying-your-problem-area]]
|
||||
=== Identifying your problem area
|
||||
. Remove ''rhgb'' and ''quiet'' from the kernel command line
|
||||
. Add ''rd.shell'' to the kernel command line. This will present a shell should
|
||||
dracut be unable to locate your root device
|
||||
. Add ''rd.shell rd.debug log_buf_len=1M'' to the kernel command line so that
|
||||
dracut shell commands are printed as they are executed
|
||||
. The file /run/initramfs/rdsosreport.txt is generated,
|
||||
which contains all the logs and the output of all significant tools, which are
|
||||
mentioned later.
|
||||
|
||||
If you want to save that output, simply mount /boot by hand or insert an USB
|
||||
stick and mount that. Then you can store the output for later inspection.
|
||||
|
||||
[[information-to-include-in-your-report]]
|
||||
=== Information to include in your report
|
||||
|
||||
[[all-bug-reports]]
|
||||
==== All bug reports
|
||||
In all cases, the following should be mentioned and attached to your bug report:
|
||||
|
||||
* The exact kernel command-line used. Typically from the bootloader
|
||||
configuration file (e.g. _/boot/grub2/grub.cfg_ (or _/boot/efi/EFI/redhat/grub.cfg_ for EFI systems))
|
||||
or from _/proc/cmdline_.
|
||||
* A copy of your disk partition information from _/etc/fstab_, which might be
|
||||
obtained booting an old working initramfs or a rescue medium.
|
||||
* Turn on dracut debugging (see _the 'debugging dracut' section_), and attach
|
||||
the file /run/initramfs/rdsosreport.txt.
|
||||
* If you use a dracut configuration file, please include _/etc/dracut.conf_ and
|
||||
all files in _/etc/dracut.conf.d/*.conf_
|
||||
|
||||
[[network-root-device-related-problems]]
|
||||
==== Network root device related problems
|
||||
This section details information to include when experiencing problems on a
|
||||
system whose root device is located on a network attached volume (e.g. iSCSI,
|
||||
NFS or NBD). As well as the information from <<all-bug-reports>>, include the
|
||||
following information:
|
||||
|
||||
|
||||
* Please include the output of
|
||||
+
|
||||
----
|
||||
# /sbin/ifup <interfacename>
|
||||
# ip addr show
|
||||
----
|
||||
|
||||
[[debugging-dracut]]
|
||||
=== Debugging dracut
|
||||
|
||||
|
||||
[[configure-a-serial-console]]
|
||||
==== Configure a serial console
|
||||
|
||||
Successfully debugging dracut will require some form of console
|
||||
logging during the system boot. This section documents configuring a
|
||||
serial console connection to record boot messages.
|
||||
|
||||
. In _/boot/grub2/grub.cfg_ (or _/boot/efi/EFI/redhat/grub.cfg_ for EFI systems),
|
||||
add the following boot arguments to the ''linux16''
|
||||
line:
|
||||
+
|
||||
----
|
||||
console=tty0 console=ttyS0,9600
|
||||
----
|
||||
+
|
||||
. More detailed information on how to configure the kernel for console output
|
||||
can be found at
|
||||
http://www.faqs.org/docs/Linux-HOWTO/Remote-Serial-Console-HOWTO.html#CONFIGURE-KERNEL.
|
||||
|
||||
[[using-the-dracut-shell]]
|
||||
==== Using the dracut shell
|
||||
|
||||
dracut offers a shell for interactive debugging in the event dracut fails to
|
||||
locate your root filesystem. To enable the shell:
|
||||
|
||||
. Add the boot parameter ''rd.shell'' to your bootloader configuration file
|
||||
(e.g. _/boot/grub2/grub.cfg_ (or _/boot/efi/EFI/redhat/grub.cfg_ for EFI systems))
|
||||
. Remove the boot arguments ''rhgb'' and ''quiet''
|
||||
+
|
||||
A sample _grub.cfg_ bootloader configuration file snippet is listed below.
|
||||
+
|
||||
----
|
||||
menuentry 'Red Hat Enterprise Linux Server (3.10.0-308.el7.x86_64) 7.0 (Maipo)' […] {
|
||||
[…]
|
||||
linux16 /vmlinuz-3.10.0-308.el7.x86_64 ro root=/dev/mapper/vg_uc1-lv_root console=tty0 rd.shell
|
||||
initrd16 /initramfs-3.10.0-308.el7.x86_64.img
|
||||
[…]
|
||||
}
|
||||
----
|
||||
+
|
||||
. If system boot fails, you will be dropped into a shell as seen in the example
|
||||
below.
|
||||
+
|
||||
----
|
||||
No root device found
|
||||
Dropping to debug shell.
|
||||
|
||||
#
|
||||
----
|
||||
+
|
||||
. Use this shell prompt to gather the information requested above
|
||||
(see <<all-bug-reports>>).
|
||||
|
||||
[[accessing-the-root-volume-from-the-dracut-shell]]
|
||||
==== Accessing the root volume from the dracut shell
|
||||
From the dracut debug shell, you can manually perform the task of locating and
|
||||
preparing your root volume for boot. The required steps will depend on how your
|
||||
root volume is configured. Common scenarios include:
|
||||
|
||||
* A block device (e.g. _/dev/sda7_)
|
||||
* A LVM logical volume (e.g. _/dev/VolGroup00/LogVol00_)
|
||||
* An encrypted device
|
||||
(e.g. _/dev/mapper/luks-4d5972ea-901c-4584-bd75-1da802417d83_)
|
||||
* A network attached device
|
||||
(e.g. _netroot=iscsi:@192.168.0.4::3260::iqn.2009-02.org.example:for.all_)
|
||||
|
||||
The exact method for locating and preparing will vary. However, to continue with
|
||||
a successful boot, the objective is to locate your root volume and create a
|
||||
symlink _/dev/root_ which points to the file system. For example, the following
|
||||
example demonstrates accessing and booting a root volume that is an encrypted
|
||||
LVM Logical volume.
|
||||
|
||||
. Inspect your partitions using parted
|
||||
+
|
||||
----
|
||||
# parted /dev/sda -s p
|
||||
Model: ATA HTS541060G9AT00 (scsi)
|
||||
Disk /dev/sda: 60.0GB
|
||||
Sector size (logical/physical): 512B/512B
|
||||
Partition Table: msdos
|
||||
Number Start End Size Type File system Flags
|
||||
1 32.3kB 10.8GB 107MB primary ext4 boot
|
||||
2 10.8GB 55.6GB 44.7GB logical lvm
|
||||
----
|
||||
+
|
||||
. You recall that your root volume was a LVM logical volume. Scan and activate
|
||||
any logical volumes.
|
||||
+
|
||||
----
|
||||
# lvm vgscan
|
||||
# lvm vgchange -ay
|
||||
----
|
||||
+
|
||||
. You should see any logical volumes now using the command blkid:
|
||||
+
|
||||
----
|
||||
# blkid
|
||||
/dev/sda1: UUID="3de247f3-5de4-4a44-afc5-1fe179750cf7" TYPE="ext4"
|
||||
/dev/sda2: UUID="Ek4dQw-cOtq-5MJu-OGRF-xz5k-O2l8-wdDj0I" TYPE="LVM2_member"
|
||||
/dev/mapper/linux-root: UUID="def0269e-424b-4752-acf3-1077bf96ad2c" TYPE="crypto_LUKS"
|
||||
/dev/mapper/linux-home: UUID="c69127c1-f153-4ea2-b58e-4cbfa9257c5e" TYPE="ext3"
|
||||
/dev/mapper/linux-swap: UUID="47b4d329-975c-4c08-b218-f9c9bf3635f1" TYPE="swap"
|
||||
----
|
||||
+
|
||||
. From the output above, you recall that your root volume exists on an encrypted
|
||||
block device. Following the guidance disk encryption guidance from the
|
||||
Installation Guide, you unlock your encrypted root volume.
|
||||
+
|
||||
----
|
||||
# UUID=$(cryptsetup luksUUID /dev/mapper/linux-root)
|
||||
# cryptsetup luksOpen /dev/mapper/linux-root luks-$UUID
|
||||
Enter passphrase for /dev/mapper/linux-root:
|
||||
Key slot 0 unlocked.
|
||||
----
|
||||
+
|
||||
. Next, make a symbolic link to the unlocked root volume
|
||||
+
|
||||
----
|
||||
# ln -s /dev/mapper/luks-$UUID /dev/root
|
||||
----
|
||||
+
|
||||
. With the root volume available, you may continue booting the system by exiting
|
||||
the dracut shell
|
||||
+
|
||||
----
|
||||
# exit
|
||||
----
|
||||
|
||||
[[additional-dracut-boot-parameters]]
|
||||
==== Additional dracut boot parameters
|
||||
For more debugging options, see *dracut.cmdline*(7).
|
||||
|
||||
|
||||
[[debugging-dracut-on-shutdown]]
|
||||
==== Debugging dracut on shutdown
|
||||
|
||||
To debug the shutdown sequence on systemd systems, you can _rd.break_
|
||||
on _pre-shutdown_ or _shutdown_.
|
||||
|
||||
To do this from an already booted system:
|
||||
----
|
||||
# mkdir -p /run/initramfs/etc/cmdline.d
|
||||
# echo "rd.break=pre-shutdown" > /run/initramfs/etc/cmdline.d/debug.conf
|
||||
# touch /run/initramfs/.need_shutdown
|
||||
----
|
||||
|
||||
This will give you a dracut shell after the system pivot'ed back in the
|
||||
initramfs.
|
||||
|
22
git2spec.pl
22
git2spec.pl
@@ -1,5 +1,21 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
sub last_tag {
|
||||
open( GIT, 'git log --pretty=format:%H |');
|
||||
LINE: while( <GIT> ) {
|
||||
open( GIT2, "git tag --contains $_ |");
|
||||
while( <GIT2> ) {
|
||||
chomp;
|
||||
last LINE if /..*/;
|
||||
}
|
||||
close GIT2;
|
||||
}
|
||||
$tag=$_;
|
||||
close GIT2;
|
||||
close GIT; # be done
|
||||
return $tag;
|
||||
};
|
||||
|
||||
sub create_patches {
|
||||
my $tag=shift;
|
||||
my $pdir=shift;
|
||||
@@ -15,12 +31,12 @@ my $datestr = strftime "%Y%m%d", gmtime;
|
||||
|
||||
my $tag=shift;
|
||||
my $pdir=shift;
|
||||
$tag=`git describe --abbrev=0 --tags` if not defined $tag;
|
||||
chomp($tag);
|
||||
$tag=&last_tag if not defined $tag;
|
||||
my @patches=&create_patches($tag, $pdir);
|
||||
my $num=$#patches + 2;
|
||||
$tag=~s/[^0-9]+?([0-9]+)/$1/;
|
||||
my $release="$num";
|
||||
my $release="$num.git$datestr";
|
||||
$release="1" if $num == 1;
|
||||
|
||||
while(<>) {
|
||||
if (/^Version:/) {
|
||||
|
@@ -1,7 +0,0 @@
|
||||
all:
|
||||
$(MAKE) -C ..
|
||||
|
||||
clean:
|
||||
$(MAKE) -C .. clean
|
||||
|
||||
.PHONY: all clean
|
File diff suppressed because it is too large
Load Diff
@@ -1,731 +0,0 @@
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
/***
|
||||
This file is part of systemd.
|
||||
|
||||
Copyright 2010 Lennart Poettering
|
||||
|
||||
systemd is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
systemd is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "hashmap.h"
|
||||
#include "macro.h"
|
||||
|
||||
#define NBUCKETS 127
|
||||
|
||||
struct hashmap_entry {
|
||||
const void *key;
|
||||
void *value;
|
||||
struct hashmap_entry *bucket_next, *bucket_previous;
|
||||
struct hashmap_entry *iterate_next, *iterate_previous;
|
||||
};
|
||||
|
||||
struct Hashmap {
|
||||
hash_func_t hash_func;
|
||||
compare_func_t compare_func;
|
||||
|
||||
struct hashmap_entry *iterate_list_head, *iterate_list_tail;
|
||||
unsigned n_entries;
|
||||
|
||||
bool from_pool;
|
||||
};
|
||||
|
||||
#define BY_HASH(h) ((struct hashmap_entry**) ((uint8_t*) (h) + ALIGN(sizeof(Hashmap))))
|
||||
|
||||
struct pool {
|
||||
struct pool *next;
|
||||
unsigned n_tiles;
|
||||
unsigned n_used;
|
||||
};
|
||||
|
||||
static struct pool *first_hashmap_pool = NULL;
|
||||
static void *first_hashmap_tile = NULL;
|
||||
|
||||
static struct pool *first_entry_pool = NULL;
|
||||
static void *first_entry_tile = NULL;
|
||||
|
||||
static void* allocate_tile(struct pool **first_pool, void **first_tile, size_t tile_size) {
|
||||
unsigned i;
|
||||
|
||||
if (*first_tile) {
|
||||
void *r;
|
||||
|
||||
r = *first_tile;
|
||||
*first_tile = * (void**) (*first_tile);
|
||||
return r;
|
||||
}
|
||||
|
||||
if (_unlikely_(!*first_pool) || _unlikely_((*first_pool)->n_used >= (*first_pool)->n_tiles)) {
|
||||
unsigned n;
|
||||
size_t size;
|
||||
struct pool *p;
|
||||
|
||||
n = *first_pool ? (*first_pool)->n_tiles : 0;
|
||||
n = MAX(512U, n * 2);
|
||||
size = PAGE_ALIGN(ALIGN(sizeof(struct pool)) + n*tile_size);
|
||||
n = (size - ALIGN(sizeof(struct pool))) / tile_size;
|
||||
|
||||
p = malloc(size);
|
||||
if (!p)
|
||||
return NULL;
|
||||
|
||||
p->next = *first_pool;
|
||||
p->n_tiles = n;
|
||||
p->n_used = 0;
|
||||
|
||||
*first_pool = p;
|
||||
}
|
||||
|
||||
i = (*first_pool)->n_used++;
|
||||
|
||||
return ((uint8_t*) (*first_pool)) + ALIGN(sizeof(struct pool)) + i*tile_size;
|
||||
}
|
||||
|
||||
static void deallocate_tile(void **first_tile, void *p) {
|
||||
* (void**) p = *first_tile;
|
||||
*first_tile = p;
|
||||
}
|
||||
|
||||
#ifndef __OPTIMIZE__
|
||||
|
||||
static void drop_pool(struct pool *p) {
|
||||
while (p) {
|
||||
struct pool *n;
|
||||
n = p->next;
|
||||
free(p);
|
||||
p = n;
|
||||
}
|
||||
}
|
||||
|
||||
__attribute__((destructor)) static void cleanup_pool(void) {
|
||||
/* Be nice to valgrind */
|
||||
|
||||
drop_pool(first_hashmap_pool);
|
||||
drop_pool(first_entry_pool);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
unsigned string_hash_func(const void *p) {
|
||||
unsigned hash = 5381;
|
||||
const signed char *c;
|
||||
|
||||
/* DJB's hash function */
|
||||
|
||||
for (c = p; *c; c++)
|
||||
hash = (hash << 5) + hash + (unsigned) *c;
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
int string_compare_func(const void *a, const void *b) {
|
||||
return strcmp(a, b);
|
||||
}
|
||||
|
||||
unsigned trivial_hash_func(const void *p) {
|
||||
return PTR_TO_UINT(p);
|
||||
}
|
||||
|
||||
int trivial_compare_func(const void *a, const void *b) {
|
||||
return a < b ? -1 : (a > b ? 1 : 0);
|
||||
}
|
||||
|
||||
Hashmap *hashmap_new(hash_func_t hash_func, compare_func_t compare_func) {
|
||||
bool b;
|
||||
Hashmap *h;
|
||||
size_t size;
|
||||
|
||||
b = is_main_thread();
|
||||
|
||||
size = ALIGN(sizeof(Hashmap)) + NBUCKETS * sizeof(struct hashmap_entry*);
|
||||
|
||||
if (b) {
|
||||
h = allocate_tile(&first_hashmap_pool, &first_hashmap_tile, size);
|
||||
if (!h)
|
||||
return NULL;
|
||||
|
||||
memset(h, 0, size);
|
||||
} else {
|
||||
h = malloc0(size);
|
||||
|
||||
if (!h)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
h->hash_func = hash_func ? hash_func : trivial_hash_func;
|
||||
h->compare_func = compare_func ? compare_func : trivial_compare_func;
|
||||
|
||||
h->n_entries = 0;
|
||||
h->iterate_list_head = h->iterate_list_tail = NULL;
|
||||
|
||||
h->from_pool = b;
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
int hashmap_ensure_allocated(Hashmap **h, hash_func_t hash_func, compare_func_t compare_func) {
|
||||
assert(h);
|
||||
|
||||
if (*h)
|
||||
return 0;
|
||||
|
||||
if (!(*h = hashmap_new(hash_func, compare_func)))
|
||||
return -ENOMEM;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void link_entry(Hashmap *h, struct hashmap_entry *e, unsigned hash) {
|
||||
assert(h);
|
||||
assert(e);
|
||||
|
||||
/* Insert into hash table */
|
||||
e->bucket_next = BY_HASH(h)[hash];
|
||||
e->bucket_previous = NULL;
|
||||
if (BY_HASH(h)[hash])
|
||||
BY_HASH(h)[hash]->bucket_previous = e;
|
||||
BY_HASH(h)[hash] = e;
|
||||
|
||||
/* Insert into iteration list */
|
||||
e->iterate_previous = h->iterate_list_tail;
|
||||
e->iterate_next = NULL;
|
||||
if (h->iterate_list_tail) {
|
||||
assert(h->iterate_list_head);
|
||||
h->iterate_list_tail->iterate_next = e;
|
||||
} else {
|
||||
assert(!h->iterate_list_head);
|
||||
h->iterate_list_head = e;
|
||||
}
|
||||
h->iterate_list_tail = e;
|
||||
|
||||
h->n_entries++;
|
||||
assert(h->n_entries >= 1);
|
||||
}
|
||||
|
||||
static void unlink_entry(Hashmap *h, struct hashmap_entry *e, unsigned hash) {
|
||||
assert(h);
|
||||
assert(e);
|
||||
|
||||
/* Remove from iteration list */
|
||||
if (e->iterate_next)
|
||||
e->iterate_next->iterate_previous = e->iterate_previous;
|
||||
else
|
||||
h->iterate_list_tail = e->iterate_previous;
|
||||
|
||||
if (e->iterate_previous)
|
||||
e->iterate_previous->iterate_next = e->iterate_next;
|
||||
else
|
||||
h->iterate_list_head = e->iterate_next;
|
||||
|
||||
/* Remove from hash table bucket list */
|
||||
if (e->bucket_next)
|
||||
e->bucket_next->bucket_previous = e->bucket_previous;
|
||||
|
||||
if (e->bucket_previous)
|
||||
e->bucket_previous->bucket_next = e->bucket_next;
|
||||
else
|
||||
BY_HASH(h)[hash] = e->bucket_next;
|
||||
|
||||
assert(h->n_entries >= 1);
|
||||
h->n_entries--;
|
||||
}
|
||||
|
||||
static void remove_entry(Hashmap *h, struct hashmap_entry *e) {
|
||||
unsigned hash;
|
||||
|
||||
assert(h);
|
||||
assert(e);
|
||||
|
||||
hash = h->hash_func(e->key) % NBUCKETS;
|
||||
|
||||
unlink_entry(h, e, hash);
|
||||
|
||||
if (h->from_pool)
|
||||
deallocate_tile(&first_entry_tile, e);
|
||||
else
|
||||
free(e);
|
||||
}
|
||||
|
||||
void hashmap_free(Hashmap*h) {
|
||||
|
||||
if (!h)
|
||||
return;
|
||||
|
||||
hashmap_clear(h);
|
||||
|
||||
if (h->from_pool)
|
||||
deallocate_tile(&first_hashmap_tile, h);
|
||||
else
|
||||
free(h);
|
||||
}
|
||||
|
||||
void hashmap_free_free(Hashmap *h) {
|
||||
void *p;
|
||||
|
||||
while ((p = hashmap_steal_first(h)))
|
||||
free(p);
|
||||
|
||||
hashmap_free(h);
|
||||
}
|
||||
|
||||
void hashmap_clear(Hashmap *h) {
|
||||
if (!h)
|
||||
return;
|
||||
|
||||
while (h->iterate_list_head)
|
||||
remove_entry(h, h->iterate_list_head);
|
||||
}
|
||||
|
||||
static struct hashmap_entry *hash_scan(Hashmap *h, unsigned hash, const void *key) {
|
||||
struct hashmap_entry *e;
|
||||
assert(h);
|
||||
assert(hash < NBUCKETS);
|
||||
|
||||
for (e = BY_HASH(h)[hash]; e; e = e->bucket_next)
|
||||
if (h->compare_func(e->key, key) == 0)
|
||||
return e;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int hashmap_put(Hashmap *h, const void *key, void *value) {
|
||||
struct hashmap_entry *e;
|
||||
unsigned hash;
|
||||
|
||||
assert(h);
|
||||
|
||||
hash = h->hash_func(key) % NBUCKETS;
|
||||
|
||||
if ((e = hash_scan(h, hash, key))) {
|
||||
|
||||
if (e->value == value)
|
||||
return 0;
|
||||
|
||||
return -EEXIST;
|
||||
}
|
||||
|
||||
if (h->from_pool)
|
||||
e = allocate_tile(&first_entry_pool, &first_entry_tile, sizeof(struct hashmap_entry));
|
||||
else
|
||||
e = new(struct hashmap_entry, 1);
|
||||
|
||||
if (!e)
|
||||
return -ENOMEM;
|
||||
|
||||
e->key = key;
|
||||
e->value = value;
|
||||
|
||||
link_entry(h, e, hash);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int hashmap_replace(Hashmap *h, const void *key, void *value) {
|
||||
struct hashmap_entry *e;
|
||||
unsigned hash;
|
||||
|
||||
assert(h);
|
||||
|
||||
hash = h->hash_func(key) % NBUCKETS;
|
||||
|
||||
if ((e = hash_scan(h, hash, key))) {
|
||||
e->key = key;
|
||||
e->value = value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return hashmap_put(h, key, value);
|
||||
}
|
||||
|
||||
void* hashmap_get(Hashmap *h, const void *key) {
|
||||
unsigned hash;
|
||||
struct hashmap_entry *e;
|
||||
|
||||
if (!h)
|
||||
return NULL;
|
||||
|
||||
hash = h->hash_func(key) % NBUCKETS;
|
||||
|
||||
if (!(e = hash_scan(h, hash, key)))
|
||||
return NULL;
|
||||
|
||||
return e->value;
|
||||
}
|
||||
|
||||
void* hashmap_remove(Hashmap *h, const void *key) {
|
||||
struct hashmap_entry *e;
|
||||
unsigned hash;
|
||||
void *data;
|
||||
|
||||
if (!h)
|
||||
return NULL;
|
||||
|
||||
hash = h->hash_func(key) % NBUCKETS;
|
||||
|
||||
if (!(e = hash_scan(h, hash, key)))
|
||||
return NULL;
|
||||
|
||||
data = e->value;
|
||||
remove_entry(h, e);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
int hashmap_remove_and_put(Hashmap *h, const void *old_key, const void *new_key, void *value) {
|
||||
struct hashmap_entry *e;
|
||||
unsigned old_hash, new_hash;
|
||||
|
||||
if (!h)
|
||||
return -ENOENT;
|
||||
|
||||
old_hash = h->hash_func(old_key) % NBUCKETS;
|
||||
if (!(e = hash_scan(h, old_hash, old_key)))
|
||||
return -ENOENT;
|
||||
|
||||
new_hash = h->hash_func(new_key) % NBUCKETS;
|
||||
if (hash_scan(h, new_hash, new_key))
|
||||
return -EEXIST;
|
||||
|
||||
unlink_entry(h, e, old_hash);
|
||||
|
||||
e->key = new_key;
|
||||
e->value = value;
|
||||
|
||||
link_entry(h, e, new_hash);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hashmap_remove_and_replace(Hashmap *h, const void *old_key, const void *new_key, void *value) {
|
||||
struct hashmap_entry *e, *k;
|
||||
unsigned old_hash, new_hash;
|
||||
|
||||
if (!h)
|
||||
return -ENOENT;
|
||||
|
||||
old_hash = h->hash_func(old_key) % NBUCKETS;
|
||||
if (!(e = hash_scan(h, old_hash, old_key)))
|
||||
return -ENOENT;
|
||||
|
||||
new_hash = h->hash_func(new_key) % NBUCKETS;
|
||||
|
||||
if ((k = hash_scan(h, new_hash, new_key)))
|
||||
if (e != k)
|
||||
remove_entry(h, k);
|
||||
|
||||
unlink_entry(h, e, old_hash);
|
||||
|
||||
e->key = new_key;
|
||||
e->value = value;
|
||||
|
||||
link_entry(h, e, new_hash);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* hashmap_remove_value(Hashmap *h, const void *key, void *value) {
|
||||
struct hashmap_entry *e;
|
||||
unsigned hash;
|
||||
|
||||
if (!h)
|
||||
return NULL;
|
||||
|
||||
hash = h->hash_func(key) % NBUCKETS;
|
||||
|
||||
if (!(e = hash_scan(h, hash, key)))
|
||||
return NULL;
|
||||
|
||||
if (e->value != value)
|
||||
return NULL;
|
||||
|
||||
remove_entry(h, e);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void *hashmap_iterate(Hashmap *h, Iterator *i, const void **key) {
|
||||
struct hashmap_entry *e;
|
||||
|
||||
assert(i);
|
||||
|
||||
if (!h)
|
||||
goto at_end;
|
||||
|
||||
if (*i == ITERATOR_LAST)
|
||||
goto at_end;
|
||||
|
||||
if (*i == ITERATOR_FIRST && !h->iterate_list_head)
|
||||
goto at_end;
|
||||
|
||||
e = *i == ITERATOR_FIRST ? h->iterate_list_head : (struct hashmap_entry*) *i;
|
||||
|
||||
if (e->iterate_next)
|
||||
*i = (Iterator) e->iterate_next;
|
||||
else
|
||||
*i = ITERATOR_LAST;
|
||||
|
||||
if (key)
|
||||
*key = e->key;
|
||||
|
||||
return e->value;
|
||||
|
||||
at_end:
|
||||
*i = ITERATOR_LAST;
|
||||
|
||||
if (key)
|
||||
*key = NULL;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *hashmap_iterate_backwards(Hashmap *h, Iterator *i, const void **key) {
|
||||
struct hashmap_entry *e;
|
||||
|
||||
assert(i);
|
||||
|
||||
if (!h)
|
||||
goto at_beginning;
|
||||
|
||||
if (*i == ITERATOR_FIRST)
|
||||
goto at_beginning;
|
||||
|
||||
if (*i == ITERATOR_LAST && !h->iterate_list_tail)
|
||||
goto at_beginning;
|
||||
|
||||
e = *i == ITERATOR_LAST ? h->iterate_list_tail : (struct hashmap_entry*) *i;
|
||||
|
||||
if (e->iterate_previous)
|
||||
*i = (Iterator) e->iterate_previous;
|
||||
else
|
||||
*i = ITERATOR_FIRST;
|
||||
|
||||
if (key)
|
||||
*key = e->key;
|
||||
|
||||
return e->value;
|
||||
|
||||
at_beginning:
|
||||
*i = ITERATOR_FIRST;
|
||||
|
||||
if (key)
|
||||
*key = NULL;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *hashmap_iterate_skip(Hashmap *h, const void *key, Iterator *i) {
|
||||
unsigned hash;
|
||||
struct hashmap_entry *e;
|
||||
|
||||
if (!h)
|
||||
return NULL;
|
||||
|
||||
hash = h->hash_func(key) % NBUCKETS;
|
||||
|
||||
if (!(e = hash_scan(h, hash, key)))
|
||||
return NULL;
|
||||
|
||||
*i = (Iterator) e;
|
||||
|
||||
return e->value;
|
||||
}
|
||||
|
||||
void* hashmap_first(Hashmap *h) {
|
||||
|
||||
if (!h)
|
||||
return NULL;
|
||||
|
||||
if (!h->iterate_list_head)
|
||||
return NULL;
|
||||
|
||||
return h->iterate_list_head->value;
|
||||
}
|
||||
|
||||
void* hashmap_first_key(Hashmap *h) {
|
||||
|
||||
if (!h)
|
||||
return NULL;
|
||||
|
||||
if (!h->iterate_list_head)
|
||||
return NULL;
|
||||
|
||||
return (void*) h->iterate_list_head->key;
|
||||
}
|
||||
|
||||
void* hashmap_last(Hashmap *h) {
|
||||
|
||||
if (!h)
|
||||
return NULL;
|
||||
|
||||
if (!h->iterate_list_tail)
|
||||
return NULL;
|
||||
|
||||
return h->iterate_list_tail->value;
|
||||
}
|
||||
|
||||
void* hashmap_steal_first(Hashmap *h) {
|
||||
void *data;
|
||||
|
||||
if (!h)
|
||||
return NULL;
|
||||
|
||||
if (!h->iterate_list_head)
|
||||
return NULL;
|
||||
|
||||
data = h->iterate_list_head->value;
|
||||
remove_entry(h, h->iterate_list_head);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void* hashmap_steal_first_key(Hashmap *h) {
|
||||
void *key;
|
||||
|
||||
if (!h)
|
||||
return NULL;
|
||||
|
||||
if (!h->iterate_list_head)
|
||||
return NULL;
|
||||
|
||||
key = (void*) h->iterate_list_head->key;
|
||||
remove_entry(h, h->iterate_list_head);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
unsigned hashmap_size(Hashmap *h) {
|
||||
|
||||
if (!h)
|
||||
return 0;
|
||||
|
||||
return h->n_entries;
|
||||
}
|
||||
|
||||
bool hashmap_isempty(Hashmap *h) {
|
||||
|
||||
if (!h)
|
||||
return true;
|
||||
|
||||
return h->n_entries == 0;
|
||||
}
|
||||
|
||||
int hashmap_merge(Hashmap *h, Hashmap *other) {
|
||||
struct hashmap_entry *e;
|
||||
|
||||
assert(h);
|
||||
|
||||
if (!other)
|
||||
return 0;
|
||||
|
||||
for (e = other->iterate_list_head; e; e = e->iterate_next) {
|
||||
int r;
|
||||
|
||||
if ((r = hashmap_put(h, e->key, e->value)) < 0)
|
||||
if (r != -EEXIST)
|
||||
return r;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void hashmap_move(Hashmap *h, Hashmap *other) {
|
||||
struct hashmap_entry *e, *n;
|
||||
|
||||
assert(h);
|
||||
|
||||
/* The same as hashmap_merge(), but every new item from other
|
||||
* is moved to h. This function is guaranteed to succeed. */
|
||||
|
||||
if (!other)
|
||||
return;
|
||||
|
||||
for (e = other->iterate_list_head; e; e = n) {
|
||||
unsigned h_hash, other_hash;
|
||||
|
||||
n = e->iterate_next;
|
||||
|
||||
h_hash = h->hash_func(e->key) % NBUCKETS;
|
||||
|
||||
if (hash_scan(h, h_hash, e->key))
|
||||
continue;
|
||||
|
||||
other_hash = other->hash_func(e->key) % NBUCKETS;
|
||||
|
||||
unlink_entry(other, e, other_hash);
|
||||
link_entry(h, e, h_hash);
|
||||
}
|
||||
}
|
||||
|
||||
int hashmap_move_one(Hashmap *h, Hashmap *other, const void *key) {
|
||||
unsigned h_hash, other_hash;
|
||||
struct hashmap_entry *e;
|
||||
|
||||
if (!other)
|
||||
return 0;
|
||||
|
||||
assert(h);
|
||||
|
||||
h_hash = h->hash_func(key) % NBUCKETS;
|
||||
if (hash_scan(h, h_hash, key))
|
||||
return -EEXIST;
|
||||
|
||||
other_hash = other->hash_func(key) % NBUCKETS;
|
||||
if (!(e = hash_scan(other, other_hash, key)))
|
||||
return -ENOENT;
|
||||
|
||||
unlink_entry(other, e, other_hash);
|
||||
link_entry(h, e, h_hash);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Hashmap *hashmap_copy(Hashmap *h) {
|
||||
Hashmap *copy;
|
||||
|
||||
assert(h);
|
||||
|
||||
if (!(copy = hashmap_new(h->hash_func, h->compare_func)))
|
||||
return NULL;
|
||||
|
||||
if (hashmap_merge(copy, h) < 0) {
|
||||
hashmap_free(copy);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
char **hashmap_get_strv(Hashmap *h) {
|
||||
char **sv;
|
||||
Iterator it;
|
||||
char *item;
|
||||
int n;
|
||||
|
||||
sv = new(char*, h->n_entries+1);
|
||||
if (!sv)
|
||||
return NULL;
|
||||
|
||||
n = 0;
|
||||
HASHMAP_FOREACH(item, h, it)
|
||||
sv[n++] = item;
|
||||
sv[n] = NULL;
|
||||
|
||||
return sv;
|
||||
}
|
@@ -1,91 +0,0 @@
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
#ifndef foohashmaphfoo
|
||||
#define foohashmaphfoo
|
||||
|
||||
/***
|
||||
This file is part of systemd.
|
||||
|
||||
Copyright 2010 Lennart Poettering
|
||||
|
||||
systemd is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
systemd is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Pretty straightforward hash table implementation. As a minor
|
||||
* optimization a NULL hashmap object will be treated as empty hashmap
|
||||
* for all read operations. That way it is not necessary to
|
||||
* instantiate an object for each Hashmap use. */
|
||||
|
||||
typedef struct Hashmap Hashmap;
|
||||
typedef struct _IteratorStruct _IteratorStruct;
|
||||
typedef _IteratorStruct* Iterator;
|
||||
|
||||
#define ITERATOR_FIRST ((Iterator) 0)
|
||||
#define ITERATOR_LAST ((Iterator) -1)
|
||||
|
||||
typedef unsigned (*hash_func_t)(const void *p);
|
||||
typedef int (*compare_func_t)(const void *a, const void *b);
|
||||
|
||||
unsigned string_hash_func(const void *p);
|
||||
int string_compare_func(const void *a, const void *b);
|
||||
|
||||
unsigned trivial_hash_func(const void *p);
|
||||
int trivial_compare_func(const void *a, const void *b);
|
||||
|
||||
Hashmap *hashmap_new(hash_func_t hash_func, compare_func_t compare_func);
|
||||
void hashmap_free(Hashmap *h);
|
||||
void hashmap_free_free(Hashmap *h);
|
||||
Hashmap *hashmap_copy(Hashmap *h);
|
||||
int hashmap_ensure_allocated(Hashmap **h, hash_func_t hash_func, compare_func_t compare_func);
|
||||
|
||||
int hashmap_put(Hashmap *h, const void *key, void *value);
|
||||
int hashmap_replace(Hashmap *h, const void *key, void *value);
|
||||
void* hashmap_get(Hashmap *h, const void *key);
|
||||
void* hashmap_remove(Hashmap *h, const void *key);
|
||||
void* hashmap_remove_value(Hashmap *h, const void *key, void *value);
|
||||
int hashmap_remove_and_put(Hashmap *h, const void *old_key, const void *new_key, void *value);
|
||||
int hashmap_remove_and_replace(Hashmap *h, const void *old_key, const void *new_key, void *value);
|
||||
|
||||
int hashmap_merge(Hashmap *h, Hashmap *other);
|
||||
void hashmap_move(Hashmap *h, Hashmap *other);
|
||||
int hashmap_move_one(Hashmap *h, Hashmap *other, const void *key);
|
||||
|
||||
unsigned hashmap_size(Hashmap *h);
|
||||
bool hashmap_isempty(Hashmap *h);
|
||||
|
||||
void *hashmap_iterate(Hashmap *h, Iterator *i, const void **key);
|
||||
void *hashmap_iterate_backwards(Hashmap *h, Iterator *i, const void **key);
|
||||
void *hashmap_iterate_skip(Hashmap *h, const void *key, Iterator *i);
|
||||
|
||||
void hashmap_clear(Hashmap *h);
|
||||
void *hashmap_steal_first(Hashmap *h);
|
||||
void *hashmap_steal_first_key(Hashmap *h);
|
||||
void* hashmap_first(Hashmap *h);
|
||||
void* hashmap_first_key(Hashmap *h);
|
||||
void* hashmap_last(Hashmap *h);
|
||||
|
||||
char **hashmap_get_strv(Hashmap *h);
|
||||
|
||||
#define HASHMAP_FOREACH(e, h, i) \
|
||||
for ((i) = ITERATOR_FIRST, (e) = hashmap_iterate((h), &(i), NULL); (e); (e) = hashmap_iterate((h), &(i), NULL))
|
||||
|
||||
#define HASHMAP_FOREACH_KEY(e, k, h, i) \
|
||||
for ((i) = ITERATOR_FIRST, (e) = hashmap_iterate((h), &(i), (const void**) &(k)); (e); (e) = hashmap_iterate((h), &(i), (const void**) &(k)))
|
||||
|
||||
#define HASHMAP_FOREACH_BACKWARDS(e, h, i) \
|
||||
for ((i) = ITERATOR_LAST, (e) = hashmap_iterate_backwards((h), &(i), NULL); (e); (e) = hashmap_iterate_backwards((h), &(i), NULL))
|
||||
|
||||
#endif
|
@@ -1,12 +0,0 @@
|
||||
# src/shared/hashmap.lo - a libtool object file
|
||||
# Generated by libtool (GNU libtool) 2.4.2
|
||||
#
|
||||
# Please DO NOT delete this file!
|
||||
# It is necessary for linking the library.
|
||||
|
||||
# Name of the PIC object.
|
||||
pic_object='.libs/hashmap.o'
|
||||
|
||||
# Name of the non-PIC object
|
||||
non_pic_object='hashmap.o'
|
||||
|
294
install/log.c
294
install/log.c
@@ -1,294 +0,0 @@
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
/***
|
||||
This file is part of systemd.
|
||||
|
||||
Copyright 2010 Lennart Poettering
|
||||
|
||||
systemd is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
systemd is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "log.h"
|
||||
#include "util.h"
|
||||
#include "macro.h"
|
||||
|
||||
#define SNDBUF_SIZE (8*1024*1024)
|
||||
|
||||
static LogTarget log_target = LOG_TARGET_CONSOLE;
|
||||
static int log_max_level = LOG_WARNING;
|
||||
static int log_facility = LOG_DAEMON;
|
||||
|
||||
static int console_fd = STDERR_FILENO;
|
||||
|
||||
static bool show_location = false;
|
||||
|
||||
/* Akin to glibc's __abort_msg; which is private and we hence cannot
|
||||
* use here. */
|
||||
static char *log_abort_msg = NULL;
|
||||
|
||||
void log_close_console(void) {
|
||||
|
||||
if (console_fd < 0)
|
||||
return;
|
||||
|
||||
if (getpid() == 1) {
|
||||
if (console_fd >= 3)
|
||||
close_nointr_nofail(console_fd);
|
||||
|
||||
console_fd = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static int log_open_console(void) {
|
||||
|
||||
if (console_fd >= 0)
|
||||
return 0;
|
||||
|
||||
if (getpid() == 1) {
|
||||
|
||||
console_fd = open_terminal("/dev/console", O_WRONLY|O_NOCTTY|O_CLOEXEC);
|
||||
if (console_fd < 0) {
|
||||
log_error("Failed to open /dev/console for logging: %s", strerror(-console_fd));
|
||||
return console_fd;
|
||||
}
|
||||
|
||||
log_debug("Successfully opened /dev/console for logging.");
|
||||
} else
|
||||
console_fd = STDERR_FILENO;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int log_open(void) {
|
||||
return log_open_console();
|
||||
}
|
||||
|
||||
|
||||
void log_close(void) {
|
||||
log_close_console();
|
||||
}
|
||||
|
||||
|
||||
void log_set_max_level(int level) {
|
||||
assert((level & LOG_PRIMASK) == level);
|
||||
|
||||
log_max_level = level;
|
||||
}
|
||||
|
||||
void log_set_facility(int facility) {
|
||||
log_facility = facility;
|
||||
}
|
||||
|
||||
static int write_to_console(
|
||||
int level,
|
||||
const char*file,
|
||||
int line,
|
||||
const char *func,
|
||||
const char *buffer) {
|
||||
|
||||
char location[64];
|
||||
struct iovec iovec[5];
|
||||
unsigned n = 0;
|
||||
|
||||
if (console_fd < 0)
|
||||
return 0;
|
||||
|
||||
zero(iovec);
|
||||
|
||||
IOVEC_SET_STRING(iovec[n++], "dracut-install: ");
|
||||
|
||||
if (show_location) {
|
||||
snprintf(location, sizeof(location), "(%s:%u) ", file, line);
|
||||
IOVEC_SET_STRING(iovec[n++], location);
|
||||
}
|
||||
|
||||
IOVEC_SET_STRING(iovec[n++], buffer);
|
||||
IOVEC_SET_STRING(iovec[n++], "\n");
|
||||
|
||||
if (writev(console_fd, iovec, n) < 0)
|
||||
return -errno;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int log_dispatch(
|
||||
int level,
|
||||
const char*file,
|
||||
int line,
|
||||
const char *func,
|
||||
char *buffer) {
|
||||
|
||||
int r = 0;
|
||||
|
||||
if (log_target == LOG_TARGET_NULL)
|
||||
return 0;
|
||||
|
||||
/* Patch in LOG_DAEMON facility if necessary */
|
||||
if ((level & LOG_FACMASK) == 0)
|
||||
level = log_facility | LOG_PRI(level);
|
||||
|
||||
do {
|
||||
char *e;
|
||||
int k = 0;
|
||||
|
||||
buffer += strspn(buffer, NEWLINE);
|
||||
|
||||
if (buffer[0] == 0)
|
||||
break;
|
||||
|
||||
if ((e = strpbrk(buffer, NEWLINE)))
|
||||
*(e++) = 0;
|
||||
|
||||
k = write_to_console(level, file, line, func, buffer);
|
||||
if (k < 0)
|
||||
return k;
|
||||
buffer = e;
|
||||
} while (buffer);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int log_metav(
|
||||
int level,
|
||||
const char*file,
|
||||
int line,
|
||||
const char *func,
|
||||
const char *format,
|
||||
va_list ap) {
|
||||
|
||||
char buffer[LINE_MAX];
|
||||
int saved_errno, r;
|
||||
|
||||
if (_likely_(LOG_PRI(level) > log_max_level))
|
||||
return 0;
|
||||
|
||||
saved_errno = errno;
|
||||
vsnprintf(buffer, sizeof(buffer), format, ap);
|
||||
char_array_0(buffer);
|
||||
|
||||
r = log_dispatch(level, file, line, func, buffer);
|
||||
errno = saved_errno;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int log_meta(
|
||||
int level,
|
||||
const char*file,
|
||||
int line,
|
||||
const char *func,
|
||||
const char *format, ...) {
|
||||
|
||||
int r;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
r = log_metav(level, file, line, func, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||||
_noreturn_ static void log_assert(const char *text, const char *file, int line, const char *func, const char *format) {
|
||||
static char buffer[LINE_MAX];
|
||||
|
||||
snprintf(buffer, sizeof(buffer), format, text, file, line, func);
|
||||
|
||||
char_array_0(buffer);
|
||||
log_abort_msg = buffer;
|
||||
|
||||
log_dispatch(LOG_CRIT, file, line, func, buffer);
|
||||
abort();
|
||||
}
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
_noreturn_ void log_assert_failed(const char *text, const char *file, int line, const char *func) {
|
||||
log_assert(text, file, line, func, "Assertion '%s' failed at %s:%u, function %s(). Aborting.");
|
||||
}
|
||||
|
||||
_noreturn_ void log_assert_failed_unreachable(const char *text, const char *file, int line, const char *func) {
|
||||
log_assert(text, file, line, func, "Code should not be reached '%s' at %s:%u, function %s(). Aborting.");
|
||||
}
|
||||
|
||||
void log_set_target(LogTarget target) {
|
||||
assert(target >= 0);
|
||||
assert(target < _LOG_TARGET_MAX);
|
||||
|
||||
log_target = target;
|
||||
}
|
||||
|
||||
int log_set_target_from_string(const char *e) {
|
||||
LogTarget t;
|
||||
|
||||
t = log_target_from_string(e);
|
||||
if (t < 0)
|
||||
return -EINVAL;
|
||||
|
||||
log_set_target(t);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int log_set_max_level_from_string(const char *e) {
|
||||
int t;
|
||||
|
||||
t = log_level_from_string(e);
|
||||
if (t < 0)
|
||||
return t;
|
||||
|
||||
log_set_max_level(t);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void log_parse_environment(void) {
|
||||
const char *e;
|
||||
|
||||
if ((e = getenv("DRACUT_LOG_TARGET")))
|
||||
if (log_set_target_from_string(e) < 0)
|
||||
log_warning("Failed to parse log target %s. Ignoring.", e);
|
||||
|
||||
if ((e = getenv("DRACUT_LOG_LEVEL")))
|
||||
if (log_set_max_level_from_string(e) < 0)
|
||||
log_warning("Failed to parse log level %s. Ignoring.", e);
|
||||
|
||||
}
|
||||
|
||||
LogTarget log_get_target(void) {
|
||||
return log_target;
|
||||
}
|
||||
|
||||
int log_get_max_level(void) {
|
||||
return log_max_level;
|
||||
}
|
||||
|
||||
|
||||
static const char *const log_target_table[] = {
|
||||
[LOG_TARGET_CONSOLE] = "console",
|
||||
[LOG_TARGET_AUTO] = "auto",
|
||||
[LOG_TARGET_SAFE] = "safe",
|
||||
[LOG_TARGET_NULL] = "null"
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(log_target, LogTarget);
|
115
install/log.h
115
install/log.h
@@ -1,115 +0,0 @@
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
#ifndef foologhfoo
|
||||
#define foologhfoo
|
||||
|
||||
/***
|
||||
This file is part of systemd.
|
||||
|
||||
Copyright 2010 Lennart Poettering
|
||||
|
||||
systemd is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
systemd is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <syslog.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "macro.h"
|
||||
|
||||
typedef enum LogTarget{
|
||||
LOG_TARGET_CONSOLE,
|
||||
LOG_TARGET_KMSG,
|
||||
LOG_TARGET_JOURNAL,
|
||||
LOG_TARGET_JOURNAL_OR_KMSG,
|
||||
LOG_TARGET_SYSLOG,
|
||||
LOG_TARGET_SYSLOG_OR_KMSG,
|
||||
LOG_TARGET_AUTO, /* console if stderr is tty, JOURNAL_OR_KMSG otherwise */
|
||||
LOG_TARGET_SAFE, /* console if stderr is tty, KMSG otherwise */
|
||||
LOG_TARGET_NULL,
|
||||
_LOG_TARGET_MAX,
|
||||
_LOG_TARGET_INVALID = -1
|
||||
} LogTarget;
|
||||
|
||||
void log_set_target(LogTarget target);
|
||||
void log_set_max_level(int level);
|
||||
void log_set_facility(int facility);
|
||||
|
||||
int log_set_target_from_string(const char *e);
|
||||
int log_set_max_level_from_string(const char *e);
|
||||
|
||||
void log_show_color(bool b);
|
||||
void log_show_location(bool b);
|
||||
|
||||
int log_show_color_from_string(const char *e);
|
||||
int log_show_location_from_string(const char *e);
|
||||
|
||||
LogTarget log_get_target(void);
|
||||
int log_get_max_level(void);
|
||||
|
||||
int log_open(void);
|
||||
void log_close(void);
|
||||
void log_forget_fds(void);
|
||||
|
||||
void log_close_syslog(void);
|
||||
void log_close_journal(void);
|
||||
void log_close_kmsg(void);
|
||||
void log_close_console(void);
|
||||
|
||||
void log_parse_environment(void);
|
||||
|
||||
int log_meta(
|
||||
int level,
|
||||
const char*file,
|
||||
int line,
|
||||
const char *func,
|
||||
const char *format, ...) _printf_attr_(5,6);
|
||||
|
||||
int log_metav(
|
||||
int level,
|
||||
const char*file,
|
||||
int line,
|
||||
const char *func,
|
||||
const char *format,
|
||||
va_list ap);
|
||||
|
||||
_noreturn_ void log_assert_failed(const char *text, const char *file, int line, const char *func);
|
||||
_noreturn_ void log_assert_failed_unreachable(const char *text, const char *file, int line, const char *func);
|
||||
|
||||
/* This modifies the buffer passed! */
|
||||
int log_dump_internal(
|
||||
int level,
|
||||
const char*file,
|
||||
int line,
|
||||
const char *func,
|
||||
char *buffer);
|
||||
|
||||
#define log_full(level, ...) log_meta(level, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
|
||||
#define log_debug(...) log_meta(LOG_DEBUG, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
#define log_info(...) log_meta(LOG_INFO, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
#define log_notice(...) log_meta(LOG_NOTICE, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
#define log_warning(...) log_meta(LOG_WARNING, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
#define log_error(...) log_meta(LOG_ERR, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
||||
|
||||
/* This modifies the buffer passed! */
|
||||
#define log_dump(level, buffer) log_dump_internal(level, __FILE__, __LINE__, __func__, buffer)
|
||||
|
||||
const char *log_target_to_string(LogTarget target);
|
||||
LogTarget log_target_from_string(const char *s);
|
||||
|
||||
const char *log_level_to_string(int i);
|
||||
int log_level_from_string(const char *s);
|
||||
|
||||
#endif
|
284
install/macro.h
284
install/macro.h
@@ -1,284 +0,0 @@
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/***
|
||||
This file is part of systemd.
|
||||
|
||||
Copyright 2010 Lennart Poettering
|
||||
|
||||
systemd is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
systemd is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <assert.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#define _printf_attr_(a,b) __attribute__ ((format (printf, a, b)))
|
||||
#define _sentinel_ __attribute__ ((sentinel))
|
||||
#define _noreturn_ __attribute__((noreturn))
|
||||
#define _unused_ __attribute__ ((unused))
|
||||
#define _destructor_ __attribute__ ((destructor))
|
||||
#define _pure_ __attribute__ ((pure))
|
||||
#define _const_ __attribute__ ((const))
|
||||
#define _deprecated_ __attribute__ ((deprecated))
|
||||
#define _packed_ __attribute__ ((packed))
|
||||
#define _malloc_ __attribute__ ((malloc))
|
||||
#define _weak_ __attribute__ ((weak))
|
||||
#define _likely_(x) (__builtin_expect(!!(x),1))
|
||||
#define _unlikely_(x) (__builtin_expect(!!(x),0))
|
||||
#define _public_ __attribute__ ((visibility("default")))
|
||||
#define _hidden_ __attribute__ ((visibility("hidden")))
|
||||
#define _weakref_(x) __attribute__((weakref(#x)))
|
||||
#define _introspect_(x) __attribute__((section("introspect." x)))
|
||||
#define _alignas_(x) __attribute__((aligned(__alignof(x))))
|
||||
#define _cleanup_(x) __attribute__((cleanup(x)))
|
||||
|
||||
/* automake test harness */
|
||||
#define EXIT_TEST_SKIP 77
|
||||
|
||||
#define XSTRINGIFY(x) #x
|
||||
#define STRINGIFY(x) XSTRINGIFY(x)
|
||||
|
||||
/* Rounds up */
|
||||
|
||||
#define ALIGN4(l) (((l) + 3) & ~3)
|
||||
#define ALIGN8(l) (((l) + 7) & ~7)
|
||||
|
||||
#if __SIZEOF_POINTER__ == 8
|
||||
#define ALIGN(l) ALIGN8(l)
|
||||
#elif __SIZEOF_POINTER__ == 4
|
||||
#define ALIGN(l) ALIGN4(l)
|
||||
#else
|
||||
#error "Wut? Pointers are neither 4 nor 8 bytes long?"
|
||||
#endif
|
||||
|
||||
#define ALIGN_PTR(p) ((void*) ALIGN((unsigned long) p))
|
||||
#define ALIGN4_PTR(p) ((void*) ALIGN4((unsigned long) p))
|
||||
#define ALIGN8_PTR(p) ((void*) ALIGN8((unsigned long) p))
|
||||
|
||||
static inline size_t ALIGN_TO(size_t l, size_t ali) {
|
||||
return ((l + ali - 1) & ~(ali - 1));
|
||||
}
|
||||
|
||||
#define ALIGN_TO_PTR(p, ali) ((void*) ALIGN_TO((unsigned long) p))
|
||||
|
||||
#define ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0]))
|
||||
|
||||
/*
|
||||
* container_of - cast a member of a structure out to the containing structure
|
||||
* @ptr: the pointer to the member.
|
||||
* @type: the type of the container struct this is embedded in.
|
||||
* @member: the name of the member within the struct.
|
||||
*
|
||||
*/
|
||||
#define container_of(ptr, type, member) \
|
||||
__extension__ ({ \
|
||||
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)( (char *)__mptr - offsetof(type,member) ); \
|
||||
})
|
||||
|
||||
#undef MAX
|
||||
#define MAX(a,b) \
|
||||
__extension__ ({ \
|
||||
typeof(a) _a = (a); \
|
||||
typeof(b) _b = (b); \
|
||||
_a > _b ? _a : _b; \
|
||||
})
|
||||
|
||||
#define MAX3(x,y,z) \
|
||||
__extension__ ({ \
|
||||
typeof(x) _c = MAX(x,y); \
|
||||
MAX(_c, z); \
|
||||
})
|
||||
|
||||
#undef MIN
|
||||
#define MIN(a,b) \
|
||||
__extension__ ({ \
|
||||
typeof(a) _a = (a); \
|
||||
typeof(b) _b = (b); \
|
||||
_a < _b ? _a : _b; \
|
||||
})
|
||||
|
||||
#ifndef CLAMP
|
||||
#define CLAMP(x, low, high) \
|
||||
__extension__ ({ \
|
||||
typeof(x) _x = (x); \
|
||||
typeof(low) _low = (low); \
|
||||
typeof(high) _high = (high); \
|
||||
((_x > _high) ? _high : ((_x < _low) ? _low : _x)); \
|
||||
})
|
||||
#endif
|
||||
|
||||
#define assert_se(expr) \
|
||||
do { \
|
||||
if (_unlikely_(!(expr))) \
|
||||
log_assert_failed(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__); \
|
||||
} while (false) \
|
||||
|
||||
/* We override the glibc assert() here. */
|
||||
#undef assert
|
||||
#ifdef NDEBUG
|
||||
#define assert(expr) do {} while(false)
|
||||
#else
|
||||
#define assert(expr) assert_se(expr)
|
||||
#endif
|
||||
|
||||
#define assert_not_reached(t) \
|
||||
do { \
|
||||
log_assert_failed_unreachable(t, __FILE__, __LINE__, __PRETTY_FUNCTION__); \
|
||||
} while (false)
|
||||
|
||||
#if defined(static_assert)
|
||||
#define assert_cc(expr) \
|
||||
do { \
|
||||
static_assert(expr, #expr); \
|
||||
} while (false)
|
||||
#else
|
||||
#define assert_cc(expr) \
|
||||
do { \
|
||||
switch (0) { \
|
||||
case 0: \
|
||||
case !!(expr): \
|
||||
; \
|
||||
} \
|
||||
} while (false)
|
||||
#endif
|
||||
|
||||
#define PTR_TO_UINT(p) ((unsigned int) ((uintptr_t) (p)))
|
||||
#define UINT_TO_PTR(u) ((void*) ((uintptr_t) (u)))
|
||||
|
||||
#define PTR_TO_UINT32(p) ((uint32_t) ((uintptr_t) (p)))
|
||||
#define UINT32_TO_PTR(u) ((void*) ((uintptr_t) (u)))
|
||||
|
||||
#define PTR_TO_ULONG(p) ((unsigned long) ((uintptr_t) (p)))
|
||||
#define ULONG_TO_PTR(u) ((void*) ((uintptr_t) (u)))
|
||||
|
||||
#define PTR_TO_INT(p) ((int) ((intptr_t) (p)))
|
||||
#define INT_TO_PTR(u) ((void*) ((intptr_t) (u)))
|
||||
|
||||
#define TO_INT32(p) ((int32_t) ((intptr_t) (p)))
|
||||
#define INT32_TO_PTR(u) ((void*) ((intptr_t) (u)))
|
||||
|
||||
#define PTR_TO_LONG(p) ((long) ((intptr_t) (p)))
|
||||
#define LONG_TO_PTR(u) ((void*) ((intptr_t) (u)))
|
||||
|
||||
#define memzero(x,l) (memset((x), 0, (l)))
|
||||
#define zero(x) (memzero(&(x), sizeof(x)))
|
||||
|
||||
#define CHAR_TO_STR(x) ((char[2]) { x, 0 })
|
||||
|
||||
#define char_array_0(x) x[sizeof(x)-1] = 0;
|
||||
|
||||
#define IOVEC_SET_STRING(i, s) \
|
||||
do { \
|
||||
struct iovec *_i = &(i); \
|
||||
char *_s = (char *)(s); \
|
||||
_i->iov_base = _s; \
|
||||
_i->iov_len = strlen(_s); \
|
||||
} while(false)
|
||||
|
||||
static inline size_t IOVEC_TOTAL_SIZE(const struct iovec *i, unsigned n) {
|
||||
unsigned j;
|
||||
size_t r = 0;
|
||||
|
||||
for (j = 0; j < n; j++)
|
||||
r += i[j].iov_len;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline size_t IOVEC_INCREMENT(struct iovec *i, unsigned n, size_t k) {
|
||||
unsigned j;
|
||||
|
||||
for (j = 0; j < n; j++) {
|
||||
size_t sub;
|
||||
|
||||
if (_unlikely_(k <= 0))
|
||||
break;
|
||||
|
||||
sub = MIN(i[j].iov_len, k);
|
||||
i[j].iov_len -= sub;
|
||||
i[j].iov_base = (uint8_t*) i[j].iov_base + sub;
|
||||
k -= sub;
|
||||
}
|
||||
|
||||
return k;
|
||||
}
|
||||
|
||||
#define VA_FORMAT_ADVANCE(format, ap) \
|
||||
do { \
|
||||
int _argtypes[128]; \
|
||||
size_t _i, _k; \
|
||||
_k = parse_printf_format((format), ELEMENTSOF(_argtypes), _argtypes); \
|
||||
assert(_k < ELEMENTSOF(_argtypes)); \
|
||||
for (_i = 0; _i < _k; _i++) { \
|
||||
if (_argtypes[_i] & PA_FLAG_PTR) { \
|
||||
(void) va_arg(ap, void*); \
|
||||
continue; \
|
||||
} \
|
||||
\
|
||||
switch (_argtypes[_i]) { \
|
||||
case PA_INT: \
|
||||
case PA_INT|PA_FLAG_SHORT: \
|
||||
case PA_CHAR: \
|
||||
(void) va_arg(ap, int); \
|
||||
break; \
|
||||
case PA_INT|PA_FLAG_LONG: \
|
||||
(void) va_arg(ap, long int); \
|
||||
break; \
|
||||
case PA_INT|PA_FLAG_LONG_LONG: \
|
||||
(void) va_arg(ap, long long int); \
|
||||
break; \
|
||||
case PA_WCHAR: \
|
||||
(void) va_arg(ap, wchar_t); \
|
||||
break; \
|
||||
case PA_WSTRING: \
|
||||
case PA_STRING: \
|
||||
case PA_POINTER: \
|
||||
(void) va_arg(ap, void*); \
|
||||
break; \
|
||||
case PA_FLOAT: \
|
||||
case PA_DOUBLE: \
|
||||
(void) va_arg(ap, double); \
|
||||
break; \
|
||||
case PA_DOUBLE|PA_FLAG_LONG_DOUBLE: \
|
||||
(void) va_arg(ap, long double); \
|
||||
break; \
|
||||
default: \
|
||||
assert_not_reached("Unknown format string argument."); \
|
||||
} \
|
||||
} \
|
||||
} while(false)
|
||||
|
||||
/* Because statfs.t_type can be int on some architecures, we have to cast
|
||||
* the const magic to the type, otherwise the compiler warns about
|
||||
* signed/unsigned comparison, because the magic can be 32 bit unsigned.
|
||||
*/
|
||||
#define F_TYPE_CMP(a, b) (a == (typeof(a)) b)
|
||||
|
||||
|
||||
/* Returns the number of chars needed to format variables of the
|
||||
* specified type as a decimal string. Adds in extra space for a
|
||||
* negative '-' prefix. */
|
||||
|
||||
#define DECIMAL_STR_MAX(type) \
|
||||
(1+(sizeof(type) <= 1 ? 3 : \
|
||||
sizeof(type) <= 2 ? 5 : \
|
||||
sizeof(type) <= 4 ? 10 : \
|
||||
sizeof(type) <= 8 ? 20 : sizeof(int[-2*(sizeof(type) > 8)])))
|
||||
|
||||
#include "log.h"
|
279
install/util.c
279
install/util.c
@@ -1,279 +0,0 @@
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
/***
|
||||
This file is part of systemd.
|
||||
|
||||
Copyright 2010 Lennart Poettering
|
||||
|
||||
systemd is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
systemd is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
static inline pid_t gettid(void) {
|
||||
return (pid_t) syscall(SYS_gettid);
|
||||
}
|
||||
|
||||
size_t page_size(void) {
|
||||
static __thread size_t pgsz = 0;
|
||||
long r;
|
||||
|
||||
if (_likely_(pgsz > 0))
|
||||
return pgsz;
|
||||
|
||||
assert_se((r = sysconf(_SC_PAGESIZE)) > 0);
|
||||
|
||||
pgsz = (size_t) r;
|
||||
|
||||
return pgsz;
|
||||
}
|
||||
|
||||
bool endswith(const char *s, const char *postfix) {
|
||||
size_t sl, pl;
|
||||
|
||||
assert(s);
|
||||
assert(postfix);
|
||||
|
||||
sl = strlen(s);
|
||||
pl = strlen(postfix);
|
||||
|
||||
if (pl == 0)
|
||||
return true;
|
||||
|
||||
if (sl < pl)
|
||||
return false;
|
||||
|
||||
return memcmp(s + sl - pl, postfix, pl) == 0;
|
||||
}
|
||||
int close_nointr(int fd) {
|
||||
assert(fd >= 0);
|
||||
|
||||
for (;;) {
|
||||
int r;
|
||||
|
||||
r = close(fd);
|
||||
if (r >= 0)
|
||||
return r;
|
||||
|
||||
if (errno != EINTR)
|
||||
return -errno;
|
||||
}
|
||||
}
|
||||
|
||||
void close_nointr_nofail(int fd) {
|
||||
int saved_errno = errno;
|
||||
|
||||
/* like close_nointr() but cannot fail, and guarantees errno
|
||||
* is unchanged */
|
||||
|
||||
assert_se(close_nointr(fd) == 0);
|
||||
|
||||
errno = saved_errno;
|
||||
}
|
||||
|
||||
int open_terminal(const char *name, int mode) {
|
||||
int fd, r;
|
||||
unsigned c = 0;
|
||||
|
||||
/*
|
||||
* If a TTY is in the process of being closed opening it might
|
||||
* cause EIO. This is horribly awful, but unlikely to be
|
||||
* changed in the kernel. Hence we work around this problem by
|
||||
* retrying a couple of times.
|
||||
*
|
||||
* https://bugs.launchpad.net/ubuntu/+source/linux/+bug/554172/comments/245
|
||||
*/
|
||||
|
||||
for (;;) {
|
||||
if ((fd = open(name, mode)) >= 0)
|
||||
break;
|
||||
|
||||
if (errno != EIO)
|
||||
return -errno;
|
||||
|
||||
if (c >= 20)
|
||||
return -errno;
|
||||
|
||||
usleep(50 * USEC_PER_MSEC);
|
||||
c++;
|
||||
}
|
||||
|
||||
if (fd < 0)
|
||||
return -errno;
|
||||
|
||||
if ((r = isatty(fd)) < 0) {
|
||||
close_nointr_nofail(fd);
|
||||
return -errno;
|
||||
}
|
||||
|
||||
if (!r) {
|
||||
close_nointr_nofail(fd);
|
||||
return -ENOTTY;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
bool streq_ptr(const char *a, const char *b) {
|
||||
|
||||
/* Like streq(), but tries to make sense of NULL pointers */
|
||||
|
||||
if (a && b)
|
||||
return streq(a, b);
|
||||
|
||||
if (!a && !b)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
bool is_main_thread(void) {
|
||||
static __thread int cached = 0;
|
||||
|
||||
if (_unlikely_(cached == 0))
|
||||
cached = getpid() == gettid() ? 1 : -1;
|
||||
|
||||
return cached > 0;
|
||||
}
|
||||
|
||||
int safe_atou(const char *s, unsigned *ret_u) {
|
||||
char *x = NULL;
|
||||
unsigned long l;
|
||||
|
||||
assert(s);
|
||||
assert(ret_u);
|
||||
|
||||
errno = 0;
|
||||
l = strtoul(s, &x, 0);
|
||||
|
||||
if (!x || *x || errno)
|
||||
return errno ? -errno : -EINVAL;
|
||||
|
||||
if ((unsigned long) (unsigned) l != l)
|
||||
return -ERANGE;
|
||||
|
||||
*ret_u = (unsigned) l;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *const log_level_table[] = {
|
||||
[LOG_EMERG] = "emerg",
|
||||
[LOG_ALERT] = "alert",
|
||||
[LOG_CRIT] = "crit",
|
||||
[LOG_ERR] = "err",
|
||||
[LOG_WARNING] = "warning",
|
||||
[LOG_NOTICE] = "notice",
|
||||
[LOG_INFO] = "info",
|
||||
[LOG_DEBUG] = "debug"
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(log_level, int);
|
||||
|
||||
char *strnappend(const char *s, const char *suffix, size_t b) {
|
||||
size_t a;
|
||||
char *r;
|
||||
|
||||
if (!s && !suffix)
|
||||
return strdup("");
|
||||
|
||||
if (!s)
|
||||
return strndup(suffix, b);
|
||||
|
||||
if (!suffix)
|
||||
return strdup(s);
|
||||
|
||||
assert(s);
|
||||
assert(suffix);
|
||||
|
||||
a = strlen(s);
|
||||
if (b > ((size_t) -1) - a)
|
||||
return NULL;
|
||||
|
||||
r = new(char, a+b+1);
|
||||
if (!r)
|
||||
return NULL;
|
||||
|
||||
memcpy(r, s, a);
|
||||
memcpy(r+a, suffix, b);
|
||||
r[a+b] = 0;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
char *strappend(const char *s, const char *suffix) {
|
||||
return strnappend(s, suffix, suffix ? strlen(suffix) : 0);
|
||||
}
|
||||
|
||||
char *strjoin(const char *x, ...) {
|
||||
va_list ap;
|
||||
size_t l;
|
||||
char *r, *p;
|
||||
|
||||
va_start(ap, x);
|
||||
|
||||
if (x) {
|
||||
l = strlen(x);
|
||||
|
||||
for (;;) {
|
||||
const char *t;
|
||||
size_t n;
|
||||
|
||||
t = va_arg(ap, const char *);
|
||||
if (!t)
|
||||
break;
|
||||
|
||||
n = strlen(t);
|
||||
if (n > ((size_t) -1) - l) {
|
||||
va_end(ap);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
l += n;
|
||||
}
|
||||
} else
|
||||
l = 0;
|
||||
|
||||
va_end(ap);
|
||||
|
||||
r = new(char, l+1);
|
||||
if (!r)
|
||||
return NULL;
|
||||
|
||||
if (x) {
|
||||
p = stpcpy(r, x);
|
||||
|
||||
va_start(ap, x);
|
||||
|
||||
for (;;) {
|
||||
const char *t;
|
||||
|
||||
t = va_arg(ap, const char *);
|
||||
if (!t)
|
||||
break;
|
||||
|
||||
p = stpcpy(p, t);
|
||||
}
|
||||
|
||||
va_end(ap);
|
||||
} else
|
||||
r[0] = 0;
|
||||
|
||||
return r;
|
||||
}
|
565
install/util.h
565
install/util.h
@@ -1,565 +0,0 @@
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
#ifndef fooutilhfoo
|
||||
#define fooutilhfoo
|
||||
|
||||
/***
|
||||
This file is part of systemd.
|
||||
|
||||
Copyright 2010 Lennart Poettering
|
||||
|
||||
systemd is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
systemd is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <sched.h>
|
||||
#include <limits.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
#include "macro.h"
|
||||
|
||||
typedef uint64_t usec_t;
|
||||
typedef uint64_t nsec_t;
|
||||
|
||||
typedef struct dual_timestamp {
|
||||
usec_t realtime;
|
||||
usec_t monotonic;
|
||||
} dual_timestamp;
|
||||
|
||||
#define MSEC_PER_SEC 1000ULL
|
||||
#define USEC_PER_SEC 1000000ULL
|
||||
#define USEC_PER_MSEC 1000ULL
|
||||
#define NSEC_PER_SEC 1000000000ULL
|
||||
#define NSEC_PER_MSEC 1000000ULL
|
||||
#define NSEC_PER_USEC 1000ULL
|
||||
|
||||
#define USEC_PER_MINUTE (60ULL*USEC_PER_SEC)
|
||||
#define NSEC_PER_MINUTE (60ULL*NSEC_PER_SEC)
|
||||
#define USEC_PER_HOUR (60ULL*USEC_PER_MINUTE)
|
||||
#define NSEC_PER_HOUR (60ULL*NSEC_PER_MINUTE)
|
||||
#define USEC_PER_DAY (24ULL*USEC_PER_HOUR)
|
||||
#define NSEC_PER_DAY (24ULL*NSEC_PER_HOUR)
|
||||
#define USEC_PER_WEEK (7ULL*USEC_PER_DAY)
|
||||
#define NSEC_PER_WEEK (7ULL*NSEC_PER_DAY)
|
||||
#define USEC_PER_MONTH (2629800ULL*USEC_PER_SEC)
|
||||
#define NSEC_PER_MONTH (2629800ULL*NSEC_PER_SEC)
|
||||
#define USEC_PER_YEAR (31557600ULL*USEC_PER_SEC)
|
||||
#define NSEC_PER_YEAR (31557600ULL*NSEC_PER_SEC)
|
||||
|
||||
/* What is interpreted as whitespace? */
|
||||
#define WHITESPACE " \t\n\r"
|
||||
#define NEWLINE "\n\r"
|
||||
#define QUOTES "\"\'"
|
||||
#define COMMENTS "#;\n"
|
||||
|
||||
#define FORMAT_TIMESTAMP_MAX 64
|
||||
#define FORMAT_TIMESTAMP_PRETTY_MAX 256
|
||||
#define FORMAT_TIMESPAN_MAX 64
|
||||
#define FORMAT_BYTES_MAX 8
|
||||
|
||||
#define ANSI_HIGHLIGHT_ON "\x1B[1;39m"
|
||||
#define ANSI_HIGHLIGHT_RED_ON "\x1B[1;31m"
|
||||
#define ANSI_HIGHLIGHT_GREEN_ON "\x1B[1;32m"
|
||||
#define ANSI_HIGHLIGHT_YELLOW_ON "\x1B[1;33m"
|
||||
#define ANSI_HIGHLIGHT_OFF "\x1B[0m"
|
||||
|
||||
usec_t now(clockid_t clock);
|
||||
|
||||
dual_timestamp* dual_timestamp_get(dual_timestamp *ts);
|
||||
dual_timestamp* dual_timestamp_from_realtime(dual_timestamp *ts, usec_t u);
|
||||
|
||||
#define dual_timestamp_is_set(ts) ((ts)->realtime > 0)
|
||||
|
||||
usec_t timespec_load(const struct timespec *ts);
|
||||
struct timespec *timespec_store(struct timespec *ts, usec_t u);
|
||||
|
||||
usec_t timeval_load(const struct timeval *tv);
|
||||
struct timeval *timeval_store(struct timeval *tv, usec_t u);
|
||||
|
||||
size_t page_size(void);
|
||||
#define PAGE_ALIGN(l) ALIGN_TO((l), page_size())
|
||||
|
||||
#define streq(a,b) (strcmp((a),(b)) == 0)
|
||||
#define strneq(a, b, n) (strncmp((a), (b), (n)) == 0)
|
||||
|
||||
bool streq_ptr(const char *a, const char *b);
|
||||
|
||||
#define new(t, n) ((t*) malloc(sizeof(t)*(n)))
|
||||
|
||||
#define new0(t, n) ((t*) calloc((n), sizeof(t)))
|
||||
|
||||
#define newa(t, n) ((t*) alloca(sizeof(t)*(n)))
|
||||
|
||||
#define newdup(t, p, n) ((t*) memdup(p, sizeof(t)*(n)))
|
||||
|
||||
#define malloc0(n) (calloc((n), 1))
|
||||
|
||||
static inline const char* yes_no(bool b) {
|
||||
return b ? "yes" : "no";
|
||||
}
|
||||
|
||||
static inline const char* strempty(const char *s) {
|
||||
return s ? s : "";
|
||||
}
|
||||
|
||||
static inline const char* strnull(const char *s) {
|
||||
return s ? s : "(null)";
|
||||
}
|
||||
|
||||
static inline const char *strna(const char *s) {
|
||||
return s ? s : "n/a";
|
||||
}
|
||||
|
||||
static inline bool isempty(const char *p) {
|
||||
return !p || !p[0];
|
||||
}
|
||||
|
||||
bool endswith(const char *s, const char *postfix);
|
||||
bool startswith(const char *s, const char *prefix);
|
||||
bool startswith_no_case(const char *s, const char *prefix);
|
||||
|
||||
bool first_word(const char *s, const char *word);
|
||||
|
||||
int close_nointr(int fd);
|
||||
void close_nointr_nofail(int fd);
|
||||
void close_many(const int fds[], unsigned n_fd);
|
||||
|
||||
int parse_boolean(const char *v);
|
||||
int parse_usec(const char *t, usec_t *usec);
|
||||
int parse_nsec(const char *t, nsec_t *nsec);
|
||||
int parse_bytes(const char *t, off_t *bytes);
|
||||
int parse_pid(const char *s, pid_t* ret_pid);
|
||||
int parse_uid(const char *s, uid_t* ret_uid);
|
||||
#define parse_gid(s, ret_uid) parse_uid(s, ret_uid)
|
||||
|
||||
int safe_atou(const char *s, unsigned *ret_u);
|
||||
int safe_atoi(const char *s, int *ret_i);
|
||||
|
||||
int safe_atollu(const char *s, unsigned long long *ret_u);
|
||||
int safe_atolli(const char *s, long long int *ret_i);
|
||||
|
||||
#if __WORDSIZE == 32
|
||||
static inline int safe_atolu(const char *s, unsigned long *ret_u) {
|
||||
assert_cc(sizeof(unsigned long) == sizeof(unsigned));
|
||||
return safe_atou(s, (unsigned*) ret_u);
|
||||
}
|
||||
static inline int safe_atoli(const char *s, long int *ret_u) {
|
||||
assert_cc(sizeof(long int) == sizeof(int));
|
||||
return safe_atoi(s, (int*) ret_u);
|
||||
}
|
||||
#else
|
||||
static inline int safe_atolu(const char *s, unsigned long *ret_u) {
|
||||
assert_cc(sizeof(unsigned long) == sizeof(unsigned long long));
|
||||
return safe_atollu(s, (unsigned long long*) ret_u);
|
||||
}
|
||||
static inline int safe_atoli(const char *s, long int *ret_u) {
|
||||
assert_cc(sizeof(long int) == sizeof(long long int));
|
||||
return safe_atolli(s, (long long int*) ret_u);
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline int safe_atou32(const char *s, uint32_t *ret_u) {
|
||||
assert_cc(sizeof(uint32_t) == sizeof(unsigned));
|
||||
return safe_atou(s, (unsigned*) ret_u);
|
||||
}
|
||||
|
||||
static inline int safe_atoi32(const char *s, int32_t *ret_i) {
|
||||
assert_cc(sizeof(int32_t) == sizeof(int));
|
||||
return safe_atoi(s, (int*) ret_i);
|
||||
}
|
||||
|
||||
static inline int safe_atou64(const char *s, uint64_t *ret_u) {
|
||||
assert_cc(sizeof(uint64_t) == sizeof(unsigned long long));
|
||||
return safe_atollu(s, (unsigned long long*) ret_u);
|
||||
}
|
||||
|
||||
static inline int safe_atoi64(const char *s, int64_t *ret_i) {
|
||||
assert_cc(sizeof(int64_t) == sizeof(long long int));
|
||||
return safe_atolli(s, (long long int*) ret_i);
|
||||
}
|
||||
|
||||
char *split(const char *c, size_t *l, const char *separator, char **state);
|
||||
char *split_quoted(const char *c, size_t *l, char **state);
|
||||
|
||||
#define FOREACH_WORD(word, length, s, state) \
|
||||
for ((state) = NULL, (word) = split((s), &(length), WHITESPACE, &(state)); (word); (word) = split((s), &(length), WHITESPACE, &(state)))
|
||||
|
||||
#define FOREACH_WORD_SEPARATOR(word, length, s, separator, state) \
|
||||
for ((state) = NULL, (word) = split((s), &(length), (separator), &(state)); (word); (word) = split((s), &(length), (separator), &(state)))
|
||||
|
||||
#define FOREACH_WORD_QUOTED(word, length, s, state) \
|
||||
for ((state) = NULL, (word) = split_quoted((s), &(length), &(state)); (word); (word) = split_quoted((s), &(length), &(state)))
|
||||
|
||||
pid_t get_parent_of_pid(pid_t pid, pid_t *ppid);
|
||||
int get_starttime_of_pid(pid_t pid, unsigned long long *st);
|
||||
|
||||
int write_one_line_file(const char *fn, const char *line);
|
||||
int write_one_line_file_atomic(const char *fn, const char *line);
|
||||
int read_one_line_file(const char *fn, char **line);
|
||||
int read_full_file(const char *fn, char **contents, size_t *size);
|
||||
|
||||
int parse_env_file(const char *fname, const char *separator, ...) _sentinel_;
|
||||
int load_env_file(const char *fname, char ***l);
|
||||
int write_env_file(const char *fname, char **l);
|
||||
|
||||
char *strappend(const char *s, const char *suffix);
|
||||
char *strnappend(const char *s, const char *suffix, size_t length);
|
||||
|
||||
char *replace_env(const char *format, char **env);
|
||||
char **replace_env_argv(char **argv, char **env);
|
||||
|
||||
int readlink_malloc(const char *p, char **r);
|
||||
int readlink_and_make_absolute(const char *p, char **r);
|
||||
int readlink_and_canonicalize(const char *p, char **r);
|
||||
|
||||
int reset_all_signal_handlers(void);
|
||||
|
||||
char *strstrip(char *s);
|
||||
char *delete_chars(char *s, const char *bad);
|
||||
char *truncate_nl(char *s);
|
||||
|
||||
char *file_in_same_dir(const char *path, const char *filename);
|
||||
|
||||
int rmdir_parents(const char *path, const char *stop);
|
||||
|
||||
int get_process_comm(pid_t pid, char **name);
|
||||
int get_process_cmdline(pid_t pid, size_t max_length, bool comm_fallback, char **line);
|
||||
int get_process_exe(pid_t pid, char **name);
|
||||
int get_process_uid(pid_t pid, uid_t *uid);
|
||||
|
||||
char hexchar(int x);
|
||||
int unhexchar(char c);
|
||||
char octchar(int x);
|
||||
int unoctchar(char c);
|
||||
char decchar(int x);
|
||||
int undecchar(char c);
|
||||
|
||||
char *cescape(const char *s);
|
||||
char *cunescape(const char *s);
|
||||
char *cunescape_length(const char *s, size_t length);
|
||||
|
||||
char *xescape(const char *s, const char *bad);
|
||||
|
||||
char *bus_path_escape(const char *s);
|
||||
char *bus_path_unescape(const char *s);
|
||||
|
||||
char *ascii_strlower(char *path);
|
||||
|
||||
bool dirent_is_file(const struct dirent *de);
|
||||
bool dirent_is_file_with_suffix(const struct dirent *de, const char *suffix);
|
||||
|
||||
bool ignore_file(const char *filename);
|
||||
|
||||
bool chars_intersect(const char *a, const char *b);
|
||||
|
||||
char *format_timestamp(char *buf, size_t l, usec_t t);
|
||||
char *format_timestamp_pretty(char *buf, size_t l, usec_t t);
|
||||
char *format_timespan(char *buf, size_t l, usec_t t);
|
||||
|
||||
int make_stdio(int fd);
|
||||
int make_null_stdio(void);
|
||||
|
||||
unsigned long long random_ull(void);
|
||||
|
||||
#define __DEFINE_STRING_TABLE_LOOKUP(name,type,scope) \
|
||||
scope const char *name##_to_string(type i) { \
|
||||
if (i < 0 || i >= (type) ELEMENTSOF(name##_table)) \
|
||||
return NULL; \
|
||||
return name##_table[i]; \
|
||||
} \
|
||||
scope type name##_from_string(const char *s) { \
|
||||
type i; \
|
||||
unsigned u = 0; \
|
||||
assert(s); \
|
||||
for (i = 0; i < (type)ELEMENTSOF(name##_table); i++) \
|
||||
if (name##_table[i] && \
|
||||
streq(name##_table[i], s)) \
|
||||
return i; \
|
||||
if (safe_atou(s, &u) >= 0 && \
|
||||
u < ELEMENTSOF(name##_table)) \
|
||||
return (type) u; \
|
||||
return (type) -1; \
|
||||
} \
|
||||
struct __useless_struct_to_allow_trailing_semicolon__
|
||||
|
||||
#define DEFINE_STRING_TABLE_LOOKUP(name,type) __DEFINE_STRING_TABLE_LOOKUP(name,type,)
|
||||
#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP(name,type) __DEFINE_STRING_TABLE_LOOKUP(name,type,static)
|
||||
|
||||
int fd_nonblock(int fd, bool nonblock);
|
||||
int fd_cloexec(int fd, bool cloexec);
|
||||
|
||||
int close_all_fds(const int except[], unsigned n_except);
|
||||
|
||||
bool fstype_is_network(const char *fstype);
|
||||
|
||||
int chvt(int vt);
|
||||
|
||||
int read_one_char(FILE *f, char *ret, usec_t timeout, bool *need_nl);
|
||||
int ask(char *ret, const char *replies, const char *text, ...);
|
||||
|
||||
int reset_terminal_fd(int fd, bool switch_to_text);
|
||||
int reset_terminal(const char *name);
|
||||
|
||||
int open_terminal(const char *name, int mode);
|
||||
int acquire_terminal(const char *name, bool fail, bool force, bool ignore_tiocstty_eperm);
|
||||
int release_terminal(void);
|
||||
|
||||
int flush_fd(int fd);
|
||||
|
||||
int ignore_signals(int sig, ...);
|
||||
int default_signals(int sig, ...);
|
||||
int sigaction_many(const struct sigaction *sa, ...);
|
||||
|
||||
int close_pipe(int p[]);
|
||||
int fopen_temporary(const char *path, FILE **_f, char **_temp_path);
|
||||
|
||||
ssize_t loop_read(int fd, void *buf, size_t nbytes, bool do_poll);
|
||||
ssize_t loop_write(int fd, const void *buf, size_t nbytes, bool do_poll);
|
||||
|
||||
bool is_device_path(const char *path);
|
||||
|
||||
int dir_is_empty(const char *path);
|
||||
|
||||
void rename_process(const char name[8]);
|
||||
|
||||
void sigset_add_many(sigset_t *ss, ...);
|
||||
|
||||
char* gethostname_malloc(void);
|
||||
bool hostname_is_set(void);
|
||||
char* getlogname_malloc(void);
|
||||
|
||||
int getttyname_malloc(int fd, char **r);
|
||||
int getttyname_harder(int fd, char **r);
|
||||
|
||||
int get_ctty_devnr(pid_t pid, dev_t *d);
|
||||
int get_ctty(pid_t, dev_t *_devnr, char **r);
|
||||
|
||||
int chmod_and_chown(const char *path, mode_t mode, uid_t uid, gid_t gid);
|
||||
int fchmod_and_fchown(int fd, mode_t mode, uid_t uid, gid_t gid);
|
||||
|
||||
int rm_rf_children(int fd, bool only_dirs, bool honour_sticky, struct stat *root_dev);
|
||||
int rm_rf(const char *path, bool only_dirs, bool delete_root, bool honour_sticky);
|
||||
|
||||
int pipe_eof(int fd);
|
||||
|
||||
cpu_set_t* cpu_set_malloc(unsigned *ncpus);
|
||||
|
||||
void status_vprintf(const char *status, bool ellipse, const char *format, va_list ap);
|
||||
void status_printf(const char *status, bool ellipse, const char *format, ...);
|
||||
void status_welcome(void);
|
||||
|
||||
int fd_columns(int fd);
|
||||
unsigned columns(void);
|
||||
|
||||
int fd_lines(int fd);
|
||||
unsigned lines(void);
|
||||
|
||||
int running_in_chroot(void);
|
||||
|
||||
char *ellipsize(const char *s, size_t length, unsigned percent);
|
||||
char *ellipsize_mem(const char *s, size_t old_length, size_t new_length, unsigned percent);
|
||||
|
||||
int touch(const char *path);
|
||||
|
||||
char *unquote(const char *s, const char *quotes);
|
||||
char *normalize_env_assignment(const char *s);
|
||||
|
||||
int wait_for_terminate(pid_t pid, siginfo_t *status);
|
||||
int wait_for_terminate_and_warn(const char *name, pid_t pid);
|
||||
|
||||
_noreturn_ void freeze(void);
|
||||
|
||||
bool null_or_empty(struct stat *st);
|
||||
int null_or_empty_path(const char *fn);
|
||||
|
||||
DIR *xopendirat(int dirfd, const char *name, int flags);
|
||||
|
||||
void dual_timestamp_serialize(FILE *f, const char *name, dual_timestamp *t);
|
||||
void dual_timestamp_deserialize(const char *value, dual_timestamp *t);
|
||||
|
||||
char *fstab_node_to_udev_node(const char *p);
|
||||
|
||||
bool tty_is_vc(const char *tty);
|
||||
bool tty_is_vc_resolve(const char *tty);
|
||||
bool tty_is_console(const char *tty);
|
||||
int vtnr_from_tty(const char *tty);
|
||||
const char *default_term_for_tty(const char *tty);
|
||||
|
||||
void execute_directory(const char *directory, DIR *_d, char *argv[]);
|
||||
|
||||
int kill_and_sigcont(pid_t pid, int sig);
|
||||
|
||||
bool nulstr_contains(const char*nulstr, const char *needle);
|
||||
|
||||
bool plymouth_running(void);
|
||||
|
||||
void parse_syslog_priority(char **p, int *priority);
|
||||
void skip_syslog_pid(char **buf);
|
||||
void skip_syslog_date(char **buf);
|
||||
|
||||
bool hostname_is_valid(const char *s);
|
||||
char* hostname_cleanup(char *s);
|
||||
|
||||
char* strshorten(char *s, size_t l);
|
||||
|
||||
int terminal_vhangup_fd(int fd);
|
||||
int terminal_vhangup(const char *name);
|
||||
|
||||
int vt_disallocate(const char *name);
|
||||
|
||||
int copy_file(const char *from, const char *to);
|
||||
int symlink_or_copy(const char *from, const char *to);
|
||||
int symlink_or_copy_atomic(const char *from, const char *to);
|
||||
|
||||
int fchmod_umask(int fd, mode_t mode);
|
||||
|
||||
bool display_is_local(const char *display);
|
||||
int socket_from_display(const char *display, char **path);
|
||||
|
||||
int get_user_creds(const char **username, uid_t *uid, gid_t *gid, const char **home);
|
||||
int get_group_creds(const char **groupname, gid_t *gid);
|
||||
|
||||
int in_group(const char *name);
|
||||
|
||||
int glob_exists(const char *path);
|
||||
|
||||
int dirent_ensure_type(DIR *d, struct dirent *de);
|
||||
|
||||
int in_search_path(const char *path, char **search);
|
||||
int get_files_in_directory(const char *path, char ***list);
|
||||
|
||||
char *join(const char *x, ...) _sentinel_;
|
||||
|
||||
bool is_main_thread(void);
|
||||
|
||||
bool in_charset(const char *s, const char* charset);
|
||||
|
||||
int block_get_whole_disk(dev_t d, dev_t *ret);
|
||||
|
||||
int file_is_priv_sticky(const char *p);
|
||||
|
||||
int strdup_or_null(const char *a, char **b);
|
||||
|
||||
#define NULSTR_FOREACH(i, l) \
|
||||
for ((i) = (l); (i) && *(i); (i) = strchr((i), 0)+1)
|
||||
|
||||
#define NULSTR_FOREACH_PAIR(i, j, l) \
|
||||
for ((i) = (l), (j) = strchr((i), 0)+1; (i) && *(i); (i) = strchr((j), 0)+1, (j) = *(i) ? strchr((i), 0)+1 : (i))
|
||||
|
||||
const char *ioprio_class_to_string(int i);
|
||||
int ioprio_class_from_string(const char *s);
|
||||
|
||||
const char *sigchld_code_to_string(int i);
|
||||
int sigchld_code_from_string(const char *s);
|
||||
|
||||
const char *log_facility_unshifted_to_string(int i);
|
||||
int log_facility_unshifted_from_string(const char *s);
|
||||
|
||||
const char *log_level_to_string(int i);
|
||||
int log_level_from_string(const char *s);
|
||||
|
||||
const char *sched_policy_to_string(int i);
|
||||
int sched_policy_from_string(const char *s);
|
||||
|
||||
const char *rlimit_to_string(int i);
|
||||
int rlimit_from_string(const char *s);
|
||||
|
||||
const char *ip_tos_to_string(int i);
|
||||
int ip_tos_from_string(const char *s);
|
||||
|
||||
const char *signal_to_string(int i);
|
||||
int signal_from_string(const char *s);
|
||||
|
||||
int signal_from_string_try_harder(const char *s);
|
||||
|
||||
extern int saved_argc;
|
||||
extern char **saved_argv;
|
||||
|
||||
bool kexec_loaded(void);
|
||||
|
||||
int prot_from_flags(int flags);
|
||||
|
||||
char *format_bytes(char *buf, size_t l, off_t t);
|
||||
|
||||
int fd_wait_for_event(int fd, int event, usec_t timeout);
|
||||
|
||||
void* memdup(const void *p, size_t l);
|
||||
|
||||
int is_kernel_thread(pid_t pid);
|
||||
|
||||
static inline void freep(void *p) {
|
||||
free(*(void**) p);
|
||||
}
|
||||
|
||||
static inline void fclosep(FILE **f) {
|
||||
if (*f)
|
||||
fclose(*f);
|
||||
}
|
||||
|
||||
static inline void pclosep(FILE **f) {
|
||||
if (*f)
|
||||
pclose(*f);
|
||||
}
|
||||
|
||||
static inline void closep(int *fd) {
|
||||
if (*fd >= 0)
|
||||
close_nointr_nofail(*fd);
|
||||
}
|
||||
|
||||
static inline void closedirp(DIR **d) {
|
||||
if (*d)
|
||||
closedir(*d);
|
||||
}
|
||||
|
||||
static inline void umaskp(mode_t *u) {
|
||||
umask(*u);
|
||||
}
|
||||
|
||||
#define _cleanup_free_ _cleanup_(freep)
|
||||
#define _cleanup_fclose_ _cleanup_(fclosep)
|
||||
#define _cleanup_pclose_ _cleanup_(pclosep)
|
||||
#define _cleanup_close_ _cleanup_(closep)
|
||||
#define _cleanup_closedir_ _cleanup_(closedirp)
|
||||
#define _cleanup_umask_ _cleanup_(umaskp)
|
||||
#define _cleanup_globfree_ _cleanup_(globfree)
|
||||
|
||||
int fd_inc_sndbuf(int fd, size_t n);
|
||||
int fd_inc_rcvbuf(int fd, size_t n);
|
||||
|
||||
int fork_agent(pid_t *pid, const int except[], unsigned n_except, const char *path, ...);
|
||||
|
||||
int setrlimit_closest(int resource, const struct rlimit *rlim);
|
||||
|
||||
int getenv_for_pid(pid_t pid, const char *field, char **_value);
|
||||
|
||||
int can_sleep(const char *type);
|
||||
|
||||
bool is_valid_documentation_url(const char *url);
|
||||
|
||||
bool in_initrd(void);
|
||||
|
||||
void warn_melody(void);
|
||||
|
||||
char *strjoin(const char *x, ...) _sentinel_;
|
||||
|
||||
#endif
|
@@ -27,26 +27,20 @@ usage()
|
||||
echo
|
||||
echo "-h, --help print a help message and exit."
|
||||
echo "-s, --size sort the contents of the initramfs by size."
|
||||
echo "-m, --mod list modules."
|
||||
echo "-f, --file <filename> print the contents of <filename>."
|
||||
echo "-k, --kver <kernel version> inspect the initramfs of <kernel version>."
|
||||
echo
|
||||
} >&2
|
||||
}
|
||||
|
||||
|
||||
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
|
||||
|
||||
sorted=0
|
||||
modules=0
|
||||
declare -A filenames
|
||||
|
||||
unset POSIXLY_CORRECT
|
||||
TEMP=$(getopt \
|
||||
-o "shmf:k:" \
|
||||
-o "shf:k:" \
|
||||
--long kver: \
|
||||
--long file: \
|
||||
--long mod \
|
||||
--long help \
|
||||
--long size \
|
||||
-- "$@")
|
||||
@@ -64,7 +58,6 @@ while (($# > 0)); do
|
||||
-f|--file) filenames[${2#/}]=1; shift;;
|
||||
-s|--size) sorted=1;;
|
||||
-h|--help) usage; exit 0;;
|
||||
-m|--mod) modules=1;;
|
||||
--) shift;break;;
|
||||
*) usage; exit 1;;
|
||||
esac
|
||||
@@ -84,15 +77,7 @@ if [[ $1 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
[[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
|
||||
|
||||
if [[ -d /boot/loader/entries || -L /boot/loader/entries ]] \
|
||||
&& [[ $MACHINE_ID ]] \
|
||||
&& [[ -d /boot/${MACHINE_ID} || -L /boot/${MACHINE_ID} ]] ; then
|
||||
image="/boot/${MACHINE_ID}/${KERNEL_VERSION}/initrd"
|
||||
else
|
||||
image="/boot/initramfs-${KERNEL_VERSION}.img"
|
||||
fi
|
||||
image="/boot/initramfs-${KERNEL_VERSION}.img"
|
||||
fi
|
||||
|
||||
shift
|
||||
@@ -110,126 +95,47 @@ if ! [[ -f "$image" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
extract_files()
|
||||
{
|
||||
(( ${#filenames[@]} == 1 )) && nofileinfo=1
|
||||
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
|
||||
((ret+=$?))
|
||||
[[ $nofileinfo ]] || echo "========================================================================"
|
||||
[[ $nofileinfo ]] || echo
|
||||
done
|
||||
}
|
||||
|
||||
list_modules()
|
||||
{
|
||||
echo "dracut modules:"
|
||||
$CAT "$image" 2>/dev/null | cpio --extract --verbose --quiet --to-stdout -- 'lib/dracut/modules.txt' 'usr/lib/dracut/modules.txt' 2>/dev/null
|
||||
((ret+=$?))
|
||||
}
|
||||
|
||||
list_files()
|
||||
{
|
||||
echo "========================================================================"
|
||||
if [ "$sorted" -eq 1 ]; then
|
||||
$CAT "$image" 2>/dev/null | cpio --extract --verbose --quiet --list | sort -n -k5
|
||||
else
|
||||
$CAT "$image" 2>/dev/null | cpio --extract --verbose --quiet --list | sort -k9
|
||||
fi
|
||||
((ret+=$?))
|
||||
echo "========================================================================"
|
||||
}
|
||||
|
||||
|
||||
if (( ${#filenames[@]} <= 0 )); then
|
||||
echo "Image: $image: $(du -h $image | while read a b; do echo $a;done)"
|
||||
echo "========================================================================"
|
||||
fi
|
||||
|
||||
read -N 6 bin < "$image"
|
||||
case $bin in
|
||||
$'\x71\xc7'*|070701)
|
||||
CAT="cat --"
|
||||
is_early=$(cpio --extract --verbose --quiet --to-stdout -- 'early_cpio' < "$image" 2>/dev/null)
|
||||
if [[ "$is_early" ]]; then
|
||||
if (( ${#filenames[@]} > 0 )); then
|
||||
extract_files
|
||||
else
|
||||
echo "Early CPIO image"
|
||||
list_files
|
||||
fi
|
||||
SKIP="$dracutbasedir/skipcpio"
|
||||
if ! [[ -x $SKIP ]]; then
|
||||
echo
|
||||
echo "'$SKIP' not found, cannot display remaining contents!" >&2
|
||||
echo
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
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 --"
|
||||
;;
|
||||
CAT="zcat";;
|
||||
BZh*)
|
||||
CAT="bzcat --"
|
||||
;;
|
||||
$'\x71\xc7'*|070701)
|
||||
CAT="cat --"
|
||||
;;
|
||||
$'\x02\x21'*)
|
||||
CAT="lz4 -d -c"
|
||||
;;
|
||||
$'\x89'LZO$'\0'*)
|
||||
CAT="lzop -d -c"
|
||||
;;
|
||||
CAT="bzcat";;
|
||||
070701)
|
||||
CAT="cat";;
|
||||
*)
|
||||
CAT="xzcat";
|
||||
if echo "test"|xz|xzcat --single-stream >/dev/null 2>&1; then
|
||||
CAT="xzcat --single-stream --"
|
||||
else
|
||||
CAT="xzcat --"
|
||||
CAT="xzcat --single-stream"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
skipcpio()
|
||||
{
|
||||
$SKIP "$@" | $ORIG_CAT
|
||||
}
|
||||
|
||||
if [[ $SKIP ]]; then
|
||||
ORIG_CAT="$CAT"
|
||||
CAT=skipcpio
|
||||
fi
|
||||
|
||||
ret=0
|
||||
|
||||
if (( ${#filenames[@]} > 0 )); then
|
||||
extract_files
|
||||
(( ${#filenames[@]} == 1 )) && nofileinfo=1
|
||||
for f in ${!filenames[@]}; do
|
||||
[[ $nofileinfo ]] || echo "initramfs:/$f"
|
||||
[[ $nofileinfo ]] || echo "========================================================================"
|
||||
$CAT -- $image | cpio --extract --verbose --quiet --to-stdout $f 2>/dev/null
|
||||
((ret+=$?))
|
||||
[[ $nofileinfo ]] || echo "========================================================================"
|
||||
[[ $nofileinfo ]] || echo
|
||||
done
|
||||
else
|
||||
version=$($CAT "$image" 2>/dev/null | cpio --extract --verbose --quiet --to-stdout -- 'lib/dracut/dracut-*' 'usr/lib/dracut/dracut-*' 2>/dev/null)
|
||||
echo "Image: $image: $(du -h $image | while read a b; do echo $a;done)"
|
||||
echo "========================================================================"
|
||||
$CAT -- "$image" | cpio --extract --verbose --quiet --to-stdout -- 'dracut-*' 2>/dev/null
|
||||
((ret+=$?))
|
||||
echo "Version: $version"
|
||||
echo
|
||||
if [ "$modules" -eq 1 ]; then
|
||||
list_modules
|
||||
echo "========================================================================"
|
||||
echo "========================================================================"
|
||||
if [ "$sorted" -eq 1 ]; then
|
||||
$CAT -- "$image" | cpio --extract --verbose --quiet --list | sort -n -k5
|
||||
else
|
||||
echo -n "Arguments: "
|
||||
$CAT "$image" 2>/dev/null | cpio --extract --verbose --quiet --to-stdout -- 'lib/dracut/build-parameter.txt' 'usr/lib/dracut/build-parameter.txt' 2>/dev/null
|
||||
echo
|
||||
list_modules
|
||||
list_files
|
||||
$CAT -- "$image" | cpio --extract --verbose --quiet --list | sort -k9
|
||||
fi
|
||||
((ret+=$?))
|
||||
echo "========================================================================"
|
||||
fi
|
||||
|
||||
exit $ret
|
@@ -1,63 +0,0 @@
|
||||
#
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
#
|
||||
# Copyright 2013 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
__contains_word () {
|
||||
local word=$1; shift
|
||||
for w in $*; do [[ $w = $word ]] && return 0; done
|
||||
return 1
|
||||
}
|
||||
|
||||
_lsinitrd() {
|
||||
local field_vals= cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
local -A OPTS=(
|
||||
[STANDALONE]='-s --size -h --help'
|
||||
|
||||
[ARG]='-f --file -k --kver'
|
||||
)
|
||||
|
||||
if __contains_word "$prev" ${OPTS[ARG]}; then
|
||||
case $prev in
|
||||
--file|-f)
|
||||
comps=$(compgen -f -- "$cur")
|
||||
compopt -o filenames
|
||||
;;
|
||||
--kver|-k)
|
||||
comps=$(cd /lib/modules; echo [0-9]*)
|
||||
;;
|
||||
*)
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ $cur = -* ]]; then
|
||||
COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
|
||||
return 0
|
||||
fi
|
||||
|
||||
comps=$(compgen -f -- "$cur")
|
||||
compopt -o filenames
|
||||
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -F _lsinitrd lsinitrd
|
73
lsinitrd.1
Normal file
73
lsinitrd.1
Normal file
@@ -0,0 +1,73 @@
|
||||
'\" t
|
||||
.\" Title: lsinitrd
|
||||
.\" Author: [see the "AUTHORS" section]
|
||||
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
|
||||
.\" Date: 07/17/2013
|
||||
.\" Manual: dracut
|
||||
.\" Source: dracut
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "LSINITRD" "1" "07/17/2013" "dracut" "dracut"
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * Define some portability stuff
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.\" http://bugs.debian.org/507673
|
||||
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * set default formatting
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" disable hyphenation
|
||||
.nh
|
||||
.\" disable justification (adjust text to left margin only)
|
||||
.ad l
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * MAIN CONTENT STARTS HERE *
|
||||
.\" -----------------------------------------------------------------
|
||||
.SH "NAME"
|
||||
lsinitrd \- tool to show the contents of an initramfs image
|
||||
.SH "SYNOPSIS"
|
||||
.sp
|
||||
\fBlsinitrd\fR [\fIOPTION\&...\fR] [<image> [<filename> [<filename> [\&...] ]]]
|
||||
.sp
|
||||
\fBlsinitrd\fR [\fIOPTION\&...\fR] \-k <kernel\-version>
|
||||
.SH "DESCRIPTION"
|
||||
.sp
|
||||
lsinitrd shows the contents of an initramfs image\&. if <image> is omitted, then lsinitrd uses the default image \fI/boot/<machine\-id>/<kernel\-version>/initrd\fR or \fI/boot/initramfs\-<kernel\-version>\&.img\fR\&.
|
||||
.SH "OPTIONS"
|
||||
.PP
|
||||
\fB\-h, \-\-help\fR
|
||||
.RS 4
|
||||
print a help message and exit\&.
|
||||
.RE
|
||||
.PP
|
||||
\fB\-s, \-\-size\fR
|
||||
.RS 4
|
||||
sort the contents of the initramfs by size\&.
|
||||
.RE
|
||||
.PP
|
||||
\fB\-f, \-\-file\fR\ \&\fI<filename>\fR
|
||||
.RS 4
|
||||
print the contents of <filename>\&.
|
||||
.RE
|
||||
.PP
|
||||
\fB\-k, \-\-kver\fR\ \&\fI<kernel version>\fR
|
||||
.RS 4
|
||||
inspect the initramfs of <kernel version>\&.
|
||||
.RE
|
||||
.SH "AVAILABILITY"
|
||||
.sp
|
||||
The lsinitrd command is part of the dracut package and is available from \m[blue]\fBhttps://dracut\&.wiki\&.kernel\&.org\fR\m[]
|
||||
.SH "AUTHORS"
|
||||
.sp
|
||||
Harald Hoyer
|
||||
.sp
|
||||
Amerigo Wang
|
||||
.sp
|
||||
Nikoli
|
||||
.SH "SEE ALSO"
|
||||
.sp
|
||||
\fBdracut\fR(8)
|
@@ -1,52 +0,0 @@
|
||||
LSINITRD(1)
|
||||
=========
|
||||
:doctype: manpage
|
||||
:man source: dracut
|
||||
:man manual: dracut
|
||||
|
||||
NAME
|
||||
----
|
||||
lsinitrd - tool to show the contents of an initramfs image
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
*lsinitrd* ['OPTION...'] [<image> [<filename> [<filename> [...] ]]]
|
||||
|
||||
*lsinitrd* ['OPTION...'] -k <kernel-version>
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
lsinitrd shows the contents of an initramfs image. if <image> is omitted, then
|
||||
lsinitrd uses the default image _/boot/<machine-id>/<kernel-version>/initrd_ or
|
||||
_/boot/initramfs-<kernel-version>.img_.
|
||||
|
||||
OPTIONS
|
||||
-------
|
||||
**-h, --help**::
|
||||
print a help message and exit.
|
||||
|
||||
**-s, --size**::
|
||||
sort the contents of the initramfs by size.
|
||||
|
||||
**-f, --file** _<filename>_::
|
||||
print the contents of <filename>.
|
||||
|
||||
**-k, --kver** _<kernel version>_::
|
||||
inspect the initramfs of <kernel version>.
|
||||
|
||||
AVAILABILITY
|
||||
------------
|
||||
The lsinitrd command is part of the dracut package and is available from
|
||||
link:$$https://dracut.wiki.kernel.org$$[https://dracut.wiki.kernel.org]
|
||||
|
||||
AUTHORS
|
||||
-------
|
||||
Harald Hoyer
|
||||
|
||||
Amerigo Wang
|
||||
|
||||
Nikoli
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
*dracut*(8)
|
@@ -1,66 +1,102 @@
|
||||
#!/bin/bash --norc
|
||||
kver=$(uname -r)
|
||||
|
||||
error() { echo "$@" >&2; }
|
||||
|
||||
usage () {
|
||||
[[ $1 = '-n' ]] && cmd=echo || cmd=error
|
||||
|
||||
$cmd "usage: ${0##*/} [--version] [--help] [-v] [-f] [--preload <module>]"
|
||||
$cmd " [--image-version] [--with=<module>]"
|
||||
$cmd " [--nocompress]"
|
||||
$cmd " <initrd-image> <kernel-version>"
|
||||
$cmd ""
|
||||
$cmd " (ex: ${0##*/} /boot/initramfs-$kver.img $kver)"
|
||||
|
||||
[[ $1 = '-n' ]] && exit 0
|
||||
exit 1
|
||||
error() {
|
||||
local NONL=""
|
||||
if [ "$1" == "-n" ]; then
|
||||
NONL="-n"
|
||||
shift
|
||||
fi
|
||||
echo $NONL "$@" > /dev/stderr
|
||||
}
|
||||
|
||||
# Little helper function for reading args from the commandline.
|
||||
# it automatically handles -a b and -a=b variants, and returns 1 if
|
||||
# we need to shift $3.
|
||||
read_arg() {
|
||||
# $1 = arg name
|
||||
# $2 = arg value
|
||||
# $3 = arg parameter
|
||||
local rematch='^[^=]*=(.*)$'
|
||||
if [[ $2 =~ $rematch ]]; then
|
||||
read "$1" <<< "${BASH_REMATCH[1]}"
|
||||
elif [[ $3 != -* ]]; then
|
||||
# Only read next arg if it not an arg itself.
|
||||
read "$1" <<< "$3"
|
||||
# There is no way to shift our callers args, so
|
||||
# return 1 to indicate they should do it instead.
|
||||
return 1
|
||||
usage () {
|
||||
if [ "$1" == "-n" ]; then
|
||||
cmd=echo
|
||||
else
|
||||
cmd=error
|
||||
fi
|
||||
|
||||
$cmd "usage: `basename $0` [--version] [--help] [-v] [-f] [--preload <module>]"
|
||||
$cmd " [--image-version] [--with=<module>]"
|
||||
$cmd " <initrd-image> <kernel-version>"
|
||||
$cmd ""
|
||||
$cmd " (ex: `basename $0` /boot/initramfs-$(uname -r).img $(uname -r))"
|
||||
|
||||
if [ "$1" == "-n" ]; then
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
while (($# > 0)); do
|
||||
case ${1%%=*} in
|
||||
--with-usb) read_arg usbmodule "$@" || shift
|
||||
basicmodules="$basicmodules ${usbmodule:-usb-storage}"
|
||||
unset usbmodule;;
|
||||
--with-avail) read_arg modname "$@" || shift
|
||||
basicmodules="$basicmodules $modname";;
|
||||
--with) read_arg modname "$@" || shift
|
||||
basicmodules="$basicmodules $modname";;
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
--with-usb*)
|
||||
if [ "$1" != "${1##--with-usb=}" ]; then
|
||||
usbmodule=${1##--with-usb=}
|
||||
else
|
||||
usbmodule="usb-storage"
|
||||
fi
|
||||
basicmodules="$basicmodules $usbmodule"
|
||||
unset usbmodule
|
||||
;;
|
||||
--with-avail*)
|
||||
if [ "$1" != "${1##--with-avail=}" ]; then
|
||||
modname=${1##--with-avail=}
|
||||
else
|
||||
modname=$2
|
||||
shift
|
||||
fi
|
||||
|
||||
basicmodules="$basicmodules $modname"
|
||||
;;
|
||||
--with*)
|
||||
if [ "$1" != "${1##--with=}" ]; then
|
||||
modname=${1##--with=}
|
||||
else
|
||||
modname=$2
|
||||
shift
|
||||
fi
|
||||
|
||||
basicmodules="$basicmodules $modname"
|
||||
;;
|
||||
--version)
|
||||
echo "mkinitrd: dracut compatibility wrapper"
|
||||
exit 0;;
|
||||
-v|--verbose) dracut_args="${dracut_args} -v";;
|
||||
-f|--force) dracut_args="${dracut_args} -f";;
|
||||
--preload) read_arg modname "$@" || shift
|
||||
basicmodules="$basicmodules $modname";;
|
||||
--image-version) img_vers=yes;;
|
||||
--rootfs) read_arg rootfs "$@" || shift
|
||||
dracut_args="${dracut_args} --filesystems $rootfs";;
|
||||
--nocompress) dracut_args="$dracut_args --no-compress";;
|
||||
--help) usage -n;;
|
||||
--builtin) ;;
|
||||
exit 0
|
||||
;;
|
||||
-v|--verbose)
|
||||
dracut_args="${dracut_args} -v"
|
||||
;;
|
||||
-f|--force)
|
||||
dracut_args="${dracut_args} -f"
|
||||
;;
|
||||
--preload*)
|
||||
if [ "$1" != "${1##--preload=}" ]; then
|
||||
modname=${1##--preload=}
|
||||
else
|
||||
modname=$2
|
||||
shift
|
||||
fi
|
||||
basicmodules="$basicmodules $modname"
|
||||
;;
|
||||
--image-version)
|
||||
img_vers=yes
|
||||
;;
|
||||
--rootfs*)
|
||||
if [ "$1" != "${1##--rootfs=}" ]; then
|
||||
rootfs="${1##--rootfs=}"
|
||||
else
|
||||
rootfs="$2"
|
||||
shift
|
||||
fi
|
||||
dracut_args="${dracut_args} --filesystems $rootfs"
|
||||
;;
|
||||
--builtin*) ;;
|
||||
--without*) ;;
|
||||
--without-usb) ;;
|
||||
--fstab*) ;;
|
||||
--nocompress) ;;
|
||||
--ifneeded) ;;
|
||||
--omit-scsi-modules) ;;
|
||||
--omit-ide-modules) ;;
|
||||
@@ -70,32 +106,45 @@ while (($# > 0)); do
|
||||
--allow-missing) ;;
|
||||
--net-dev*) ;;
|
||||
--noresume) ;;
|
||||
--rootdev*) ;;
|
||||
--thawdev*) ;;
|
||||
--rootopts*) ;;
|
||||
--root*) ;;
|
||||
--loopdev*) ;;
|
||||
--loopfs*) ;;
|
||||
--loopopts*) ;;
|
||||
--looppath*) ;;
|
||||
--dsdt*) ;;
|
||||
--rootdev*) ;;
|
||||
--thawdev*) ;;
|
||||
--rootopts*) ;;
|
||||
--root*) ;;
|
||||
--loopdev*) ;;
|
||||
--loopfs*) ;;
|
||||
--loopopts*) ;;
|
||||
--looppath*) ;;
|
||||
--dsdt*) ;;
|
||||
--bootchart) ;;
|
||||
*) if [[ ! $target ]]; then
|
||||
target=$1
|
||||
elif [[ ! $kernel ]]; then
|
||||
kernel=$1
|
||||
--help)
|
||||
usage -n
|
||||
;;
|
||||
*)
|
||||
if [ -z "$target" ]; then
|
||||
target=$1
|
||||
elif [ -z "$kernel" ]; then
|
||||
kernel=$1
|
||||
else
|
||||
usage
|
||||
fi;;
|
||||
usage
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
shift
|
||||
done
|
||||
|
||||
[[ $target && $kernel ]] || usage
|
||||
[[ $img_vers ]] && target="$target-$kernel"
|
||||
|
||||
if [[ $basicmodules ]]; then
|
||||
dracut $dracut_args --add-drivers "$basicmodules" "$target" "$kernel"
|
||||
else
|
||||
dracut $dracut_args "$target" "$kernel"
|
||||
if [ -z "$target" -o -z "$kernel" ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
if [ -n "$img_vers" ]; then
|
||||
target="$target-$kernel"
|
||||
fi
|
||||
|
||||
if [ -n "$basicmodules" ]; then
|
||||
dracut $dracut_args --add-drivers "$basicmodules" "$target" "$kernel"
|
||||
else
|
||||
dracut $dracut_args "$target" "$kernel"
|
||||
fi
|
||||
|
||||
# vim:ts=8:sw=4:sts=4:et
|
||||
|
103
mkinitrd.8
Normal file
103
mkinitrd.8
Normal file
@@ -0,0 +1,103 @@
|
||||
'\" t
|
||||
.\" Title: mkinitrd
|
||||
.\" Author: [see the "AUTHORS" section]
|
||||
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
|
||||
.\" Date: 07/17/2013
|
||||
.\" Manual: dracut
|
||||
.\" Source: dracut
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "MKINITRD" "8" "07/17/2013" "dracut" "dracut"
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * Define some portability stuff
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.\" http://bugs.debian.org/507673
|
||||
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
|
||||
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * set default formatting
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" disable hyphenation
|
||||
.nh
|
||||
.\" disable justification (adjust text to left margin only)
|
||||
.ad l
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * MAIN CONTENT STARTS HERE *
|
||||
.\" -----------------------------------------------------------------
|
||||
.SH "NAME"
|
||||
mkinitrd \- is a compat wrapper, which calls dracut to generate an initramfs
|
||||
.SH "SYNOPSIS"
|
||||
.sp
|
||||
\fBmkinitrd\fR [\fIOPTION\&...\fR] [<initrd\-image>] <kernel\-version>
|
||||
.SH "DESCRIPTION"
|
||||
.sp
|
||||
mkinitrd creates an initramfs image <initrd\-image> for the kernel with version <kernel\-version> by calling "dracut"\&.
|
||||
.if n \{\
|
||||
.sp
|
||||
.\}
|
||||
.RS 4
|
||||
.it 1 an-trap
|
||||
.nr an-no-space-flag 1
|
||||
.nr an-break-flag 1
|
||||
.br
|
||||
.ps +1
|
||||
\fBImportant\fR
|
||||
.ps -1
|
||||
.br
|
||||
.sp
|
||||
If a more fine grained control over the resulting image is needed, "dracut" should be called directly\&.
|
||||
.sp .5v
|
||||
.RE
|
||||
.SH "OPTIONS"
|
||||
.PP
|
||||
\fB\-\-version\fR
|
||||
.RS 4
|
||||
print info about the version
|
||||
.RE
|
||||
.PP
|
||||
\fB\-v, \-\-verbose\fR
|
||||
.RS 4
|
||||
increase verbosity level
|
||||
.RE
|
||||
.PP
|
||||
\fB\-f, \-\-force\fR
|
||||
.RS 4
|
||||
overwrite existing initramfs file\&.
|
||||
.RE
|
||||
.PP
|
||||
\fB*\-\-image\-version\fR
|
||||
.RS 4
|
||||
append the kernel version to the target image <initrd\-image>\-<kernel\-version>\&.
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-with=<module>\fR
|
||||
.RS 4
|
||||
add the kernel module <module> to the initramfs\&.
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-preload=<module>\fR
|
||||
.RS 4
|
||||
preload the kernel module <module> in the initramfs before any other kernel modules are loaded\&. This can be used to ensure a certain device naming, which should in theory be avoided and the use of symbolic links in /dev is encouraged\&.
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-nocompress\fR
|
||||
.RS 4
|
||||
do not compress the resulting image\&.
|
||||
.RE
|
||||
.PP
|
||||
\fB\-\-help\fR
|
||||
.RS 4
|
||||
print a help message and exit\&.
|
||||
.RE
|
||||
.SH "AVAILABILITY"
|
||||
.sp
|
||||
The mkinitrd command is part of the dracut package and is available from \m[blue]\fBhttps://dracut\&.wiki\&.kernel\&.org\fR\m[]
|
||||
.SH "AUTHORS"
|
||||
.sp
|
||||
Harald Hoyer
|
||||
.SH "SEE ALSO"
|
||||
.sp
|
||||
\fBdracut\fR(8)
|
@@ -1,65 +0,0 @@
|
||||
MKINITRD(8)
|
||||
=========
|
||||
:doctype: manpage
|
||||
:man source: dracut
|
||||
:man manual: dracut
|
||||
|
||||
NAME
|
||||
----
|
||||
mkinitrd - is a compat wrapper, which calls dracut to generate an initramfs
|
||||
|
||||
SYNOPSIS
|
||||
--------
|
||||
*mkinitrd* ['OPTION...'] [<initrd-image>] <kernel-version>
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
mkinitrd creates an initramfs image <initrd-image> for the kernel with
|
||||
version <kernel-version> by calling "dracut".
|
||||
|
||||
[IMPORTANT]
|
||||
If a more fine grained control over the resulting image is needed,
|
||||
"dracut" should be called directly.
|
||||
|
||||
OPTIONS
|
||||
-------
|
||||
**--version**::
|
||||
print info about the version
|
||||
|
||||
**-v, --verbose**::
|
||||
increase verbosity level
|
||||
|
||||
**-f, --force**::
|
||||
overwrite existing initramfs file.
|
||||
|
||||
**--image-version*::
|
||||
append the kernel version to the target image
|
||||
<initrd-image>-<kernel-version>.
|
||||
|
||||
**--with=<module>**::
|
||||
add the kernel module <module> to the initramfs.
|
||||
|
||||
**--preload=<module>**::
|
||||
preload the kernel module <module> in the initramfs before any other kernel
|
||||
modules are loaded. This can be used to ensure a certain device naming,
|
||||
which should in theory be avoided and the use of symbolic links in /dev is
|
||||
encouraged.
|
||||
|
||||
**--nocompress**::
|
||||
do not compress the resulting image.
|
||||
|
||||
**--help**::
|
||||
print a help message and exit.
|
||||
|
||||
AVAILABILITY
|
||||
------------
|
||||
The mkinitrd command is part of the dracut package and is available from
|
||||
link:$$https://dracut.wiki.kernel.org$$[https://dracut.wiki.kernel.org]
|
||||
|
||||
AUTHORS
|
||||
-------
|
||||
Harald Hoyer
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
*dracut*(8)
|
@@ -1,20 +0,0 @@
|
||||
#!/bin/bash
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
check() {
|
||||
require_binaries /bin/bash
|
||||
}
|
||||
|
||||
depends() {
|
||||
return 0
|
||||
}
|
||||
|
||||
install() {
|
||||
# If another shell is already installed, do not use bash
|
||||
[[ -x $initdir/bin/sh ]] && return
|
||||
|
||||
# Prefer bash as /bin/sh if it is available.
|
||||
inst /bin/bash && ln -sf bash "${initdir}/bin/sh"
|
||||
}
|
||||
|
@@ -1,29 +0,0 @@
|
||||
#!/bin/bash
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
check() {
|
||||
[[ "$mount_needs" ]] && return 1
|
||||
require_binaries /sbin/bootchartd || return 1
|
||||
return 255
|
||||
}
|
||||
|
||||
depends() {
|
||||
return 0
|
||||
}
|
||||
|
||||
install() {
|
||||
inst_symlink /init /sbin/init
|
||||
inst_dir /lib/bootchart/tmpfs
|
||||
|
||||
inst_multiple bootchartd bash \
|
||||
/lib/bootchart/bootchart-collector /etc/bootchartd.conf \
|
||||
accton \
|
||||
echo \
|
||||
grep \
|
||||
usleep
|
||||
|
||||
inst /usr/bin/pkill /bin/pkill
|
||||
inst /usr/bin/[ /bin/[
|
||||
}
|
||||
|
2
modules.d/00dash/check
Executable file
2
modules.d/00dash/check
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
[ -x /bin/dash ]
|
6
modules.d/00dash/install
Executable file
6
modules.d/00dash/install
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
# If another shell is already installed, do not use dash
|
||||
[ -x "${initdir}/bin/sh" ] && return
|
||||
|
||||
# Prefer dash as /bin/sh if it is available.
|
||||
inst /bin/dash && ln -sf dash "${initdir}/bin/sh"
|
@@ -1,20 +0,0 @@
|
||||
#!/bin/bash
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
check() {
|
||||
require_binaries /bin/dash
|
||||
}
|
||||
|
||||
depends() {
|
||||
return 0
|
||||
}
|
||||
|
||||
install() {
|
||||
# If another shell is already installed, do not use dash
|
||||
[[ -x $initdir/bin/sh ]] && return
|
||||
|
||||
# Prefer dash as /bin/sh if it is available.
|
||||
inst /bin/dash && ln -sf dash "${initdir}/bin/sh"
|
||||
}
|
||||
|
@@ -1,18 +0,0 @@
|
||||
#!/bin/bash
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
check() {
|
||||
[[ "$mount_needs" ]] && return 1
|
||||
require_binaries $systemdutildir/systemd-bootchart || return 1
|
||||
return 255
|
||||
}
|
||||
|
||||
depends() {
|
||||
return 0
|
||||
}
|
||||
|
||||
install() {
|
||||
inst_symlink /init /sbin/init
|
||||
inst_multiple $systemdutildir/systemd-bootchart
|
||||
}
|
5
modules.d/01fips/check
Executable file
5
modules.d/01fips/check
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
[[ $1 = -d ]] && exit 0
|
||||
exit 255
|
||||
|
@@ -3,7 +3,7 @@
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
if ! fipsmode=$(getarg fips) || [ $fipsmode = "0" ]; then
|
||||
rm -f -- /etc/modprobe.d/fips.conf >/dev/null 2>&1
|
||||
rm -f /etc/modprobe.d/fips.conf >/dev/null 2>&1
|
||||
elif getarg boot= >/dev/null; then
|
||||
. /sbin/fips.sh
|
||||
if mount_boot; then
|
||||
|
@@ -1,8 +0,0 @@
|
||||
#!/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
|
@@ -3,7 +3,7 @@
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
if ! fipsmode=$(getarg fips) || [ $fipsmode = "0" ]; then
|
||||
rm -f -- /etc/modprobe.d/fips.conf >/dev/null 2>&1
|
||||
rm -f /etc/modprobe.d/fips.conf >/dev/null 2>&1
|
||||
elif ! [ -f /tmp/fipsdone ]; then
|
||||
. /sbin/fips.sh
|
||||
mount_boot
|
||||
|
@@ -15,12 +15,6 @@ mount_boot()
|
||||
UUID=*)
|
||||
boot="/dev/disk/by-uuid/${boot#UUID=}"
|
||||
;;
|
||||
PARTUUID=*)
|
||||
boot="/dev/disk/by-partuuid/${boot#PARTUUID=}"
|
||||
;;
|
||||
PARTLABEL=*)
|
||||
boot="/dev/disk/by-partlabel/${boot#PARTLABEL=}"
|
||||
;;
|
||||
/dev/*)
|
||||
;;
|
||||
*)
|
||||
@@ -33,11 +27,13 @@ mount_boot()
|
||||
i=0
|
||||
while ! [ -e $boot ]; do
|
||||
if [ $UDEVVERSION -ge 143 ]; then
|
||||
udevadm settle --exit-if-exists=$boot
|
||||
udevadm settle --exit-if-exists=$boot >/dev/null 2>&1
|
||||
else
|
||||
udevadm settle --timeout=30
|
||||
udevadm settle --timeout=30 >/dev/null 2>&1
|
||||
fi
|
||||
[ -e $boot ] && break
|
||||
modprobe scsi_wait_scan && rmmod scsi_wait_scan
|
||||
[ -e $boot ] && break
|
||||
sleep 0.5
|
||||
i=$(($i+1))
|
||||
[ $i -gt 40 ] && break
|
||||
@@ -50,7 +46,7 @@ mount_boot()
|
||||
info "Mounting $boot as /boot"
|
||||
mount -oro "$boot" /boot || return 1
|
||||
elif [ -d "$NEWROOT/boot" ]; then
|
||||
rm -fr -- /boot
|
||||
rm -fr /boot
|
||||
ln -sf "$NEWROOT/boot" /boot
|
||||
fi
|
||||
}
|
||||
@@ -60,7 +56,7 @@ do_rhevh_check()
|
||||
KERNEL=$(uname -r)
|
||||
kpath=${1}
|
||||
|
||||
# If we're on RHEV-H, the kernel is in /run/initramfs/live/vmlinuz0
|
||||
# If we're on RHEV-H, the kernel is in /dev/.initramfs/live/vmlinuz0
|
||||
HMAC_SUM_ORIG=$(cat $NEWROOT/boot/.vmlinuz-${KERNEL}.hmac | while read a b; do printf "%s\n" $a; done)
|
||||
HMAC_SUM_CALC=$(sha512hmac $kpath | while read a b; do printf "%s\n" $a; done || return 1)
|
||||
if [ -z "$HMAC_SUM_ORIG" ] || [ -z "$HMAC_SUM_CALC" ] || [ "${HMAC_SUM_ORIG}" != "${HMAC_SUM_CALC}" ]; then
|
||||
@@ -71,24 +67,45 @@ do_rhevh_check()
|
||||
return 0
|
||||
}
|
||||
|
||||
fips_load_crypto()
|
||||
do_fips()
|
||||
{
|
||||
local _v
|
||||
local _s
|
||||
local _v
|
||||
local _module
|
||||
info "Checking integrity of kernel"
|
||||
KERNEL=$(uname -r)
|
||||
|
||||
if ! [ -e "/boot/.vmlinuz-${KERNEL}.hmac" ]; then
|
||||
warn "/boot/.vmlinuz-${KERNEL}.hmac does not exist"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ -e "/dev/.initramfs/live/vmlinuz0" ]; then
|
||||
do_rhevh_check /dev/.initramfs/live/vmlinuz0 || return 1
|
||||
elif [ -e "/dev/.initramfs/live/isolinux/vmlinuz0" ]; then
|
||||
do_rhevh_check /dev/.initramfs/live/isolinux/vmlinuz0 || return 1
|
||||
else
|
||||
sha512hmac -c "/boot/.vmlinuz-${KERNEL}.hmac" || 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}" 2>/tmp/fips.modprobe_err; 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
|
||||
[ "$_k" = "driver" ] && _v=$(str_replace "$_v" "_" "-")
|
||||
[ "$_v" != "$_module" ] && continue
|
||||
_found=1
|
||||
break
|
||||
done </proc/crypto
|
||||
[ "$_found" = "0" ] && cat /tmp/fips.modprobe_err >&2 && return 1
|
||||
[ "$_found" = "0" ] && return 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
@@ -97,49 +114,6 @@ fips_load_crypto()
|
||||
info "Self testing crypto algorithms"
|
||||
modprobe tcrypt || return 1
|
||||
rmmod tcrypt
|
||||
}
|
||||
|
||||
do_fips()
|
||||
{
|
||||
local _v
|
||||
local _s
|
||||
local _v
|
||||
local _module
|
||||
|
||||
KERNEL=$(uname -r)
|
||||
|
||||
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
|
||||
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"
|
||||
|
||||
> /tmp/fipsdone
|
||||
|
35
modules.d/01fips/install
Executable file
35
modules.d/01fips/install
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
inst_hook pre-trigger 01 "$moddir/fips-boot.sh"
|
||||
inst_hook pre-pivot 01 "$moddir/fips-noboot.sh"
|
||||
inst "$moddir/fips.sh" /sbin/fips.sh
|
||||
dracut_install sha512hmac rmmod insmod mount uname umount
|
||||
|
||||
libdir="lib"
|
||||
if ldd $(find_binary sha512hmac) 2>/dev/null | grep -q /lib64/; then
|
||||
libdir="lib64"
|
||||
fi
|
||||
|
||||
if [ -e /usr/$libdir/libsoftokn3.so ]; then
|
||||
dracut_install \
|
||||
/usr/$libdir/libsoftokn3.so /usr/$libdir/libsoftokn3.chk
|
||||
else
|
||||
dracut_install \
|
||||
/$libdir/libsoftokn3.so /$libdir/libsoftokn3.chk
|
||||
fi
|
||||
|
||||
for i in /{usr,}/$libdir/libssl.so* /{usr,}/$libdir/libcrypto.so* \
|
||||
/{usr,}/$libdir/.libssl.so*.hmac /{usr,}/$libdir/.libcrypto.so*.hmac; do
|
||||
[ -e $i ] || continue
|
||||
dracut_install $i
|
||||
done
|
||||
|
||||
dracut_install -o /usr/$libdir/hmaccalc/sha*hmac.hmac
|
||||
dracut_install fipscheck
|
||||
dracut_install /etc/system-fips
|
||||
|
||||
if command -v prelink >/dev/null; then
|
||||
dracut_install prelink
|
||||
fi
|
||||
|
||||
# vim:ts=8:sw=4:sts=4:et
|
18
modules.d/01fips/installkernel
Executable file
18
modules.d/01fips/installkernel
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
_fipsmodules="aead aes_generic aes-x86_64 ansi_cprng arc4 blowfish camellia cast6 cbc ccm "
|
||||
_fipsmodules+="chainiv crc32c 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+="sha384 sha512 sha512_generic tcrypt tea tnepres twofish wp256 wp384 wp512 xeta xtea xts zlib"
|
||||
|
||||
mkdir -p "${initdir}/etc/modprobe.d"
|
||||
|
||||
for mod in $_fipsmodules; do
|
||||
if hostonly='' instmods $mod; then
|
||||
echo $mod >> "${initdir}/etc/fipsmodules"
|
||||
echo "blacklist $mod" >> "${initdir}/etc/modprobe.d/fips.conf"
|
||||
fi
|
||||
done
|
||||
|
||||
# vim:ts=8:sw=4:sts=4:et
|
@@ -1,68 +0,0 @@
|
||||
#!/bin/bash
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
check() {
|
||||
return 255
|
||||
}
|
||||
|
||||
depends() {
|
||||
return 0
|
||||
}
|
||||
|
||||
installkernel() {
|
||||
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 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-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
|
||||
|
||||
inst_libdir_file libsoftokn3.so libsoftokn3.so \
|
||||
libsoftokn3.chk libfreebl3.so libfreebl3.chk \
|
||||
libssl.so 'hmaccalc/sha512hmac.hmac' libssl.so.10 \
|
||||
libfreeblpriv3.so libfreeblpriv3.chk
|
||||
|
||||
inst_multiple -o prelink
|
||||
inst_simple /etc/system-fips
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ This adds the following parameters:
|
||||
rd.caps=1
|
||||
turn the caps module on/off
|
||||
rd.caps.initdrop=cap_sys_module,cap_sys_rawio
|
||||
drop the specified comma separated capabilities
|
||||
drop the specified comma seperated capabilities
|
||||
rd.caps.disablemodules=1
|
||||
turn off module loading
|
||||
rd.caps.disablekexec=1
|
||||
@@ -10,13 +10,13 @@ rd.caps.disablekexec=1
|
||||
|
||||
If module loading is turned off, all modules have to be loaded in the
|
||||
initramfs, which are used later on. This can be done with
|
||||
"rd.driver.pre="
|
||||
rd.driver.pre=autofs4,sunrpc,ipt_REJECT,nf_conntrack_ipv4,....
|
||||
"rdloaddriver="
|
||||
rdloaddriver=autofs4,sunrpc,ipt_REJECT,nf_conntrack_ipv4,....
|
||||
|
||||
Because the kernel command line would get huge with all those drivers, I
|
||||
recommend to make use of $initramfs/etc/cmdline.
|
||||
|
||||
So, all rd.caps.* and rd.driver.pre arguments are in caps.conf can be
|
||||
So, all rd.caps.* and rdloaddriver arguments are in caps.conf can be
|
||||
copied to $initramfs/etc/cmdline with "-i caps.conf /etc/cmdline".
|
||||
|
||||
Also all modules have to be loaded in the initramfs via "--add-drivers".
|
||||
|
@@ -12,7 +12,7 @@ if [ "$capsmode" = "1" ]; then
|
||||
|
||||
info "Loading CAPS_MODULES $CAPS_MODULES"
|
||||
for i in $CAPS_MODULES;do modprobe $i 2>&1 >/dev/null | vinfo; done
|
||||
|
||||
|
||||
if [ "$CAPS_MODULES_DISABLED" = "1" -a -e /proc/sys/kernel/modules_disabled ]; then
|
||||
info "Disabling module loading."
|
||||
echo $CAPS_MODULES_DISABLED > /proc/sys/kernel/modules_disabled
|
||||
@@ -29,7 +29,7 @@ if [ "$capsmode" = "1" ]; then
|
||||
echo $CAPS_USERMODEHELPER_BSET > /proc/sys/kernel/usermodehelper/bset
|
||||
echo $CAPS_USERMODEHELPER_BSET > /proc/sys/kernel/usermodehelper/inheritable
|
||||
fi
|
||||
|
||||
|
||||
echo "CAPS_INIT_DROP=\"$CAPS_INIT_DROP\"" > /etc/capsdrop
|
||||
info "Will drop capabilities $CAPS_INIT_DROP from init."
|
||||
fi
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user