Compare commits
406 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
09eaf9f5b3 | ||
![]() |
89d44e720b | ||
![]() |
7224913d16 | ||
![]() |
026b81e980 | ||
![]() |
6571cd4073 | ||
![]() |
67ab4f7718 | ||
![]() |
f71145d20d | ||
![]() |
407fbc9e13 | ||
![]() |
5ffa0114c0 | ||
![]() |
08084370fd | ||
![]() |
70c6b773ca | ||
![]() |
0d339e7ffb | ||
![]() |
f0558da598 | ||
![]() |
ec1aa3bc48 | ||
![]() |
26c231f13b | ||
![]() |
99c7b70d1d | ||
![]() |
92f26b6202 | ||
![]() |
0c6565c810 | ||
![]() |
d8aeb3a72a | ||
![]() |
2cf987f5c3 | ||
![]() |
53fe81e752 | ||
![]() |
e716c0f121 | ||
![]() |
1048124120 | ||
![]() |
84a12fbc21 | ||
![]() |
1d97bb8b39 | ||
![]() |
4ea629b9e1 | ||
![]() |
ad200fbc8c | ||
![]() |
b47d7a5fd4 | ||
![]() |
5d897c82b9 | ||
![]() |
4d0f1d7b28 | ||
![]() |
2d2c8c2078 | ||
![]() |
8bc04b98c7 | ||
![]() |
71947dcb91 | ||
![]() |
9c2a1d0de6 | ||
![]() |
94165394ff | ||
![]() |
3aa221aa1d | ||
![]() |
a0df73b493 | ||
![]() |
5bccc94598 | ||
![]() |
a5f44604f7 | ||
![]() |
8c6151bd63 | ||
![]() |
d531a0a307 | ||
![]() |
3639d2431f | ||
![]() |
44cf581732 | ||
![]() |
b65bde04e7 | ||
![]() |
28a6eef3be | ||
![]() |
69b35075f3 | ||
![]() |
744054779f | ||
![]() |
b19c5d51f8 | ||
![]() |
22048b44db | ||
![]() |
1488a9b34d | ||
![]() |
d5b5bb3103 | ||
![]() |
f8be752874 | ||
![]() |
520047c3c4 | ||
![]() |
ae2d48a366 | ||
![]() |
472edf825e | ||
![]() |
cc51bc6fdb | ||
![]() |
55cb17c677 | ||
![]() |
ee876e03b9 | ||
![]() |
579ca216b4 | ||
![]() |
a20d24ded2 | ||
![]() |
1e2673fd98 | ||
![]() |
16c88e493f | ||
![]() |
1e570bf8e3 | ||
![]() |
d9087a2d85 | ||
![]() |
e08710a289 | ||
![]() |
b03e991113 | ||
![]() |
a51aa0d0e2 | ||
![]() |
f82659c552 | ||
![]() |
f653c86229 | ||
![]() |
edcbd379d5 | ||
![]() |
3d3ddf082b | ||
![]() |
f6eb1f1d1f | ||
![]() |
b47e023767 | ||
![]() |
529f7bf358 | ||
![]() |
9f037266ee | ||
![]() |
c7896f1251 | ||
![]() |
361306c131 | ||
![]() |
f48f9341a5 | ||
![]() |
d686298315 | ||
![]() |
9f88b0370d | ||
![]() |
2dbd71b77a | ||
![]() |
483b1e3aa8 | ||
![]() |
c8f3a1c057 | ||
![]() |
ef914f7d83 | ||
![]() |
0efc6c716a | ||
![]() |
4f9f76cd62 | ||
![]() |
8d95b8b338 | ||
![]() |
7abd426438 | ||
![]() |
8fab6e0463 | ||
![]() |
c9aa3cc950 | ||
![]() |
f9ad49c2a5 | ||
![]() |
3eca0cc846 | ||
![]() |
9f6baa127a | ||
![]() |
f79e587cf3 | ||
![]() |
1d2c070071 | ||
![]() |
7828692f97 | ||
![]() |
cacaa90c63 | ||
![]() |
b23a2837db | ||
![]() |
30430fbe30 | ||
![]() |
50b08e7b85 | ||
![]() |
43fed15129 | ||
![]() |
bebb12fd0e | ||
![]() |
b4692ce388 | ||
![]() |
df96787019 | ||
![]() |
d2a9c4a8e7 | ||
![]() |
fbaf1517c3 | ||
![]() |
57038a41fa | ||
![]() |
521c57aca5 | ||
![]() |
ede0532c58 | ||
![]() |
547bbe4876 | ||
![]() |
fe1484f3db | ||
![]() |
d161561290 | ||
![]() |
2cf4f4fb74 | ||
![]() |
b6fd45163a | ||
![]() |
4d76a85df1 | ||
![]() |
d77540c8e4 | ||
![]() |
784df1e4e3 | ||
![]() |
6d82d7bcd5 | ||
![]() |
2614421601 | ||
![]() |
200e235dee | ||
![]() |
0636ce1a7f | ||
![]() |
6042b30c58 | ||
![]() |
604d1eb21a | ||
![]() |
14b43bcaee | ||
![]() |
c79f3883cd | ||
![]() |
df42cd3dbd | ||
![]() |
01bbe8311a | ||
![]() |
21928b97b0 | ||
![]() |
e82e54df2c | ||
![]() |
ecc6da6bf5 | ||
![]() |
b35ff065ec | ||
![]() |
187c355bf4 | ||
![]() |
70516a04fe | ||
![]() |
fcd65d2418 | ||
![]() |
9073ff54c1 | ||
![]() |
840d8e4733 | ||
![]() |
5ad3803dac | ||
![]() |
e04d02cc3a | ||
![]() |
51153fb18c | ||
![]() |
2268e3a32a | ||
![]() |
8b88dc7f71 | ||
![]() |
eecb3d5552 | ||
![]() |
f629355b2f | ||
![]() |
78274fe2b4 | ||
![]() |
4744e27350 | ||
![]() |
31cfc9aa5e | ||
![]() |
a2ead9a486 | ||
![]() |
db2b12fa91 | ||
![]() |
cbf66c5f06 | ||
![]() |
037984c80e | ||
![]() |
9337c692bc | ||
![]() |
c438bdb0d2 | ||
![]() |
144787fe30 | ||
![]() |
8eb81d482c | ||
![]() |
0363998d0a | ||
![]() |
806572d058 | ||
![]() |
81ea383998 | ||
![]() |
8442dc45b6 | ||
![]() |
cfede42fc3 | ||
![]() |
982d59afea | ||
![]() |
ca024e3378 | ||
![]() |
dbf8f6ba0e | ||
![]() |
02805bd1fc | ||
![]() |
965d14726a | ||
![]() |
b0772db56a | ||
![]() |
d695143329 | ||
![]() |
59aa65c9b2 | ||
![]() |
ffc5bf686d | ||
![]() |
ec3c59518d | ||
![]() |
cfe32ef5ba | ||
![]() |
8be5a0fa94 | ||
![]() |
bd4be59fb2 | ||
![]() |
a6d3be9dd5 | ||
![]() |
40913ad219 | ||
![]() |
afd1fd8d41 | ||
![]() |
38111b9622 | ||
![]() |
41153ca4f2 | ||
![]() |
3df2306981 | ||
![]() |
022c5a802f | ||
![]() |
832d85cbbc | ||
![]() |
f72318243c | ||
![]() |
a82d207b8d | ||
![]() |
53e3244dba | ||
![]() |
37427748d1 | ||
![]() |
6e26f9b447 | ||
![]() |
5bfbfbfc22 | ||
![]() |
2c431e8ec4 | ||
![]() |
8aeec251e3 | ||
![]() |
f2d887d7d5 | ||
![]() |
fe98cfee37 | ||
![]() |
cad10a7f80 | ||
![]() |
3734f4ae48 | ||
![]() |
4b13b2e2bf | ||
![]() |
f6a58604a0 | ||
![]() |
65ceb56dd5 | ||
![]() |
cce69be668 | ||
![]() |
a54658c158 | ||
![]() |
335bb5a35b | ||
![]() |
982161e062 | ||
![]() |
5a81678219 | ||
![]() |
168952cea6 | ||
![]() |
5dc1be1df8 | ||
![]() |
cb08b0132f | ||
![]() |
eb6e141adb | ||
![]() |
c6c704fda6 | ||
![]() |
eef7649e71 | ||
![]() |
f8d50f60b3 | ||
![]() |
476eb1b345 | ||
![]() |
c32908cee3 | ||
![]() |
dc1504121b | ||
![]() |
c6a91ec992 | ||
![]() |
689c3e1fcd | ||
![]() |
1bd76bf981 | ||
![]() |
2e7257a2e3 | ||
![]() |
76b83902dc | ||
![]() |
2de297334b | ||
![]() |
b4664769dc | ||
![]() |
7f217d7726 | ||
![]() |
8a1a2f6ca4 | ||
![]() |
bd66d2b59a | ||
![]() |
9f630a1889 | ||
![]() |
04ab68a4dd | ||
![]() |
a7c9cbe1a2 | ||
![]() |
97903dfc47 | ||
![]() |
25ff71b0c7 | ||
![]() |
324be70f80 | ||
![]() |
b8a81fb885 | ||
![]() |
0a35a80b93 | ||
![]() |
c9143a63fe | ||
![]() |
6625b74e90 | ||
![]() |
bd3bf2ce41 | ||
![]() |
f7cadaa843 | ||
![]() |
e173f0b384 | ||
![]() |
1e4a880125 | ||
![]() |
d8f0e320c2 | ||
![]() |
76c14799da | ||
![]() |
ef5c6eb927 | ||
![]() |
50bc2253d3 | ||
![]() |
f5af0df821 | ||
![]() |
b80078af39 | ||
![]() |
990e945ffd | ||
![]() |
8a5456e872 | ||
![]() |
46a1738161 | ||
![]() |
6c3b8e2c17 | ||
![]() |
b48f5e847c | ||
![]() |
bdb818997d | ||
![]() |
fc87119069 | ||
![]() |
078acb598b | ||
![]() |
030b8a160f | ||
![]() |
0e979d4829 | ||
![]() |
66b750a08e | ||
![]() |
31b6f4a3ae | ||
![]() |
a5cde2dd18 | ||
![]() |
2f6fe2ec79 | ||
![]() |
e03c77cb5b | ||
![]() |
b5c2fc1141 | ||
![]() |
513d26f7b7 | ||
![]() |
f1354b8af9 | ||
![]() |
b2de89c5dc | ||
![]() |
8d51acbbe9 | ||
![]() |
ac3f1c6e87 | ||
![]() |
61c4c83235 | ||
![]() |
85f8bb16b2 | ||
![]() |
6dd4370eaa | ||
![]() |
0441230c51 | ||
![]() |
26433e9c1f | ||
![]() |
4dd68ca415 | ||
![]() |
882c4c5a48 | ||
![]() |
2b59885976 | ||
![]() |
cb74b38247 | ||
![]() |
e7da9734d8 | ||
![]() |
0cec230406 | ||
![]() |
f06905139f | ||
![]() |
56bf6156d6 | ||
![]() |
317191848a | ||
![]() |
3d3f32aea3 | ||
![]() |
b7b062ba79 | ||
![]() |
4e25cf6edf | ||
![]() |
5055abb615 | ||
![]() |
abbb76fe93 | ||
![]() |
478314a90e | ||
![]() |
8cd592dfcb | ||
![]() |
d8eb522e80 | ||
![]() |
c3d81de59b | ||
![]() |
02aa795514 | ||
![]() |
0884261283 | ||
![]() |
f94ceb13b8 | ||
![]() |
4ce3a1b1bb | ||
![]() |
888d53f270 | ||
![]() |
dc824f1994 | ||
![]() |
3a00cf9ecc | ||
![]() |
803be5aa50 | ||
![]() |
52c4c9484d | ||
![]() |
7e60091c6b | ||
![]() |
04febed782 | ||
![]() |
2ff3fc73c8 | ||
![]() |
d33d60774f | ||
![]() |
f8208d682f | ||
![]() |
0635530dda | ||
![]() |
6e3cc00f48 | ||
![]() |
25aa3c5a6e | ||
![]() |
4d518aec86 | ||
![]() |
74db72dd0b | ||
![]() |
4fed3ddf16 | ||
![]() |
b8a9dc2d3f | ||
![]() |
2c0317213e | ||
![]() |
5861184e87 | ||
![]() |
6a2c23d125 | ||
![]() |
af8c8ed9f6 | ||
![]() |
b43d651511 | ||
![]() |
66666c670a | ||
![]() |
d37ad6aea0 | ||
![]() |
a3f00efc99 | ||
![]() |
8a0d2fc56f | ||
![]() |
ffcc64bdea | ||
![]() |
778f767bcc | ||
![]() |
e12c1a8da1 | ||
![]() |
8d021e4b8a | ||
![]() |
95268ffed3 | ||
![]() |
9eded206c9 | ||
![]() |
b642ce5340 | ||
![]() |
34769a1445 | ||
![]() |
b7ddf6c1d8 | ||
![]() |
cf38fc7389 | ||
![]() |
ddd01008ff | ||
![]() |
7a5f1ee46a | ||
![]() |
379c34d2cf | ||
![]() |
334cc28327 | ||
![]() |
edea870c3c | ||
![]() |
86191581d1 | ||
![]() |
07f3e4f168 | ||
![]() |
b6f0dcbda1 | ||
![]() |
5e5f3d5e6c | ||
![]() |
25b36ef124 | ||
![]() |
f5a9e45923 | ||
![]() |
1701d7adc8 | ||
![]() |
d18bc9070d | ||
![]() |
86bf239ede | ||
![]() |
d433da4473 | ||
![]() |
3249c257a0 | ||
![]() |
a6b63f9192 | ||
![]() |
b019d405d9 | ||
![]() |
004fd0557d | ||
![]() |
2efa546f26 | ||
![]() |
0330b91987 | ||
![]() |
e0a38de881 | ||
![]() |
d06580986b | ||
![]() |
03a44f0bf0 | ||
![]() |
8b6e099892 | ||
![]() |
34248c926c | ||
![]() |
14c47b0ee4 | ||
![]() |
edd3262efd | ||
![]() |
9cb8447c90 | ||
![]() |
cc227886c6 | ||
![]() |
6d2a7942aa | ||
![]() |
43dfbeec7b | ||
![]() |
3335ed0ef4 | ||
![]() |
b6e244f794 | ||
![]() |
14669e3a86 | ||
![]() |
552ecca6db | ||
![]() |
9373aec650 | ||
![]() |
30befb85e3 | ||
![]() |
ed293f6d0c | ||
![]() |
cd9592385d | ||
![]() |
7e2bca4820 | ||
![]() |
c4e48eaea1 | ||
![]() |
3905f6695e | ||
![]() |
2a3faa2df9 | ||
![]() |
86de902e35 | ||
![]() |
c1df00d2c6 | ||
![]() |
75cade1216 | ||
![]() |
a2c631c0a3 | ||
![]() |
6bee336909 | ||
![]() |
5c4bb360e3 | ||
![]() |
969394f503 | ||
![]() |
4977febf46 | ||
![]() |
285e81c9e2 | ||
![]() |
d663f5aeb0 | ||
![]() |
370329ca3b | ||
![]() |
5978983b30 | ||
![]() |
753c82d0e6 | ||
![]() |
9fcfa04ca9 | ||
![]() |
9c463909d6 | ||
![]() |
9d169a07ce | ||
![]() |
dee929cded | ||
![]() |
e0e2fb26c9 | ||
![]() |
fcbcb2521c | ||
![]() |
28f0b27fb9 | ||
![]() |
0ddc098eb0 | ||
![]() |
11c0e7d44e | ||
![]() |
dfb08e9f1c | ||
![]() |
e539fa9980 | ||
![]() |
e76921a58e | ||
![]() |
96d22bd7d6 | ||
![]() |
927d9273c4 | ||
![]() |
56a4cffd30 | ||
![]() |
682a2a9d1a | ||
![]() |
0b1296aa4f | ||
![]() |
fb67e4aa36 | ||
![]() |
4cfd24d179 | ||
![]() |
81dcf7c90a | ||
![]() |
075de7be45 | ||
![]() |
7b2d3d995c | ||
![]() |
d20d307d69 | ||
![]() |
12018c91ea | ||
![]() |
68910ba4a5 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -8,3 +8,6 @@
|
||||
/modules.d/99base/switch_root
|
||||
/test/*/test.log
|
||||
test*.img
|
||||
/.buildpath
|
||||
/.project
|
||||
/dracut-version.sh
|
||||
|
11
AUTHORS
11
AUTHORS
@@ -5,24 +5,24 @@ Warren Togami <wtogami@redhat.com>
|
||||
Amadeusz Żołnowski <aidecoe@aidecoe.name>
|
||||
Jeremy Katz <katzj@redhat.com>
|
||||
David Dillow <dave@thedillows.org>
|
||||
Michal Soltys <soltys@ziu.info>
|
||||
Will Woods <wwoods@redhat.com>
|
||||
Michal Soltys <soltys@ziu.info>
|
||||
Dave Young <dyoung@redhat.com>
|
||||
Amerigo Wang <amwang@redhat.com>
|
||||
Andrey Borzenkov <arvidjaar@gmail.com>
|
||||
Colin Guthrie <colin@mageia.org>
|
||||
Andreas Thienemann <andreas@bawue.net>
|
||||
Hans de Goede <hdegoede@redhat.com>
|
||||
Peter Jones <pjones@redhat.com>
|
||||
Amerigo Wang <amwang@redhat.com>
|
||||
Colin Guthrie <colin@mageia.org>
|
||||
John Reiser <jreiser@bitwagon.com>
|
||||
Luca Berra <bluca@vodka.it>
|
||||
Dave Young <dyoung@redhat.com>
|
||||
Daniel Drake <dsd@laptop.org>
|
||||
Marc Grimme <grimme@atix.de>
|
||||
Dan Horák <dhorak@redhat.com>
|
||||
Roberto Sassu <roberto.sassu@polito.it>
|
||||
Anton Blanchard <anton@samba.org>
|
||||
Bill Nottingham <notting@redhat.com>
|
||||
Brian C. Lane <bcl@redhat.com>
|
||||
Dan Horák <dhorak@redhat.com>
|
||||
David Cantrell <dcantrell@redhat.com>
|
||||
Lance Albertson <lance@osuosl.org>
|
||||
Marian Ganisin <mganisin@redhat.com>
|
||||
@@ -47,6 +47,7 @@ Frederic Crozat <fcrozat@mandriva.com>
|
||||
Glen Gray <slaine@slaine.org>
|
||||
Hermann Gausterer <git-dracut-2012@mrq1.org>
|
||||
James Laska <jlaska@redhat.com>
|
||||
Jan Stodola <jstodola@redhat.com>
|
||||
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
|
||||
Leho Kraav <leho@kraav.com>
|
||||
Lubomir Rintel <lkundrak@v3.sk>
|
||||
|
101
Makefile
101
Makefile
@@ -1,4 +1,4 @@
|
||||
VERSION=015
|
||||
VERSION=020
|
||||
GITVERSION=$(shell [ -d .git ] && git rev-list --abbrev-commit -n 1 HEAD |cut -b 1-8)
|
||||
|
||||
prefix ?= /usr
|
||||
@@ -9,44 +9,75 @@ sysconfdir ?= ${prefix}/etc
|
||||
bindir ?= ${prefix}/bin
|
||||
mandir ?= ${prefix}/share/man
|
||||
|
||||
manpages = dracut.8 dracut.cmdline.7 dracut.conf.5 dracut-catimages.8 dracut-gencmdline.8
|
||||
manpages = dracut.8 dracut.cmdline.7 dracut.conf.5 dracut-catimages.8
|
||||
|
||||
.PHONY: install clean archive rpm testimage test all check AUTHORS doc
|
||||
|
||||
all: syncheck dracut-version.sh install/dracut-install
|
||||
|
||||
install/dracut-install:
|
||||
$(MAKE) -C install dracut-install
|
||||
|
||||
doc: $(manpages) dracut.html
|
||||
all: syncheck
|
||||
|
||||
%: %.xml
|
||||
xsltproc -o $@ -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
|
||||
|
||||
dracut.html: dracut.xml $(manpages)
|
||||
%.xml: %.asc
|
||||
asciidoc -d manpage -b docbook -o $@ $<
|
||||
|
||||
dracut.html: dracut.asc $(manpages)
|
||||
asciidoc -a numbered -d book -b docbook -o dracut.xml dracut.asc
|
||||
xsltproc -o dracut.html --xinclude -nonet \
|
||||
--stringparam draft.mode yes \
|
||||
--stringparam html.stylesheet http://docs.redhat.com/docs/en-US/Common_Content/css/default.css \
|
||||
--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.xml
|
||||
rm dracut.xml
|
||||
|
||||
install: doc
|
||||
install: doc dracut-version.sh
|
||||
mkdir -p $(DESTDIR)$(pkglibdir)
|
||||
mkdir -p $(DESTDIR)$(bindir)
|
||||
mkdir -p $(DESTDIR)$(sysconfdir)
|
||||
mkdir -p $(DESTDIR)$(pkglibdir)/modules.d
|
||||
mkdir -p $(DESTDIR)$(mandir)/man5 $(DESTDIR)$(mandir)/man7 $(DESTDIR)$(mandir)/man8
|
||||
install -m 0755 dracut $(DESTDIR)$(bindir)/dracut
|
||||
install -m 0755 dracut-gencmdline $(DESTDIR)$(bindir)/dracut-gencmdline
|
||||
install -m 0755 dracut-catimages $(DESTDIR)$(bindir)/dracut-catimages
|
||||
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 $(DESTDIR)$(bindir)/lsinitrd
|
||||
install -m 0755 lsinitrd.sh $(DESTDIR)$(bindir)/lsinitrd
|
||||
install -m 0644 dracut.conf $(DESTDIR)$(sysconfdir)/dracut.conf
|
||||
mkdir -p $(DESTDIR)$(sysconfdir)/dracut.conf.d
|
||||
install -m 0755 dracut-functions $(DESTDIR)$(pkglibdir)/dracut-functions
|
||||
install -m 0755 dracut-logger $(DESTDIR)$(pkglibdir)/dracut-logger
|
||||
install -m 0755 dracut-functions.sh $(DESTDIR)$(pkglibdir)/dracut-functions.sh
|
||||
install -m 0755 dracut-version.sh $(DESTDIR)$(pkglibdir)/dracut-version.sh
|
||||
ln -s 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
|
||||
cp -arx modules.d $(DESTDIR)$(pkglibdir)
|
||||
install -m 0644 dracut.8 $(DESTDIR)$(mandir)/man8/dracut.8
|
||||
install -m 0644 dracut-catimages.8 $(DESTDIR)$(mandir)/man8/dracut-catimages.8
|
||||
install -m 0644 dracut-gencmdline.8 $(DESTDIR)$(mandir)/man8/dracut-gencmdline.8
|
||||
install -m 0644 dracut.conf.5 $(DESTDIR)$(mandir)/man5/dracut.conf.5
|
||||
install -m 0644 dracut.cmdline.7 $(DESTDIR)$(mandir)/man7/dracut.cmdline.7
|
||||
ln -s dracut.cmdline.7 $(DESTDIR)$(mandir)/man7/dracut.kernel.7
|
||||
if [ -n "$(systemdsystemunitdir)" ]; then \
|
||||
mkdir -p $(DESTDIR)$(systemdsystemunitdir); \
|
||||
for i in \
|
||||
modules.d/98systemd/dracut-initqueue.service \
|
||||
modules.d/98systemd/dracut-pre-pivot.service \
|
||||
modules.d/98systemd/dracut-pre-trigger.service \
|
||||
modules.d/98systemd/dracut-pre-udev.service \
|
||||
modules.d/98systemd/initrd-switch-root.service \
|
||||
modules.d/98systemd/initrd-switch-root.target \
|
||||
dracut-shutdown.service; do \
|
||||
install -m 0644 $$i $(DESTDIR)$(systemdsystemunitdir); \
|
||||
done; \
|
||||
mkdir -p $(DESTDIR)$(systemdsystemunitdir)/shutdown.target.wants; \
|
||||
ln -s ../dracut-shutdown.service \
|
||||
$(DESTDIR)$(systemdsystemunitdir)/shutdown.target.wants/dracut-shutdown.service; \
|
||||
fi
|
||||
$(MAKE) -C install install
|
||||
|
||||
dracut-version.sh:
|
||||
@echo "DRACUT_VERSION=$(VERSION)-$(GITVERSION)" > dracut-version.sh
|
||||
|
||||
clean:
|
||||
$(RM) *~
|
||||
@@ -56,33 +87,39 @@ clean:
|
||||
$(RM) dracut-*.rpm dracut-*.tar.bz2
|
||||
$(RM) $(manpages) dracut.html
|
||||
$(MAKE) -C test clean
|
||||
$(MAKE) -C install clean
|
||||
|
||||
archive: dracut-$(VERSION)-$(GITVERSION).tar.bz2
|
||||
|
||||
dist: dracut-$(VERSION).tar.gz
|
||||
dist: dracut-$(VERSION).tar.bz2
|
||||
|
||||
dracut-$(VERSION).tar.bz2:
|
||||
git archive --format=tar $(VERSION) --prefix=dracut-$(VERSION)/ |bzip2 > dracut-$(VERSION).tar.bz2
|
||||
|
||||
dracut-$(VERSION).tar.gz:
|
||||
git archive --format=tar $(VERSION) --prefix=dracut-$(VERSION)/ |gzip > dracut-$(VERSION).tar.gz
|
||||
dracut-$(VERSION).tar.bz2: doc
|
||||
git archive --format=tar $(VERSION) --prefix=dracut-$(VERSION)/ > dracut-$(VERSION).tar
|
||||
mkdir -p dracut-$(VERSION)
|
||||
cp $(manpages) dracut.html dracut-$(VERSION)
|
||||
tar -rf dracut-$(VERSION).tar dracut-$(VERSION)/*.[0-9] dracut-$(VERSION)/dracut.html
|
||||
rm -fr dracut-$(VERSION).tar.bz2 dracut-$(VERSION)
|
||||
bzip2 -9 dracut-$(VERSION).tar
|
||||
rm -f dracut-$(VERSION).tar
|
||||
|
||||
rpm: dracut-$(VERSION).tar.bz2
|
||||
rpmbuild=$$(mktemp -d -t rpmbuild-dracut.XXXXXX); src=$$(pwd); \
|
||||
cp dracut-$(VERSION).tar.bz2 "$$rpmbuild"; \
|
||||
$$src/git2spec.pl $(VERSION) "$$rpmbuild" < dracut.spec > $$rpmbuild/dracut.spec; \
|
||||
LANG=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" -ba dracut.spec; ) && \
|
||||
( mv "$$rpmbuild"/noarch/*.rpm .; mv "$$rpmbuild"/*.src.rpm .;rm -fr "$$rpmbuild"; ls *.rpm )
|
||||
( mv "$$rpmbuild"/$$(arch)/*.rpm .; mv "$$rpmbuild"/*.src.rpm .;rm -fr "$$rpmbuild"; ls *.rpm )
|
||||
|
||||
syncheck:
|
||||
@ret=0;for i in dracut-logger modules.d/99base/init modules.d/*/*.sh; do \
|
||||
@ret=0;for i in dracut-initramfs-restore.sh dracut-logger.sh \
|
||||
modules.d/99base/init.sh modules.d/*/*.sh; do \
|
||||
[ "$${i##*/}" = "module-setup.sh" ] && continue; \
|
||||
[ "$${i##*/}" = "caps.sh" ] && continue; \
|
||||
read line < "$$i"; [ "$${line#*bash*}" != "$$line" ] && continue; \
|
||||
dash -n "$$i" ; ret=$$(($$ret+$$?)); \
|
||||
done;exit $$ret
|
||||
@ret=0;for i in dracut modules.d/02caps/caps.sh modules.d/*/module-setup.sh; do \
|
||||
@ret=0;for i in *.sh mkinitrd-dracut.sh modules.d/*/*.sh \
|
||||
modules.d/*/module-setup.sh; do \
|
||||
bash -n "$$i" ; ret=$$(($$ret+$$?)); \
|
||||
done;exit $$ret
|
||||
|
||||
@@ -90,18 +127,18 @@ check: all syncheck
|
||||
$(MAKE) -C test check
|
||||
|
||||
testimage: all
|
||||
./dracut -l -a debug -f test-$(shell uname -r).img $(shell uname -r)
|
||||
@echo wrote test-$(shell uname -r).img
|
||||
./dracut.sh -l -a debug -f test-$(shell uname -r).img $(shell uname -r)
|
||||
@echo wrote test-$(shell uname -r).img
|
||||
|
||||
testimages: all
|
||||
./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
|
||||
./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
|
||||
|
||||
hostimage: all
|
||||
./dracut -H -l -a debug -f test-$(shell uname -r).img $(shell uname -r)
|
||||
@echo wrote test-$(shell uname -r).img
|
||||
./dracut.sh -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
|
||||
|
107
NEWS
107
NEWS
@@ -1,3 +1,110 @@
|
||||
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
|
||||
|
8
README
8
README
@@ -62,9 +62,17 @@ 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
|
||||
|
||||
|
@@ -103,6 +103,9 @@ init has the following hook points to inject scripts:
|
||||
a timeout.
|
||||
|
||||
/lib/dracut/hooks/pre-pivot/*.sh
|
||||
scripts to run before latter initramfs cleanups
|
||||
|
||||
/lib/dracut/hooks/cleanup/*.sh
|
||||
scripts to run before the real init is executed and the initramfs
|
||||
disappears
|
||||
All processes started before should be killed here.
|
||||
|
11
README.testsuite
Normal file
11
README.testsuite
Normal file
@@ -0,0 +1,11 @@
|
||||
For the testsuite to work, you will have to install at least the following software packages:
|
||||
dash
|
||||
asciidoc
|
||||
mdadm
|
||||
lvm2
|
||||
cryptsetup
|
||||
nfs-utils
|
||||
netbsd-iscsi
|
||||
nbd
|
||||
dhcp
|
||||
iscsi-initiator-utils
|
27
TODO
27
TODO
@@ -1,24 +1,37 @@
|
||||
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
|
||||
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
|
||||
|
||||
- The hard-coded list of udev rules that we care about is kind of lame.
|
||||
- fix btrfs subvolume mounting for /usr (fsck)
|
||||
- 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
|
||||
- the hard-coded list of udev rules that we care about is kind of lame.
|
||||
- automatic kexec fallback
|
||||
- panic fallback
|
||||
- fsck for $NEWROOT/usr
|
||||
|
||||
GENERATOR TODO
|
||||
|
||||
- Default module specification could use some work
|
||||
- udev rule copying, as mentioned above, is a bit too hard-coded
|
||||
- add interpreter/plugin-scripts to be sourced at the beginning or end (can use dracut-functions)
|
||||
- provide "installkernel" and "new-kernel-pkg"
|
||||
- add mechanism for module specific command line options
|
||||
- pkg-config integration, to make it easy for other packages to use us.
|
||||
- add recovery image creator (mkrecovery)
|
||||
- default module specification could use some work
|
||||
- udev rule copying, as mentioned above, is a bit too hard-coded
|
||||
|
||||
CODE TODO
|
||||
- document functions
|
||||
|
||||
- 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)
|
||||
- Bug 524727 - Dracut + encrypted root + networking
|
||||
- https://bugzilla.redhat.com/show_bug.cgi?id=524727 - Dracut + encrypted root + networking
|
||||
|
||||
|
59
dracut-catimages.8.asc
Normal file
59
dracut-catimages.8.asc
Normal file
@@ -0,0 +1,59 @@
|
||||
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)
|
||||
|
@@ -1,116 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" []>
|
||||
<!-- lifted from troff+man by doclifter -->
|
||||
<refentry id='dracutcatimages8'>
|
||||
<refmeta>
|
||||
<refentrytitle>DRACUT-CATIMAGES</refentrytitle>
|
||||
<manvolnum>8</manvolnum>
|
||||
<refmiscinfo class='source'>June 2009</refmiscinfo>
|
||||
<refmiscinfo class='manual'>Linux</refmiscinfo>
|
||||
</refmeta>
|
||||
<refnamediv id='name'>
|
||||
<refname>dracut-catimages</refname>
|
||||
<refpurpose>creates initial ramdisk image by concatenating images</refpurpose>
|
||||
</refnamediv>
|
||||
<!-- body begins here -->
|
||||
<refsynopsisdiv id='synopsis'>
|
||||
<cmdsynopsis>
|
||||
<command>dracut-catimages</command> <arg choice='opt' rep='repeat'><replaceable>OPTION</replaceable></arg>
|
||||
<arg choice='plain'><replaceable><initramfs</replaceable></arg>
|
||||
<arg choice='plain'><replaceable>base</replaceable></arg>
|
||||
<arg choice='plain'><replaceable>image></replaceable></arg>
|
||||
<arg choice='opt' rep='repeat'><replaceable><image></replaceable></arg>
|
||||
<sbr/>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
|
||||
<refsect1 id='description'><title>DESCRIPTION</title>
|
||||
<para><command>dracut-catimages</command>
|
||||
creates an initial ramdisk image by concatenating several images from the command
|
||||
line and /boot/dracut/*.img</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id='options'><title>OPTIONS</title>
|
||||
<variablelist remap='TP'>
|
||||
<varlistentry>
|
||||
<term><option>-f</option>, <option>--force</option></term>
|
||||
<listitem>
|
||||
<para>overwrite existing initramfs file.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>-i</option>, <option>--imagedir</option></term>
|
||||
<listitem>
|
||||
<para>Directory with additional images to add (default: /boot/dracut/)</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>-o</option>, <option>--overlaydir</option></term>
|
||||
<listitem>
|
||||
<para>Overlay directory, which contains additional files that will be used to create an additional image</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>--nooverlay</option></term>
|
||||
<listitem>
|
||||
<para>Do not use the overlay directory</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>--noimagedir</option></term>
|
||||
<listitem>
|
||||
<para>Do not use the additional image directory</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>-h</option>, <option>--help</option></term>
|
||||
<listitem>
|
||||
<para>display help text and exit.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>--debug</option></term>
|
||||
<listitem>
|
||||
<para>output debug information of the build process</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>-v</option>, <option>--verbose</option></term>
|
||||
<listitem>
|
||||
<para>verbose output during the build process</para>
|
||||
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id='files'><title>FILES</title>
|
||||
<variablelist remap='TP'>
|
||||
<varlistentry>
|
||||
<term><filename>/boot/dracut/*.img</filename></term>
|
||||
<listitem>
|
||||
<para></para> <!-- FIXME: blank list item -->
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id='authors'><title>AUTHORS</title>
|
||||
<literallayout remap='.nf'>
|
||||
Harald Hoyer <harald@redhat.com>
|
||||
</literallayout> <!-- .fi -->
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id='availability'><title>AVAILABILITY</title>
|
||||
<para>The dracut-catimages command is part of the dracut package and is available from
|
||||
<ulink url='https://dracut.wiki.kernel.org'>https://dracut.wiki.kernel.org</ulink></para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id='see_also'><title>SEE ALSO</title>
|
||||
<para><citerefentry><refentrytitle>dracut</refentrytitle><manvolnum>8</manvolnum></citerefentry></para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
1103
dracut-functions
1103
dracut-functions
File diff suppressed because it is too large
Load Diff
1366
dracut-functions.sh
Executable file
1366
dracut-functions.sh
Executable file
File diff suppressed because it is too large
Load Diff
@@ -1,716 +0,0 @@
|
||||
#!/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 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 --quiet --show-depends $1 | 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/,_rnetdev//' -e 's/_rnetdev//' -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
|
@@ -1,46 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" []>
|
||||
<!-- lifted from troff+man by doclifter -->
|
||||
<refentry id='dracutgencmdline8'>
|
||||
<refmeta>
|
||||
<refentrytitle>DRACUT-GENCMDLINE</refentrytitle>
|
||||
<manvolnum>8</manvolnum>
|
||||
<refmiscinfo class='source'>June 2009</refmiscinfo>
|
||||
<refmiscinfo class='manual'>Linux</refmiscinfo>
|
||||
</refmeta>
|
||||
<refnamediv id='name'>
|
||||
<refname>dracut-gencmdline</refname>
|
||||
<refpurpose>generates kernel command line parameters for the dracut generated initramfs</refpurpose>
|
||||
</refnamediv>
|
||||
<!-- body begins here -->
|
||||
<refsynopsisdiv id='synopsis'>
|
||||
<cmdsynopsis>
|
||||
<command>dracut-gencmdline</command>
|
||||
<sbr/>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
|
||||
<refsect1 id='description'><title>DESCRIPTION</title>
|
||||
<para><command>dracut-gencmdline</command>
|
||||
generates kernel command line parameters for the dracut generated initramfs, which are very specific to the host system.</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id='authors'><title>AUTHORS</title>
|
||||
<literallayout remap='.nf'>
|
||||
Harald Hoyer <harald@redhat.com>
|
||||
</literallayout> <!-- .fi -->
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id='availability'><title>AVAILABILITY</title>
|
||||
<para>The dracut-gencmdline command is part of the dracut package and is available from
|
||||
<ulink url='https://dracut.wiki.kernel.org'>https://dracut.wiki.kernel.org</ulink></para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 id='see_also'><title>SEE ALSO</title>
|
||||
<para><citerefentry><refentrytitle>dracut</refentrytitle><manvolnum>8</manvolnum></citerefentry></para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
19
dracut-initramfs-restore.sh
Normal file
19
dracut-initramfs-restore.sh
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
set -e
|
||||
cd /run/initramfs
|
||||
IMG="/boot/initramfs-$(uname -r).img"
|
||||
[ -f .need_shutdown -a -f "$IMG" ] || exit 1
|
||||
if zcat "$IMG" | cpio -id >/dev/null 2>&1; then
|
||||
rm .need_shutdown
|
||||
elif xzcat "$IMG" | cpio -id >/dev/null 2>&1; then
|
||||
rm .need_shutdown
|
||||
else
|
||||
# something failed, so we clean up
|
||||
rm -f /run/initramfs/shutdown
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
@@ -116,7 +116,7 @@ dlog_init() {
|
||||
|
||||
if [ -z "$fileloglvl" ]; then
|
||||
[ -w "$logfile" ] && fileloglvl=4 || fileloglvl=0
|
||||
elif [ $fileloglvl -gt 0 ]; then
|
||||
elif (( $fileloglvl >= 0 )); then
|
||||
__oldumask=$(umask)
|
||||
umask 0377
|
||||
! [ -e "$logfile" ] && >"$logfile"
|
||||
@@ -138,7 +138,7 @@ dlog_init() {
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $sysloglvl -gt 0 ]; then
|
||||
if (( $sysloglvl >= 0 )); then
|
||||
if ! [ -S /dev/log -a -w /dev/log ] || ! command -v logger >/dev/null
|
||||
then
|
||||
# We cannot log to syslog, so turn this facility off.
|
||||
@@ -148,7 +148,7 @@ dlog_init() {
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $sysloglvl -gt 0 -o $kmsgloglvl -gt 0 ]; then
|
||||
if (($sysloglvl >= 0)) || (($kmsgloglvl >= 0 )); then
|
||||
if [ -n "$dracutbasedir" ]; then
|
||||
readonly syslogfacility=user
|
||||
else
|
||||
@@ -159,11 +159,44 @@ dlog_init() {
|
||||
|
||||
local lvl; local maxloglvl_l=0
|
||||
for lvl in $stdloglvl $sysloglvl $fileloglvl $kmsgloglvl; do
|
||||
[ $lvl -gt $maxloglvl_l ] && maxloglvl_l=$lvl
|
||||
(( $lvl > $maxloglvl_l )) && maxloglvl_l=$lvl
|
||||
done
|
||||
readonly maxloglvl=$maxloglvl_l
|
||||
export maxloglvl
|
||||
|
||||
|
||||
if (($stdloglvl < 6)) && (($kmsgloglvl < 6)) && (($fileloglvl < 6)); then
|
||||
unset dtrace
|
||||
dtrace() { :; };
|
||||
fi
|
||||
|
||||
if (($stdloglvl < 5)) && (($kmsgloglvl < 5)) && (($fileloglvl < 5)); then
|
||||
unset ddebug
|
||||
ddebug() { :; };
|
||||
fi
|
||||
|
||||
if (($stdloglvl < 4)) && (($kmsgloglvl < 4)) && (($fileloglvl < 4)); then
|
||||
unset dinfo
|
||||
dinfo() { :; };
|
||||
fi
|
||||
|
||||
if (($stdloglvl < 3)) && (($kmsgloglvl < 3)) && (($fileloglvl < 3)); then
|
||||
unset dwarn
|
||||
dwarn() { :; };
|
||||
unset dwarning
|
||||
dwarning() { :; };
|
||||
fi
|
||||
|
||||
if (($stdloglvl < 2)) && (($kmsgloglvl < 2)) && (($fileloglvl < 2)); then
|
||||
unset derror
|
||||
derror() { :; };
|
||||
fi
|
||||
|
||||
if (($stdloglvl < 1)) && (($kmsgloglvl < 1)) && (($fileloglvl < 1)); then
|
||||
unset dfatal
|
||||
dfatal() { :; };
|
||||
fi
|
||||
|
||||
[ -n "$errmsg" ] && derror "$errmsg"
|
||||
|
||||
return $ret
|
||||
@@ -275,14 +308,14 @@ _do_dlog() {
|
||||
local lvlc=$(_lvl2char "$lvl") || return 0
|
||||
local msg="$lvlc: $*"
|
||||
|
||||
[ $lvl -le $stdloglvl ] && echo "$msg" >&2
|
||||
if [ $lvl -le $sysloglvl ]; then
|
||||
(( $lvl <= $stdloglvl )) && echo "$msg" >&2
|
||||
if (( $lvl <= $sysloglvl )); then
|
||||
logger -t "dracut[$$]" -p $(_lvl2syspri $lvl) "$msg"
|
||||
fi
|
||||
if [ $lvl -le $fileloglvl -a -w "$logfile" -a -f "$logfile" ]; then
|
||||
if (( $lvl <= $fileloglvl )) && [[ -w "$logfile" ]] && [[ -f "$logfile" ]]; then
|
||||
echo "$msg" >>"$logfile"
|
||||
fi
|
||||
[ $lvl -le $kmsgloglvl ] && \
|
||||
(( $lvl <= $kmsgloglvl )) && \
|
||||
echo "<$(_dlvl2syslvl $lvl)>dracut[$$] $msg" >/dev/kmsg
|
||||
}
|
||||
|
||||
@@ -304,9 +337,9 @@ _do_dlog() {
|
||||
# echo "This is a warning" | dwarn
|
||||
dlog() {
|
||||
[ -z "$maxloglvl" ] && return 0
|
||||
[ $1 -le $maxloglvl ] || return 0
|
||||
(( $1 <= $maxloglvl )) || return 0
|
||||
|
||||
if [ $# -gt 1 ]; then
|
||||
if (( $# > 1 )); then
|
||||
_do_dlog "$@"
|
||||
else
|
||||
while read line; do
|
19
dracut-shutdown.service
Normal file
19
dracut-shutdown.service
Normal file
@@ -0,0 +1,19 @@
|
||||
# This file is part of systemd.
|
||||
#
|
||||
# systemd 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.
|
||||
|
||||
[Unit]
|
||||
Description=Restore /run/initramfs
|
||||
After=getty@tty1.service prefdm.service
|
||||
Before=reboot.service shutdown.target
|
||||
DefaultDependencies=no
|
||||
ConditionPathExists=/run/initramfs/.need_shutdown
|
||||
ConditionPathExists=!/run/initramfs/bin/sh
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/lib/dracut/dracut-initramfs-restore
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
387
dracut.8.asc
Normal file
387
dracut.8.asc
Normal file
@@ -0,0 +1,387 @@
|
||||
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
|
||||
-----------
|
||||
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)
|
||||
|
||||
OPTIONS
|
||||
-------
|
||||
**-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" ...
|
||||
----
|
||||
===============================
|
||||
|
||||
**--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-only**::
|
||||
only install kernel drivers and firmware files
|
||||
|
||||
**--no-kernel**::
|
||||
do not install kernel drivers and firmware files
|
||||
|
||||
**--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
|
||||
|
||||
**--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.
|
||||
|
||||
**-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_.
|
||||
====
|
||||
|
||||
**--no-hostonly**::
|
||||
Disable Host-Only mode
|
||||
|
||||
**--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>_"::
|
||||
Mount _<device>_ on _<mountpoint>_ with _<filesystem type>_ and _<filesystem
|
||||
options>_ in the initramfs
|
||||
|
||||
**-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" ...
|
||||
----
|
||||
===============================
|
||||
|
||||
**--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 "--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 "--compress=xz --check=crc32
|
||||
--lzma2=dict=1MiB"
|
||||
====
|
||||
|
||||
**--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.
|
||||
|
||||
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
|
||||
|
||||
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.
|
||||
|
||||
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*::
|
||||
Project Leader and Developer
|
||||
|
||||
*Victor Lowther*::
|
||||
Developer
|
||||
|
||||
*Philippe Seewer*::
|
||||
Developer
|
||||
|
||||
*Warren Togami*::
|
||||
Developer
|
||||
|
||||
*Amadeusz Żołnowski*::
|
||||
Developer
|
||||
|
||||
*Jeremy Katz*::
|
||||
Developer
|
||||
|
||||
*David Dillow*::
|
||||
Developer
|
||||
|
||||
*Will Woods*::
|
||||
Developer
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
*dracut.cmdline*(7) *dracut.conf*(5)
|
670
dracut.8.xml
670
dracut.8.xml
@@ -1,670 +0,0 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!-- This document was created with Syntext Serna Free. --><!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" []>
|
||||
<!-- vim: set ts=8 sts=2 sw=2 et: -->
|
||||
<refentry id="dracut8">
|
||||
<refentryinfo>
|
||||
<title>dracut</title>
|
||||
<productname>dracut</productname>
|
||||
<authorgroup>
|
||||
<author>
|
||||
<contrib>Project Leader, Developer</contrib>
|
||||
<firstname>Harald</firstname>
|
||||
<surname>Hoyer</surname>
|
||||
<email>harald@redhat.com</email>
|
||||
</author>
|
||||
<author>
|
||||
<contrib>Developer</contrib>
|
||||
<firstname>Victor</firstname>
|
||||
<surname>Lowther</surname>
|
||||
<email>victor.lowther@gmail.com</email>
|
||||
</author>
|
||||
<author>
|
||||
<contrib>Developer</contrib>
|
||||
<firstname>Philippe</firstname>
|
||||
<surname>Seewer</surname>
|
||||
<email>philippe.seewer@bfh.ch</email>
|
||||
</author>
|
||||
<author>
|
||||
<contrib>Developer</contrib>
|
||||
<firstname>Warren</firstname>
|
||||
<surname>Togami</surname>
|
||||
</author>
|
||||
<author>
|
||||
<contrib>Developer</contrib>
|
||||
<firstname>Amadeusz</firstname>
|
||||
<surname>Żołnowski</surname>
|
||||
<email>aidecoe@aidecoe.name</email>
|
||||
</author>
|
||||
<author>
|
||||
<contrib>Developer</contrib>
|
||||
<firstname>Jeremy</firstname>
|
||||
<surname>Katz</surname>
|
||||
</author>
|
||||
<author>
|
||||
<contrib>Developer</contrib>
|
||||
<firstname>David</firstname>
|
||||
<surname>Dillow</surname>
|
||||
<email>dave@thedillows.org</email>
|
||||
</author>
|
||||
</authorgroup>
|
||||
</refentryinfo>
|
||||
<refmeta>
|
||||
<refentrytitle>dracut</refentrytitle>
|
||||
<manvolnum>8</manvolnum>
|
||||
<refmiscinfo class="version"/>
|
||||
</refmeta>
|
||||
<refnamediv>
|
||||
<refname>dracut</refname>
|
||||
<refpurpose>create initial ramdisk images for preloading modules</refpurpose>
|
||||
</refnamediv>
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>dracut</command>
|
||||
<arg choice="opt" rep="repeat">
|
||||
<replaceable>OPTION</replaceable>
|
||||
</arg>
|
||||
<arg choice="opt">
|
||||
<replaceable><image></replaceable>
|
||||
<arg choice="opt">
|
||||
<replaceable><kernel-version></replaceable>
|
||||
</arg>
|
||||
</arg>
|
||||
<sbr/>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<para><command>dracut</command>
|
||||
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.</para>
|
||||
<para>
|
||||
For a complete list of kernel command line options see
|
||||
<citerefentry>
|
||||
<refentrytitle>dracut.cmdline</refentrytitle>
|
||||
<manvolnum>7</manvolnum>
|
||||
</citerefentry>
|
||||
</para>
|
||||
<refsect2>
|
||||
<title>Options</title>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>-f</option>
|
||||
</term>
|
||||
<term>
|
||||
<option>--force</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>overwrite existing initramfs file.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>-m</option>
|
||||
</term>
|
||||
<term>
|
||||
<option>--modules <replaceable><list of dracut modules></replaceable></option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>specify a space-separated list of dracut modules to call
|
||||
when building the initramfs.
|
||||
Modules are located in
|
||||
<filename>/usr/lib/dracut/modules.d</filename>. This parameter can be specified multiple times.</para>
|
||||
<para>
|
||||
If [LIST] has multiple arguments, then you have to put these in quotes.
|
||||
For example:
|
||||
<screen># dracut --modules "module1 module2" ...</screen>
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>-o</option>
|
||||
</term>
|
||||
<term>
|
||||
<option>--omit <replaceable><list of dracut modules></replaceable></option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>omit a space-separated list of dracut modules. This parameter can be specified multiple times.</para>
|
||||
<para>
|
||||
If [LIST] has multiple arguments, then you have to put these in quotes.
|
||||
For example:
|
||||
<screen># dracut --omit "module1 module2" ...</screen>
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>-a</option>
|
||||
</term>
|
||||
<term>
|
||||
<option>--add <replaceable><list of dracut modules></replaceable></option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>add a space-separated list of dracut modules to the default set of modules. This parameter can be specified multiple times.</para>
|
||||
<para>
|
||||
If [LIST] has multiple arguments, then you have to put these in quotes.
|
||||
For example:
|
||||
<screen># dracut --add "module1 module2" ...</screen>
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--force-add <replaceable><list of dracut modules></replaceable></option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>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.</para>
|
||||
<para>
|
||||
If [LIST] has multiple arguments, then you have to put these in quotes.
|
||||
For example:
|
||||
<screen># dracut --force-add "module1 module2" ...</screen>
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>-d</option>
|
||||
</term>
|
||||
<term>
|
||||
<option>--drivers <replaceable><list of kernel modules></replaceable></option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>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.</para>
|
||||
<para>
|
||||
If [LIST] has multiple arguments, then you have to put these in quotes.
|
||||
For example:
|
||||
<screen># dracut --drivers "kmodule1 kmodule2" ...</screen>
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--add-drivers <replaceable><list of kernel modules></replaceable></option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>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.</para>
|
||||
<para>
|
||||
If [LIST] has multiple arguments, then you have to put these in quotes.
|
||||
For example:
|
||||
<screen># dracut --add-drivers "kmodule1 kmodule2" ...</screen>
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--filesystems <replaceable><list of filesystems></replaceable></option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>specify a space-separated list of kernel filesystem modules to exclusively
|
||||
include in the generic initramfs. This parameter can be specified multiple times.</para>
|
||||
<para>
|
||||
If [LIST] has multiple arguments, then you have to put these in quotes.
|
||||
For example:
|
||||
<screen># dracut --filesystems "filesystem1 filesystem2" ...</screen>
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>-k</option>
|
||||
</term>
|
||||
<term>
|
||||
<option>--kmoddir <replaceable><kernel directory></replaceable></option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>specify the directory, where to look for kernel modules</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option> --fwdir <replaceable><dir>[:<dir>...]</replaceable></option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>specify additional directories, where to look for firmwares. This parameter can be specified multiple times.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--kernel-only</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>only install kernel drivers and firmware files</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--no-kernel</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>do not install kernel drivers and firmware files</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--mdadmconf</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>include local <filename>/etc/mdadm.conf</filename></para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--nomdadmconf</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>do not include local <filename>/etc/mdadm.conf</filename></para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--lvmconf</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>include local <filename>/etc/lvm/lvm.conf</filename></para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--nolvmconf</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>do not include local <filename>/etc/lvm/lvm.conf</filename></para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--fscks [LIST]</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>add a space-separated list of fsck tools, in addition to
|
||||
<filename>dracut.conf</filename>'s specification; the
|
||||
installation is opportunistic (non-existing tools are ignored)
|
||||
</para>
|
||||
<para>
|
||||
If [LIST] has multiple arguments, then you have to put these in quotes.
|
||||
For example:
|
||||
<screen># dracut --fscks "fsck.foo barfsck" ...</screen>
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--nofscks</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>inhibit installation of any fsck tools</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--strip</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>strip binaries in the initramfs (default)</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--nostrip</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>do not strip binaries in the initramfs</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--prefix <replaceable><dir></replaceable></option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>prefix initramfs files with the specified directory</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--noprefix</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>do not prefix initramfs files (default)</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--ctty</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>if possible, try to spawn an emergency shell on a terminal
|
||||
with job control</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>-h</option>
|
||||
</term>
|
||||
<term>
|
||||
<option>--help</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>display help text and exit.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--debug</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>output debug information of the build process</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>-v</option>
|
||||
</term>
|
||||
<term>
|
||||
<option>--verbose</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>increase verbosity level (default is info(4))</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>-q</option>
|
||||
</term>
|
||||
<term>
|
||||
<option>--quiet</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>decrease verbosity level (default is info(4))</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>-c</option>
|
||||
</term>
|
||||
<term>
|
||||
<option>--conf <replaceable><dracut configuration file></replaceable></option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>specify configuration file to use.
|
||||
Default:
|
||||
<filename>/etc/dracut.conf</filename></para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--confdir <replaceable><configuration directory></replaceable></option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>specify configuration directory to use.
|
||||
Default:
|
||||
<filename>/etc/dracut.conf.d</filename></para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--sshkey <replaceable><sshkey file></replaceable></option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>ssh key file used with ssh-client module.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>-l</option>
|
||||
</term>
|
||||
<term>
|
||||
<option>--local</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>activates the local mode. dracut will use modules from the current working
|
||||
directory instead of the system-wide installed modules in
|
||||
<filename>/usr/lib/dracut/modules.d</filename>.
|
||||
This is useful when running dracut from a git checkout.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>-H</option>
|
||||
</term>
|
||||
<term>
|
||||
<option>--hostonly</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Host-Only mode: Install only what is needed for booting
|
||||
the local host instead of a generic host.
|
||||
<warning>
|
||||
<para>If chrooted to another root other than the real root device, use "--fstab" and provide a valid <filename>/etc/fstab</filename>.</para>
|
||||
</warning></para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--fstab</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Use <filename>/etc/fstab</filename> instead of <filename>/proc/self/mountinfo</filename>.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--add_fstab <replaceable><filename></replaceable> </option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Add entries of <replaceable><filename></replaceable> to the initramfs /etc/fstab.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--mount "<replaceable><device></replaceable> <replaceable><mountpoint></replaceable> <replaceable><filesystem type></replaceable> <replaceable><filesystem options></replaceable>"</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Add entries of <replaceable><filename></replaceable> to the initramfs /etc/fstab.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>-i</option>
|
||||
</term>
|
||||
<term>
|
||||
<option>--include <replaceable><SOURCE></replaceable> <replaceable><TARGET></replaceable></option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>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.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>-I</option>
|
||||
</term>
|
||||
<term>
|
||||
<option>--install <replaceable><file list></replaceable></option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>install the space separated list of files into the initramfs.</para>
|
||||
<para>
|
||||
If [LIST] has multiple arguments, then you have to put these in quotes.
|
||||
For example:
|
||||
<screen># dracut --install "/bin/foo /sbin/bar" ...</screen>
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--gzip</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>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"</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--bzip2</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Compress the generated initramfs using bzip2.
|
||||
<warning>
|
||||
<para>Make sure your kernel has bzip2 decompression support compiled in, otherwise you will not be able to boot. Equivalent to "--compress=bzip2"</para>
|
||||
</warning></para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--lzma</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Compress the generated initramfs using lzma.
|
||||
<warning>
|
||||
<para>Make sure your kernel has lzma decompression support compiled in, otherwise you will not be able to boot. Equivalent to "--compress=lzma -9"</para>
|
||||
</warning></para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--xz</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Compress the generated initramfs using xz.
|
||||
<warning>
|
||||
<para>Make sure your kernel has xz decompression support compiled in, otherwise you will not be able to boot. Equivalent to "--compress=xz --check=crc32 --lzma2=dict=1MiB"</para>
|
||||
</warning></para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--compress <replaceable><compressor></replaceable></option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>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.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--no-compress</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Do not compress the generated initramfs. This will override any other compression options.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--list-modules</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>List all available dracut modules.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>-M</option>
|
||||
</term>
|
||||
<term>
|
||||
<option>--show-modules</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Print included module's name to standard output during build.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--keep</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Keep the initramfs temporary directory for debugging purposes.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect2>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>Files</title>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<filename>/var/log/dracut.log</filename>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>logfile of initramfs image creation</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<filename>/tmp/dracut.log</filename>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>logfile of initramfs image creation, if <filename>/var/log/dracut.log</filename> is not writable</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<filename>/etc/dracut.conf</filename>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>see <citerefentry>
|
||||
<refentrytitle>dracut.conf</refentrytitle>
|
||||
<manvolnum>5</manvolnum>
|
||||
</citerefentry></para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<filename>/etc/dracut.conf.d/*.conf</filename>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>see <citerefentry>
|
||||
<refentrytitle>dracut.conf</refentrytitle>
|
||||
<manvolnum>5</manvolnum>
|
||||
</citerefentry></para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
<refsect2>
|
||||
<title>Configuration in the Initramfs</title>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<filename>/etc/conf.d/</filename>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Any files found in <filename>/etc/conf.d/</filename> will be sourced in the initramfs to
|
||||
set initial values. Command line options will override these values
|
||||
set in the configuration files.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<filename>/etc/cmdline</filename>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Can contain additional command line options.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect2>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>Availability</title>
|
||||
<para>The dracut command is part of the dracut package and is available from
|
||||
<ulink url='https://dracut.wiki.kernel.org'>https://dracut.wiki.kernel.org</ulink></para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>See Also</title>
|
||||
<para>
|
||||
<citerefentry>
|
||||
<refentrytitle>dracut.cmdline</refentrytitle>
|
||||
<manvolnum>7</manvolnum>
|
||||
</citerefentry>
|
||||
<citerefentry>
|
||||
<refentrytitle>dracut.conf</refentrytitle>
|
||||
<manvolnum>5</manvolnum>
|
||||
</citerefentry>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
1033
dracut.asc
Normal file
1033
dracut.asc
Normal file
File diff suppressed because it is too large
Load Diff
649
dracut.cmdline.7.asc
Normal file
649
dracut.cmdline.7.asc
Normal file
@@ -0,0 +1,649 @@
|
||||
DRACUT.CMDLINE(7)
|
||||
=================
|
||||
:doctype: manpage
|
||||
:man source: dracut
|
||||
:man manual: dracut
|
||||
|
||||
NAME
|
||||
----
|
||||
dracut.cmdline - dracut kernel command line options
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
The root device used by the kernel is specified in the boot configuration
|
||||
file on the kernel command line, as always.
|
||||
|
||||
The traditional _root=/dev/sda1_ style device specification is allowed, but not
|
||||
encouraged. The root device should better be identified by LABEL or UUID. If a
|
||||
label is used, as in _root=LABEL=<label_of_root>_ the initramfs will search all
|
||||
available devices for a filesystem with the appropriate label, and mount that
|
||||
device as the root filesystem. _root=UUID=<uuidnumber>_ will mount the partition
|
||||
with that UUID as the root filesystem.
|
||||
|
||||
In the following all kernel command line parameters, which are processed by
|
||||
dracut, are described.
|
||||
|
||||
"rd.*" parameters mentioned without "=" are boolean parameters. They can be
|
||||
turned on/off by setting them to {0|1}. If the assignment with "=" is missing
|
||||
"=1" is implied. For example _rd.info_ can be turned off with _rd.info=0_ or
|
||||
turned on with _rd.info=1_ or _rd.info_. The last value in the kernel command
|
||||
line is the value, which is honored.
|
||||
|
||||
Standard
|
||||
~~~~~~~~
|
||||
**init=**_<path to real init>_::
|
||||
specify the path to the init programm to be started after the initramfs has
|
||||
finished
|
||||
|
||||
**root=**_<path to blockdevice>_::
|
||||
specify the block device to use as the root filesystem.
|
||||
+
|
||||
E.g.:
|
||||
+
|
||||
----
|
||||
root=/dev/sda1
|
||||
root=/dev/disk/by-path/pci-0000:00:1f.1-scsi-0:0:1:0-part1
|
||||
root=/dev/disk/by-label/Root
|
||||
root=LABEL=Root
|
||||
root=/dev/disk/by-uuid/3f5ad593-4546-4a94-a374-bcfb68aa11f7
|
||||
root=UUID=3f5ad593-4546-4a94-a374-bcfb68aa11f7
|
||||
root=PARTUUID=3f5ad593-4546-4a94-a374-bcfb68aa11f7
|
||||
----
|
||||
|
||||
**rootfstype=**_<filesystem type>_:: "auto" if not specified, e.g.:
|
||||
+
|
||||
----
|
||||
rootfstype=ext3
|
||||
----
|
||||
|
||||
**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.
|
||||
|
||||
**rd.fstab=0**::
|
||||
do not honor special mount options for the root filesystem found in
|
||||
_/etc/fstab_ of the real root.
|
||||
|
||||
**resume=**_<path to resume partition>_
|
||||
+
|
||||
E.g.:
|
||||
+
|
||||
----
|
||||
resume=/dev/disk/by-path/pci-0000:00:1f.1-scsi-0:0:1:0-part1
|
||||
resume=/dev/disk/by-uuid/3f5ad593-4546-4a94-a374-bcfb68aa11f7
|
||||
resume=UUID=3f5ad593-4546-4a94-a374-bcfb68aa11f7
|
||||
----
|
||||
|
||||
|
||||
Misc
|
||||
~~~~
|
||||
**rd.driver.blacklist=**_<drivername>[,<drivername>,...]_::
|
||||
do not load kernel module <drivername>. This parameter can be specified
|
||||
multiple times.
|
||||
|
||||
**rd.driver.pre=**_<drivername>[,<drivername>,...]_::
|
||||
force loading kernel module <drivername>. This parameter can be specified
|
||||
multiple times.
|
||||
|
||||
**rd.driver.post=**_<drivername>[,<drivername>,...]_::
|
||||
force loading kernel module <drivername> after all automatic loading modules
|
||||
have been loaded. This parameter can be specified multiple times.
|
||||
|
||||
[[dracutkerneldebug]]
|
||||
Debug
|
||||
~~~~~
|
||||
**rd.info**::
|
||||
print informational output though "quiet" is set
|
||||
|
||||
**rd.shell**::
|
||||
allow dropping to a shell, if root mounting fails
|
||||
|
||||
**rd.debug**::
|
||||
set -x for the dracut shell and logs to dmesg, console and
|
||||
_/run/initramfs/init.log_
|
||||
|
||||
**rd.break**::
|
||||
drop to a shell at the end
|
||||
|
||||
**rd.break=**_{cmdline|pre-udev|pre-trigger|initqueue|pre-mount|mount|pre-pivot|cleanup}_::
|
||||
drop to a shell on defined breakpoint
|
||||
|
||||
**rd.udev.info**::
|
||||
set udev to loglevel info
|
||||
|
||||
**rd.udev.debug**::
|
||||
set udev to loglevel debug
|
||||
|
||||
I18N
|
||||
~~~~
|
||||
**vconsole.keymap=**_<keymap base file name>_::
|
||||
keyboard translation table loaded by loadkeys; taken from keymaps directory;
|
||||
will be written as KEYMAP to _/etc/vconsole.conf_ in the initramfs, e.g.:
|
||||
+
|
||||
----
|
||||
vconsole.keymap=de-latin1-nodeadkeys
|
||||
----
|
||||
|
||||
**vconsole.keymap.ext=**_<list of keymap base file names>_::
|
||||
list of extra keymaps to bo loaded (sep. by space); will be written as
|
||||
EXT_KEYMAP to _/etc/vconsole.conf_ in the initramfs
|
||||
|
||||
**vconsole.unicode**[=_{0|1}_]::
|
||||
boolean, indicating UTF-8 mode; will be written as UNICODE to
|
||||
_/etc/vconsole.conf_ in the initramfs
|
||||
|
||||
**vconsole.font=**_<font base file name>_::
|
||||
console font; taken from consolefonts directory; will be written as FONT to
|
||||
_/etc/vconsole.conf_ in the initramfs; e.g.:
|
||||
+
|
||||
----
|
||||
vconsole.font=LatArCyrHeb-16
|
||||
----
|
||||
|
||||
**vconsole.font.map=**_<console map base file name>_::
|
||||
see description of '-m' parameter in setfont manual; taken from consoletrans
|
||||
directory; will be written as FONT_MAP to _/etc/vconsole.conf_ in the
|
||||
initramfs
|
||||
|
||||
**vconsole.font.unimap=**_<unicode table base file name>_::
|
||||
see description of '-u' parameter in setfont manual; taken from unimaps
|
||||
directory; will be written as FONT_UNIMAP to _/etc/vconsole.conf_ in the
|
||||
initramfs
|
||||
|
||||
**locale.LANG=**_<locale>_::
|
||||
taken from the environment; if no UNICODE is defined we set its value in
|
||||
basis of LANG value (whether it ends with ".utf8" (or similar) or not); will
|
||||
be written as LANG to _/etc/locale.conf_ in the initramfs; e.g.:
|
||||
+
|
||||
----
|
||||
locale.LANG=pl_PL.utf8
|
||||
----
|
||||
|
||||
**locale.LC_ALL=**_<locale>_::
|
||||
taken from the environment; will be written as LC_ALL to _/etc/locale.conf_
|
||||
in the initramfs
|
||||
|
||||
LVM
|
||||
~~~
|
||||
**rd.lvm=0**::
|
||||
disable LVM detection
|
||||
|
||||
**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.
|
||||
|
||||
**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.
|
||||
|
||||
**rd.lvm.conf=0**::
|
||||
remove any _/etc/lvm/lvm.conf_, which may exist in the initramfs
|
||||
|
||||
crypto LUKS
|
||||
~~~~~~~~~~~
|
||||
**rd.luks=0**::
|
||||
disable crypto LUKS detection
|
||||
|
||||
**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.
|
||||
|
||||
**rd.luks.allow-discards=**_<luks uuid>_::
|
||||
Allow using of discards (TRIM) requests for 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.
|
||||
|
||||
**rd.luks.allow-discards::
|
||||
Allow using of discards (TRIM) requests on all LUKS partitions.
|
||||
|
||||
**rd.luks.crypttab=0**::
|
||||
do not check, if LUKS partition is in _/etc/crypttab_
|
||||
|
||||
crypto LUKS - key on removable device support
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
**rd.luks.key=**_<keypath>:<keydev>:<luksdev>_::
|
||||
_keypath_ is a path to key file to look for. It's REQUIRED. When _keypath_ ends with '.gpg' it's considered to be key encrypted symmetrically with GPG. You will be prompted for password on boot. GPG support comes with 'crypt-gpg' module which needs to be added explicitly.
|
||||
+
|
||||
_keydev_ is a device on which key file resides. It might be kernel name of devices (should start with "/dev/"), UUID (prefixed with "UUID=") or label (prefix with "LABEL="). You don't have to specify full UUID. Just its beginning will suffice, even if its ambiguous. All matching devices will be probed. This parameter is recommended, but not required. If not present, all block devices will be probed, which may significantly increase boot time.
|
||||
+
|
||||
If _luksdev_ is given, the specified key will only be applied for that LUKS device. Possible values are the same as for _keydev_. Unless you have several LUKS devices, you don't have to specify this parameter. The simplest usage is:
|
||||
+
|
||||
----
|
||||
rd.luks.key=/foo/bar.key
|
||||
----
|
||||
+
|
||||
As you see, you can skip colons in such a case.
|
||||
|
||||
MD RAID
|
||||
~~~~~~~
|
||||
**rd.md=0**::
|
||||
disable MD RAID detection
|
||||
|
||||
**rd.md.imsm=0**::
|
||||
disable MD RAID for imsm/isw raids, use DM RAID instead
|
||||
|
||||
**rd.md.ddf=0**::
|
||||
disable MD RAID for SNIA ddf raids, use DM RAID instead
|
||||
|
||||
**rd.md.conf=0**::
|
||||
ignore mdadm.conf included in initramfs
|
||||
|
||||
**rd.md.waitclean=1**::
|
||||
wait for any resync, recovery, or reshape activity to finish before continuing
|
||||
|
||||
**rd.md.uuid=**_<md raid uuid>_::
|
||||
only activate the raid sets with the given UUID. This parameter can be
|
||||
specified multiple times.
|
||||
|
||||
DM RAID
|
||||
~~~~~~~
|
||||
**rd.dm=0**::
|
||||
disable DM RAID detection
|
||||
|
||||
**rd.dm.uuid=**_<dm raid uuid>_::
|
||||
only activate the raid sets with the given UUID. This parameter can be
|
||||
specified multiple times.
|
||||
|
||||
FIPS
|
||||
~~~~
|
||||
**rd.fips**::
|
||||
enable FIPS
|
||||
|
||||
**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>
|
||||
----
|
||||
|
||||
**rd.fips.skipkernel**::
|
||||
skip checksum check of the kernel image. Useful, if the kernel image is not
|
||||
in a separate boot partition.
|
||||
|
||||
Network
|
||||
~~~~~~~
|
||||
**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.
|
||||
|
||||
auto6::: IPv6 autoconfiguration
|
||||
|
||||
dhcp6::: IPv6 DHCP
|
||||
|
||||
ibft::: iBFT autoconfiguration
|
||||
|
||||
**ip=**_<interface>_:_{dhcp|on|any|dhcp6|auto6}_[:[_<mtu>_][:_<macaddr>_]]::
|
||||
This parameter can be specified multiple times.
|
||||
+
|
||||
dhcp|on|any|dhcp6::: get ip from dhcp server on a specific interface
|
||||
auto6::: do IPv6 autoconfiguration
|
||||
<macaddr>::: optionally set <macaddr> on the <interface>
|
||||
|
||||
**ip=**_<client-IP>_:_<server-IP>_:_<gateway-IP>_:_<netmask>_:_<client_hostname>_:_<interface>_:_{none|off|dhcp|on|any|dhcp6|auto6|ibft}_[:[_<mtu>_][:_<macaddr>_]]::
|
||||
explicit network configuration. If you want do define a IPv6 address, put it
|
||||
in brackets (e.g. [2001:DB8::1]). This parameter can be specified multiple
|
||||
times.
|
||||
+
|
||||
<macaddr>::: optionally set <macaddr> on the <interface>
|
||||
|
||||
**ifname=**_<interface>_:_<MAC>_::
|
||||
Assign network device name <interface> (ie eth0) to the NIC with MAC <MAC>.
|
||||
Note: If you use this option you _must_ specify an ifname= argument for all
|
||||
interfaces used in ip= or fcoe= arguments. However, if the interface in
|
||||
ip= or fcoe= is a bridge, bonding or vlan interface, you should specify
|
||||
an ifname= for _each_ of its underlying interfaces. This parameter can be
|
||||
specified multiple times.
|
||||
|
||||
**bootdev=**_<interface>_::
|
||||
specify network interface to use routing and netroot information from.
|
||||
Required if multiple ip= lines are used.
|
||||
|
||||
**nameserver=**__<IP>__ [**nameserver=**__<IP>__ ...]::
|
||||
specify nameserver(s) to use
|
||||
|
||||
**biosdevname=0**::
|
||||
boolean, turn off biosdevname network interface renaming
|
||||
|
||||
**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)
|
||||
|
||||
**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
|
||||
|
||||
**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
|
||||
|
||||
|
||||
NFS
|
||||
~~~
|
||||
**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 ",".
|
||||
|
||||
**root=**nfs:[_<server-ip>_:]_<root-dir>_[:_<nfs-options>_], **root=**nfs4:[_<server-ip>_:]_<root-dir>_[:_<nfs-options>_], **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>]
|
||||
----
|
||||
|
||||
**root=**_/dev/nfs_ nfsroot=[_<server-ip>_:]_<root-dir>_[:_<nfs-options>_]::
|
||||
_Deprecated!_ kernel Documentation_/filesystems/nfsroot.txt_ defines this
|
||||
method. This is supported by dracut, but not recommended.
|
||||
|
||||
**rd.nfs.domain=**_<NFSv4 domain name>_::
|
||||
Set the NFSv4 domain name. Will overwrite the settings in _/etc/idmap.conf_.
|
||||
|
||||
iSCSI
|
||||
~~~~~
|
||||
**root=**iscsi:[_<username>_:_<password>_[:_<reverse>_:_<password>_]@][_<servername>_]:[_<protocol>_]:[_<port>_][:[_<iscsi_iface_name>_]:[_<netdev_name>_]]:[_<LUN>_]:_<targetname>_::
|
||||
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. 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. See
|
||||
link:$$http://tools.ietf.org/html/rfc4173#section-5$$[rfc4173].
|
||||
e.g.:
|
||||
+
|
||||
----
|
||||
root=iscsi:192.168.50.1::::iqn.2009-06.dracut:target0
|
||||
----
|
||||
+
|
||||
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
|
||||
----
|
||||
|
||||
**root=**_???_ **netroot=**iscsi:[_<username>_:_<password>_[:_<reverse>_:_<password>_]@][_<servername>_]:[_<protocol>_]:[_<port>_][:[_<iscsi_iface_name>_]:[_<netdev_name>_]]:[_<LUN>_]:_<targetname>_ ...::
|
||||
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
|
||||
----
|
||||
+
|
||||
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
|
||||
----
|
||||
|
||||
**root=**_???_ **rd.iscsi.initiator=**_<initiator>_ **rd.iscsi.target.name=**_<target name>_ **rd.iscsi.target.ip=**_<target ip>_ **rd.iscsi.target.port=**_<target port>_ **rd.iscsi.target.group=**_<target group>_ **rd.iscsi.username=**_<username>_ **rd.iscsi.password=**_<password>_ **rd.iscsi.in.username=**_<in username>_ **rd.iscsi.in.password=**_<in password>_::
|
||||
manually specify all iscsistart parameter (see **+iscsistart --help+**)
|
||||
|
||||
**root=**_???_ **netroot=**iscsi **rd.iscsi.firmware=1**::
|
||||
will read the iscsi parameter from the BIOS firmware
|
||||
|
||||
**rd.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 rd.iscsi.param=node.session.timeo.replacement_timeout=30"
|
||||
----
|
||||
+
|
||||
will result in
|
||||
+
|
||||
----
|
||||
iscsistart -b --param node.session.timeo.replacement_timeout=30
|
||||
----
|
||||
|
||||
FCoE
|
||||
~~~~
|
||||
**fcoe=**_<edd|interface|MAC>_:_{dcb|nodcb}_::
|
||||
Try to connect to a FCoE SAN through the NIC specified by _<interface>_ or
|
||||
_<MAC>_ or EDD settings. For the second argument, currently only nodcb is
|
||||
supported. This parameter can be specified multiple times. Note: letters in
|
||||
the MAC-address must be lowercase!
|
||||
|
||||
NBD
|
||||
~~~
|
||||
**root=**??? **netroot=**nbd:_<server>_:_<port>_[:_<fstype>_[:_<mountopts>_[:_<nbdopts>_]]]::
|
||||
mount nbd share from <server>
|
||||
|
||||
**root=dhcp** with **dhcp** **root-path=**nbd:_<server>_:_<port>_[:_<fstype>_[:_<mountopts>_[:_<nbdopts>_]]]::
|
||||
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.
|
||||
|
||||
DASD
|
||||
~~~~
|
||||
**rd.dasd=**....::
|
||||
same syntax as the kernel module parameter (s390 only)
|
||||
|
||||
ZFCP
|
||||
~~~~
|
||||
**rd.zfcp=**_<zfcp adaptor device bus ID>_,_<WWPN>_,_<FCPLUN>_::
|
||||
rd.zfcp can be specified multiple times on the kernel command line. e.g.:
|
||||
+
|
||||
----
|
||||
rd.zfcp=0.0.4000,0x5005076300C213e9,0x5022000000000000
|
||||
----
|
||||
|
||||
**rd.zfcp.conf=0**::
|
||||
ignore zfcp.conf included in the initramfs
|
||||
|
||||
ZNET
|
||||
~~~~
|
||||
**rd.znet=**_<nettype>_,_<subchannels>_,_<options>_::
|
||||
rd.znet can be specified multiple times on the kernel command line. e.g.:
|
||||
+
|
||||
----
|
||||
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
|
||||
----
|
||||
|
||||
Plymouth Boot Splash
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
**plymouth.enable=0**::
|
||||
disable the plymouth bootsplash completly.
|
||||
|
||||
**rd.plymouth=0**::
|
||||
disable the plymouth bootsplash only for the initramfs.
|
||||
|
||||
Kernel keys
|
||||
~~~~~~~~~~~
|
||||
**masterkey=**_<kernel master key path name>_::
|
||||
Set the path name of the kernel master key. e.g.:
|
||||
+
|
||||
----
|
||||
masterkey=/etc/keys/kmk-trusted.blob
|
||||
----
|
||||
|
||||
**masterkeytype=**_<kernel master key type>_::
|
||||
Set the type of the kernel master key. e.g.:
|
||||
+
|
||||
----
|
||||
masterkeytype=trusted
|
||||
----
|
||||
|
||||
**evmkey=**_<EVM key path name>_::
|
||||
Set the path name of the EVM key. e.g.:
|
||||
+
|
||||
----
|
||||
evmkey=/etc/keys/evm-trusted.blob
|
||||
----
|
||||
|
||||
**ecryptfskey=**_<eCryptfs key path name>_::
|
||||
Set the path name of the eCryptfs key. e.g.:
|
||||
+
|
||||
----
|
||||
ecryptfskey=/etc/keys/ecryptfs-trusted.blob
|
||||
----
|
||||
|
||||
Deprecated, renamed Options
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Here is a list of options, which were used in dracut prior to version 008, and their new replacement.
|
||||
|
||||
rdbreak:: rd.break
|
||||
|
||||
rd_CCW:: rd.ccw
|
||||
|
||||
rd_DASD_MOD:: rd.dasd
|
||||
|
||||
rd_DASD:: rd.dasd
|
||||
|
||||
rdinitdebug rdnetdebug:: rd.debug
|
||||
|
||||
rd_NO_DM:: rd.dm=0
|
||||
|
||||
rd_DM_UUID:: rd.dm.uuid
|
||||
|
||||
rdblacklist:: rd.driver.blacklist
|
||||
|
||||
rdinsmodpost:: rd.driver.post
|
||||
|
||||
rdloaddriver:: rd.driver.pre
|
||||
|
||||
rd_NO_FSTAB:: rd.fstab=0
|
||||
|
||||
rdinfo:: rd.info
|
||||
|
||||
check:: rd.live.check
|
||||
|
||||
rdlivedebug:: rd.live.debug
|
||||
|
||||
live_dir:: rd.live.dir
|
||||
|
||||
liveimg:: rd.live.image
|
||||
|
||||
overlay:: rd.live.overlay
|
||||
|
||||
readonly_overlay:: rd.live.overlay.readonly
|
||||
|
||||
reset_overlay:: rd.live.overlay.reset
|
||||
|
||||
live_ram:: rd.live.ram
|
||||
|
||||
rd_NO_CRYPTTAB:: rd.luks.crypttab=0
|
||||
|
||||
rd_LUKS_KEYDEV_UUID:: rd.luks.keydev.uuid
|
||||
|
||||
rd_LUKS_KEYPATH:: rd.luks.keypath
|
||||
|
||||
rd_NO_LUKS:: rd.luks=0
|
||||
|
||||
rd_LUKS_UUID:: rd.luks.uuid
|
||||
|
||||
rd_NO_LVMCONF:: rd.lvm.conf
|
||||
|
||||
rd_LVM_LV:: rd.lvm.lv
|
||||
|
||||
rd_NO_LVM:: rd.lvm=0
|
||||
|
||||
rd_LVM_SNAPSHOT:: rd.lvm.snapshot
|
||||
|
||||
rd_LVM_SNAPSIZE:: rd.lvm.snapsize
|
||||
|
||||
rd_LVM_VG:: rd.lvm.vg
|
||||
|
||||
rd_NO_MDADMCONF:: rd.md.conf=0
|
||||
|
||||
rd_NO_MDIMSM:: rd.md.imsm=0
|
||||
|
||||
rd_NO_MD:: rd.md=0
|
||||
|
||||
rd_MD_UUID:: rd.md.uuid
|
||||
|
||||
rd_NFS_DOMAIN:: rd.nfs.domain
|
||||
|
||||
iscsi_initiator:: rd.iscsi.initiator
|
||||
|
||||
iscsi_target_name:: rd.iscsi.target.name
|
||||
|
||||
iscsi_target_ip:: rd.iscsi.target.ip
|
||||
|
||||
iscsi_target_port:: rd.iscsi.target.port
|
||||
|
||||
iscsi_target_group:: rd.iscsi.target.group
|
||||
|
||||
iscsi_username:: rd.iscsi.username
|
||||
|
||||
iscsi_password:: rd.iscsi.password
|
||||
|
||||
iscsi_in_username:: rd.iscsi.in.username
|
||||
|
||||
iscsi_in_password:: rd.iscsi.in.password
|
||||
|
||||
iscsi_firmware:: rd.iscsi.firmware=0
|
||||
|
||||
rd_NO_PLYMOUTH:: rd.plymouth=0
|
||||
|
||||
rd_retry:: rd.retry
|
||||
|
||||
rdshell:: rd.shell
|
||||
|
||||
rd_NO_SPLASH:: rd.splash
|
||||
|
||||
rdudevdebug:: rd.udev.debug
|
||||
|
||||
rdudevinfo:: rd.udev.info
|
||||
|
||||
rd_NO_ZFCPCONF:: rd.zfcp.conf=0
|
||||
|
||||
rd_ZFCP:: rd.zfcp
|
||||
|
||||
rd_ZNET:: rd.znet
|
||||
|
||||
KEYMAP:: vconsole.keymap
|
||||
|
||||
KEYTABLE:: vconsole.keymap
|
||||
|
||||
SYSFONT:: vconsole.font
|
||||
|
||||
CONTRANS:: vconsole.font.map
|
||||
|
||||
UNIMAP:: vconsole.font.unimap
|
||||
|
||||
UNICODE:: vconsole.unicode
|
||||
|
||||
EXT_KEYMAP:: vconsole.keymap.ext
|
||||
|
||||
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.
|
||||
|
||||
_/etc/cmdline.d/*.conf_::
|
||||
Can contain additional command line options.
|
||||
|
||||
AUTHOR
|
||||
------
|
||||
*Harald Hoyer*::
|
||||
Project Leader and Developer
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
*dracut*(8) *dracut.conf*(5)
|
1324
dracut.cmdline.7.xml
1324
dracut.cmdline.7.xml
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,7 @@
|
||||
# PUT YOUR CONFIG HERE OR IN separate files named *.conf
|
||||
# in /etc/dracut.conf.d
|
||||
# /etc/dracut.conf.d/*.conf will override the settings in here
|
||||
|
||||
# Sample dracut config file
|
||||
|
||||
logfile=/var/log/dracut.log
|
||||
@@ -38,3 +42,7 @@ lvmconf="yes"
|
||||
|
||||
# inhibit installation of any fsck tools
|
||||
#nofscks="yes"
|
||||
|
||||
# set the directory for temporary files
|
||||
# default: /var/tmp
|
||||
#tmpdir=/tmp
|
||||
|
139
dracut.conf.5.asc
Normal file
139
dracut.conf.5.asc
Normal file
@@ -0,0 +1,139 @@
|
||||
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_
|
||||
|
||||
Description
|
||||
-----------
|
||||
_dracut.conf_ is loaded during the initialisation phase of dracut. Command line
|
||||
parameter will overwrite any values set here. _dracut.conf.d/*.conf_ files are
|
||||
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.
|
||||
|
||||
*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.
|
||||
|
||||
*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.
|
||||
|
||||
*install_items+=*" __<kernel modules>__ "::
|
||||
Specify a space-separated list of files, which are added to the initramfs
|
||||
image.
|
||||
|
||||
*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.
|
||||
|
||||
*do_strip=*"__{yes|no}__"::
|
||||
Strip 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.
|
||||
|
||||
*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.
|
||||
|
||||
*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.
|
||||
|
||||
*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)
|
||||
|
||||
*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 included module's name to standard output during build.
|
||||
|
||||
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,287 +0,0 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!-- This document was created with Syntext Serna Free. --><!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" []>
|
||||
<!-- vim: set ts=8 sts=2 sw=2 et: -->
|
||||
<refentry id="dracutconf5">
|
||||
<refentryinfo>
|
||||
<title>dracut.conf</title>
|
||||
<productname>dracut</productname>
|
||||
<authorgroup>
|
||||
<author>
|
||||
<contrib>Developer</contrib>
|
||||
<firstname>Harald</firstname>
|
||||
<surname>Hoyer</surname>
|
||||
<email>harald@redhat.com</email>
|
||||
</author>
|
||||
</authorgroup>
|
||||
</refentryinfo>
|
||||
<refmeta>
|
||||
<refentrytitle>dracut.conf</refentrytitle>
|
||||
<manvolnum>5</manvolnum>
|
||||
</refmeta>
|
||||
<refnamediv>
|
||||
<refname>dracut.conf</refname>
|
||||
<refpurpose>configuration file(s) for dracut</refpurpose>
|
||||
</refnamediv>
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>/etc/dracut.conf</command>
|
||||
<arg choice="plain">
|
||||
<replaceable>/etc/dracut.conf.d/*.conf</replaceable>
|
||||
</arg>
|
||||
<sbr/>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<para><filename>dracut.conf</filename>
|
||||
is loaded during the initialisation phase of dracut.
|
||||
Command line parameter will overwrite any values set here.
|
||||
<emphasis><filename>dracut.conf.d/*.conf</filename> files are read in alphanumerical order and will</emphasis>
|
||||
overwrite parameters set in <filename>/etc/dracut.conf</filename>. 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.</para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<envar>dracutmodules+=" <replaceable><dracut modules></replaceable> "</envar>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Specify a space-separated list of dracut modules to
|
||||
call when building the initramfs. Modules are located
|
||||
in <filename>/usr/lib/dracut/modules.d</filename>.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<envar>omit_dracutmodules+=" <replaceable><dracut modules></replaceable> "</envar>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Omit a space-separated list of dracut modules.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<envar>add_dracutmodules+=" <replaceable><dracut modules></replaceable> "</envar>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Add a space-separated list of dracut modules.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<envar>drivers+=" <replaceable><kernel modules></replaceable> "</envar>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>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.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<envar>add_drivers+=" <replaceable><kernel modules></replaceable> "</envar>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Specify a space-separated list of kernel
|
||||
modules to add to the initramfs.
|
||||
The kernel modules have to be specified without the ".ko" suffix.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<envar>install_items+=" <replaceable><kernel modules></replaceable> "</envar>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Specify a space-separated list of files, which are added to the initramfs image.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<envar>filesystems+=" <replaceable><filesystem names></replaceable> "</envar>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Specify a space-separated list of kernel filesystem
|
||||
modules to exclusively include in the generic
|
||||
initramfs.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<envar>drivers_dir="<replaceable><kernel modules directory></replaceable>"</envar>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Specify the directory, where to look for kernel modules</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<envar>fw_dir+=" :<replaceable><dir></replaceable>[:<replaceable><dir></replaceable> ...] "</envar>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Specify additional directories, where to look for firmwares, separated by <constant>:</constant></para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<envar>install_items+=" <replaceable><file></replaceable>[ <replaceable><file></replaceable> ...] "</envar>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Specify additional files to include in the initramfs, separated by spaces.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<envar>do_strip="<replaceable>{yes|no}</replaceable>"</envar>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Strip binaries in the initramfs (default=yes)</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<envar>hostonly="<replaceable>{yes|no}</replaceable>"</envar>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Host-Only mode: Install only what is needed for booting
|
||||
the local host instead of a generic host.
|
||||
<warning><para>If chrooted to another root other than the real root device, use <option>--fstab</option> and provide a valid <filename>/etc/fstab</filename>.</para>
|
||||
</warning>
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<envar>use_fstab="<replaceable>{yes|no}</replaceable>"</envar>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Use <filename>/etc/fstab</filename> instead of <filename>/proc/self/mountinfo</filename>.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<envar>add_fstab+=" <replaceable><filename></replaceable> "</envar>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Add entries of <replaceable><filename></replaceable> to the initramfs /etc/fstab.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<envar>mdadmconf="<replaceable>{yes|no}</replaceable>"</envar>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Include local <filename>/etc/mdadm.conf</filename> (default=yes)</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<envar>lvmconf="<replaceable>{yes|no}</replaceable>"</envar>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Include local <filename>/etc/lvm/lvm.conf</filename> (default=yes)</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<envar>fscks=" <replaceable><fsck tools></replaceable> "</envar>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Add a space-separated list of fsck tools. If nothing is
|
||||
specified, the default is: "<replaceable>umount mount
|
||||
/sbin/fsck* xfs_db xfs_check xfs_repair e2fsck jfs_fsck
|
||||
reiserfsck btrfsck</replaceable>"
|
||||
</para>
|
||||
<para>The installation is opportunistic (non-existing tools are ignored).</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<envar>nofscks="<replaceable>{yes}</replaceable>"</envar>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>If specified, inhibit installation of any fsck tools.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<envar>kernel_only="<replaceable>{yes|no}</replaceable>"</envar>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Only install kernel drivers and firmware files. (default=no)</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<envar>no_kernel="<replaceable>{yes|no}</replaceable>"</envar>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Do not install kernel drivers and firmware files (default=no)</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<envar>stdloglvl="<replaceable>{0-6}</replaceable>"</envar>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Set logging to standard error level.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<envar>sysloglvl="<replaceable>{0-6}</replaceable>"</envar>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Set logging to syslog level.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<envar>fileloglvl="<replaceable>{0-6}</replaceable>"</envar>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Set logging to file level.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<envar>logfile="<replaceable><file></replaceable>"</envar>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Path to log file.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<envar>show_modules="<replaceable>{yes|no}</replaceable>"</envar>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Print included module's name to standard output during build.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>Files</title>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<filename>/etc/dracut/conf.d/</filename>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Any <filename>/etc/dracut/conf.d/*.conf</filename> file can overwrite the values in <filename>/etc/dracut.conf</filename>.
|
||||
The configuration files are read in alphanumerical order.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>See Also</title>
|
||||
<para><citerefentry>
|
||||
<refentrytitle>dracut</refentrytitle>
|
||||
<manvolnum>8</manvolnum>
|
||||
</citerefentry>
|
||||
<citerefentry>
|
||||
<refentrytitle>dracut.cmdline</refentrytitle>
|
||||
<manvolnum>7</manvolnum>
|
||||
</citerefentry>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
@@ -2,9 +2,13 @@
|
||||
|
||||
# i18n
|
||||
i18n_vars="/etc/sysconfig/keyboard:KEYTABLE-KEYMAP /etc/sysconfig/i18n:SYSFONT-FONT,FONTACM-FONT_MAP,FONT_UNIMAP"
|
||||
add_dracutmodules+=" rpmversion "
|
||||
omit_dracutmodules+=" dash "
|
||||
omit_drivers+=" .*/fs/ocfs/.* "
|
||||
add_dracutmodules+=" systemd "
|
||||
stdloglvl=3
|
||||
prefix=/run/initramfs
|
||||
realinitpath="/usr/lib/systemd/systemd"
|
||||
install_items+=" vi /etc/virc ps grep cat rm openvt "
|
||||
install_items+=" vi /etc/virc ps grep cat rm "
|
||||
prefix="/"
|
||||
systemdutildir=/usr/lib/systemd
|
||||
systemdsystemunitdir=/usr/lib/systemd/system
|
||||
udevdir=/usr/lib/udev
|
||||
|
@@ -26,10 +26,20 @@
|
||||
# store for logging
|
||||
dracut_args="$@"
|
||||
|
||||
set -o pipefail
|
||||
|
||||
usage() {
|
||||
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
|
||||
if [[ -f $dracutbasedir/dracut-version.sh ]]; then
|
||||
. $dracutbasedir/dracut-version.sh
|
||||
fi
|
||||
|
||||
# 80x25 linebreak here ^
|
||||
cat << EOF
|
||||
Usage: $0 [OPTION]... <initramfs> <kernel-version>
|
||||
|
||||
Version: $DRACUT_VERSION
|
||||
|
||||
Creates initial ramdisk images for preloading modules
|
||||
|
||||
-f, --force Overwrite existing initramfs file.
|
||||
@@ -40,8 +50,10 @@ Creates initial ramdisk images for preloading 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
|
||||
--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.
|
||||
@@ -78,12 +90,15 @@ Creates initial ramdisk images for preloading modules
|
||||
Default: /etc/dracut.conf
|
||||
--confdir [DIR] Specify configuration directory to use *.conf files
|
||||
from. Default: /etc/dracut.conf.d
|
||||
--tmpdir [DIR] Temporary directory to be used instead of default
|
||||
/var/tmp.
|
||||
-l, --local Local mode. Use modules from the current working
|
||||
directory instead of the system-wide installed in
|
||||
/usr/lib/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.
|
||||
--no-hostonly Disables Host-Only mode
|
||||
--fstab Use /etc/fstab to determine the root device.
|
||||
--add-fstab [FILE] Add file to the initramfs fstab
|
||||
--mount "[DEV] [MP] [FSTYPE] [FSOPTS]"
|
||||
@@ -118,8 +133,8 @@ Creates initial ramdisk images for preloading modules
|
||||
-M, --show-modules Print included module's name to standard output during
|
||||
build.
|
||||
--keep Keep the temporary initramfs for debugging purposes
|
||||
--printsize Print out the module install size
|
||||
--sshkey [SSHKEY] Add ssh key to initramfs (use with ssh-client module)
|
||||
--ctty Add control tty for emergency shells
|
||||
|
||||
If [LIST] has multiple arguments, then you have to put these in quotes.
|
||||
For example:
|
||||
@@ -204,18 +219,22 @@ push_arg() {
|
||||
}
|
||||
|
||||
verbosity_mod_l=0
|
||||
unset kernel
|
||||
unset outfile
|
||||
|
||||
while (($# > 0)); do
|
||||
case ${1%%=*} in
|
||||
-a|--add) push_arg add_dracutmodules_l "$@" || shift;;
|
||||
--force-add) push_arg force_add_dracutmodules_l "$@" || shift;;
|
||||
--add-drivers) push_arg add_drivers_l "$@" || shift;;
|
||||
--omit-drivers) push_arg omit_drivers_l "$@" || shift;;
|
||||
-m|--modules) push_arg dracutmodules_l "$@" || shift;;
|
||||
-o|--omit) push_arg omit_dracutmodules_l "$@" || shift;;
|
||||
-d|--drivers) push_arg drivers_l "$@" || shift;;
|
||||
--filesystems) push_arg filesystems_l "$@" || shift;;
|
||||
-I|--install) push_arg install_items_l "$@" || shift;;
|
||||
--fwdir) push_arg fw_dir_l "$@" || shift;;
|
||||
--libdirs) push_arg libdirs_l "$@" || shift;;
|
||||
--fscks) push_arg fscks_l "$@" || shift;;
|
||||
--add-fstab) push_arg add_fstab_l "$@" || shift;;
|
||||
--mount) push_arg fstab_lines "$@" || shift;;
|
||||
@@ -223,6 +242,7 @@ while (($# > 0)); do
|
||||
-k|--kmoddir) read_arg drivers_dir_l "$@" || shift;;
|
||||
-c|--conf) read_arg conffile "$@" || shift;;
|
||||
--confdir) read_arg confdir "$@" || shift;;
|
||||
--tmpdir) read_arg tmpdir_l "$@" || shift;;
|
||||
-L|--stdlog) read_arg stdloglvl_l "$@" || shift;;
|
||||
--compress) read_arg compress_l "$@" || shift;;
|
||||
--prefix) read_arg prefix_l "$@" || shift;;
|
||||
@@ -238,12 +258,16 @@ while (($# > 0)); do
|
||||
--nolvmconf) lvmconf_l="no";;
|
||||
--debug) debug="yes";;
|
||||
--profile) profile="yes";;
|
||||
--ctty) cttyhack="yes";;
|
||||
--sshkey) read_arg sshkey "$@" || shift;;
|
||||
-v|--verbose) ((verbosity_mod_l++));;
|
||||
-q|--quiet) ((verbosity_mod_l--));;
|
||||
-l|--local) allowlocal="yes" ;;
|
||||
-l|--local)
|
||||
allowlocal="yes"
|
||||
[[ -f "$(readlink -f ${0%/*})/dracut-functions.sh" ]] \
|
||||
&& dracutbasedir="$(readlink -f ${0%/*})"
|
||||
;;
|
||||
-H|--hostonly) hostonly_l="yes" ;;
|
||||
--no-hostonly) hostonly_l="no" ;;
|
||||
--fstab) use_fstab_l="yes" ;;
|
||||
-h|--help) usage; exit 1 ;;
|
||||
-i|--include) push include_src "$2"
|
||||
@@ -261,6 +285,7 @@ while (($# > 0)); do
|
||||
show_modules_l="yes"
|
||||
;;
|
||||
--keep) keep="yes";;
|
||||
--printsize) printsize="yes";;
|
||||
-*) printf "\nUnknown option: %s\n\n" "$1" >&2; usage; exit 1;;
|
||||
*)
|
||||
if ! [[ ${outfile+x} ]]; then
|
||||
@@ -268,6 +293,7 @@ while (($# > 0)); do
|
||||
elif ! [[ ${kernel+x} ]]; then
|
||||
kernel=$1
|
||||
else
|
||||
echo "Unknown argument: $1"
|
||||
usage; exit 1;
|
||||
fi
|
||||
;;
|
||||
@@ -279,18 +305,21 @@ if ! [[ $kernel ]]; then
|
||||
fi
|
||||
[[ $outfile ]] || outfile="/boot/initramfs-$kernel.img"
|
||||
|
||||
for i in /usr/bin /bin /usr/sbin /sbin; do
|
||||
for i in /usr/sbin /sbin /usr/bin /bin; do
|
||||
rl=$i
|
||||
if [ -L "$i" ]; then
|
||||
rl=$(readlink -f $i)
|
||||
fi
|
||||
PATH="$PATH:$rl"
|
||||
NPATH+=":$rl"
|
||||
done
|
||||
export PATH
|
||||
export PATH="${NPATH#:}"
|
||||
unset NPATH
|
||||
unset LD_LIBRARY_PATH
|
||||
unset GREP_OPTIONS
|
||||
|
||||
export DRACUT_LOG_LEVEL=warning
|
||||
[[ $debug ]] && {
|
||||
export DRACUT_LOG_LEVEL=debug
|
||||
export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): ';
|
||||
set -x
|
||||
}
|
||||
@@ -303,9 +332,6 @@ unset GREP_OPTIONS
|
||||
|
||||
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
|
||||
|
||||
[[ $allowlocal && -f "$(readlink -f ${0%/*})/dracut-functions" ]] && \
|
||||
dracutbasedir="$(readlink -f ${0%/*})"
|
||||
|
||||
# if we were not passed a config file, try the default one
|
||||
if [[ ! -f $conffile ]]; then
|
||||
[[ $allowlocal ]] && conffile="$dracutbasedir/dracut.conf" || \
|
||||
@@ -340,13 +366,6 @@ if (( ${#force_add_dracutmodules_l[@]} )); then
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
if (( ${#add_drivers_l[@]} )); then
|
||||
while pop add_drivers_l val; do
|
||||
add_drivers+=" $val "
|
||||
done
|
||||
fi
|
||||
|
||||
if (( ${#fscks_l[@]} )); then
|
||||
while pop fscks_l val; do
|
||||
fscks+=" $val "
|
||||
@@ -386,13 +405,6 @@ if (( ${#omit_dracutmodules_l[@]} )); then
|
||||
done
|
||||
fi
|
||||
|
||||
if (( ${#drivers_l[@]} )); then
|
||||
drivers=''
|
||||
while pop drivers_l val; do
|
||||
drivers+="$val "
|
||||
done
|
||||
fi
|
||||
|
||||
if (( ${#filesystems_l[@]} )); then
|
||||
filesystems=''
|
||||
while pop filesystems_l val; do
|
||||
@@ -407,6 +419,13 @@ if (( ${#fw_dir_l[@]} )); then
|
||||
done
|
||||
fi
|
||||
|
||||
if (( ${#libdirs_l[@]} )); then
|
||||
libdirs=''
|
||||
while pop libdirs_l val; do
|
||||
libdirs+="$val "
|
||||
done
|
||||
fi
|
||||
|
||||
[[ $stdloglvl_l ]] && stdloglvl=$stdloglvl_l
|
||||
[[ ! $stdloglvl ]] && stdloglvl=4
|
||||
stdloglvl=$((stdloglvl + verbosity_mod_l))
|
||||
@@ -423,6 +442,8 @@ stdloglvl=$((stdloglvl + verbosity_mod_l))
|
||||
[[ $lvmconf_l ]] && lvmconf=$lvmconf_l
|
||||
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
|
||||
[[ $fw_dir ]] || fw_dir="/lib/firmware/updates /lib/firmware"
|
||||
[[ $tmpdir_l ]] && tmpdir="$tmpdir_l"
|
||||
[[ $tmpdir ]] || tmpdir=/var/tmp
|
||||
[[ $do_strip ]] || do_strip=no
|
||||
[[ $compress_l ]] && compress=$compress_l
|
||||
[[ $show_modules_l ]] && show_modules=$show_modules_l
|
||||
@@ -446,13 +467,27 @@ fi
|
||||
[[ $hostonly = yes ]] && hostonly="-h"
|
||||
[[ $hostonly != "-h" ]] && unset hostonly
|
||||
|
||||
if [[ -f $dracutbasedir/dracut-functions ]]; then
|
||||
. $dracutbasedir/dracut-functions
|
||||
else
|
||||
echo "Cannot find $dracutbasedir/dracut-functions." >&2
|
||||
echo "Are you running from a git checkout?" >&2
|
||||
echo "Try passing -l as an argument to $0" >&2
|
||||
readonly TMPDIR="$tmpdir"
|
||||
readonly initdir=$(mktemp --tmpdir="$TMPDIR/" -d -t initramfs.XXXXXX)
|
||||
[ -d "$initdir" ] || {
|
||||
echo "dracut: mktemp --tmpdir=\"$TMPDIR/\" -d -t initramfs.XXXXXXfailed." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
export DRACUT_KERNEL_LAZY="1"
|
||||
export DRACUT_RESOLVE_LAZY="1"
|
||||
|
||||
if [[ -f $dracutbasedir/dracut-functions.sh ]]; then
|
||||
. $dracutbasedir/dracut-functions.sh
|
||||
else
|
||||
echo "dracut: Cannot find $dracutbasedir/dracut-functions.sh." >&2
|
||||
echo "dracut: Are you running from a git checkout?" >&2
|
||||
echo "dracut: Try passing -l as an argument to $0" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -f $dracutbasedir/dracut-version.sh ]]; then
|
||||
. $dracutbasedir/dracut-version.sh
|
||||
fi
|
||||
|
||||
# Verify bash version, curret minimum is 3.1
|
||||
@@ -462,9 +497,40 @@ if (( ${BASH_VERSINFO[0]} < 3 ||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dracutfunctions=$dracutbasedir/dracut-functions
|
||||
dracutfunctions=$dracutbasedir/dracut-functions.sh
|
||||
export dracutfunctions
|
||||
|
||||
if (( ${#drivers_l[@]} )); then
|
||||
drivers=''
|
||||
while pop drivers_l val; do
|
||||
drivers+="$val "
|
||||
done
|
||||
fi
|
||||
drivers=${drivers/-/_}
|
||||
|
||||
if (( ${#add_drivers_l[@]} )); then
|
||||
while pop add_drivers_l val; do
|
||||
add_drivers+=" $val "
|
||||
done
|
||||
fi
|
||||
add_drivers=${add_drivers/-/_}
|
||||
|
||||
if (( ${#omit_drivers_l[@]} )); then
|
||||
while pop omit_drivers_l val; do
|
||||
omit_drivers+=" $val "
|
||||
done
|
||||
fi
|
||||
omit_drivers=${omit_drivers/-/_}
|
||||
|
||||
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
|
||||
|
||||
|
||||
ddebug "Executing $0 $dracut_args"
|
||||
|
||||
[[ $do_list = yes ]] && {
|
||||
@@ -477,18 +543,6 @@ ddebug "Executing $0 $dracut_args"
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Detect lib paths
|
||||
[[ $libdir ]] || for libdir in /lib64 /lib; do
|
||||
[[ -d $libdir ]] && break
|
||||
done || {
|
||||
dfatal 'No lib directory?!!!'
|
||||
exit 1
|
||||
}
|
||||
|
||||
[[ $usrlibdir ]] || for usrlibdir in /usr/lib64 /usr/lib; do
|
||||
[[ -d $usrlibdir ]] && break
|
||||
done || dwarn 'No usr/lib directory!'
|
||||
|
||||
# This is kinda legacy -- eventually it should go away.
|
||||
case $dracutmodules in
|
||||
""|auto) dracutmodules="all" ;;
|
||||
@@ -496,15 +550,10 @@ esac
|
||||
|
||||
abs_outfile=$(readlink -f "$outfile") && outfile="$abs_outfile"
|
||||
|
||||
srcmods="/lib/modules/$kernel/"
|
||||
[[ $drivers_dir ]] && {
|
||||
if vercmp $(modprobe --version | cut -d' ' -f3) lt 3.7; then
|
||||
dfatal 'To use --kmoddir option module-init-tools >= 3.7 is required.'
|
||||
exit 1
|
||||
fi
|
||||
srcmods="$drivers_dir"
|
||||
[[ -f $srcmods/modules.dep ]] || {
|
||||
dfatal "$srcmods/modules.dep is missing. Did you run depmod?"
|
||||
exit 1
|
||||
}
|
||||
export srcmods
|
||||
|
||||
if [[ -f $outfile && ! $force ]]; then
|
||||
dfatal "Will not override existing initramfs ($outfile) without --force"
|
||||
@@ -525,13 +574,6 @@ elif [[ -f "$outfile" && ! -w "$outfile" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
readonly TMPDIR=/var/tmp
|
||||
readonly initdir=$(mktemp --tmpdir=/var/tmp/ -d -t initramfs.XXXXXX)
|
||||
[ -d "$initdir" ] || {
|
||||
dfatal "mktemp failed."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# clean up after ourselves no matter how we die.
|
||||
trap 'ret=$?;[[ $keep ]] && echo "Not removing $initdir." >&2 || rm -rf "$initdir";exit $ret;' EXIT
|
||||
# clean up after ourselves no matter how we die.
|
||||
@@ -577,11 +619,11 @@ fi
|
||||
_get_fs_type() (
|
||||
[[ $1 ]] || return
|
||||
if [[ -b $1 ]] && get_fs_env $1; then
|
||||
echo "$1|$ID_FS_TYPE"
|
||||
echo "$(readlink -f $1)|$ID_FS_TYPE"
|
||||
return 1
|
||||
fi
|
||||
if [[ -b /dev/block/$1 ]] && get_fs_env /dev/block/$1; then
|
||||
echo "/dev/block/$1|$ID_FS_TYPE"
|
||||
echo "$(readlink -f /dev/block/$1)|$ID_FS_TYPE"
|
||||
return 1
|
||||
fi
|
||||
if fstype=$(find_dev_fstype $1); then
|
||||
@@ -601,12 +643,31 @@ for dev in "${host_devs[@]}"; do
|
||||
done
|
||||
done
|
||||
|
||||
[[ -d $udevdir ]] \
|
||||
|| udevdir=$(pkg-config udev --variable=udevdir 2>/dev/null)
|
||||
if ! [[ -d "$udevdir" ]]; then
|
||||
[[ -d /lib/udev ]] && udevdir=/lib/udev
|
||||
[[ -d /usr/lib/udev ]] && udevdir=/usr/lib/udev
|
||||
fi
|
||||
|
||||
[[ -d $systemdutildir ]] \
|
||||
|| systemdutildir=$(pkg-config systemd --variable=systemdutildir 2>/dev/null)
|
||||
[[ -d $systemdsystemunitdir ]] \
|
||||
|| systemdsystemunitdir=$(pkg-config systemd --variable=systemdsystemunitdir 2>/dev/null)
|
||||
|
||||
if ! [[ -d "$systemdutildir" ]]; then
|
||||
[[ -d /lib/systemd ]] && systemdutildir=/lib/systemd
|
||||
[[ -d /usr/lib/systemd ]] && systemdutildir=/usr/lib/systemd
|
||||
fi
|
||||
[[ -d "$systemdsystemunitdir" ]] || systemdsystemunitdir=${systemdutildir}/system
|
||||
|
||||
export initdir dracutbasedir dracutmodules drivers \
|
||||
fw_dir drivers_dir debug no_kernel kernel_only \
|
||||
add_drivers mdadmconf lvmconf filesystems \
|
||||
use_fstab fstab_lines libdir usrlibdir fscks nofscks cttyhack \
|
||||
add_drivers omit_drivers mdadmconf lvmconf filesystems \
|
||||
use_fstab fstab_lines libdirs fscks nofscks \
|
||||
stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
|
||||
debug host_fs_types host_devs sshkey
|
||||
debug host_fs_types host_devs sshkey add_fstab \
|
||||
DRACUT_VERSION udevdir systemdutildir systemdsystemunitdir
|
||||
|
||||
# Create some directory structure first
|
||||
[[ $prefix ]] && mkdir -m 0755 -p "${initdir}${prefix}"
|
||||
@@ -615,24 +676,25 @@ export initdir dracutbasedir dracutmodules drivers \
|
||||
[[ $prefix ]] && ln -sfn "${prefix#/}/lib" "$initdir/lib"
|
||||
|
||||
if [[ $prefix ]]; then
|
||||
for d in bin etc lib "$libdir" sbin tmp usr var; do
|
||||
for d in bin etc lib sbin tmp usr var $libdirs; do
|
||||
strstr "$d" "/" && continue
|
||||
ln -sfn "${prefix#/}/${d#/}" "$initdir/$d"
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ $kernel_only != yes ]]; then
|
||||
for d in bin etc lib "$libdir" sbin tmp usr var var/log usr/bin usr/sbin; do
|
||||
for d in usr/bin usr/sbin bin etc lib sbin tmp usr var var/log var/run var/lock $libdirs; do
|
||||
[[ -e "${initdir}${prefix}/$d" ]] && continue
|
||||
if [ -h "/$d" ]; then
|
||||
inst "/$d" "${prefix}/$d"
|
||||
if [ -L "/$d" ]; then
|
||||
inst_symlink "/$d" "${prefix}/$d"
|
||||
else
|
||||
mkdir -m 0755 -p "${initdir}${prefix}/$d"
|
||||
fi
|
||||
done
|
||||
|
||||
for d in dev proc sys sysroot root run run/lock run/initramfs; do
|
||||
if [ -h "/$d" ]; then
|
||||
inst "/$d"
|
||||
if [ -L "/$d" ]; then
|
||||
inst_symlink "/$d"
|
||||
else
|
||||
mkdir -m 0755 -p "$initdir/$d"
|
||||
fi
|
||||
@@ -651,7 +713,17 @@ else
|
||||
done
|
||||
fi
|
||||
|
||||
mkdir -p "${initdir}/etc/cmdline.d"
|
||||
if [[ $kernel_only != yes ]]; then
|
||||
mkdir -p "${initdir}/etc/cmdline.d"
|
||||
for _d in $hookdirs; do
|
||||
mkdir -m 0755 -p ${initdir}/lib/dracut/hooks/$_d
|
||||
done
|
||||
if [[ "$UID" = "0" ]]; then
|
||||
[ -c ${initdir}/dev/null ] || mknod ${initdir}/dev/null c 1 3
|
||||
[ -c ${initdir}/dev/kmsg ] || mknod ${initdir}/dev/kmsg c 1 11
|
||||
[ -c ${initdir}/dev/console ] || mknod ${initdir}/dev/console c 5 1
|
||||
fi
|
||||
fi
|
||||
|
||||
mods_to_load=""
|
||||
# check all our modules to see if they should be sourced.
|
||||
@@ -659,6 +731,9 @@ mods_to_load=""
|
||||
for_each_module_dir check_module
|
||||
for_each_module_dir check_mount
|
||||
|
||||
strstr "$mods_to_load" "fips" && export DRACUT_FIPS_MODE=1
|
||||
|
||||
_isize=0 #initramfs size
|
||||
modules_loaded=" "
|
||||
# source our modules.
|
||||
for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
|
||||
@@ -667,27 +742,45 @@ for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
|
||||
[[ $show_modules = yes ]] && echo "$_d_mod" || \
|
||||
dinfo "*** Including module: $_d_mod ***"
|
||||
if [[ $kernel_only = yes ]]; then
|
||||
module_installkernel $_d_mod
|
||||
module_installkernel $_d_mod || {
|
||||
dfatal "installkernel failed in module $_d_mod"
|
||||
exit 1
|
||||
}
|
||||
else
|
||||
module_install $_d_mod
|
||||
if [[ $no_kernel != yes ]]; then
|
||||
module_installkernel $_d_mod
|
||||
module_installkernel $_d_mod || {
|
||||
dfatal "installkernel failed in module $_d_mod"
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
fi
|
||||
mods_to_load=${mods_to_load// $_d_mod /}
|
||||
modules_loaded+="$_d_mod "
|
||||
|
||||
#print the module install size
|
||||
if [ -n "$printsize" ]; then
|
||||
_isize_new=$(du -sk ${initdir}|cut -f1)
|
||||
_isize_delta=$(($_isize_new - $_isize))
|
||||
echo "$_d_mod install size: ${_isize_delta}k"
|
||||
_isize=$_isize_new
|
||||
fi
|
||||
fi
|
||||
done
|
||||
unset moddir
|
||||
|
||||
for i in $modules_loaded; do
|
||||
mkdir -p $initdir/lib/dracut
|
||||
echo "$i" >> $initdir/lib/dracut/modules.txt
|
||||
done
|
||||
|
||||
dinfo "*** Including modules done ***"
|
||||
|
||||
## final stuff that has to happen
|
||||
|
||||
# generate module dependencies for the initrd
|
||||
if [[ -d $initdir/lib/modules/$kernel ]] && \
|
||||
! depmod -a -b "$initdir" $kernel; then
|
||||
dfatal "\"depmod -a $kernel\" failed."
|
||||
exit 1
|
||||
if [[ $no_kernel != yes ]]; then
|
||||
dinfo "*** Installing kernel module dependencies and firmware ***"
|
||||
dracut_kernel_post
|
||||
dinfo "*** Installing kernel module dependencies and firmware done ***"
|
||||
fi
|
||||
|
||||
while pop include_src src && pop include_target tgt; do
|
||||
@@ -707,29 +800,35 @@ while pop include_src src && pop include_target tgt; do
|
||||
mkdir -m 0755 -p "$s"
|
||||
chmod --reference="$i" "$s"
|
||||
fi
|
||||
cp -a -t "$s" "$i"/*
|
||||
cp --reflink=auto --sparse=auto -pfLr -t "$s" "$i"/*
|
||||
else
|
||||
cp -a -t "$s" "$i"
|
||||
cp --reflink=auto --sparse=auto -pfLr -t "$s" "$i"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
for item in $install_items; do
|
||||
dracut_install -o "$item"
|
||||
done
|
||||
unset item
|
||||
|
||||
while pop fstab_lines line; do
|
||||
echo "$line 0 0" >> "${initdir}/etc/fstab"
|
||||
done
|
||||
|
||||
for f in $add_fstab; do
|
||||
cat $f >> "${initdir}/etc/fstab"
|
||||
done
|
||||
|
||||
if [[ $kernel_only != yes ]]; then
|
||||
(( ${#install_items[@]} > 0 )) && dracut_install ${install_items[@]}
|
||||
|
||||
while pop fstab_lines line; do
|
||||
echo "$line 0 0" >> "${initdir}/etc/fstab"
|
||||
done
|
||||
|
||||
for f in $add_fstab; do
|
||||
cat $f >> "${initdir}/etc/fstab"
|
||||
done
|
||||
|
||||
if [[ $DRACUT_RESOLVE_LAZY ]] && [[ -x /usr/bin/dracut-install ]]; then
|
||||
dinfo "*** Resolving executable dependencies ***"
|
||||
find "$initdir" -type f \
|
||||
'(' -perm -0100 -or -perm -0010 -or -perm -0001 ')' \
|
||||
-not -path '*.ko' -print0 \
|
||||
| xargs -0 dracut-install ${initdir+-D "$initdir"} -R ${DRACUT_FIPS_MODE+-H}
|
||||
dinfo "*** Resolving executable dependencies done***"
|
||||
fi
|
||||
|
||||
# make sure that library links are correct and up to date
|
||||
for f in /etc/ld.so.conf /etc/ld.so.conf.d/*; do
|
||||
[[ -f $f ]] && inst_simple "$f"
|
||||
@@ -750,7 +849,7 @@ fi
|
||||
|
||||
# strip binaries
|
||||
if [[ $do_strip = yes ]] ; then
|
||||
for p in strip grep find; do
|
||||
for p in strip xargs find; do
|
||||
if ! type -P $p >/dev/null; then
|
||||
derror "Could not find '$p'. You should run $0 with '--nostrip'."
|
||||
do_strip=no
|
||||
@@ -758,33 +857,43 @@ if [[ $do_strip = yes ]] ; then
|
||||
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
|
||||
dinfo "Stripping $f"
|
||||
strip -g "$f" 2>/dev/null|| :
|
||||
if strstr "$modules_loaded" " fips " && command -v prelink >/dev/null; then
|
||||
dinfo "*** pre-unlinking files ***"
|
||||
for dir in "$initdir/bin" \
|
||||
"$initdir/sbin" \
|
||||
"$initdir/usr/bin" \
|
||||
"$initdir/usr/sbin"; do
|
||||
[[ -L "$dir" ]] && continue
|
||||
for i in "$dir"/*; do
|
||||
[[ -L $i ]] && continue
|
||||
[[ -x $i ]] && prelink -u $i &>/dev/null
|
||||
done
|
||||
done
|
||||
dinfo "*** pre-unlinking files done ***"
|
||||
fi
|
||||
|
||||
if [[ $do_strip = yes ]] ; then
|
||||
dinfo "*** Stripping files ***"
|
||||
find "$initdir" -type f \
|
||||
'(' -perm -0100 -or -perm -0010 -or -perm -0001 \
|
||||
-or -path '*/lib/modules/*.ko' ')' -print0 \
|
||||
| xargs -0 strip -g 2>/dev/null
|
||||
dinfo "*** Stripping files done ***"
|
||||
fi
|
||||
|
||||
type hardlink &>/dev/null && {
|
||||
dinfo "*** hardlinking files ***"
|
||||
hardlink "$initdir" 2>&1
|
||||
dinfo "*** hardlinking files done ***"
|
||||
}
|
||||
|
||||
if strstr "$modules_loaded" " fips " && command -v prelink >/dev/null; then
|
||||
for i in $initdir/bin/* \
|
||||
$initdir/sbin/* \
|
||||
$initdir/usr/bin/* \
|
||||
$initdir/usr/sbin/*; do
|
||||
[ -x $i ] && prelink -u $i &>/dev/null
|
||||
done
|
||||
fi
|
||||
|
||||
dinfo "*** Creating image file ***"
|
||||
if ! ( cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet| \
|
||||
$compress > "$outfile"; ); then
|
||||
dfatal "dracut: creation of $outfile failed"
|
||||
exit 1
|
||||
fi
|
||||
dinfo "*** Creating image file done ***"
|
||||
|
||||
dinfo "Wrote $outfile:"
|
||||
dinfo "$(ls -l "$outfile")"
|
90
dracut.spec
90
dracut.spec
@@ -13,7 +13,7 @@ Version: xxx
|
||||
Release: xxx
|
||||
|
||||
Summary: Initramfs generator using udev
|
||||
%if 0%{?fedora} || 0%{?rhel} > 6
|
||||
%if 0%{?fedora} || 0%{?rhel}
|
||||
Group: System Environment/Base
|
||||
%endif
|
||||
%if 0%{?suse_version}
|
||||
@@ -25,24 +25,26 @@ URL: https://dracut.wiki.kernel.org/
|
||||
# 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
|
||||
|
||||
BuildArch: noarch
|
||||
BuildRequires: dash bash git
|
||||
%if 0%{?fedora} || 0%{?rhel} > 6
|
||||
|
||||
%if 0%{?fedora} || 0%{?rhel}
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
%endif
|
||||
%if 0%{?suse_version}
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
%endif
|
||||
|
||||
%if 0%{?fedora} || 0%{?rhel} > 6
|
||||
%if 0%{?fedora} || 0%{?rhel}
|
||||
BuildRequires: docbook-style-xsl docbook-dtds libxslt
|
||||
%endif
|
||||
|
||||
%if 0%{?suse_version}
|
||||
BuildRequires: docbook-xsl-stylesheets libxslt
|
||||
-BuildRequires: docbook-xsl-stylesheets libxslt
|
||||
%endif
|
||||
|
||||
%if 0%{?fedora} > 12 || 0%{?rhel} >= 6
|
||||
BuildRequires: asciidoc
|
||||
|
||||
%if 0%{?fedora} > 12 || 0%{?rhel}
|
||||
# no "provides", because dracut does not offer
|
||||
# all functionality of the obsoleted packages
|
||||
Obsoletes: mkinitrd <= 6.0.93
|
||||
@@ -51,6 +53,10 @@ 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
|
||||
@@ -60,17 +66,23 @@ Obsoletes: dracut-kernel < 005
|
||||
Provides: dracut-kernel = %{version}-%{release}
|
||||
|
||||
Requires: bash
|
||||
Requires: bzip2
|
||||
Requires: coreutils
|
||||
Requires: cpio
|
||||
Requires: filesystem >= 2.1.0
|
||||
Requires: findutils
|
||||
Requires: grep
|
||||
Requires: gzip
|
||||
Requires: hardlink
|
||||
Requires: gzip xz
|
||||
Requires: module-init-tools >= 3.7-9
|
||||
Requires: sed
|
||||
Requires: udev
|
||||
Requires: util-linux >= 2.20
|
||||
Requires: file
|
||||
Requires: udev > 166
|
||||
%if 0%{?fedora} || 0%{?rhel} > 6
|
||||
Requires: util-linux >= 2.21
|
||||
Requires: systemd >= 44-15
|
||||
%else
|
||||
Requires: util-linux-ng >= 2.21
|
||||
%endif
|
||||
|
||||
%if 0%{?fedora} || 0%{?rhel} > 6
|
||||
Conflicts: initscripts < 8.63-1
|
||||
@@ -94,7 +106,7 @@ Provides: dracut-generic = %{version}-%{release}
|
||||
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
|
||||
%if 0%{?fedora} || 0%{?rhel} >= 6
|
||||
%package fips
|
||||
Summary: Dracut modules to build a dracut initramfs with an integrity check
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
@@ -118,7 +130,7 @@ Requires: %{name}-fips = %{version}-%{release}
|
||||
|
||||
%description fips-aesni
|
||||
This package requires everything which is needed to build an
|
||||
all purpose initramfs with dracut, which does an integrity check
|
||||
all purpose initramfs with dracut, which does an integrity check
|
||||
and adds the aesni-intel kernel module.
|
||||
|
||||
%package caps
|
||||
@@ -152,18 +164,21 @@ git am -p1 %{patches}
|
||||
%endif
|
||||
|
||||
%build
|
||||
make
|
||||
make all
|
||||
|
||||
%install
|
||||
%if 0%{?fedora} || 0%{?rhel} > 6
|
||||
%if 0%{?fedora} || 0%{?rhel}
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
%endif
|
||||
make install DESTDIR=$RPM_BUILD_ROOT \
|
||||
libdir=%{_prefix}/lib \
|
||||
bindir=%{_bindir} \
|
||||
%if %{defined _unitdir}
|
||||
systemdsystemunitdir=%{_unitdir} \
|
||||
%endif
|
||||
sysconfdir=/etc mandir=%{_mandir}
|
||||
|
||||
echo %{name}-%{version}-%{release} > $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/10rpmversion/dracut-version
|
||||
echo "DRACUT_VERSION=%{version}-%{release}" > $RPM_BUILD_ROOT/%{dracutlibdir}/dracut-version.sh
|
||||
|
||||
%if 0%{?fedora} == 0 && 0%{?rhel} == 0
|
||||
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/01fips
|
||||
@@ -173,13 +188,21 @@ rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/02fips-aesni
|
||||
# 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
|
||||
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/98selinux
|
||||
%endif
|
||||
|
||||
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} > 6
|
||||
%if 0%{?fedora} || 0%{?rhel}
|
||||
install -m 0644 dracut.conf.d/fedora.conf.example $RPM_BUILD_ROOT/etc/dracut.conf.d/01-dist.conf
|
||||
install -m 0644 dracut.conf.d/fips.conf.example $RPM_BUILD_ROOT/etc/dracut.conf.d/40-fips.conf
|
||||
%endif
|
||||
@@ -212,13 +235,17 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%if 0%{?fedora} > 12 || 0%{?rhel} >= 6 || 0%{?suse_version} > 9999
|
||||
%{_bindir}/mkinitrd
|
||||
%{_bindir}/lsinitrd
|
||||
%{_bindir}/dracut-install
|
||||
%endif
|
||||
%dir %{dracutlibdir}
|
||||
%dir %{dracutlibdir}/modules.d
|
||||
%{dracutlibdir}/dracut-functions.sh
|
||||
%{dracutlibdir}/dracut-functions
|
||||
%{dracutlibdir}/dracut-logger
|
||||
%{dracutlibdir}/dracut-version.sh
|
||||
%{dracutlibdir}/dracut-logger.sh
|
||||
%{dracutlibdir}/dracut-initramfs-restore
|
||||
%config(noreplace) /etc/dracut.conf
|
||||
%if 0%{?fedora} || 0%{?suse_version} || 0%{?rhel} > 6
|
||||
%if 0%{?fedora} || 0%{?suse_version} || 0%{?rhel}
|
||||
%config /etc/dracut.conf.d/01-dist.conf
|
||||
%endif
|
||||
%dir /etc/dracut.conf.d
|
||||
@@ -228,11 +255,13 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%{_mandir}/man5/dracut.conf.5*
|
||||
%{dracutlibdir}/modules.d/00bootchart
|
||||
%{dracutlibdir}/modules.d/00dash
|
||||
%{dracutlibdir}/modules.d/04watchdog
|
||||
%{dracutlibdir}/modules.d/05busybox
|
||||
%{dracutlibdir}/modules.d/10i18n
|
||||
%{dracutlibdir}/modules.d/10rpmversion
|
||||
%{dracutlibdir}/modules.d/30convertfs
|
||||
%{dracutlibdir}/modules.d/45url-lib
|
||||
%{dracutlibdir}/modules.d/50plymouth
|
||||
%{dracutlibdir}/modules.d/80cms
|
||||
%{dracutlibdir}/modules.d/90btrfs
|
||||
%{dracutlibdir}/modules.d/90crypt
|
||||
%{dracutlibdir}/modules.d/90dm
|
||||
@@ -242,6 +271,7 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%{dracutlibdir}/modules.d/90lvm
|
||||
%{dracutlibdir}/modules.d/90mdraid
|
||||
%{dracutlibdir}/modules.d/90multipath
|
||||
%{dracutlibdir}/modules.d/90qemu
|
||||
%{dracutlibdir}/modules.d/91crypt-gpg
|
||||
%{dracutlibdir}/modules.d/95debug
|
||||
%{dracutlibdir}/modules.d/95resume
|
||||
@@ -252,20 +282,31 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%{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/97biosdevname
|
||||
%{dracutlibdir}/modules.d/97masterkey
|
||||
%{dracutlibdir}/modules.d/98ecryptfs
|
||||
%{dracutlibdir}/modules.d/98integrity
|
||||
%{dracutlibdir}/modules.d/98selinux
|
||||
%{dracutlibdir}/modules.d/98integrity
|
||||
%endif
|
||||
%{dracutlibdir}/modules.d/97biosdevname
|
||||
%{dracutlibdir}/modules.d/98ecryptfs
|
||||
%{dracutlibdir}/modules.d/98pollcdrom
|
||||
%{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
|
||||
%config(noreplace) /etc/logrotate.d/dracut_log
|
||||
%attr(0644,root,root) %ghost %config(missingok,noreplace) %{_localstatedir}/log/dracut.log
|
||||
%dir %{_sharedstatedir}/initramfs
|
||||
%if %{defined _unitdir}
|
||||
%{_unitdir}/*.service
|
||||
%{_unitdir}/*.target
|
||||
%{_unitdir}/*/*.service
|
||||
%endif
|
||||
|
||||
%files network
|
||||
%defattr(-,root,root,0755)
|
||||
@@ -273,13 +314,14 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%{dracutlibdir}/modules.d/95fcoe
|
||||
%{dracutlibdir}/modules.d/95iscsi
|
||||
%{dracutlibdir}/modules.d/90livenet
|
||||
%{dracutlibdir}/modules.d/90qemu-net
|
||||
%{dracutlibdir}/modules.d/95nbd
|
||||
%{dracutlibdir}/modules.d/95nfs
|
||||
%{dracutlibdir}/modules.d/95ssh-client
|
||||
%{dracutlibdir}/modules.d/45ifcfg
|
||||
%{dracutlibdir}/modules.d/95znet
|
||||
|
||||
%if 0%{?fedora} || 0%{?rhel} > 6
|
||||
%if 0%{?fedora} || 0%{?rhel}
|
||||
%files fips
|
||||
%defattr(-,root,root,0755)
|
||||
%{dracutlibdir}/modules.d/01fips
|
||||
@@ -297,9 +339,7 @@ rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%files tools
|
||||
%defattr(-,root,root,0755)
|
||||
%{_mandir}/man8/dracut-gencmdline.8*
|
||||
%{_mandir}/man8/dracut-catimages.8*
|
||||
%{_bindir}/dracut-gencmdline
|
||||
%{_bindir}/dracut-catimages
|
||||
%dir /boot/dracut
|
||||
%dir /var/lib/dracut
|
||||
|
729
dracut.xml
729
dracut.xml
@@ -1,729 +0,0 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!-- This document was created with Syntext Serna Free. -->
|
||||
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" []>
|
||||
<book>
|
||||
<title><inlinemediaobject>
|
||||
<imageobject>
|
||||
<imagedata valign="middle" fileref="dracut.png" format="PNG"/>
|
||||
</imageobject>
|
||||
<imageobject>
|
||||
<imagedata valign="middle" fileref="dracut.svg" format="SVG"/>
|
||||
</imageobject>
|
||||
<imageobject>
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="dracut.svg" encoding="UTF-8" parse="xml"/>
|
||||
</imageobject>
|
||||
</inlinemediaobject>dracut</title>
|
||||
<bookinfo>
|
||||
<author>
|
||||
<firstname>Harald</firstname>
|
||||
<surname>Hoyer</surname>
|
||||
</author>
|
||||
<pubdate>2010</pubdate>
|
||||
<edition>Version 1.0</edition>
|
||||
<copyright>
|
||||
<year>2010</year>
|
||||
<holder>Harald Hoyer</holder>
|
||||
</copyright>
|
||||
<legalnotice>
|
||||
<para>
|
||||
This work is licensed under the Creative Commons Attribution/Share-Alike License. To view a copy of this license, visit <ulink url="http://creativecommons.org/licenses/by-sa/3.0/">http://creativecommons.org/licenses/by-sa/3.0/</ulink> or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
|
||||
</para>
|
||||
</legalnotice>
|
||||
</bookinfo>
|
||||
<toc/>
|
||||
<chapter>
|
||||
<chapterinfo>
|
||||
<legalnotice>
|
||||
<para>
|
||||
This section is a modified version of <ulink url="http://en.wikipedia.org/wiki/Initrd">http://en.wikipedia.org/wiki/Initrd</ulink>, which is licensed under the Creative Commons Attribution/Share-Alike License.
|
||||
</para>
|
||||
</legalnotice>
|
||||
</chapterinfo>
|
||||
<title>Introduction</title>
|
||||
<section>
|
||||
<title>Definition</title>
|
||||
<para>An <emphasis>initial ramdisk</emphasis> is a temporary file system used in the boot process of the Linux kernel. <emphasis>initrd</emphasis> and <emphasis>initramfs</emphasis> 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.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Rationale </title>
|
||||
<para>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.
|
||||
</para>
|
||||
<para>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).
|
||||
</para>
|
||||
<para>To further complicate matters, the root file system may be on a software <acronym>RAID</acronym> volume, <acronym>LVM</acronym>, <acronym>NFS</acronym> (on diskless workstations), or on an encrypted partition. All of these require special preparations to mount.
|
||||
</para>
|
||||
<para>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. </para>
|
||||
<para>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.
|
||||
</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Implementation </title>
|
||||
<para>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: </para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>The root file system itself </para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>A boot image on an optical disc
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>A small ext2/ext3 or <acronym>FAT</acronym>-formatted partition on a local disk (a <emphasis>boot partition</emphasis>)</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>A <acronym>TFTP</acronym> server (on systems that can boot from Ethernet) </para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
<para>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.
|
||||
</para>
|
||||
<para>Depending on which algorithms were compiled statically into it, the kernel can currently unpack initrd/initramfs images compressed with gzip, bzip2 and <acronym>LZMA</acronym>. </para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Mount preparations </title>
|
||||
<para>dracut can generate a customized initrams image which contains only whatever is necessary to boot some particular computer, such as <acronym>ATA</acronym>, <acronym>SCSI</acronym> and filesystem kernel modules (host-only mode).</para>
|
||||
<para>dracut can also generate a more generic initramfs image (default mode). </para>
|
||||
<para>dracut's initramfs starts only with the device name of the root file system (or its <acronym>UUID</acronym>) and must discover everything else at boot time. A complex cascade of tasks must be performed to get the root file system mounted: </para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>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. </para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>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. </para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>If the root file system is on NFS, dracut does then: <itemizedlist>
|
||||
<listitem>
|
||||
<para>Bring up the primary network interface. </para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Invoke a DHCP client, with which it can obtain a DHCP lease. </para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Extract the name of the NFS share and the address of the NFS server from the lease. </para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Mount the <acronym>NFS</acronym> share. </para>
|
||||
</listitem>
|
||||
</itemizedlist></para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>If the root file system appears to be on a software <acronym>RAID</acronym> device, there is no way of knowing which devices the <acronym>RAID</acronym> volume spans; the standard <acronym>MD</acronym> utilities must be invoked to scan all available block devices with a raid signature and bring the required ones online. </para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>If the root file system appears to be on a logical volume, the <acronym>LVM</acronym> utilities must be invoked to scan for and activate the volume group containing it. </para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>If the root file system is on an encrypted block device: <itemizedlist>
|
||||
<listitem>
|
||||
<para>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 <acronym>USB</acronym> security dongle). </para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Create a decryption target with the device mapper. </para>
|
||||
</listitem>
|
||||
</itemizedlist></para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
<para>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 <acronym>LVM</acronym>, <acronym>RAID</acronym> or encryption to get at the root file system. </para>
|
||||
<para>When the root file system finally becomes visible: <itemizedlist>
|
||||
<listitem>
|
||||
<para>Any maintenance tasks which cannot run on a mounted root file system are done. </para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>The root file system is mounted read-only. </para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Any processes which must continue running (such as the rd.splash screen helper and its command <acronym>FIFO</acronym>) are hoisted into the newly-mounted root file system. </para>
|
||||
</listitem>
|
||||
</itemizedlist></para>
|
||||
<para>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.
|
||||
</para>
|
||||
</section>
|
||||
</chapter>
|
||||
<chapter>
|
||||
<title>User Manual</title>
|
||||
<section>
|
||||
<title>Creating an initramfs Image</title>
|
||||
<para>To create a initramfs image, the most simple command is:</para>
|
||||
<screen># dracut</screen>
|
||||
<para>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-<replaceable><kernel version></replaceable>.img and contains the kernel modules of the currently active kernel with version <replaceable><kernel version></replaceable>.</para>
|
||||
<para>If the initramfs image already exists, dracut will display an error message, and to overwrite the existing image, you have to use the <option>--force</option> option. </para>
|
||||
<screen># dracut --force</screen>
|
||||
<para>If you want to specify another filename for the resulting image you would issue a command like:</para>
|
||||
<screen># dracut foobar.img</screen>
|
||||
<para>To generate an image for a specific kernel version, the command would be:</para>
|
||||
<screen># dracut foobar.img 2.6.40-1.rc5.f20</screen>
|
||||
<para>A shortcut to generate the image at the default location for a specific kernel version is:</para>
|
||||
<screen># dracut '' 2.6.40-1.rc5.f20</screen>
|
||||
<para>If you want to create lighter, smaller initramfs images, you may want to specify the <option>--host-only</option> or <option>-H</option> 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. The usage of the <option>--host-only</option> option is only for experts and you will have to keep the broken pieces. At least keep a copy of a general purpose image (and corresponding kernel) as a fallback to rescue your system.</para>
|
||||
<section>
|
||||
<title>Inspecting the Contents</title>
|
||||
<para>To see the contents of the image created by dracut, you can use the <command>lsinitrd</command> tool.</para>
|
||||
<screen># lsinitrd /boot/initramfs-$(uname -r).img | less</screen>
|
||||
<para>To display the contents of a file in the initramfs also use the <command>lsinitrd</command> tool:</para>
|
||||
<screen># lsinitrd /boot/initramfs-$(uname -r).img /etc/ld.so.conf
|
||||
include ld.so.conf.d/*.conf</screen>
|
||||
</section>
|
||||
<section>
|
||||
<title>Adding dracut Modules</title>
|
||||
<para>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 <filename>/etc/dracut.conf</filename> or <filename>/etc/dracut.conf.d/myconf.conf</filename>. See the man page <xref linkend="dracutconf5"/>. You can also add dracut modules on the command line by using the <option>-a</option> or <option>--add</option> option:</para>
|
||||
<screen># dracut --add bootchart initramfs-bootchart.img</screen>
|
||||
<para>To see a list of available dracut modules, use the <option>--list-modules</option> option:</para>
|
||||
<screen># dracut --list-modules</screen>
|
||||
<para>or, if you have a dracut version earlier than <literal>008</literal>, issue the command:</para>
|
||||
<screen># for mod in /usr/lib/dracut/modules.d/*; do echo ${mod##*/??}; done</screen>
|
||||
</section>
|
||||
<section>
|
||||
<title>Omitting dracut Modules</title>
|
||||
<para>Sometimes you don't want a dracut module to be included for reasons of speed, size or functionality. To do this, either specify the <envar>omit_dracutmodules</envar> variable in the <filename>dracut.conf</filename> or <filename>/etc/dracut.conf.d/myconf.conf</filename> configuration file (see man page <xref linkend="dracutconf5"/>), or use the <option>-o</option> or <option>--omit</option> option on the command line:</para>
|
||||
<screen># dracut -o "multipath lvm" no-multipath-lvm.img</screen>
|
||||
</section>
|
||||
<section>
|
||||
<title>Adding Kernel Modules</title>
|
||||
<para>If you need a special kernel module in the initramfs, which is not automatically picked up by dracut, you have the use the <option>--add-drivers</option> option on the command line or the drivers vaiable in the <filename>/etc/dracut.conf</filename> or <filename>/etc/dracut.conf.d/myconf.conf</filename> configuration file (see man page <xref linkend="dracutconf5"/>):</para>
|
||||
<screen># dracut --add-drivers mymod initramfs-with-mymod.img</screen>
|
||||
</section>
|
||||
</section>
|
||||
<section>
|
||||
<title>Boot parameters</title>
|
||||
<para>The generated initramfs.img file normally 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 <varname>LABEL</varname> or <varname>UUID</varname> on the kernel command line for your root device, dracut will find it and boot from it.</para>
|
||||
<para>The kernel command line usually can be configured in <filename>/boot/grub/grub.conf</filename>, if grub is your bootloader and it also can be edited in the real boot process in the grub menu.</para>
|
||||
<para>The kernel command line can also be provided by the dhcp server with the root-path option. See <xref linkend="NetworkBoot"/>.</para>
|
||||
<para>For a full reference of all kernel command line parameters, see the <xref linkend="dracutconf5"/> or <xref linkend="dracut8"/> man page.</para>
|
||||
<section>
|
||||
<title>Specifying the root Device</title>
|
||||
<para>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 <envar>root=</envar> option. The most basic one is <envar>root=<replaceable><path to device node></replaceable></envar>:</para>
|
||||
<screen>root=/dev/sda2</screen>
|
||||
<para>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:</para>
|
||||
<screen>root=UUID=19e9dda3-5a38-484d-a9b0-fa6b067d0331</screen>
|
||||
<para>or</para>
|
||||
<screen>root=LABEL=myrootpartitionlabel</screen>
|
||||
<para>To see all <envar>UUID</envar>s or <envar>LABEL</envar>s on your system, do:</para>
|
||||
<screen># ls -l /dev/disk/by-uuid</screen>
|
||||
<para>or</para>
|
||||
<screen># ls -l /dev/disk/by-label</screen>
|
||||
<para>If your root partition is on the network see <xref linkend="NetworkBoot"/>.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Keyboard Settings</title>
|
||||
<para>If you have to input passwords for encrypted disk volumes, you might want to set the keyboard layout and specify a display font.</para>
|
||||
<para>A typical german kernel command would contain:</para>
|
||||
<screen>vconsole.font=latarcyrheb-sun16 vconsole.keymap=de-latin1-nodeadkeys locale.LANG=de_DE.UTF-8</screen>
|
||||
<para>Setting these options can override the setting stored on your system, if you use a modern init system, like systemd.</para>
|
||||
<para>For dracut versions prior to version <literal>008</literal> the line would look like:</para>
|
||||
<screen>LANG=de_DE.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=de-latin1-nodeadkeys</screen>
|
||||
</section>
|
||||
<section>
|
||||
<title>Blacklisting Kernel Modules</title>
|
||||
<para>Sometimes it is required to prevent the automatic kernel module loading of a specific kernel module. To do this, just add <envar>rd.blacklist=<replaceable><kernel module name></replaceable></envar>, with <replaceable><kernel module name></replaceable> not containing the <filename>.ko</filename> suffix, to the kernel command line. For example:</para>
|
||||
<screen>rd.blacklist=mptsas rd.blacklist=nouveau</screen>
|
||||
<para>The option can be specified multiple times on the kernel command line.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Speeding up the Boot Process</title>
|
||||
<para>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 <acronym>LVM</acronym> volume or not on a raid partition, or that it lives inside a specific crypto <acronym>LUKS</acronym> encrypted volume. By default, dracut searches everywhere. A typical dracut kernel command line for a plain primary or logical partition would contain:</para>
|
||||
<screen>rd.luks=0 rd.lvm=0 rd.md=0 rd.dm=0</screen>
|
||||
<para>on systems with dracut version prior to <literal>008</literal> the line would look like:</para>
|
||||
<screen>rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM</screen>
|
||||
<para>This turns off every automatic assembly of <acronym>LVM</acronym>, <acronym>MD</acronym> raids, <acronym>DM</acronym> raids and crypto <acronym>LUKS</acronym>.</para>
|
||||
<para>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.</para>
|
||||
</section>
|
||||
<section id="Injecting">
|
||||
<title>Injecting custom Files</title>
|
||||
<para>To add your own files to the initramfs image, you have several possibilities.</para>
|
||||
<para>The <option>--include</option> option let you specify a source path and a target path. For example</para>
|
||||
<screen># dracut --include cmdline-preset /etc/cmdline initramfs-cmdline-pre.img</screen>
|
||||
<para>will create an initramfs image, where the file cmdline-preset will be copied inside the initramfs to <filename>/etc/cmdline</filename>. <option>--include</option> can only be specified once.</para>
|
||||
<screen># mkdir rd.live.overlay
|
||||
# mkdir rd.live.overlay/etc
|
||||
# mkdir rd.live.overlay/etc/conf.d
|
||||
# echo "ip=auto" >> rd.live.overlay/etc/cmdline
|
||||
# echo export TESTVAR=testtest >> rd.live.overlay/etc/conf.d/testvar.conf
|
||||
# echo export TESTVAR=testtest >> rd.live.overlay/etc/conf.d/testvar.conf
|
||||
# tree rd.live.overlay/
|
||||
rd.live.overlay/
|
||||
└── etc
|
||||
├── cmdline
|
||||
└── conf.d
|
||||
└── testvar.conf
|
||||
# dracut --include rd.live.overlay / initramfs-rd.live.overlay.img</screen>
|
||||
<para>This will put the contents of the rd.live.overlay directory into the root of the initramfs image.</para>
|
||||
<para>The <option>--install</option> 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.</para>
|
||||
<screen># dracut --install 'strace fsck.ext3 ssh' initramfs-dbg.img</screen>
|
||||
<para>This will create an initramfs with the <command>strace</command>, <command>fsck.ext3</command> and <command>ssh</command> executables, together with the libraries needed to start those. The <option>--install</option> option can be specified multiple times.</para>
|
||||
</section>
|
||||
</section>
|
||||
<section id="NetworkBoot">
|
||||
<title>Network Boot</title>
|
||||
<para>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.</para>
|
||||
<para>On a Red Hat Enterprise Linux or Fedora system, this means, you have to install the <filename>dracut-network</filename> rpm package:</para>
|
||||
<screen># yum install dracut-network</screen>
|
||||
<para>The resulting initramfs image can be served by a boot manager residing on your local hard drive or it can be served by a <acronym>PXE</acronym>/<acronym>TFTP</acronym> server.</para>
|
||||
<para>How to setup your <acronym>PXE</acronym>/<acronym>TFTP</acronym> server can be found in the <ulink url="http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/">Red Hat Enterprise Linux Storage Administration Guide</ulink>.</para>
|
||||
<para>If you specify <envar>rd.ip=auto</envar> 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 <acronym>TFTP</acronym>/<acronym>DHCP</acronym> server. If you can't pass a kernel command line, then you can inject <filename>/etc/cmdline</filename>, with a method described in <xref linkend="Injecting"/>.
|
||||
</para>
|
||||
<section>
|
||||
<title>Reducing the Image Size</title>
|
||||
<para>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.</para>
|
||||
<para>You can also specify the exact dracut and kernel modules to produce a very tiny initramfs image.</para>
|
||||
<para>For example for a <acronym>NFS</acronym> image, you would do:</para>
|
||||
<screen># dracut -m "nfs network base" initramfs-nfs-only.img</screen>
|
||||
<para>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 <option>--host-only</option> option:</para>
|
||||
<screen># dracut -m "nfs network base" --host-only initramfs-nfs-host-only.img</screen>
|
||||
<para>This will reduce the size of the initramfs image significantly.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>NFS Root Device</title>
|
||||
<para/>
|
||||
</section>
|
||||
<section>
|
||||
<title>iSCSI Root Device</title>
|
||||
<para>
|
||||
</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>FCoE Root Device</title>
|
||||
<para>
|
||||
</para>
|
||||
</section>
|
||||
</section>
|
||||
<section>
|
||||
<title>Troubleshooting</title>
|
||||
<para>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: <ulink url="http://fedoraproject.org/wiki/How_to_debug_Dracut_problems">http://fedoraproject.org/wiki/How_to_debug_Dracut_problems</ulink></para>
|
||||
<section id="identifying-your-problem-area">
|
||||
<title>Identifying your problem area</title>
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>Remove ''rhgb'' and ''quiet'' from the kernel command line
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Add ''rd.shell'' to the kernel command line. This will present a shell should dracut be unable to locate your root device
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Add ''rd.shell rd.debug'' to the kernel command line so that dracut shell commands are printed as they are executed
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>With dracut >= 002-11, you can inspect the rd.debug output with:
|
||||
</para>
|
||||
<screen># less /run/initramfs/init.log
|
||||
# dmesg | less</screen>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
</section>
|
||||
<section id="information-to-include-in-your-report">
|
||||
<title id="information-to-include-in-your-report-title">Information to include in your report</title>
|
||||
<section id="all-bug-reports">
|
||||
<title id="all-bug-reports-title">All bug reports</title>
|
||||
<para>In all cases, the following should be mentioned and attached to your bug report:
|
||||
</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>The exact kernel command-line used. Typically from the bootloader configuration file (e.g. <filename>/etc/grub.conf</filename>) or from <filename>/proc/cmdline</filename>.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>A copy of your disk partition information from <filename>/etc/fstab</filename>, which might be obtained booting an old working initramfs or a rescue medium.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>A device listing from device-mapper. This can be obtained by running the command <screen># dmsetup ls --tree</screen></para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>A list of block device attributes including vol_id compatible mode. This can be obtained by running the commands: <screen># blkid -p
|
||||
# blkid -p -o udev</screen></para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Turn on dracut debugging (see <filename>the 'debugging dracut' section</filename>), and attach all relevant information from the boot log. This can be obtained by running the command <screen># dmesg|grep dracut</screen></para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>If you use a dracut configuration file, please include <filename>/etc/dracut.conf</filename>
|
||||
and all files in <filename>/etc/dracut.conf.d/*.conf</filename></para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
<section id="logical-volume-management-related-problems">
|
||||
<title id="logical-volume-management-related-problems-title">Logical Volume Management related problems</title>
|
||||
<para>As well as the information from <xref linkend="all-bug-reports"/> include the following information:
|
||||
</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>Include physical volume information by running the command: <screen># lvm pvdisplay</screen></para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Include volume group information by running the command: <screen># lvm vgdisplay</screen></para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Include logical volume information by running the command: <screen># lvm lvdisplay</screen></para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
<section id="software-raid-related-problems">
|
||||
<title id="software-raid-related-problems-title">Software RAID related problems</title>
|
||||
<para>As well as the information from <xref linkend="all-bug-reports"/>, include the following information:
|
||||
</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>If using software RAID disk partitions, please include the output of <screen># cat /proc/mdstat</screen></para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
<section id="network-root-device-related-problems">
|
||||
<title id="network-root-device-related-problems-title">Network root device related problems</title>
|
||||
<para>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 <xref linkend="all-bug-reports"/>, include the following information:
|
||||
</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>Please include the output of <screen># /sbin/ifup <replaceable><interfacename></replaceable>
|
||||
# ip addr show</screen></para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
</section>
|
||||
<section id="debugging-dracut">
|
||||
<title id="debugging-dracut-title">Debugging dracut</title>
|
||||
<section id="configure-a-serial-console">
|
||||
<title id="configure-a-serial-console-title">Configure a serial console</title>
|
||||
<para>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.
|
||||
</para>
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>First, enable serial console output for both the kernel and the bootloader.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Open the file <filename>/etc/grub.conf</filename> for editing. Below the line ''timeout=5'', add the following:
|
||||
<screen>serial --unit=0 --speed=9600
|
||||
terminal --timeout=5 serial console</screen></para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Also in <filename>/etc/grub.conf</filename>, add the following boot arguemnts to the ''kernel'' line:
|
||||
<screen>console=tty0 console=ttyS0,9600</screen></para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>When finished, the <filename>/etc/grub.conf</filename> file should look similar to the example below.
|
||||
<screen>default=0
|
||||
timeout=5
|
||||
serial --unit=0 --speed=9600
|
||||
terminal --timeout=5 serial console
|
||||
title Fedora (2.6.29.5-191.fc11.x86_64)
|
||||
root (hd0,0)
|
||||
kernel /vmlinuz-2.6.29.5-191.fc11.x86_64 ro root=/dev/mapper/vg_uc1-lv_root console=tty0 console=ttyS0,9600
|
||||
initrd /dracut-2.6.29.5-191.fc11.x86_64.img</screen></para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>More detailed information on how to configure the kernel for console output can be found at <ulink url="http://www.faqs.org/docs/Linux-HOWTO/Remote-Serial-Console-HOWTO.html#CONFIGURE-KERNEL">http://www.faqs.org/docs/Linux-HOWTO/Remote-Serial-Console-HOWTO.html#CONFIGURE-KERNEL</ulink>.
|
||||
</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
<note>
|
||||
<title>Redirecting non-interactive output</title>
|
||||
<para>You can redirect all non-interactive output to <filename>/dev/kmsg</filename> and the kernel will put it out on the console when it reaches the kernel buffer by doing<screen># exec >/dev/kmsg 2>&1 </dev/console</screen></para>
|
||||
</note>
|
||||
</section>
|
||||
<section id="using-the-dracut-shell">
|
||||
<title id="using-the-dracut-shell-title">Using the dracut shell</title>
|
||||
<para>Dracut offers a shell for interactive debugging in the event dracut fails to locate your root filesystem. To enable the shell:
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>Add the boot parameter ''rd.shell'' to your bootloader configuration file (e.g. <filename>/etc/grub.conf</filename>)</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Remove the boot arguments ''rhgb'' and ''quiet''
|
||||
</para>
|
||||
<para>
|
||||
A sample <filename>/etc/grub.conf</filename> bootloader configuration file is listed below.
|
||||
</para>
|
||||
<para><screen>default=0
|
||||
timeout=5
|
||||
serial --unit=0 --speed=9600
|
||||
terminal --timeout=5 serial console
|
||||
title Fedora (2.6.29.5-191.fc11.x86_64)
|
||||
root (hd0,0)
|
||||
kernel /vmlinuz-2.6.29.5-191.fc11.x86_64 ro root=/dev/mapper/vg_uc1-lv_root console=tty0 rd.shell
|
||||
initrd /dracut-2.6.29.5-191.fc11.x86_64.img</screen></para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>If system boot fails, you will be dropped into a shell as seen in the example below.
|
||||
<screen>No root device found
|
||||
Dropping to debug shell.
|
||||
|
||||
sh: can't access tty; job control turned off
|
||||
|
||||
# </screen></para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Use this shell prompt to gather the information requested above (see <xref linkend="all-bug-reports"/>).
|
||||
</para>
|
||||
</listitem>
|
||||
</orderedlist></para>
|
||||
</section>
|
||||
<section id="accessing-the-root-volume-from-the-dracut-shell">
|
||||
<title id="accessing-the-root-volume-from-the-dracut-shell-title">Accessing the root volume from the dracut shell</title>
|
||||
<para>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:
|
||||
</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>A block device (e.g. <filename>/dev/sda7</filename>)
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>A LVM logical volume (e.g. <filename>/dev/VolGroup00/LogVol00</filename>)
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>An encrypted device (e.g. <filename>/dev/mapper/luks-4d5972ea-901c-4584-bd75-1da802417d83</filename>)
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>A network attached device (e.g. netroot=iscsi:@192.168.0.4::3260::iqn.2009-02.org.fedoraproject:for.all)
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
<para>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 <filename>/dev/root</filename> 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. </para>
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>Inspect your partitions using <command>parted</command><screen># 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</screen></para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>You recall that your root volume was a LVM logical volume. Scan and activate any logical volumes.
|
||||
<screen># lvm vgscan
|
||||
# lvm vgchange -ay</screen></para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>You should see any logical volumes now using the command <command>blkid</command>:
|
||||
<screen># 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"
|
||||
</screen></para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>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.
|
||||
<screen># 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. </screen></para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Next, make a symbolic link to the unlocked root volume
|
||||
<screen># ln -s /dev/mapper/luks-$UUID /dev/root</screen></para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>With the root volume available, you may continue booting the system by exiting the dracut shell
|
||||
<screen># exit</screen></para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
</section>
|
||||
<section id="additional-dracut-boot-parameters">
|
||||
<title id="additional-dracut-boot-parameters-title">Additional dracut boot parameters</title>
|
||||
<para>For more debugging options, see <xref linkend="dracut-kernel-debug"/> in the man page <xref linkend="dracutkernel7"/>.</para>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
</chapter>
|
||||
<chapter>
|
||||
<title>Developer Manual</title>
|
||||
<section>
|
||||
<title>dracut Components</title>
|
||||
<para>dracut uses a modular system to build and extend the initramfs image. All modules are located in <filename>/usr/lib/dracut/modules.d</filename> or in <filename><replaceable><git-src></replaceable>/modules.d</filename>. The most basic dracut module is <filename>99base</filename>. In <filename>99base</filename> the initial shell script <command>init</command> is defined, which gets run by the kernel after initramfs loading. Although you can replace <command>init</command> with your own version of <filename>99base</filename>, 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 <xref linkend="stages"/>.</para>
|
||||
<para>The main script, which creates the initramfs is <command>dracut</command> itsself. It parses all arguments and sets up the directory, in which everything is installed. It then executes all <command>check</command>, <command>install</command>, <command>installkernel</command> 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 <command>check</command>, <command>install</command> and <command>installkernel</command> are found in in the file <filename>dracut-functions</filename>. These shell functions are available to all module installer (<command>install</command>, <command>installkernel</command>) scripts, without the need to source <filename>dracut-functions</filename>.</para>
|
||||
<para>A module can check the preconditions for <command>install</command> and <command>installkernel</command> with the <command>check</command> script. Also dependencies can be expressed with <command>check</command>. If a module passed <command>check</command>, <command>install</command> and <command>installkernel</command> 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 <command>installkernel</command>. All other files found in a module directory are module specific and mostly are hook scripts and udev rules.</para>
|
||||
</section>
|
||||
<section id="stages">
|
||||
<title>Boot Process Stages</title>
|
||||
<para>The <command>init</command> script in <filename>99base</filename> is the main script, which prepares the root file system for usage, runs udev, mounts the real root device, kills the remaining processes, and switches to the real root device for further booting. 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 <command>init</command>.
|
||||
Common used functions are in <filename>dracut-lib.sh</filename>, which can be sourced by any script. </para>
|
||||
<section>
|
||||
<title>Basic Setup</title>
|
||||
<para>The first thing <command>init</command> does, is to mount <filename>/proc</filename> and <filename>/sys</filename> and manually create the basic device nodes and symbolic links in <filename>/dev</filename> needed to execute basic commands. Then logging is setup according to kernel command line arguments. <filename>/dev/pts</filename> and <filename>/dev/shm</filename> are mounted and the first hook is sourced.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Hook: cmdline</title>
|
||||
<para>The <literal>
|
||||
<function>cmdline</function>
|
||||
</literal> 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.</para>
|
||||
<para>In this hook the most important environment variable is defined: <envar>root</envar>. The second one is <envar>rootok</envar>, which indicates, that a module claimed to be able to parse the <envar>root</envar> defined. So for example, <envar>root=</envar><replaceable>iscsi:....</replaceable> will be claimed by the <function>iscsi</function> dracut module, which then sets <envar>rootok</envar>.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Hook: pre-udev</title>
|
||||
<para>This hook is executed right after the <function>cmdline</function> hook and a check if <envar>root</envar> and <envar>rootok</envar> were set. Here modules can take action with the final <envar>root</envar>, and before <command>udev</command> has been run.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Start Udev</title>
|
||||
<para>Now <command>udev</command> is started and the logging for <command>udev</command> is setup.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Hook: pre-trigger</title>
|
||||
<para>In this hook, you can set udev environment variables with <code>udevadm control --property=<envar>KEY</envar>=<replaceable>value</replaceable></code> or control the further execution of <command>udev</command> with <command>udevadm</command>.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Trigger Udev</title>
|
||||
<para><command>udev</command> is triggered by calling <command>udevadm trigger</command>, which sends <constant>add</constant> events for all devices and subsystems.
|
||||
</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Main Loop</title>
|
||||
<para>Now the main loop of <command>99base/init</command> begins. Here we loop until <command>udev</command> has settled and all scripts in <filename>initqueue/finished</filename> returned true. In this loop there are three hooks, where scripts can be inserted by calling <command>/sbin/initqueue</command>.
|
||||
</para>
|
||||
<section>
|
||||
<title>Initqueue</title>
|
||||
<para>This hook gets executed every time a script is inserted here, regardless of the <command>udev</command> state.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Initqueue settled</title>
|
||||
<para>This hooks gets executed every time <command>udev</command> has settled.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Initqueue timeout</title>
|
||||
<para>This hooks gets executed, when the main loop counter becomes half of the rd.retry counter.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Initqueue finished</title>
|
||||
<para>This hook is called after <command>udev</command> has settled and if all scripts herein return <errorcode>0</errorcode> the main loop will be ended.</para>
|
||||
</section>
|
||||
</section>
|
||||
<section>
|
||||
<title>Hook: pre-mount</title>
|
||||
<para>Before the root device is mounted all scripts in the hook pre-mount are executed. In some cases (e.g. <acronym>NFS</acronym>) the real root device is already mounted, though.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Hook: mount</title>
|
||||
<para>This hook is mainly to mount the real root device.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Hook: pre-pivot</title>
|
||||
<para>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.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Cleanup and switch_root</title>
|
||||
<para>Init kills all <command>udev</command> processes, cleans up the environment, sets up the arguments for the real <command>init</command> process and finally calls <command>switch_root</command>. <command>switch_root</command> removes the whole filesystem hierarchy of the initramfs, chroot()s to the real root device and calls <command>/sbin/init</command> with the specified arguments.</para>
|
||||
<para>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.</para>
|
||||
</section>
|
||||
</section>
|
||||
<section>
|
||||
<title>Network Infrastructure</title>
|
||||
<para>
|
||||
</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Writing a Module</title>
|
||||
<para>A simple example module is <filename>96insmodpost</filename>, which modprobes a kernel module after udev has settled and the basic device drivers have been loaded.</para>
|
||||
<para>All module installation information is in the file module-setup.sh.</para>
|
||||
<para>First we create a <function>check()</function> function, which just exits with <errorcode>0</errorcode> indicating that this module should be included by default.</para>
|
||||
<para><function>check()</function>:</para>
|
||||
<programlisting>return 0</programlisting>
|
||||
<para>The we create the <function>install()</function> function, which installs a cmdline hook with priority number 20 called <filename>parse-insmodpost.sh</filename>. It also installs the <filename>insmodpost.sh</filename> script in <filename>/sbin</filename>.</para>
|
||||
<para><function>install()</function>:</para>
|
||||
<programlisting>inst_hook cmdline 20 "$moddir/parse-insmodpost.sh"
|
||||
inst_simple "$moddir/insmodpost.sh" /sbin/insmodpost.sh</programlisting>
|
||||
<para>The <filename>pase-instmodpost.sh</filename> parses the kernel command line for a argument <envar>rd.driver.post</envar>, blacklists the module from being autoloaded and installs the hook <filename>insmodpost.sh</filename> in the <filename>initqueue/settled</filename>.</para>
|
||||
<para><filename>parse-insmodpost.sh</filename>:</para>
|
||||
<programlisting>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
|
||||
</programlisting>
|
||||
<para><filename>insmodpost.sh</filename>, which is called in the <filename>initqueue/settled</filename> hook will just modprobe the kernel modules specified in all <envar>rd.driver.post</envar> kernel command line parameters. It runs after <command>udev</command> has settled and is only called once (<parameter>--onetime</parameter>).</para>
|
||||
<para><filename>insmodpost.sh</filename>:</para>
|
||||
<programlisting>. /lib/dracut-lib.sh
|
||||
|
||||
for p in $(getargs rd.driver.post=); do
|
||||
modprobe $p
|
||||
done
|
||||
</programlisting>
|
||||
<section>
|
||||
<title>check()</title>
|
||||
<para><filename>
|
||||
<function>check()</function>
|
||||
</filename> is called by dracut to evaluate the inclusion of a dracut module in the initramfs.</para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term> $hostonly</term>
|
||||
<listitem>
|
||||
<para>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.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
<para><function>check()</function> should return with:</para>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term>0</term>
|
||||
<listitem>
|
||||
<para>Include the dracut module in the initramfs.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>1</term>
|
||||
<listitem>
|
||||
<para>Do not include the dracut module. The requirements are not fullfilled (missing tools, etc.)</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>255</term>
|
||||
<listitem>
|
||||
<para>Only include the dracut module, if another module requires it or if explicitly specified in the config file or on the argument list.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</section>
|
||||
<section>
|
||||
<title>depends()</title>
|
||||
<para>The function <function>depends()</function> should <function>echo</function> all other dracut module names the module depends on.</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>install()</title>
|
||||
<para>dracut_install</para>
|
||||
<para>inst</para>
|
||||
<para>inst_hook</para>
|
||||
<para>inst_rules</para>
|
||||
<para/>
|
||||
</section>
|
||||
<section>
|
||||
<title>installkernel()</title>
|
||||
<para>instmods</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Creation Functions</title>
|
||||
<para>
|
||||
</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Initramfs Functions</title>
|
||||
<para>
|
||||
</para>
|
||||
</section>
|
||||
<section>
|
||||
<title>Network Modules</title>
|
||||
<para>
|
||||
</para>
|
||||
</section>
|
||||
</section>
|
||||
</chapter>
|
||||
<appendix>
|
||||
<title>Man Pages</title>
|
||||
<section id="dracut.man">
|
||||
<title>dracut</title>
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="dracut.8.xml" encoding="UTF-8" parse="xml"/>
|
||||
</section>
|
||||
<section id="dracut.conf">
|
||||
<title>dracut.conf</title>
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="dracut.conf.5.xml" encoding="UTF-8" parse="xml"/>
|
||||
</section>
|
||||
<section id="dracut.cmdline">
|
||||
<title>dracut.cmdline</title>
|
||||
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="dracut.cmdline.7.xml" encoding="UTF-8" parse="xml"/>
|
||||
</section>
|
||||
</appendix>
|
||||
</book>
|
@@ -20,7 +20,7 @@ sub create_patches {
|
||||
my $tag=shift;
|
||||
my $pdir=shift;
|
||||
my $num=0;
|
||||
open( GIT, 'git format-patch -N --no-signature -o "'.$pdir.'" '.$tag.' |');
|
||||
open( GIT, 'git format-patch -M -N --no-signature -o "'.$pdir.'" '.$tag.' |');
|
||||
@lines=<GIT>;
|
||||
close GIT; # be done
|
||||
return @lines;
|
||||
|
17
install/Makefile
Normal file
17
install/Makefile
Normal file
@@ -0,0 +1,17 @@
|
||||
prefix ?= /usr
|
||||
bindir ?= ${prefix}/bin
|
||||
strip ?= -s
|
||||
|
||||
all: dracut-install
|
||||
|
||||
dracut-install: dracut-install.c hashmap.c log.c util.c
|
||||
gcc -std=gnu99 -O2 -g -Wall -o dracut-install dracut-install.c hashmap.c log.c util.c
|
||||
|
||||
install: dracut-install
|
||||
install $(strip) -m 0755 dracut-install $(DESTDIR)$(bindir)/dracut-install
|
||||
|
||||
clean:
|
||||
rm -f dracut-install *~
|
||||
|
||||
indent:
|
||||
indent -i8 -nut -br -linux -l120 dracut-install.c
|
736
install/dracut-install.c
Normal file
736
install/dracut-install.c
Normal file
@@ -0,0 +1,736 @@
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
/* dracut-install.c -- install files and executables
|
||||
|
||||
Copyright (C) 2012 Harald Hoyer
|
||||
Copyright (C) 2012 Red Hat, Inc. All rights reserved.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
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.
|
||||
|
||||
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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define PROGRAM_VERSION_STRING "1"
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#include <libgen.h>
|
||||
#include <limits.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "log.h"
|
||||
#include "hashmap.h"
|
||||
#include "util.h"
|
||||
|
||||
static bool arg_hmac = false;
|
||||
static bool arg_createdir = false;
|
||||
static int arg_loglevel = -1;
|
||||
static bool arg_optional = false;
|
||||
static bool arg_all = false;
|
||||
static bool arg_resolvelazy = false;
|
||||
static bool arg_resolvedeps = false;
|
||||
static char *destrootdir = NULL;
|
||||
|
||||
static Hashmap *items = NULL;
|
||||
static Hashmap *items_failed = NULL;
|
||||
|
||||
static int dracut_install(const char *src, const char *dst, bool isdir, bool resolvedeps);
|
||||
|
||||
static size_t dir_len(char const *file)
|
||||
{
|
||||
size_t length;
|
||||
/* Strip the basename and any redundant slashes before it. */
|
||||
for (length = strlen(file); 0 < length; length--)
|
||||
if (file[length] == '/')
|
||||
break;
|
||||
return length;
|
||||
}
|
||||
|
||||
static char *convert_abs_rel(const char *from, const char *target)
|
||||
{
|
||||
/* we use the 4*MAXPATHLEN, which should not overrun */
|
||||
char relative_from[MAXPATHLEN * 4];
|
||||
char *realtarget = NULL;
|
||||
char *p, *q;
|
||||
const char *realfrom = from;
|
||||
int level = 0, fromlevel = 0, targetlevel = 0;
|
||||
int l, i, rl;
|
||||
int dirlen;
|
||||
|
||||
p = strdup(target);
|
||||
dirlen = dir_len(p);
|
||||
p[dirlen] = '\0';
|
||||
q = realpath(p, NULL);
|
||||
|
||||
if (q == NULL) {
|
||||
free(p);
|
||||
log_warning("convert_abs_rel(): target '%s' directory has no realpath.", target);
|
||||
return strdup(from);
|
||||
}
|
||||
|
||||
asprintf(&realtarget, "%s/%s", q, &p[dirlen + 1]);
|
||||
free(p);
|
||||
free(q);
|
||||
|
||||
/* now calculate the relative path from <from> to <target> and
|
||||
store it in <relative_from>
|
||||
*/
|
||||
relative_from[0] = 0;
|
||||
rl = 0;
|
||||
|
||||
/* count the pathname elements of realtarget */
|
||||
for (targetlevel = 0, i = 0; realtarget[i]; i++)
|
||||
if (realtarget[i] == '/')
|
||||
targetlevel++;
|
||||
|
||||
/* count the pathname elements of realfrom */
|
||||
for (fromlevel = 0, i = 0; realfrom[i]; i++)
|
||||
if (realfrom[i] == '/')
|
||||
fromlevel++;
|
||||
|
||||
/* count the pathname elements, which are common for both paths */
|
||||
for (level = 0, i = 0; realtarget[i] && (realtarget[i] == realfrom[i]); i++)
|
||||
if (realtarget[i] == '/')
|
||||
level++;
|
||||
|
||||
free(realtarget);
|
||||
|
||||
/* add "../" to the relative_from path, until the common pathname is
|
||||
reached */
|
||||
for (i = level; i < targetlevel; i++) {
|
||||
if (i != level)
|
||||
relative_from[rl++] = '/';
|
||||
relative_from[rl++] = '.';
|
||||
relative_from[rl++] = '.';
|
||||
}
|
||||
|
||||
/* set l to the next uncommon pathname element in realfrom */
|
||||
for (l = 1, i = 1; i < level; i++)
|
||||
for (l++; realfrom[l] && realfrom[l] != '/'; l++) ;
|
||||
/* skip next '/' */
|
||||
l++;
|
||||
|
||||
/* append the uncommon rest of realfrom to the relative_from path */
|
||||
for (i = level; i <= fromlevel; i++) {
|
||||
if (rl)
|
||||
relative_from[rl++] = '/';
|
||||
while (realfrom[l] && realfrom[l] != '/')
|
||||
relative_from[rl++] = realfrom[l++];
|
||||
l++;
|
||||
}
|
||||
|
||||
relative_from[rl] = 0;
|
||||
return strdup(relative_from);
|
||||
}
|
||||
|
||||
static int ln_r(const char *src, const char *dst)
|
||||
{
|
||||
int ret;
|
||||
const char *points_to = convert_abs_rel(src, dst);
|
||||
log_info("ln -s '%s' '%s'", points_to, dst);
|
||||
ret = symlink(points_to, dst);
|
||||
|
||||
if (ret != 0) {
|
||||
log_error("ERROR: ln -s '%s' '%s': %m", points_to, dst);
|
||||
free((char *)points_to);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free((char *)points_to);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cp(const char *src, const char *dst)
|
||||
{
|
||||
int pid;
|
||||
int status;
|
||||
|
||||
pid = fork();
|
||||
if (pid == 0) {
|
||||
execlp("cp", "cp", "--reflink=auto", "--sparse=auto", "--preserve=mode", "-fL", src, dst, NULL);
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
while (waitpid(pid, &status, 0) < 0) {
|
||||
if (errno != EINTR) {
|
||||
status = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int resolve_deps(const char *src)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
char *buf = malloc(LINE_MAX);
|
||||
size_t linesize = LINE_MAX;
|
||||
FILE *fptr;
|
||||
char *cmd;
|
||||
|
||||
if (strstr(src, ".so") == 0) {
|
||||
int fd;
|
||||
fd = open(src, O_RDONLY | O_CLOEXEC);
|
||||
read(fd, buf, LINE_MAX);
|
||||
buf[LINE_MAX - 1] = '\0';
|
||||
close(fd);
|
||||
if (buf[0] == '#' && buf[1] == '!') {
|
||||
/* we have a shebang */
|
||||
char *p, *q;
|
||||
for (p = &buf[2]; *p && isspace(*p); p++) ;
|
||||
for (q = p; *q && (!isspace(*q)); q++) ;
|
||||
*q = '\0';
|
||||
log_debug("Script install: '%s'", p);
|
||||
ret = dracut_install(p, p, false, true);
|
||||
if (ret != 0)
|
||||
log_error("ERROR: failed to install '%s'", p);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* run ldd */
|
||||
asprintf(&cmd, "ldd %s", src);
|
||||
fptr = popen(cmd, "r");
|
||||
|
||||
while (!feof(fptr)) {
|
||||
char *p, *q;
|
||||
|
||||
if (getline(&buf, &linesize, fptr) <= 0)
|
||||
continue;
|
||||
|
||||
log_debug("ldd: '%s'", buf);
|
||||
|
||||
if (strstr(buf, "not a dynamic executable"))
|
||||
break;
|
||||
|
||||
p = strstr(buf, "/");
|
||||
if (p) {
|
||||
int r;
|
||||
for (q = p; *q && *q != ' ' && *q != '\n'; q++) ;
|
||||
*q = '\0';
|
||||
r = dracut_install(p, p, false, false);
|
||||
if (r != 0)
|
||||
log_error("ERROR: failed to install '%s' for '%s'", p, src);
|
||||
else
|
||||
log_debug("Lib install: '%s'", p);
|
||||
ret += r;
|
||||
|
||||
/* also install lib.so for lib.so.* files */
|
||||
q = strstr(p, ".so.");
|
||||
if (q) {
|
||||
q += 3;
|
||||
*q = '\0';
|
||||
|
||||
/* ignore errors for base lib symlink */
|
||||
if (dracut_install(p, p, false, false) == 0)
|
||||
log_debug("Lib install: '%s'", p);
|
||||
}
|
||||
}
|
||||
}
|
||||
pclose(fptr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Install ".<filename>.hmac" file for FIPS self-checks */
|
||||
static int hmac_install(const char *src, const char *dst)
|
||||
{
|
||||
char *srcpath = strdup(src);
|
||||
char *dstpath = strdup(dst);
|
||||
char *srchmacname = NULL;
|
||||
char *dsthmacname = NULL;
|
||||
size_t dlen = dir_len(src);
|
||||
|
||||
if (endswith(src, ".hmac"))
|
||||
return 0;
|
||||
|
||||
srcpath[dlen] = '\0';
|
||||
dstpath[dir_len(dst)] = '\0';
|
||||
asprintf(&srchmacname, "%s/.%s.hmac", srcpath, &src[dlen + 1]);
|
||||
asprintf(&dsthmacname, "%s/.%s.hmac", dstpath, &src[dlen + 1]);
|
||||
log_debug("hmac cp '%s' '%s')", srchmacname, dsthmacname);
|
||||
dracut_install(srchmacname, dsthmacname, false, false);
|
||||
free(dsthmacname);
|
||||
free(srchmacname);
|
||||
free(srcpath);
|
||||
free(dstpath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dracut_install(const char *src, const char *dst, bool isdir, bool resolvedeps)
|
||||
{
|
||||
struct stat sb, db;
|
||||
char *dname = NULL;
|
||||
char *fulldstpath = NULL;
|
||||
char *fulldstdir = NULL;
|
||||
int ret;
|
||||
bool src_exists = true;
|
||||
char *i, *existing;
|
||||
|
||||
log_debug("dracut_install('%s', '%s')", src, dst);
|
||||
|
||||
existing = hashmap_get(items_failed, src);
|
||||
if (existing) {
|
||||
if (strcmp(existing, src) == 0) {
|
||||
log_debug("hash hit items_failed for '%s'", src);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
existing = hashmap_get(items, dst);
|
||||
if (existing) {
|
||||
if (strcmp(existing, dst) == 0) {
|
||||
log_debug("hash hit items for '%s'", dst);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (lstat(src, &sb) < 0) {
|
||||
src_exists = false;
|
||||
if (!isdir) {
|
||||
i = strdup(src);
|
||||
hashmap_put(items_failed, i, i);
|
||||
/* src does not exist */
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
i = strdup(dst);
|
||||
hashmap_put(items, i, i);
|
||||
|
||||
asprintf(&fulldstpath, "%s%s", destrootdir, dst);
|
||||
|
||||
ret = stat(fulldstpath, &sb);
|
||||
|
||||
if (ret != 0 && (errno != ENOENT)) {
|
||||
log_error("ERROR: stat '%s': %m", fulldstpath);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
log_debug("'%s' already exists", fulldstpath);
|
||||
free(fulldstpath);
|
||||
/* dst does already exist */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* check destination directory */
|
||||
fulldstdir = strdup(fulldstpath);
|
||||
fulldstdir[dir_len(fulldstdir)] = '\0';
|
||||
|
||||
ret = stat(fulldstdir, &db);
|
||||
|
||||
if (ret < 0) {
|
||||
if (errno != ENOENT) {
|
||||
log_error("ERROR: stat '%s': %m", fulldstdir);
|
||||
return 1;
|
||||
}
|
||||
/* create destination directory */
|
||||
log_debug("dest dir '%s' does not exist", fulldstdir);
|
||||
dname = strdup(dst);
|
||||
dname[dir_len(dname)] = '\0';
|
||||
ret = dracut_install(dname, dname, true, false);
|
||||
|
||||
free(dname);
|
||||
|
||||
if (ret != 0) {
|
||||
log_error("ERROR: failed to create directory '%s'", fulldstdir);
|
||||
free(fulldstdir);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
free(fulldstdir);
|
||||
|
||||
if (isdir && !src_exists) {
|
||||
log_info("mkdir '%s'", fulldstpath);
|
||||
return mkdir(fulldstpath, 0755);
|
||||
}
|
||||
|
||||
/* ready to install src */
|
||||
|
||||
if (S_ISDIR(sb.st_mode)) {
|
||||
log_info("mkdir '%s'", fulldstpath);
|
||||
return mkdir(fulldstpath, sb.st_mode | S_IWUSR);
|
||||
}
|
||||
|
||||
if (S_ISLNK(sb.st_mode)) {
|
||||
char *abspath;
|
||||
char *absdestpath = NULL;
|
||||
|
||||
abspath = realpath(src, NULL);
|
||||
|
||||
if (abspath == NULL)
|
||||
return 1;
|
||||
|
||||
if (dracut_install(abspath, abspath, false, resolvedeps)) {
|
||||
log_debug("'%s' install error", abspath);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (lstat(abspath, &sb) != 0) {
|
||||
log_debug("lstat '%s': %m", abspath);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (lstat(fulldstpath, &sb) != 0) {
|
||||
|
||||
asprintf(&absdestpath, "%s%s", destrootdir, abspath);
|
||||
|
||||
ln_r(absdestpath, fulldstpath);
|
||||
|
||||
free(absdestpath);
|
||||
}
|
||||
|
||||
free(abspath);
|
||||
if (arg_hmac) {
|
||||
/* copy .hmac files also */
|
||||
hmac_install(src, dst);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (sb.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) {
|
||||
if (resolvedeps)
|
||||
ret += resolve_deps(src);
|
||||
if (arg_hmac) {
|
||||
/* copy .hmac files also */
|
||||
hmac_install(src, dst);
|
||||
}
|
||||
}
|
||||
|
||||
log_info("cp '%s' '%s'", src, fulldstpath);
|
||||
ret += cp(src, fulldstpath);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void item_free(char *i)
|
||||
{
|
||||
assert(i);
|
||||
free(i);
|
||||
}
|
||||
|
||||
static void usage(int status)
|
||||
{
|
||||
/* */
|
||||
printf("\
|
||||
Usage: %s -D DESTROOTDIR [OPTION]... -a SOURCE...\n\
|
||||
or: %s -D DESTROOTDIR [OPTION]... SOURCE DEST\n\
|
||||
\n\
|
||||
Install SOURCE to DEST in DESTROOTDIR with all needed dependencies.\n\
|
||||
\n\
|
||||
-D --destrootdir Install all files to DESTROOTDIR as the root\n\
|
||||
-a --all Install all SOURCE arguments to DESTROOTDIR\n\
|
||||
-o --optional If SOURCE does not exist, do not fail\n\
|
||||
-d --dir SOURCE is a directory\n\
|
||||
-l --ldd Also install shebang executables and libraries\n\
|
||||
-R --resolvelazy Only install shebang executables and libraries for all SOURCE files\n\
|
||||
-f --fips Also install all '.SOURCE.hmac' files\n\
|
||||
-v --verbose Show more output\n\
|
||||
--debug Show debug output\n\
|
||||
--version Show package version\n\
|
||||
-h --help Show this help\n\
|
||||
\n\
|
||||
Example:\n\
|
||||
# %s -D /var/tmp/test-root --ldd -a sh tr\n\
|
||||
# tree /var/tmp/test-root\n\
|
||||
/var/tmp/test-root\n\
|
||||
|-- lib64 -> usr/lib64\n\
|
||||
`-- usr\n\
|
||||
|-- bin\n\
|
||||
| |-- bash\n\
|
||||
| |-- sh -> bash\n\
|
||||
| `-- tr\n\
|
||||
`-- lib64\n\
|
||||
|-- ld-2.15.90.so\n\
|
||||
|-- ld-linux-x86-64.so.2 -> ld-2.15.90.so\n\
|
||||
|-- libc-2.15.90.so\n\
|
||||
|-- libc.so\n\
|
||||
|-- libc.so.6 -> libc-2.15.90.so\n\
|
||||
|-- libdl-2.15.90.so\n\
|
||||
|-- libdl.so -> libdl-2.15.90.so\n\
|
||||
|-- libdl.so.2 -> libdl-2.15.90.so\n\
|
||||
|-- libtinfo.so.5 -> libtinfo.so.5.9\n\
|
||||
`-- libtinfo.so.5.9\n\
|
||||
", program_invocation_short_name, program_invocation_short_name, program_invocation_short_name);
|
||||
exit(status);
|
||||
}
|
||||
|
||||
static int parse_argv(int argc, char *argv[])
|
||||
{
|
||||
int c;
|
||||
|
||||
enum {
|
||||
ARG_VERSION = 0x100,
|
||||
ARG_DEBUG
|
||||
};
|
||||
|
||||
static const struct option const options[] = {
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
{"version", no_argument, NULL, ARG_VERSION},
|
||||
{"dir", no_argument, NULL, 'd'},
|
||||
{"debug", no_argument, NULL, ARG_DEBUG},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"ldd", no_argument, NULL, 'l'},
|
||||
{"resolvelazy", no_argument, NULL, 'R'},
|
||||
{"optional", no_argument, NULL, 'o'},
|
||||
{"all", no_argument, NULL, 'a'},
|
||||
{"fips", no_argument, NULL, 'H'},
|
||||
{"destrootdir", required_argument, NULL, 'D'},
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
while ((c = getopt_long(argc, argv, "adhloD:DHILR", options, NULL)) != -1) {
|
||||
switch (c) {
|
||||
case ARG_VERSION:
|
||||
puts(PROGRAM_VERSION_STRING);
|
||||
return 0;
|
||||
case 'd':
|
||||
arg_createdir = true;
|
||||
break;
|
||||
case ARG_DEBUG:
|
||||
arg_loglevel = LOG_DEBUG;
|
||||
break;
|
||||
case 'v':
|
||||
arg_loglevel = LOG_INFO;
|
||||
break;
|
||||
case 'o':
|
||||
arg_optional = true;
|
||||
break;
|
||||
case 'l':
|
||||
arg_resolvedeps = true;
|
||||
break;
|
||||
case 'R':
|
||||
arg_resolvelazy = true;
|
||||
break;
|
||||
case 'a':
|
||||
arg_all = true;
|
||||
break;
|
||||
case 'D':
|
||||
destrootdir = strdup(optarg);
|
||||
break;
|
||||
case 'H':
|
||||
arg_hmac = true;
|
||||
break;
|
||||
case 'h':
|
||||
usage(EXIT_SUCCESS);
|
||||
break;
|
||||
default:
|
||||
usage(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
if (!optind || optind == argc) {
|
||||
usage(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int resolve_lazy(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int destrootdirlen = strlen(destrootdir);
|
||||
int ret = 0;
|
||||
char *item;
|
||||
for (i = 0; i < argc; i++) {
|
||||
const char *src = argv[i];
|
||||
char *p = argv[i];
|
||||
char *existing;
|
||||
|
||||
log_debug("resolve_deps('%s')", src);
|
||||
|
||||
if (strstr(src, destrootdir)) {
|
||||
p = &argv[i][destrootdirlen];
|
||||
}
|
||||
|
||||
existing = hashmap_get(items, p);
|
||||
if (existing) {
|
||||
if (strcmp(existing, p) == 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
item = strdup(p);
|
||||
hashmap_put(items, item, item);
|
||||
|
||||
ret += resolve_deps(src);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int install_all(int argc, char **argv)
|
||||
{
|
||||
int r = 0;
|
||||
int i;
|
||||
for (i = 0; i < argc; i++) {
|
||||
int ret;
|
||||
log_debug("Handle '%s'", argv[i]);
|
||||
|
||||
if (strchr(argv[i], '/') == NULL) {
|
||||
char *path;
|
||||
char *p, *q;
|
||||
bool end = false;
|
||||
path = getenv("PATH");
|
||||
if (path == NULL) {
|
||||
log_error("PATH is not set");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
path = strdup(path);
|
||||
p = path;
|
||||
log_debug("PATH=%s", path);
|
||||
do {
|
||||
char *newsrc = NULL;
|
||||
char *dest;
|
||||
struct stat sb;
|
||||
|
||||
for (q = p; *q && *q != ':'; q++) ;
|
||||
|
||||
if (*q == '\0')
|
||||
end = true;
|
||||
else
|
||||
*q = '\0';
|
||||
|
||||
asprintf(&newsrc, "%s/%s", p, argv[i]);
|
||||
p = q + 1;
|
||||
|
||||
if (stat(newsrc, &sb) != 0) {
|
||||
free(newsrc);
|
||||
ret = -1;
|
||||
continue;
|
||||
}
|
||||
|
||||
dest = strdup(newsrc);
|
||||
|
||||
log_debug("dracut_install '%s'", newsrc);
|
||||
ret = dracut_install(newsrc, dest, arg_createdir, arg_resolvedeps);
|
||||
if (ret == 0) {
|
||||
end = true;
|
||||
log_debug("dracut_install '%s' OK", newsrc);
|
||||
}
|
||||
free(newsrc);
|
||||
free(dest);
|
||||
} while (!end);
|
||||
free(path);
|
||||
} else {
|
||||
char *dest = strdup(argv[i]);
|
||||
ret = dracut_install(argv[i], dest, arg_createdir, arg_resolvedeps);
|
||||
free(dest);
|
||||
}
|
||||
|
||||
if ((ret != 0) && (!arg_optional)) {
|
||||
log_error("ERROR: installing '%s'", argv[i]);
|
||||
r = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int r;
|
||||
char *i;
|
||||
|
||||
r = parse_argv(argc, argv);
|
||||
if (r <= 0)
|
||||
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
|
||||
log_set_target(LOG_TARGET_CONSOLE);
|
||||
log_parse_environment();
|
||||
|
||||
if (arg_loglevel >= 0)
|
||||
log_set_max_level(arg_loglevel);
|
||||
|
||||
log_open();
|
||||
|
||||
umask(0022);
|
||||
|
||||
if (destrootdir == NULL) {
|
||||
destrootdir = getenv("DESTROOTDIR");
|
||||
if (destrootdir == NULL) {
|
||||
log_error("Environment DESTROOTDIR or argument -D is not set!");
|
||||
usage(EXIT_FAILURE);
|
||||
}
|
||||
destrootdir = strdup(destrootdir);
|
||||
}
|
||||
|
||||
items = hashmap_new(string_hash_func, string_compare_func);
|
||||
items_failed = hashmap_new(string_hash_func, string_compare_func);
|
||||
|
||||
if (!items || !items_failed) {
|
||||
log_error("Out of memory");
|
||||
r = EXIT_FAILURE;
|
||||
goto finish;
|
||||
}
|
||||
|
||||
r = EXIT_SUCCESS;
|
||||
|
||||
if (((optind + 1) < argc) && (strcmp(argv[optind + 1], destrootdir) == 0)) {
|
||||
/* ugly hack for compat mode "inst src $destrootdir" */
|
||||
if ((optind + 2) == argc) {
|
||||
argc--;
|
||||
} else {
|
||||
/* ugly hack for compat mode "inst src $destrootdir dst" */
|
||||
if ((optind + 3) == argc) {
|
||||
argc--;
|
||||
argv[optind + 1] = argv[optind + 2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (arg_resolvelazy) {
|
||||
r = resolve_lazy(argc - optind, &argv[optind]);
|
||||
} else if (arg_all || (argc - optind > 2) || ((argc - optind) == 1)) {
|
||||
r = install_all(argc - optind, &argv[optind]);
|
||||
} else {
|
||||
/* simple "inst src dst" */
|
||||
r = dracut_install(argv[optind], argv[optind + 1], arg_createdir, arg_resolvedeps);
|
||||
if ((r != 0) && (!arg_optional)) {
|
||||
log_error("ERROR: installing '%s' to '%s'", argv[optind], argv[optind + 1]);
|
||||
r = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (arg_optional)
|
||||
r = EXIT_SUCCESS;
|
||||
|
||||
finish:
|
||||
|
||||
while ((i = hashmap_steal_first(items)))
|
||||
item_free(i);
|
||||
|
||||
while ((i = hashmap_steal_first(items_failed)))
|
||||
item_free(i);
|
||||
|
||||
hashmap_free(items);
|
||||
hashmap_free(items_failed);
|
||||
|
||||
free(destrootdir);
|
||||
|
||||
return r;
|
||||
}
|
731
install/hashmap.c
Normal file
731
install/hashmap.c
Normal file
@@ -0,0 +1,731 @@
|
||||
/*-*- 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;
|
||||
}
|
91
install/hashmap.h
Normal file
91
install/hashmap.h
Normal file
@@ -0,0 +1,91 @@
|
||||
/*-*- 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
|
12
install/hashmap.lo
Normal file
12
install/hashmap.lo
Normal file
@@ -0,0 +1,12 @@
|
||||
# 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'
|
||||
|
BIN
install/hashmap.o
Normal file
BIN
install/hashmap.o
Normal file
Binary file not shown.
294
install/log.c
Normal file
294
install/log.c
Normal file
@@ -0,0 +1,294 @@
|
||||
/*-*- 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
Normal file
115
install/log.h
Normal file
@@ -0,0 +1,115 @@
|
||||
/*-*- 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
|
192
install/macro.h
Normal file
192
install/macro.h
Normal file
@@ -0,0 +1,192 @@
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
#ifndef foomacrohfoo
|
||||
#define foomacrohfoo
|
||||
|
||||
/***
|
||||
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 XSTRINGIFY(x) #x
|
||||
#define STRINGIFY(x) XSTRINGIFY(x)
|
||||
|
||||
/* Rounds up */
|
||||
#define ALIGN(l) ALIGN_TO((l), sizeof(void*))
|
||||
static inline size_t ALIGN_TO(size_t l, size_t ali) {
|
||||
return ((l + ali - 1) & ~(ali - 1));
|
||||
}
|
||||
|
||||
#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) ({ \
|
||||
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) \
|
||||
__extension__ ({ \
|
||||
typeof(a) _a = (a); \
|
||||
typeof(b) _b = (b); \
|
||||
_a > _b ? _a : _b; \
|
||||
})
|
||||
#endif
|
||||
|
||||
#define MAX3(a,b,c) \
|
||||
MAX(MAX(a,b),c)
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) \
|
||||
__extension__ ({ \
|
||||
typeof(a) _a = (a); \
|
||||
typeof(b) _b = (b); \
|
||||
_a < _b ? _a : _b; \
|
||||
})
|
||||
#endif
|
||||
|
||||
#define MIN3(a,b,c) \
|
||||
MIN(MIN(a,b),c)
|
||||
|
||||
#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)); \
|
||||
})
|
||||
|
||||
#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)
|
||||
|
||||
#define assert_cc(expr) \
|
||||
do { \
|
||||
switch (0) { \
|
||||
case 0: \
|
||||
case !!(expr): \
|
||||
; \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
#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_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;
|
||||
}
|
||||
|
||||
#include "log.h"
|
||||
|
||||
#endif
|
187
install/util.c
Normal file
187
install/util.c
Normal file
@@ -0,0 +1,187 @@
|
||||
/*-*- 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);
|
527
install/util.h
Normal file
527
install/util.h
Normal file
@@ -0,0 +1,527 @@
|
||||
/*-*- 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);
|
||||
|
||||
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);
|
||||
|
||||
#endif
|
@@ -34,20 +34,22 @@ image="${1:-/boot/initramfs-$(uname -r).img}"
|
||||
[[ -f "$image" ]] || { echo "$image does not exist" ; exit 1 ; }
|
||||
|
||||
CAT=zcat
|
||||
FILE_T=$(file "$image")
|
||||
FILE_T=$(file --dereference "$image")
|
||||
|
||||
if echo "test"|xz|xz -dc --single-stream; then
|
||||
if echo "test"|xz|xz -dc --single-stream >/dev/null 2>&1; then
|
||||
XZ_SINGLE_STREAM="--single-stream"
|
||||
fi
|
||||
|
||||
if [[ "$FILE_T" =~ ": gzip compressed data" ]]; then
|
||||
if [[ "$FILE_T" =~ :\ gzip\ compressed\ data ]]; then
|
||||
CAT=zcat
|
||||
elif [[ "$FILE_T" =~ ": xz compressed data" ]]; then
|
||||
elif [[ "$FILE_T" =~ :\ xz\ compressed\ data ]]; then
|
||||
CAT="xzcat $XZ_SINGLE_STREAM"
|
||||
elif [[ "$FILE_T" =~ ": XZ compressed data" ]]; then
|
||||
elif [[ "$FILE_T" =~ :\ XZ\ compressed\ data ]]; then
|
||||
CAT="xzcat $XZ_SINGLE_STREAM"
|
||||
elif [[ "$FILE_T" =~ :\ LZMA ]]; then
|
||||
CAT="xzcat $XZ_SINGLE_STREAM"
|
||||
elif [[ "$FILE_T" =~ :\ data ]]; then
|
||||
CAT="xzcat $XZ_SINGLE_STREAM"
|
||||
elif [[ "$FILE_T" =~ ": data" ]]; then
|
||||
CAT=lzcat
|
||||
fi
|
||||
|
||||
if [[ $# -eq 2 ]]; then
|
@@ -13,19 +13,17 @@ depends() {
|
||||
}
|
||||
|
||||
install() {
|
||||
inst /sbin/bootchartd
|
||||
inst /bin/bash
|
||||
inst_symlink /init /sbin/init
|
||||
inst_dir /lib/bootchart/tmpfs
|
||||
inst /lib/bootchart/bootchart-collector
|
||||
inst /etc/bootchartd.conf
|
||||
inst /sbin/accton
|
||||
inst /usr/bin/pkill /bin/pkill
|
||||
inst /bin/echo
|
||||
inst /bin/grep
|
||||
inst /bin/usleep
|
||||
inst /usr/bin/[ /bin/[
|
||||
|
||||
mknod -m 0666 "${initdir}/dev/null" c 1 3
|
||||
dracut_install bootchartd bash \
|
||||
/lib/bootchart/bootchart-collector /etc/bootchartd.conf \
|
||||
accton \
|
||||
echo \
|
||||
grep \
|
||||
usleep
|
||||
|
||||
inst /usr/bin/pkill /bin/pkill
|
||||
inst /usr/bin/[ /bin/[
|
||||
}
|
||||
|
||||
|
@@ -12,38 +12,33 @@ depends() {
|
||||
|
||||
installkernel() {
|
||||
local _fipsmodules _mod
|
||||
_fipsmodules="aead aes_generici aes-xts aes-x86_64 ansi_cprng cbc ccm chainiv ctr"
|
||||
_fipsmodules="aead aes_generic xts aes-x86_64 ansi_cprng cbc ccm chainiv ctr"
|
||||
_fipsmodules+=" des deflate ecb eseqiv hmac seqiv sha256 sha512"
|
||||
_fipsmodules+=" cryptomgr crypto_null tcrypt dm-mod dm-crypt"
|
||||
|
||||
mkdir -m 0755 -p "${initdir}/etc/modprobe.d"
|
||||
|
||||
for _mod in $_fipsmodules; do
|
||||
if instmods $_mod; then
|
||||
if hostonly='' instmods $_mod; then
|
||||
echo $_mod >> "${initdir}/etc/fipsmodules"
|
||||
echo "blacklist $_mod" >> "${initdir}/etc/modprobe.d/fips.conf"
|
||||
fi
|
||||
done
|
||||
hostonly='' instmods scsi_wait_scan
|
||||
}
|
||||
|
||||
install() {
|
||||
local _dir
|
||||
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
|
||||
inst_script "$moddir/fips.sh" /sbin/fips.sh
|
||||
|
||||
dracut_install sha512hmac rmmod insmod mount uname umount
|
||||
|
||||
for _dir in "$usrlibdir" "$libdir"; do
|
||||
[[ -e $_dir/libsoftokn3.so ]] && \
|
||||
dracut_install $_dir/libsoftokn3.so $_dir/libsoftokn3.chk \
|
||||
$_dir/libfreebl3.so $_dir/libfreebl3.chk && \
|
||||
break
|
||||
done
|
||||
inst_libdir_file libsoftokn3.so libsoftokn3.so \
|
||||
libsoftokn3.chk libfreebl3.so libfreebl3.chk \
|
||||
'hmaccalc/sha512hmac.hmac'
|
||||
|
||||
dracut_install $usrlibdir/hmaccalc/sha512hmac.hmac
|
||||
if command -v prelink >/dev/null; then
|
||||
dracut_install prelink
|
||||
fi
|
||||
dracut_install -o prelink
|
||||
}
|
||||
|
||||
|
27
modules.d/04watchdog/module-setup.sh
Executable file
27
modules.d/04watchdog/module-setup.sh
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/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
|
||||
}
|
||||
|
||||
install() {
|
||||
inst_hook cmdline 00 "$moddir/watchdog.sh"
|
||||
inst_hook cmdline 50 "$moddir/watchdog.sh"
|
||||
inst_hook pre-trigger 00 "$moddir/watchdog.sh"
|
||||
inst_hook initqueue 00 "$moddir/watchdog.sh"
|
||||
inst_hook mount 00 "$moddir/watchdog.sh"
|
||||
inst_hook mount 50 "$moddir/watchdog.sh"
|
||||
inst_hook mount 99 "$moddir/watchdog.sh"
|
||||
inst_hook pre-pivot 00 "$moddir/watchdog.sh"
|
||||
inst_hook pre-pivot 99 "$moddir/watchdog.sh"
|
||||
inst_hook cleanup 00 "$moddir/watchdog.sh"
|
||||
inst_hook cleanup 99 "$moddir/watchdog.sh"
|
||||
inst_hook emergency 02 "$moddir/watchdog-stop.sh"
|
||||
}
|
||||
|
7
modules.d/04watchdog/watchdog.sh
Executable file
7
modules.d/04watchdog/watchdog.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
if [ -e /dev/watchdog ]; then
|
||||
info "Triggering watchdog"
|
||||
>/dev/watchdog
|
||||
else
|
||||
modprobe ib700wdt
|
||||
fi
|
@@ -2,6 +2,8 @@
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
[ -x /lib/systemd/systemd-vconsole-setup ] && exit 0
|
||||
|
||||
[ -e /etc/vconsole.conf ] && . /etc/vconsole.conf
|
||||
|
||||
DEFAULT_FONT=LatArCyrHeb-16
|
@@ -31,7 +31,7 @@ install() {
|
||||
*) cmd=grep ;;
|
||||
esac
|
||||
|
||||
for INCL in $($cmd "^include " $MAP | cut -d' ' -f2 | tr -d '"'); do
|
||||
for INCL in $($cmd "^include " $MAP | while read a a b; do echo ${a/\"/}; done); do
|
||||
for FN in $(find ${kbddir}/keymaps -type f -name $INCL\*); do
|
||||
findkeymap $FN
|
||||
done
|
||||
@@ -84,25 +84,31 @@ install() {
|
||||
install_base() {
|
||||
dracut_install setfont loadkeys kbd_mode stty
|
||||
|
||||
inst ${moddir}/console_init /lib/udev/console_init
|
||||
inst ${moddir}/console_init.sh /lib/udev/console_init
|
||||
inst_rules ${moddir}/10-console.rules
|
||||
inst_hook cmdline 20 "${moddir}/parse-i18n.sh"
|
||||
inst_hook cleanup 20 "${moddir}/i18n-cleanup.sh"
|
||||
}
|
||||
|
||||
install_all_kbd() {
|
||||
local rel f
|
||||
|
||||
for f in $(eval find ${kbddir}/{${KBDSUBDIRS}} -type f -print)
|
||||
do
|
||||
inst_simple $f
|
||||
for _src in $(eval echo ${kbddir}/{${KBDSUBDIRS}}); do
|
||||
inst_dir "$_src"
|
||||
cp --reflink=auto --sparse=auto -prfL -t "${initdir}/${_src%/*}" "$_src"
|
||||
done
|
||||
|
||||
# remove unnecessary files
|
||||
rm -f "${initdir}${kbddir}/consoletrans/utflist"
|
||||
find "${initdir}${kbddir}/" -name README\* -delete
|
||||
find "${initdir}${kbddir}/" -name '*.gz' -print -quit \
|
||||
| while read line; do
|
||||
dracut_install gzip
|
||||
done
|
||||
|
||||
dracut_install gzip bzip2
|
||||
find "${initdir}${kbddir}/" -name '*.bz2' -print -quit \
|
||||
| while read line; do
|
||||
dracut_install bzip2
|
||||
done
|
||||
}
|
||||
|
||||
install_local_i18n() {
|
||||
|
@@ -1,30 +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
|
||||
[ -f /etc/redhat-release ]
|
||||
}
|
||||
|
||||
depends() {
|
||||
return 0
|
||||
}
|
||||
|
||||
install() {
|
||||
local _line
|
||||
local _dracut_rpm_version
|
||||
if [ -e "$moddir/dracut-version" ]; then
|
||||
_dracut_rpm_version=$(cat "$moddir/dracut-version")
|
||||
inst "$moddir/dracut-version" /lib/dracut/$_dracut_rpm_version
|
||||
else
|
||||
if rpm -qf $(type -P $0) &>/dev/null; then
|
||||
_dracut_rpm_version=$(rpm -qf --qf '%{name}-%{version}-%{release}\n' $(type -P $0) | { ver="";while read _line;do ver=$_line;done;echo $ver;} )
|
||||
mkdir -m 0755 -p $initdir/lib/dracut
|
||||
echo $_dracut_rpm_version > $initdir/lib/dracut/$_dracut_rpm_version
|
||||
fi
|
||||
fi
|
||||
inst_hook cmdline 01 "$moddir/version.sh"
|
||||
|
||||
}
|
||||
|
@@ -1,9 +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
|
||||
for i in lib/dracut/dracut-*; do
|
||||
if [ -f $i ]; then
|
||||
vinfo < $i
|
||||
fi
|
||||
done
|
||||
unset i
|
@@ -21,13 +21,13 @@ while [[ "$ROOT" != "${ROOT%/}" ]]; do
|
||||
ROOT=${ROOT%/}
|
||||
done
|
||||
|
||||
if [ ! -L $ROOT/var/run ]; then
|
||||
if [ ! -L $ROOT/var/run -a -e $ROOT/var/run ]; then
|
||||
echo "Converting /var/run to symlink"
|
||||
mv -f $ROOT/var/run $ROOT/var/run.runmove~
|
||||
ln -sfn ../run $ROOT/var/run
|
||||
fi
|
||||
|
||||
if [ ! -L $ROOT/var/lock ]; then
|
||||
if [ ! -L $ROOT/var/lock -a -e $ROOT/var/lock ]; then
|
||||
echo "Converting /var/lock to symlink"
|
||||
mv -f $ROOT/var/lock $ROOT/var/lock.lockmove~
|
||||
ln -sfn ../run/lock $ROOT/var/lock
|
||||
@@ -42,6 +42,14 @@ needconvert() {
|
||||
return 1
|
||||
}
|
||||
|
||||
if ! [ -e "$ROOT/usr/bin" ]; then
|
||||
echo "$ROOT/usr/bin does not exist!"
|
||||
echo "Make sure, the kernel command line has enough information"
|
||||
echo "to mount /usr (man dracut.cmdline)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
if ! needconvert; then
|
||||
echo "Your system is already converted."
|
||||
exit 0
|
||||
@@ -101,7 +109,7 @@ for dir in bin sbin lib lib64; do
|
||||
[[ -d "$ROOT/$dir" ]] || continue
|
||||
echo "Make a copy of \`$ROOT/usr/$dir'."
|
||||
[[ -d "$ROOT/usr/$dir" ]] \
|
||||
&& cp -ax $CP_HARDLINK "$ROOT/usr/$dir" "$ROOT/usr/${dir}.usrmove-new"
|
||||
&& cp -ax -l "$ROOT/usr/$dir" "$ROOT/usr/${dir}.usrmove-new"
|
||||
echo "Merge the copy with \`$ROOT/$dir'."
|
||||
[[ -d "$ROOT/usr/${dir}.usrmove-new" ]] \
|
||||
|| mkdir -p "$ROOT/usr/${dir}.usrmove-new"
|
||||
|
@@ -12,9 +12,8 @@ depends() {
|
||||
}
|
||||
|
||||
install() {
|
||||
dracut_install bash
|
||||
dracut_install find ldconfig mv rm cp ln
|
||||
dracut_install bash find ldconfig mv rm cp ln
|
||||
inst_hook pre-pivot 99 "$moddir/do-convertfs.sh"
|
||||
inst "$moddir/convertfs.sh" /usr/bin/convertfs
|
||||
inst_script "$moddir/convertfs.sh" /usr/bin/convertfs
|
||||
}
|
||||
|
||||
|
@@ -22,15 +22,15 @@ setup_interface() {
|
||||
# disallow MTUs from 576 and below by default, so that broken
|
||||
# MTUs are ignored, but higher stuff is allowed (1492, 1500, etc).
|
||||
if [ -n "$mtu" ] && [ $mtu -gt 576 ] ; then
|
||||
echo "if ! ip link set $netif mtu $mtu ; then"
|
||||
echo "ip link set $netif down"
|
||||
echo "ip link set $netif mtu $mtu"
|
||||
echo "ip link set $netif up"
|
||||
echo wait_for_if_up $netif
|
||||
echo "fi"
|
||||
fi > /tmp/net.$netif.up
|
||||
if ! ip link set $netif mtu $mtu ; then
|
||||
ip link set $netif down
|
||||
ip link set $netif mtu $mtu
|
||||
ip link set $netif up
|
||||
wait_for_if_up $netif
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ip addr add $ip${mask:+/$mask} ${bcast:+broadcast $bcast} dev $netif >> /tmp/net.$netif.up
|
||||
ip addr add $ip${mask:+/$mask} ${bcast:+broadcast $bcast} dev $netif
|
||||
|
||||
[ -n "$gw" ] && echo ip route add default via $gw dev $netif > /tmp/net.$netif.gw
|
||||
|
||||
@@ -66,23 +66,32 @@ case $reason in
|
||||
;;
|
||||
BOUND)
|
||||
echo "dhcp: BOND setting $netif"
|
||||
if ! arping -q -D -c 2 -I $netif $new_ip_address ; then
|
||||
warn "Duplicate address detected for $new_ip_address while doing dhcp. retrying"
|
||||
exit 1
|
||||
unset layer2
|
||||
if [ -f /sys/class/net/$netif/device/layer2 ]; then
|
||||
read layer2 < /sys/class/net/$netif/device/layer2
|
||||
fi
|
||||
if [ "$layer2" != "0" ]; then
|
||||
if ! arping -q -D -c 2 -I $netif $new_ip_address ; then
|
||||
warn "Duplicate address detected for $new_ip_address while doing dhcp. retrying"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
unset layer2
|
||||
setup_interface
|
||||
set | while read line; do
|
||||
[ "${line#new_}" = "$line" ] && continue
|
||||
echo "$line"
|
||||
done >/tmp/dhclient.$netif.dhcpopts
|
||||
echo online > /sys/class/net/$netif/uevent
|
||||
|
||||
if [ -e /tmp/net.$netif.manualup ]; then
|
||||
/sbin/netroot $netif -m
|
||||
rm -f /tmp/net.$netif.manualup
|
||||
else
|
||||
initqueue --onetime --name netroot-$netif netroot $netif
|
||||
fi
|
||||
{
|
||||
echo '. /lib/net-lib.sh'
|
||||
echo "setup_net $netif"
|
||||
echo "source_hook initqueue/online $netif"
|
||||
[ -e /tmp/net.$netif.manualup ] || echo "/sbin/netroot $netif"
|
||||
echo "rm -f $hookdir/initqueue/setup_net_$netif.sh"
|
||||
} > $hookdir/initqueue/setup_net_$netif.sh
|
||||
|
||||
>/tmp/net.$netif.up
|
||||
;;
|
||||
*) echo "dhcp: $reason";;
|
||||
esac
|
@@ -10,9 +10,7 @@
|
||||
PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
export PS4="ifup.$1.$$ + "
|
||||
exec >>/run/initramfs/loginit.pipe 2>>/run/initramfs/loginit.pipe
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
type ip_to_var >/dev/null 2>&1 || . /lib/net-lib.sh
|
||||
|
||||
# Huh? No $1?
|
||||
[ -z "$1" ] && exit 1
|
||||
@@ -33,24 +31,31 @@ fi
|
||||
# bridge this interface?
|
||||
if [ -e /tmp/bridge.info ]; then
|
||||
. /tmp/bridge.info
|
||||
if [ "$netif" = "$ethname" ]; then
|
||||
for ethname in $ethnames ; do
|
||||
if [ "$netif" = "$ethname" ]; then
|
||||
if [ "$netif" = "$bondname" ] && [ -n "$DO_BOND_SETUP" ] ; then
|
||||
: # We need to really setup bond (recursive call)
|
||||
else
|
||||
netif="$bridgename"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -e /tmp/vlan.info ]; then
|
||||
. /tmp/vlan.info
|
||||
if [ "$netif" = "$phydevice" ]; then
|
||||
if [ "$netif" = "$bondname" ] && [ -n "$DO_BOND_SETUP" ] ; then
|
||||
: # We need to really setup bond (recursive call)
|
||||
else
|
||||
netif="$bridgename"
|
||||
netif="$vlanname"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# bail immediately if the interface is already up
|
||||
# or we don't need the network
|
||||
[ -f "/tmp/net.$netif.up" ] && exit 0
|
||||
[ -f "/tmp/root.info" ] || exit 0
|
||||
. /tmp/root.info
|
||||
|
||||
# disable manual ifup while netroot is set for simplifying our logic
|
||||
# in netroot case we prefer netroot to bringup $netif automaticlly
|
||||
[ -n "$2" ] && [ -z "$netroot" ] && manualup="$2"
|
||||
[ -n "$2" -a "$2" = "-m" ] && [ -z "$netroot" ] && manualup="$2"
|
||||
[ -z "$netroot" ] && [ -z "$manualup" ] && exit 0
|
||||
[ -n "$manualup" ] && >/tmp/net.$netif.manualup
|
||||
|
||||
@@ -76,13 +81,11 @@ load_ipv6() {
|
||||
|
||||
do_ipv6auto() {
|
||||
load_ipv6
|
||||
{
|
||||
echo 0 > /proc/sys/net/ipv6/conf/$netif/forwarding
|
||||
echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_ra
|
||||
echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_redirects
|
||||
echo ip link set $netif up
|
||||
echo wait_for_if_up $netif
|
||||
} > /tmp/net.$netif.up
|
||||
echo 0 > /proc/sys/net/ipv6/conf/$netif/forwarding
|
||||
echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_ra
|
||||
echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_redirects
|
||||
ip link set $netif up
|
||||
wait_for_if_up $netif
|
||||
|
||||
[ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
|
||||
|
||||
@@ -92,28 +95,23 @@ do_ipv6auto() {
|
||||
echo nameserver $s
|
||||
done
|
||||
fi >> /tmp/net.$netif.resolv.conf
|
||||
|
||||
|
||||
echo online > /sys/class/net/$netif/uevent
|
||||
if [ -n "$manualup" ]; then
|
||||
/sbin/netroot $netif -m
|
||||
else
|
||||
initqueue --onetime --name netroot-$netif netroot $netif
|
||||
fi
|
||||
}
|
||||
|
||||
# Handle static ip configuration
|
||||
do_static() {
|
||||
strstr $ip '*:*:*' && load_ipv6
|
||||
|
||||
{
|
||||
echo ip link set $netif up
|
||||
echo wait_for_if_up $netif
|
||||
# do not flush addr for ipv6
|
||||
strstr $ip '*:*:*' || \
|
||||
echo ip addr flush dev $netif
|
||||
echo ip addr add $ip/$mask brd + dev $netif
|
||||
} > /tmp/net.$netif.up
|
||||
ip link set $netif up
|
||||
wait_for_if_up $netif
|
||||
[ -n "$macaddr" ] && ip link set address $macaddr
|
||||
[ -n "$mtu" ] && ip link set mtu $mtu
|
||||
if strstr $ip '*:*:*'; then
|
||||
# note no ip addr flush for ipv6
|
||||
ip addr add $ip/$mask dev $netif
|
||||
else
|
||||
ip addr flush dev $netif
|
||||
ip addr add $ip/$mask brd + dev $netif
|
||||
fi
|
||||
|
||||
[ -n "$gw" ] && echo ip route add default via $gw dev $netif > /tmp/net.$netif.gw
|
||||
[ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
|
||||
@@ -124,20 +122,12 @@ do_static() {
|
||||
echo nameserver $s
|
||||
done
|
||||
fi >> /tmp/net.$netif.resolv.conf
|
||||
|
||||
echo online > /sys/class/net/$netif/uevent
|
||||
if [ -n "$manualup" ]; then
|
||||
/sbin/netroot $netif -m
|
||||
else
|
||||
initqueue --onetime --name netroot-$netif netroot $netif
|
||||
fi
|
||||
}
|
||||
|
||||
# loopback is always handled the same way
|
||||
if [ "$netif" = "lo" ] ; then
|
||||
ip link set lo up
|
||||
ip addr add 127.0.0.1/8 dev lo
|
||||
>/tmp/net.$netif.up
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -171,7 +161,7 @@ if [ -e /tmp/bond.info ]; then
|
||||
|
||||
for slave in $bondslaves ; do
|
||||
ip link set $slave down
|
||||
ifenslave $bondname $slave
|
||||
echo "+$slave" > /sys/class/net/$bondname/bonding/slaves
|
||||
ip link set $slave up
|
||||
wait_for_if_up $slave
|
||||
done
|
||||
@@ -190,18 +180,44 @@ fi
|
||||
|
||||
# XXX need error handling like dhclient-script
|
||||
|
||||
if [ -e /tmp/bridge.info ]; then
|
||||
. /tmp/bridge.info
|
||||
# start bridge if necessary
|
||||
if [ "$netif" = "$bridgename" ] && [ ! -e /tmp/net.$bridgename.up ]; then
|
||||
if [ "$ethname" = "$bondname" ] ; then
|
||||
DO_BOND_SETUP=yes ifup $bondname
|
||||
else
|
||||
ip link set $ethname up
|
||||
if [ "$netif" = "$bridgename" ] && [ ! -e /tmp/net.$bridgename.up ]; then
|
||||
brctl addbr $bridgename
|
||||
brctl setfd $bridgename 0
|
||||
for ethname in $ethnames ; do
|
||||
if [ "$ethname" = "$bondname" ] ; then
|
||||
DO_BOND_SETUP=yes ifup $bondname -m
|
||||
else
|
||||
ip link set $ethname up
|
||||
fi
|
||||
wait_for_if_up $ethname
|
||||
brctl addif $bridgename $ethname
|
||||
done
|
||||
fi
|
||||
wait_for_if_up $ethname
|
||||
# Create bridge and add eth to bridge
|
||||
brctl addbr $bridgename
|
||||
brctl setfd $bridgename 0
|
||||
brctl addif $bridgename $ethname
|
||||
fi
|
||||
|
||||
get_vid() {
|
||||
case "$1" in
|
||||
vlan*)
|
||||
return ${1#vlan}
|
||||
;;
|
||||
*.*)
|
||||
return ${1##*.}
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
if [ "$netif" = "$vlanname" ] && [ ! -e /tmp/net.$vlanname.up ]; then
|
||||
modprobe 8021q
|
||||
if [ "$phydevice" = "$bondname" ] ; then
|
||||
DO_BOND_SETUP=yes ifup $phydevice -m
|
||||
else
|
||||
ip link set "$phydevice" up
|
||||
fi
|
||||
wait_for_if_up "$phydevice"
|
||||
ip link add dev "$vlanname" link "$phydevice" type vlan id "$(get_vid $vlanname; echo $?)"
|
||||
fi
|
||||
|
||||
# No ip lines default to dhcp
|
||||
@@ -221,12 +237,12 @@ for p in $(getargs ip=); do
|
||||
ip_to_var $p
|
||||
# skip ibft
|
||||
[ "$autoconf" = "ibft" ] && continue
|
||||
|
||||
|
||||
# If this option isn't directed at our interface, skip it
|
||||
[ -n "$dev" ] && [ "$dev" != "$netif" ] && continue
|
||||
|
||||
# Store config for later use
|
||||
for i in ip srv gw mask hostname; do
|
||||
for i in ip srv gw mask hostname macaddr; do
|
||||
eval '[ "$'$i'" ] && echo '$i'="$'$i'"'
|
||||
done > /tmp/net.$netif.override
|
||||
|
||||
@@ -240,6 +256,21 @@ for p in $(getargs ip=); do
|
||||
*)
|
||||
do_static ;;
|
||||
esac
|
||||
|
||||
case $autoconf in
|
||||
dhcp|on|any|dhcp6)
|
||||
;;
|
||||
*)
|
||||
if [ $? -eq 0 ]; then
|
||||
setup_net $netif
|
||||
source_hook initqueue/online $netif
|
||||
if [ -z "$manualup" ]; then
|
||||
/sbin/netroot $netif
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
break
|
||||
done
|
||||
exit 0
|
@@ -5,7 +5,7 @@
|
||||
for f in /tmp/dhclient.*.pid; do
|
||||
[ -e $f ] || continue
|
||||
read PID < $f;
|
||||
kill $PID;
|
||||
kill $PID >/dev/null 2>&1
|
||||
done
|
||||
|
||||
sleep 0.1
|
||||
@@ -13,5 +13,5 @@ sleep 0.1
|
||||
for f in /tmp/dhclient.*.pid; do
|
||||
[ -e $f ] || continue
|
||||
read PID < $f;
|
||||
kill -9 $PID;
|
||||
kill -9 $PID >/dev/null 2>&1
|
||||
done
|
||||
|
@@ -4,7 +4,6 @@
|
||||
|
||||
check() {
|
||||
local _program
|
||||
. $dracutfunctions
|
||||
|
||||
for _program in ip arping dhclient ; do
|
||||
if ! type -P $_program >/dev/null; then
|
||||
@@ -27,6 +26,7 @@ installkernel() {
|
||||
net_module_filter() {
|
||||
local _net_drivers='eth_type_trans|register_virtio_device'
|
||||
local _unwanted_drivers='/(wireless|isdn|uwb)/'
|
||||
local _ret
|
||||
# subfunctions inherit following FDs
|
||||
local _merge=8 _side2=9
|
||||
function nmf1() {
|
||||
@@ -42,6 +42,7 @@ installkernel() {
|
||||
&& ! $_fcont =~ iw_handler_get_spy ]] \
|
||||
&& echo "$_fname"
|
||||
done
|
||||
return 0
|
||||
}
|
||||
function rotor() {
|
||||
local _f1 _f2
|
||||
@@ -51,49 +52,51 @@ installkernel() {
|
||||
echo "$_f2" 1>&${_side2}
|
||||
fi
|
||||
done | nmf1 1>&${_merge}
|
||||
return 0
|
||||
}
|
||||
# Use two parallel streams to filter alternating modules.
|
||||
set +x
|
||||
eval "( ( rotor ) ${_side2}>&1 | nmf1 ) ${_merge}>&1"
|
||||
[[ $debug ]] && set -x
|
||||
return 0
|
||||
}
|
||||
|
||||
{ find_kernel_modules_by_path drivers/net; find_kernel_modules_by_path drivers/s390/net; } \
|
||||
{ find_kernel_modules_by_path drivers/net; if [ "$_arch" = "s390" -o "$_arch" = "s390x" ]; then find_kernel_modules_by_path drivers/s390/net; fi; } \
|
||||
| net_module_filter | instmods
|
||||
|
||||
instmods =drivers/net/phy
|
||||
instmods ecb arc4
|
||||
# bridge modules
|
||||
instmods bridge stp llc
|
||||
instmods ipv6
|
||||
# bonding
|
||||
instmods bonding
|
||||
# vlan
|
||||
instmods 8021q
|
||||
}
|
||||
|
||||
install() {
|
||||
local _arch _i _dir
|
||||
dracut_install ip arping tr dhclient
|
||||
dracut_install -o brctl ifenslave
|
||||
inst "$moddir/ifup" "/sbin/ifup"
|
||||
inst "$moddir/netroot" "/sbin/netroot"
|
||||
inst "$moddir/dhclient-script" "/sbin/dhclient-script"
|
||||
dracut_install ip arping dhclient sed
|
||||
dracut_install -o brctl
|
||||
inst_script "$moddir/ifup.sh" "/sbin/ifup"
|
||||
inst_script "$moddir/netroot.sh" "/sbin/netroot"
|
||||
inst_script "$moddir/dhclient-script.sh" "/sbin/dhclient-script"
|
||||
inst_simple "$moddir/net-lib.sh" "/lib/net-lib.sh"
|
||||
inst_simple "$moddir/dhclient.conf" "/etc/dhclient.conf"
|
||||
inst_hook pre-udev 50 "$moddir/ifname-genrules.sh"
|
||||
inst_hook pre-udev 60 "$moddir/net-genrules.sh"
|
||||
inst_hook cmdline 91 "$moddir/dhcp-root.sh"
|
||||
inst_hook cmdline 95 "$moddir/parse-vlan.sh"
|
||||
inst_hook cmdline 96 "$moddir/parse-bond.sh"
|
||||
inst_hook cmdline 97 "$moddir/parse-bridge.sh"
|
||||
inst_hook cmdline 98 "$moddir/parse-ip-opts.sh"
|
||||
inst_hook cmdline 99 "$moddir/parse-ifname.sh"
|
||||
inst_hook pre-pivot 10 "$moddir/kill-dhclient.sh"
|
||||
inst_hook cleanup 10 "$moddir/kill-dhclient.sh"
|
||||
|
||||
_arch=$(uname -m)
|
||||
|
||||
for _dir in "$usrlibdir/tls/$_arch" "$usrlibdir/tls" "$usrlibdir/$_arch" \
|
||||
"$usrlibdir" "$libdir"; do
|
||||
for _i in "$_dir"/libnss_dns.so.* "$_dir"/libnss_mdns4_minimal.so.*; do
|
||||
[ -e "$_i" ] && dracut_install "$_i"
|
||||
done
|
||||
done
|
||||
|
||||
inst_libdir_file {"tls/$_arch/",tls/,"$_arch/",}"libnss_dns.so.*" \
|
||||
{"tls/$_arch/",tls/,"$_arch/",}"libnss_mdns4_minimal.so.*"
|
||||
}
|
||||
|
||||
|
@@ -10,54 +10,51 @@ fix_bootif() {
|
||||
macaddr=${macaddr%:}
|
||||
# strip hardware type field from pxelinux
|
||||
[ -n "${macaddr%??:??:??:??:??:??}" ] && macaddr=${macaddr#??:}
|
||||
echo $macaddr
|
||||
# return macaddr with lowercase alpha characters expected by udev
|
||||
echo $macaddr | sed 'y/ABCDEF/abcdef/'
|
||||
}
|
||||
|
||||
# Don't continue if we don't need network
|
||||
[ -z "$netroot" ] && ! getargbool 0 rd.neednet && return;
|
||||
[ -z "$netroot" ] && ! [ -e "/tmp/net.ifaces" ] && return;
|
||||
|
||||
# Write udev rules
|
||||
{
|
||||
# bridge: attempt only the defined interface
|
||||
if [ -e /tmp/bridge.info ]; then
|
||||
. /tmp/bridge.info
|
||||
IFACES=$ethname
|
||||
IFACES+=" ${ethnames%% *}"
|
||||
fi
|
||||
|
||||
# bond: attempt only the defined interface (override bridge defines)
|
||||
if [ -e /tmp/bond.info ]; then
|
||||
. /tmp/bond.info
|
||||
# It is enough to fire up only one
|
||||
IFACES=${bondslaves%% *}
|
||||
IFACES+=" ${bondslaves%% *}"
|
||||
fi
|
||||
|
||||
if [ -e /tmp/vlan.info ]; then
|
||||
. /tmp/vlan.info
|
||||
IFACES+=" $phydevice"
|
||||
fi
|
||||
|
||||
ifup='/sbin/ifup $env{INTERFACE}'
|
||||
[ -z "$netroot" ] && ifup="$ifup -m"
|
||||
|
||||
# BOOTIF says everything, use only that one
|
||||
BOOTIF=$(getarg 'BOOTIF=')
|
||||
if [ -n "$BOOTIF" ] ; then
|
||||
BOOTIF=$(fix_bootif "$BOOTIF")
|
||||
if [ -n "$netroot" ]; then
|
||||
printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", OPTIONS+="event_timeout=360", RUN+="/sbin/ifup $env{INTERFACE}"\n' "$BOOTIF"
|
||||
else
|
||||
printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", OPTIONS+="event_timeout=360", RUN+="/sbin/ifup $env{INTERFACE} -m"\n' "$BOOTIF"
|
||||
fi
|
||||
printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="%s"\n' "$BOOTIF" "/sbin/initqueue --onetime $ifup"
|
||||
|
||||
# If we have to handle multiple interfaces, handle only them.
|
||||
elif [ -n "$IFACES" ] ; then
|
||||
for iface in $IFACES ; do
|
||||
if [ -n "$netroot" ]; then
|
||||
printf 'SUBSYSTEM=="net", ENV{INTERFACE}=="%s", OPTIONS+="event_timeout=360", RUN+="/sbin/ifup $env{INTERFACE}"\n' "$iface"
|
||||
else
|
||||
printf 'SUBSYSTEM=="net", ENV{INTERFACE}=="%s", OPTIONS+="event_timeout=360", RUN+="/sbin/ifup $env{INTERFACE} -m"\n' "$iface"
|
||||
fi
|
||||
printf 'SUBSYSTEM=="net", ENV{INTERFACE}=="%s", RUN+="%s"\n' "$iface" "/sbin/initqueue --onetime $ifup"
|
||||
done
|
||||
|
||||
# Default: We don't know the interface to use, handle all
|
||||
else
|
||||
if [ -n "$netroot" ]; then
|
||||
printf 'SUBSYSTEM=="net", OPTIONS+="event_timeout=360", RUN+="/sbin/ifup $env{INTERFACE}"\n'
|
||||
else
|
||||
printf 'SUBSYSTEM=="net", OPTIONS+="event_timeout=360", RUN+="/sbin/ifup $env{INTERFACE} -m"\n'
|
||||
fi
|
||||
printf 'SUBSYSTEM=="net", RUN+="%s"\n' "/sbin/initqueue --onetime $ifup" > /etc/udev/rules.d/61-default-net.rules
|
||||
fi
|
||||
|
||||
} > /etc/udev/rules.d/60-net.rules
|
||||
|
291
modules.d/40network/net-lib.sh
Normal file
291
modules.d/40network/net-lib.sh
Normal file
@@ -0,0 +1,291 @@
|
||||
#!/bin/sh
|
||||
|
||||
get_ip() {
|
||||
local iface="$1" ip=""
|
||||
ip=$(ip -o -f inet addr show $iface)
|
||||
ip=${ip%%/*}
|
||||
ip=${ip##* }
|
||||
}
|
||||
|
||||
iface_for_remote_addr() {
|
||||
set -- $(ip -o route get to $1)
|
||||
echo $5
|
||||
}
|
||||
|
||||
iface_for_mac() {
|
||||
local interface="" mac="$(echo $1 | sed 'y/ABCDEF/abcdef/')"
|
||||
for interface in /sys/class/net/*; do
|
||||
if [ $(cat $interface/address) = "$mac" ]; then
|
||||
echo ${interface##*/}
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
iface_has_link() {
|
||||
local interface="$1" flags=""
|
||||
[ -n "$interface" ] || return 2
|
||||
interface="/sys/class/net/$interface"
|
||||
[ -d "$interface" ] || return 2
|
||||
flags=$(cat $interface/flags)
|
||||
echo $(($flags|0x41)) > $interface/flags # 0x41: IFF_UP|IFF_RUNNING
|
||||
[ "$(cat $interface/carrier)" = 1 ] || return 1
|
||||
# XXX Do we need to reset the flags here? anaconda never bothered..
|
||||
}
|
||||
|
||||
all_ifaces_up() {
|
||||
local iface="" IFACES=""
|
||||
[ -e "/tmp/net.ifaces" ] && read IFACES < /tmp/net.ifaces
|
||||
for iface in $IFACES; do
|
||||
[ -e /tmp/net.$iface.up ] || return 1
|
||||
done
|
||||
}
|
||||
|
||||
get_netroot_ip() {
|
||||
local prefix="" server="" rest=""
|
||||
splitsep "$1" ":" prefix server rest
|
||||
case $server in
|
||||
[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*) echo "$server"; return 0 ;;
|
||||
esac
|
||||
return 1
|
||||
}
|
||||
|
||||
ip_is_local() {
|
||||
strstr "$(ip route get $1 2>/dev/null)" " via "
|
||||
}
|
||||
|
||||
ifdown() {
|
||||
local netif="$1"
|
||||
# ip down/flush ensures that routing info goes away as well
|
||||
ip link set $netif down
|
||||
ip addr flush dev $netif
|
||||
echo "#empty" > /etc/resolv.conf
|
||||
rm -f /tmp/net.$netif.did-setup
|
||||
# TODO: send "offline" uevent?
|
||||
}
|
||||
|
||||
setup_net() {
|
||||
local netif="$1" f="" gw_ip="" netroot_ip="" iface="" IFACES=""
|
||||
[ -e /tmp/net.$netif.did-setup ] && return
|
||||
[ -e "/tmp/net.ifaces" ] && read IFACES < /tmp/net.ifaces
|
||||
[ -z "$IFACES" ] && IFACES="$netif"
|
||||
# run the scripts written by ifup
|
||||
[ -e /tmp/net.$netif.gw ] && . /tmp/net.$netif.gw
|
||||
[ -e /tmp/net.$netif.hostname ] && . /tmp/net.$netif.hostname
|
||||
[ -e /tmp/net.$netif.override ] && . /tmp/net.$netif.override
|
||||
[ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
|
||||
# set up resolv.conf
|
||||
[ -e /tmp/net.$netif.resolv.conf ] && \
|
||||
cp -f /tmp/net.$netif.resolv.conf /etc/resolv.conf
|
||||
|
||||
# Handle STP Timeout: arping the default gateway.
|
||||
# (or the root server, if a) it's local or b) there's no gateway.)
|
||||
# Note: This assumes that if no router is present the
|
||||
# root server is on the same subnet.
|
||||
|
||||
# Get DHCP-provided router IP, or the cmdline-provided "gw=" argument
|
||||
[ -n "$new_routers" ] && gw_ip=${new_routers%%,*}
|
||||
[ -n "$gw" ] && gw_ip=$gw
|
||||
|
||||
# Get the "netroot" IP (if there's an IP address in there)
|
||||
netroot_ip=$(get_netroot_ip $netroot)
|
||||
|
||||
# try netroot if it's local (or there's no gateway)
|
||||
if ip_is_local $netroot_ip || [ -z "$gw_ip" ]; then
|
||||
dest="$netroot_ip"
|
||||
else
|
||||
dest="$gw_ip"
|
||||
fi
|
||||
|
||||
unset layer2
|
||||
if [ -f /sys/class/net/$netif/device/layer2 ]; then
|
||||
read layer2 < /sys/class/net/$netif/device/layer2
|
||||
fi
|
||||
|
||||
if [ "$layer2" != "0" ] && [ -n "$dest" ] && ! arping -q -f -w 60 -I $netif $dest ; then
|
||||
info "Resolving $dest via ARP on $netif failed"
|
||||
fi
|
||||
unset layer2
|
||||
|
||||
> /tmp/net.$netif.did-setup
|
||||
}
|
||||
|
||||
save_netinfo() {
|
||||
local netif="$1" IFACES="" f="" i=""
|
||||
[ -e /tmp/net.ifaces ] && read IFACES < /tmp/net.ifaces
|
||||
# Add $netif to the front of IFACES (if it's not there already).
|
||||
set -- "$netif"
|
||||
for i in $IFACES; do [ "$i" != "$netif" ] && set -- "$@" "$i"; done
|
||||
IFACES="$*"
|
||||
for i in $IFACES; do
|
||||
for f in /tmp/dhclient.$i.*; do
|
||||
[ -f $f ] && cp -f $f /tmp/net.${f#/tmp/dhclient.}
|
||||
done
|
||||
done
|
||||
echo $IFACES > /tmp/.net.ifaces.new
|
||||
mv /tmp/.net.ifaces.new /tmp/net.ifaces
|
||||
}
|
||||
|
||||
set_ifname() {
|
||||
local name="$1" mac="$2" num=0 n=""
|
||||
# if it's already set, return the existing name
|
||||
for n in $(getargs ifname=); do
|
||||
strstr "$n" "$mac" && echo ${n%%:*} && return
|
||||
done
|
||||
# otherwise, pick a new name and use that
|
||||
while [ -e /sys/class/$name$num ]; do num=$(($num+1)); done
|
||||
echo "ifname=$name$num:$mac" >> /etc/cmdline.d/45-ifname.conf
|
||||
echo "$name$num"
|
||||
}
|
||||
|
||||
ibft_to_cmdline() {
|
||||
local iface="" mac="" dev=""
|
||||
local dhcp="" ip="" gw="" mask="" hostname=""
|
||||
modprobe -q iscsi_ibft
|
||||
(
|
||||
for iface in /sys/firmware/ibft/ethernet*; do
|
||||
[ -e ${iface}/mac ] || continue
|
||||
mac=$(read a < ${iface}/mac; echo $a)
|
||||
[ -z "$ifname_mac" ] && continue
|
||||
dev=$(set_ifname ibft $ifname_mac)
|
||||
dhcp=$(read a < ${iface}/dhcp; echo $a)
|
||||
if [ -n "$dhcp" ]; then
|
||||
echo "ip=$dev:dhcp"
|
||||
else
|
||||
ip=$(read a < ${iface}/ip-addr; echo $a)
|
||||
gw=$(read a < ${iface}/gateway; echo $a)
|
||||
mask=$(read a < ${iface}/subnet-mask; echo $a)
|
||||
hostname=$(read a < ${iface}/hostname; echo $a)
|
||||
echo "ip=$ip::$gw:$mask:$hostname:$dev:none"
|
||||
fi
|
||||
done
|
||||
) >> /etc/cmdline.d/40-ibft.conf
|
||||
# reread cmdline
|
||||
unset CMDLINE
|
||||
}
|
||||
|
||||
parse_iscsi_root()
|
||||
{
|
||||
local v
|
||||
v=${1#iscsi:}
|
||||
|
||||
# extract authentication info
|
||||
case "$v" in
|
||||
*@*:*:*:*:*)
|
||||
authinfo=${v%%@*}
|
||||
v=${v#*@}
|
||||
# allow empty authinfo to allow having an @ in iscsi_target_name like this:
|
||||
# netroot=iscsi:@192.168.1.100::3260::iqn.2009-01.com.example:testdi@sk
|
||||
if [ -n "$authinfo" ]; then
|
||||
OLDIFS="$IFS"
|
||||
IFS=:
|
||||
set $authinfo
|
||||
IFS="$OLDIFS"
|
||||
if [ $# -gt 4 ]; then
|
||||
warn "Wrong authentication info in iscsi: parameter!"
|
||||
return 1
|
||||
fi
|
||||
iscsi_username=$1
|
||||
iscsi_password=$2
|
||||
if [ $# -gt 2 ]; then
|
||||
iscsi_in_username=$3
|
||||
iscsi_in_password=$4
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# extract target ip
|
||||
case "$v" in
|
||||
[[]*[]]:*)
|
||||
iscsi_target_ip=${v#[[]}
|
||||
iscsi_target_ip=${iscsi_target_ip%%[]]*}
|
||||
v=${v#[[]$iscsi_target_ip[]]:}
|
||||
;;
|
||||
*)
|
||||
iscsi_target_ip=${v%%[:]*}
|
||||
v=${v#$iscsi_target_ip:}
|
||||
;;
|
||||
esac
|
||||
|
||||
# extract target name
|
||||
case "$v" in
|
||||
*:iqn.*)
|
||||
iscsi_target_name=iqn.${v##*:iqn.}
|
||||
v=${v%:iqn.*}:
|
||||
;;
|
||||
*:eui.*)
|
||||
iscsi_target_name=iqn.${v##*:eui.}
|
||||
v=${v%:iqn.*}:
|
||||
;;
|
||||
*:naa.*)
|
||||
iscsi_target_name=iqn.${v##*:naa.}
|
||||
v=${v%:iqn.*}:
|
||||
;;
|
||||
*)
|
||||
warn "Invalid iscii target name, should begin with 'iqn.' or 'eui.' or 'naa.'"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# parse the rest
|
||||
OLDIFS="$IFS"
|
||||
IFS=:
|
||||
set $v
|
||||
IFS="$OLDIFS"
|
||||
|
||||
iscsi_protocol=$1; shift # ignored
|
||||
iscsi_target_port=$1; shift
|
||||
if [ $# -eq 3 ]; then
|
||||
iscsi_iface_name=$1; shift
|
||||
fi
|
||||
if [ $# -eq 2 ]; then
|
||||
iscsi_netdev_name=$1; shift
|
||||
fi
|
||||
iscsi_lun=$1; shift
|
||||
if [ $# -ne 0 ]; then
|
||||
warn "Invalid parameter in iscsi: parameter!"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
ip_to_var() {
|
||||
local v=${1}:
|
||||
local i
|
||||
set --
|
||||
while [ -n "$v" ]; do
|
||||
if [ "${v#\[*:*:*\]:}" != "$v" ]; then
|
||||
# handle IPv6 address
|
||||
i="${v%%\]:*}"
|
||||
i="${i##\[}"
|
||||
set -- "$@" "$i"
|
||||
v=${v#\[$i\]:}
|
||||
else
|
||||
set -- "$@" "${v%%:*}"
|
||||
v=${v#*:}
|
||||
fi
|
||||
done
|
||||
|
||||
unset ip srv gw mask hostname dev autoconf macaddr mtu
|
||||
case $# in
|
||||
0) autoconf="error" ;;
|
||||
1) autoconf=$1 ;;
|
||||
2) dev=$1; autoconf=$2 ;;
|
||||
3) dev=$1; autoconf=$2; mtu=$3 ;;
|
||||
4) dev=$1; autoconf=$2; mtu=$3; macaddr=$4 ;;
|
||||
*) ip=$1; srv=$2; gw=$3; mask=$4; hostname=$5; dev=$6; autoconf=$7; mtu=$8; macaddr=$9 ;;
|
||||
esac
|
||||
# anaconda-style argument cluster
|
||||
if strstr "$autoconf" "*.*.*.*"; then
|
||||
ip="$autoconf"
|
||||
gw=$(getarg gateway=)
|
||||
mask=$(getarg netmask=)
|
||||
hostname=$(getarg hostname=)
|
||||
dev=$(getarg ksdevice=)
|
||||
autoconf="none"
|
||||
mtu=$(getarg mtu=)
|
||||
case "$dev" in
|
||||
# ignore fancy values for ksdevice=XXX
|
||||
link|bootif|BOOTIF|ibft|*:*:*:*:*:*) dev="" ;;
|
||||
esac
|
||||
fi
|
||||
}
|
@@ -1,161 +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
|
||||
|
||||
PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
|
||||
# Huh? Empty $1?
|
||||
[ -z "$1" ] && exit 1
|
||||
|
||||
# Huh? No interface config?
|
||||
[ ! -e /tmp/net.$1.up ] && exit 1
|
||||
|
||||
# [ ! -z $2 ] means this is for manually bringing up network
|
||||
# instead of real netroot; If It's called without $2, then there's
|
||||
# no sense in doing something if no (net)root info is available
|
||||
# or root is already there
|
||||
[ -e /tmp/root.info ] || exit 1
|
||||
. /tmp/root.info
|
||||
if [ -z "$2" ]; then
|
||||
[ -d $NEWROOT/proc ] && exit 0
|
||||
[ -z "$netroot" ] && exit 1
|
||||
fi
|
||||
|
||||
# Let's see if we have to wait for other interfaces
|
||||
# Note: exit works just fine, since the last interface to be
|
||||
# online'd should see all files
|
||||
[ -e "/tmp/net.ifaces" ] && read IFACES < /tmp/net.ifaces
|
||||
for iface in $IFACES ; do
|
||||
[ -e /tmp/net.$iface.up ] || exit 1
|
||||
done
|
||||
|
||||
# Set or override primary interface
|
||||
netif=$1
|
||||
[ -e "/tmp/net.bootdev" ] && read netif < /tmp/net.bootdev
|
||||
|
||||
if [ -e /tmp/net.$netif.manualup ]; then
|
||||
rm -f /tmp/net.$netif.manualup
|
||||
fi
|
||||
|
||||
# Figure out the handler for root=dhcp by recalling all netroot cmdline
|
||||
# handlers when this is not called from manually network bringing up.
|
||||
if [ -z "$2" ]; then
|
||||
if [ "$netroot" = "dhcp" ] || [ "$netroot" = "dhcp6" ] ; then
|
||||
# Unset root so we can check later
|
||||
unset root
|
||||
|
||||
# Load dhcp options
|
||||
[ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
|
||||
|
||||
# If we have a specific bootdev with no dhcpoptions or empty root-path,
|
||||
# we die. Otherwise we just warn
|
||||
if [ -z "$new_root_path" ] ; then
|
||||
[ -n "$BOOTDEV" ] && die "No dhcp root-path received for '$BOOTDEV'"
|
||||
warn "No dhcp root-path received for '$BOOTDEV' trying other interfaces if available"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Set netroot to new_root_path, so cmdline parsers don't call
|
||||
netroot=$new_root_path
|
||||
|
||||
# FIXME!
|
||||
for f in $hookdir/cmdline/90*.sh; do
|
||||
[ -f "$f" ] && . "$f";
|
||||
done
|
||||
else
|
||||
rootok="1"
|
||||
fi
|
||||
|
||||
# Check: do we really know how to handle (net)root?
|
||||
[ -z "$root" ] && die "No or empty root= argument"
|
||||
[ -z "$rootok" ] && die "Don't know how to handle 'root=$root'"
|
||||
|
||||
handler=${netroot%%:*}
|
||||
handler=${handler%%4}
|
||||
handler=$(command -v ${handler}root)
|
||||
if [ -z "$netroot" ] || [ ! -e "$handler" ] ; then
|
||||
die "No handler for netroot type '$netroot'"
|
||||
fi
|
||||
fi
|
||||
|
||||
# We're here, so we can assume that upping interfaces is now ok
|
||||
[ -z "$IFACES" ] && IFACES="$netif"
|
||||
for iface in $IFACES ; do
|
||||
. /tmp/net.$iface.up
|
||||
done
|
||||
|
||||
[ -e /tmp/net.$netif.gw ] && . /tmp/net.$netif.gw
|
||||
[ -e /tmp/net.$netif.hostname ] && . /tmp/net.$netif.hostname
|
||||
[ -e /tmp/net.$netif.resolv.conf ] && cp -f /tmp/net.$netif.resolv.conf /etc/resolv.conf
|
||||
|
||||
# Load interface options
|
||||
[ -e /tmp/net.$netif.override ] && . /tmp/net.$netif.override
|
||||
[ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
|
||||
|
||||
# Handle STP Timeout: arping the default router if root server is
|
||||
# unknown or not local, or if not available the root server.
|
||||
# Note: This assumes that if no router is present the
|
||||
# root server is on the same subnet.
|
||||
#
|
||||
# TODO There's some netroot variants that don't (yet) have their
|
||||
# server-ip netroot
|
||||
|
||||
# Get router IP if set
|
||||
[ -n "$new_routers" ] && gw_ip=${new_routers%%,*}
|
||||
[ -n "$gw" ] && gw_ip=$gw
|
||||
# Get root server IP if set
|
||||
if [ -n "$netroot" ]; then
|
||||
dummy=${netroot#*:}
|
||||
dummy=${dummy%%:*}
|
||||
case "$dummy" in
|
||||
[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*) netroot_ip=$dummy;;
|
||||
esac
|
||||
fi
|
||||
# Default arping dest to router
|
||||
dest="$gw_ip"
|
||||
# Change to arping root server if appropriate
|
||||
if [ -n "$netroot_ip" ]; then
|
||||
if [ -z "$dest" ]; then
|
||||
# no gateway so check root server
|
||||
dest="$netroot_ip"
|
||||
else
|
||||
r=$(ip route get "$netroot_ip")
|
||||
if ! strstr "$r" ' via ' ; then
|
||||
# local root server, so don't arping gateway
|
||||
dest="$netroot_ip"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ -n "$dest" ] && ! arping -q -f -w 60 -I $netif $dest ; then
|
||||
dinfo "Resolving $dest via ARP on $netif failed"
|
||||
fi
|
||||
|
||||
# exit in case manually bring up network
|
||||
[ -n "$2" ] && exit 0
|
||||
|
||||
# Source netroot hooks before we start the handler
|
||||
source_all $hookdir/netroot
|
||||
|
||||
# Run the handler; don't store the root, it may change from device to device
|
||||
# XXX other variables to export?
|
||||
if $handler $netif $netroot $NEWROOT; then
|
||||
# Network rootfs mount successful
|
||||
for iface in $IFACES ; do
|
||||
[ -f /tmp/dhclient.$iface.lease ] && cp /tmp/dhclient.$iface.lease /tmp/net.$iface.lease
|
||||
[ -f /tmp/dhclient.$iface.dhcpopts ] && cp /tmp/dhclient.$iface.dhcpopts /tmp/net.$iface.dhcpopts
|
||||
done
|
||||
|
||||
# Save used netif for later use
|
||||
[ ! -f /tmp/net.ifaces ] && echo $netif > /tmp/net.ifaces
|
||||
else
|
||||
warn "Mounting root via '$netif' failed"
|
||||
# If we're trying with multiple interfaces, put that one down.
|
||||
# ip down/flush ensures that routeing info goes away as well
|
||||
if [ -z "$BOOTDEV" ] ; then
|
||||
ip link set $netif down
|
||||
ip addr flush dev $netif
|
||||
echo "#empty" > /etc/resolv.conf
|
||||
fi
|
||||
fi
|
||||
exit 0
|
73
modules.d/40network/netroot.sh
Executable file
73
modules.d/40network/netroot.sh
Executable file
@@ -0,0 +1,73 @@
|
||||
#!/bin/sh
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
||||
command -v getarg >/dev/null || . /lib/dracut-lib.sh
|
||||
command -v setup_net >/dev/null || . /lib/net-lib.sh
|
||||
|
||||
# Huh? Empty $1?
|
||||
[ -z "$1" ] && exit 1
|
||||
|
||||
# [ ! -z $2 ] means this is for manually bringing up network
|
||||
# instead of real netroot; If It's called without $2, then there's
|
||||
# no sense in doing something if no (net)root info is available
|
||||
# or root is already there
|
||||
[ -d $NEWROOT/proc ] && exit 0
|
||||
[ -z "$netroot" ] && exit 1
|
||||
|
||||
# Set or override primary interface
|
||||
netif=$1
|
||||
[ -e "/tmp/net.bootdev" ] && read netif < /tmp/net.bootdev
|
||||
|
||||
# Figure out the handler for root=dhcp by recalling all netroot cmdline
|
||||
# handlers when this is not called from manually network bringing up.
|
||||
if [ -z "$2" ]; then
|
||||
if [ "$netroot" = "dhcp" ] || [ "$netroot" = "dhcp6" ] ; then
|
||||
# Unset root so we can check later
|
||||
unset root
|
||||
|
||||
# Load dhcp options
|
||||
[ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
|
||||
|
||||
# If we have a specific bootdev with no dhcpoptions or empty root-path,
|
||||
# we die. Otherwise we just warn
|
||||
if [ -z "$new_root_path" ] ; then
|
||||
[ -n "$BOOTDEV" ] && die "No dhcp root-path received for '$BOOTDEV'"
|
||||
warn "No dhcp root-path received for '$BOOTDEV' trying other interfaces if available"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Set netroot to new_root_path, so cmdline parsers don't call
|
||||
netroot=$new_root_path
|
||||
|
||||
# FIXME!
|
||||
for f in $hookdir/cmdline/90*.sh; do
|
||||
[ -f "$f" ] && . "$f";
|
||||
done
|
||||
else
|
||||
rootok="1"
|
||||
fi
|
||||
|
||||
# Check: do we really know how to handle (net)root?
|
||||
[ -z "$root" ] && die "No or empty root= argument"
|
||||
[ -z "$rootok" ] && die "Don't know how to handle 'root=$root'"
|
||||
|
||||
handler=${netroot%%:*}
|
||||
handler=${handler%%4}
|
||||
handler=$(command -v ${handler}root)
|
||||
if [ -z "$netroot" ] || [ ! -e "$handler" ] ; then
|
||||
die "No handler for netroot type '$netroot'"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Source netroot hooks before we start the handler
|
||||
source_hook netroot $netif
|
||||
|
||||
# Run the handler; don't store the root, it may change from device to device
|
||||
# XXX other variables to export?
|
||||
if $handler $netif $netroot $NEWROOT; then
|
||||
# Network rootfs mount successful - save interface info for ifcfg etc.
|
||||
save_netinfo $netif
|
||||
fi
|
||||
exit 0
|
@@ -15,10 +15,7 @@
|
||||
|
||||
# Check if bond parameter is valid
|
||||
if getarg bond= >/dev/null ; then
|
||||
if [ -z "$netroot" ] ; then
|
||||
die "No netboot configured, bond is invalid"
|
||||
fi
|
||||
command -v brctl >/dev/null 2>&1 || die "No 'brctl' installed"
|
||||
:
|
||||
fi
|
||||
|
||||
# We translate list of slaves to space-separated here to mwke it easier to loop over them in ifup
|
||||
@@ -35,8 +32,8 @@ parsebond() {
|
||||
case $# in
|
||||
0) bondname=bond0; bondslaves="eth0 eth1" ;;
|
||||
1) bondname=$1; bondslaves="eth0 eth1" ;;
|
||||
2) bondname=$1; bondslaves=$(echo $2|tr "," " ") ;;
|
||||
3) bondname=$1; bondslaves=$(echo $2|tr "," " "); bondoptions=$(echo $3|tr "," " ") ;;
|
||||
2) bondname=$1; bondslaves=$(str_replace "$2" "," " ") ;;
|
||||
3) bondname=$1; bondslaves=$(str_replace "$2" "," " "); bondoptions=$(str_replace "$3" "," " ") ;;
|
||||
*) die "bond= requires zero to four parameters" ;;
|
||||
esac
|
||||
}
|
||||
@@ -56,7 +53,7 @@ if getarg bond >/dev/null; then
|
||||
bondslaves="eth0 eth1"
|
||||
fi
|
||||
# Make it suitable for initscripts export
|
||||
bondoptions=$(echo $bondoptions|tr ";" ",")
|
||||
bondoptions=$(str_replace "$bondoptions" ";" ",")
|
||||
echo "bondname=$bondname" > /tmp/bond.info
|
||||
echo "bondslaves=\"$bondslaves\"" >> /tmp/bond.info
|
||||
echo "bondoptions=\"$bondoptions\"" >> /tmp/bond.info
|
||||
|
@@ -3,8 +3,9 @@
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
#
|
||||
# Format:
|
||||
# bridge=<bridgename>:<ethname>
|
||||
# bridge=<bridgename>:<ethnames>
|
||||
#
|
||||
# <ethnames> is a comma-separated list of physical (ethernet) interfaces
|
||||
# bridge without parameters assumes bridge=br0:eth0
|
||||
#
|
||||
|
||||
@@ -13,9 +14,6 @@
|
||||
|
||||
# Check if bridge parameter is valid
|
||||
if getarg bridge= >/dev/null ; then
|
||||
if [ -z "$netroot" ] ; then
|
||||
die "No netboot configured, bridge is invalid"
|
||||
fi
|
||||
command -v brctl >/dev/null 2>&1 || die "No 'brctl' installed"
|
||||
fi
|
||||
|
||||
@@ -27,16 +25,16 @@ parsebridge() {
|
||||
v=${v#*:}
|
||||
done
|
||||
|
||||
unset bridgename ethname
|
||||
unset bridgename ethnames
|
||||
case $# in
|
||||
0) bridgename=br0; ethname=$iface ;;
|
||||
0) bridgename=br0; ethnames=$iface ;;
|
||||
1) die "bridge= requires two parameters" ;;
|
||||
2) bridgename=$1; ethname=$2 ;;
|
||||
2) bridgename=$1; ethnames=$(str_replace "$2" "," " ") ;;
|
||||
*) die "bridge= requires two parameters" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
unset bridgename ethname
|
||||
unset bridgename ethnames
|
||||
|
||||
iface=eth0
|
||||
if [ -e /tmp/bond.info ]; then
|
||||
@@ -46,7 +44,7 @@ if [ -e /tmp/bond.info ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# Parse bridge for bridgename and ethname
|
||||
# Parse bridge for bridgename and ethnames
|
||||
if bridge="$(getarg bridge)"; then
|
||||
# Read bridge= parameters if they exist
|
||||
if [ -n "$bridge" ]; then
|
||||
@@ -55,9 +53,9 @@ if bridge="$(getarg bridge)"; then
|
||||
# Simple default bridge
|
||||
if [ -z "$bridgename" ]; then
|
||||
bridgename=br0
|
||||
ethname=$iface
|
||||
ethnames=$iface
|
||||
fi
|
||||
echo "bridgename=$bridgename" > /tmp/bridge.info
|
||||
echo "ethname=$ethname" >> /tmp/bridge.info
|
||||
echo "ethnames=\"$ethnames\"" >> /tmp/bridge.info
|
||||
return
|
||||
fi
|
||||
|
@@ -26,7 +26,7 @@ parse_ifname_opts() {
|
||||
7)
|
||||
ifname_if=$1
|
||||
# udev requires MAC addresses to be lower case
|
||||
ifname_mac=`echo $2:$3:$4:$5:$6:$7 | tr '[:upper:]' '[:lower:]'`
|
||||
ifname_mac=$(echo $2:$3:$4:$5:$6:$7 | sed 'y/ABCDEF/abcdef/')
|
||||
;;
|
||||
*)
|
||||
die "Invalid arguments for ifname="
|
||||
|
@@ -5,24 +5,17 @@
|
||||
# Format:
|
||||
# ip=[dhcp|on|any]
|
||||
#
|
||||
# ip=<interface>:[dhcp|on|any]
|
||||
# ip=<interface>:[dhcp|on|any][:[<mtu>][:<macaddr>]]
|
||||
#
|
||||
# ip=<client-IP-number>:<server-IP-number>:<gateway-IP-number>:<netmask>:<client-hostname>:<interface>:[dhcp|on|any|none|off]
|
||||
# ip=<client-IP-number>:<server-IP-number>:<gateway-IP-number>:<netmask>:<client-hostname>:<interface>:{dhcp|on|any|none|off}[:[<mtu>][:<macaddr>]]
|
||||
#
|
||||
# When supplying more than only ip= line, <interface> is mandatory and
|
||||
# bootdev= must contain the name of the primary interface to use for
|
||||
# routing,dns,dhcp-options,etc.
|
||||
#
|
||||
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
|
||||
# Check if ip= lines should be used
|
||||
if getarg ip= >/dev/null ; then
|
||||
if [ -z "$netroot" ] ; then
|
||||
echo "Warning: No netboot configured, ignoring ip= lines"
|
||||
return;
|
||||
fi
|
||||
fi
|
||||
command -v getarg >/dev/null || . /lib/dracut-lib.sh
|
||||
command -v ibft_to_cmdline >/dev/null || . /lib/net-lib.sh
|
||||
|
||||
# Don't mix BOOTIF=macaddr from pxelinux and ip= lines
|
||||
getarg ip= >/dev/null && getarg BOOTIF= >/dev/null && \
|
||||
@@ -38,12 +31,13 @@ fi
|
||||
|
||||
# Count ip= lines to decide whether we need bootdev= or not
|
||||
if [ -z "$NEEDBOOTDEV" ] ; then
|
||||
local count=0
|
||||
count=0
|
||||
for p in $(getargs ip=); do
|
||||
count=$(( $count + 1 ))
|
||||
done
|
||||
[ $count -gt 1 ] && NEEDBOOTDEV=1
|
||||
fi
|
||||
unset count
|
||||
|
||||
# If needed, check if bootdev= contains anything usable
|
||||
if [ -n "$NEEDBOOTDEV" ] ; then
|
||||
@@ -51,50 +45,15 @@ if [ -n "$NEEDBOOTDEV" ] ; then
|
||||
[ -z "$BOOTDEV" ] && die "Bootdev argument is empty"
|
||||
fi
|
||||
|
||||
if [ "ibft" = "$(getarg ip=)" ]; then
|
||||
modprobe iscsi_ibft
|
||||
num=0
|
||||
(
|
||||
for iface in /sys/firmware/ibft/ethernet*; do
|
||||
[ -e ${iface}/mac ] || continue
|
||||
ifname_mac=$(read a < ${iface}/mac; echo $a)
|
||||
[ -z "$ifname_mac" ] && continue
|
||||
unset dev
|
||||
for ifname in $(getargs ifname=); do
|
||||
if strstr "$ifname" "$ifname_mac"; then
|
||||
dev=${ifname%%:*}
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$dev" ]; then
|
||||
ifname_if=ibft$num
|
||||
num=$(( $num + 1 ))
|
||||
echo "ifname=$ifname_if:$ifname_mac"
|
||||
dev=$ifname_if
|
||||
fi
|
||||
|
||||
dhcp=$(read a < ${iface}/dhcp; echo $a)
|
||||
if [ -n "$dhcp" ]; then
|
||||
echo "ip=$dev:dhcp"
|
||||
else
|
||||
ip=$(read a < ${iface}/ip-addr; echo $a)
|
||||
gw=$(read a < ${iface}/gateway; echo $a)
|
||||
mask=$(read a < ${iface}/subnet-mask; echo $a)
|
||||
hostname=$(read a < ${iface}/hostname; echo $a)
|
||||
echo "ip=$ip::$gw:$mask:$hostname:$dev:none"
|
||||
fi
|
||||
done
|
||||
) >> /etc/cmdline
|
||||
# reread cmdline
|
||||
unset CMDLINE
|
||||
fi
|
||||
# If ibft is requested, read ibft vals and write ip=XXX cmdline args
|
||||
[ "ibft" = "$(getarg ip=)" ] && ibft_to_cmdline
|
||||
|
||||
# Check ip= lines
|
||||
# XXX Would be nice if we could errorcheck ip addresses here as well
|
||||
for p in $(getargs ip=); do
|
||||
ip_to_var $p
|
||||
|
||||
# skip ibft
|
||||
# skip ibft since we did it above
|
||||
[ "$autoconf" = "ibft" ] && continue
|
||||
|
||||
# We need to have an ip= line for the specified bootdev
|
||||
@@ -110,7 +69,7 @@ for p in $(getargs ip=); do
|
||||
case $autoconf in
|
||||
error) die "Error parsing option 'ip=$p'";;
|
||||
bootp|rarp|both) die "Sorry, ip=$autoconf is currenty unsupported";;
|
||||
none|off) \
|
||||
none|off)
|
||||
[ -z "$ip" ] && \
|
||||
die "For argument 'ip=$p'\nValue '$autoconf' without static configuration does not make sense"
|
||||
[ -z "$mask" ] && \
|
||||
|
42
modules.d/40network/parse-vlan.sh
Normal file
42
modules.d/40network/parse-vlan.sh
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Format:
|
||||
# vlan=<vlanname>:<phydevice>
|
||||
#
|
||||
|
||||
# return if vlan already parsed
|
||||
[ -n "$vlanname" ] && return
|
||||
|
||||
# Check if vlan parameter is valid
|
||||
if getarg vlan= >/dev/null ; then
|
||||
:
|
||||
fi
|
||||
|
||||
parsevlan() {
|
||||
local v=${1}:
|
||||
set --
|
||||
while [ -n "$v" ]; do
|
||||
set -- "$@" "${v%%:*}"
|
||||
v=${v#*:}
|
||||
done
|
||||
|
||||
unset vlanname phydevice
|
||||
case $# in
|
||||
2) vlanname=$1; phydevice=$2 ;;
|
||||
*) die "vlan= requires two parameters" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
unset vlanname phydevice
|
||||
|
||||
if getarg vlan >/dev/null; then
|
||||
# Read vlan= parameters if they exist
|
||||
vlan="$(getarg vlan=)"
|
||||
if [ ! "$vlan" = "vlan" ]; then
|
||||
parsevlan "$(getarg vlan=)"
|
||||
fi
|
||||
|
||||
echo "vlanname=\"$vlanname\"" > /tmp/vlan.info
|
||||
echo "phydevice=\"$phydevice\"" >> /tmp/vlan.info
|
||||
return
|
||||
fi
|
@@ -18,11 +18,77 @@ if [ -e /tmp/bridge.info ]; then
|
||||
fi
|
||||
|
||||
mkdir -m 0755 -p /tmp/ifcfg/
|
||||
mkdir -m 0755 -p /tmp/ifcfg-leases/
|
||||
|
||||
get_config_line_by_subchannel()
|
||||
{
|
||||
local CHANNEL
|
||||
local line
|
||||
|
||||
CHANNELS="$1"
|
||||
while read line; do
|
||||
if strstr "$line" "$CHANNELS"; then
|
||||
echo $line
|
||||
return 0
|
||||
fi
|
||||
done < /etc/ccw.conf
|
||||
return 1
|
||||
}
|
||||
|
||||
print_s390() {
|
||||
local _netif
|
||||
local SUBCHANNELS
|
||||
local OPTIONS
|
||||
local NETTYPE
|
||||
local CONFIG_LINE
|
||||
local i
|
||||
local channel
|
||||
local OLD_IFS
|
||||
|
||||
_netif="$1"
|
||||
# if we find ccw channel, then use those, instead of
|
||||
# of the MAC
|
||||
SUBCHANNELS=$({
|
||||
for i in /sys/class/net/$_netif/device/cdev[0-9]*; do
|
||||
[ -e $i ] || continue
|
||||
channel=$(readlink -f $i)
|
||||
echo -n "${channel##*/},"
|
||||
done
|
||||
})
|
||||
[ -n "$SUBCHANNELS" ] || return 1
|
||||
|
||||
SUBCHANNELS=${SUBCHANNELS%,}
|
||||
echo "SUBCHANNELS=\"${SUBCHANNELS}\""
|
||||
CONFIG_LINE=$(get_config_line_by_subchannel $SUBCHANNELS)
|
||||
|
||||
[ $? -ne 0 -o -z "$CONFIG_LINE" ] && return
|
||||
|
||||
OLD_IFS=$IFS
|
||||
IFS=","
|
||||
set -- $CONFIG_LINE
|
||||
IFS=$OLD_IFS
|
||||
NETTYPE=$1
|
||||
shift
|
||||
SUBCHANNELS="$1"
|
||||
OPTIONS=""
|
||||
shift
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
*=*) OPTIONS="$OPTIONS $1";;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
OPTIONS=${OPTIONS## }
|
||||
echo "NETTYPE=\"${NETTYPE}\""
|
||||
echo "OPTIONS=\"${OPTIONS}\""
|
||||
}
|
||||
|
||||
|
||||
for netif in $IFACES ; do
|
||||
# bridge?
|
||||
unset bridge
|
||||
unset bond
|
||||
uuid=$(cat /proc/sys/kernel/random/uuid)
|
||||
if [ "$netif" = "$bridgename" ]; then
|
||||
bridge=yes
|
||||
elif [ "$netif" = "$bondname" ]; then
|
||||
@@ -35,17 +101,33 @@ for netif in $IFACES ; do
|
||||
echo "DEVICE=$netif"
|
||||
echo "ONBOOT=yes"
|
||||
echo "NETBOOT=yes"
|
||||
echo "UUID=$uuid"
|
||||
[ -n "$mtu" ] && echo "MTU=$mtu"
|
||||
if [ -f /tmp/net.$netif.lease ]; then
|
||||
strstr "$ip" '*:*:*' &&
|
||||
echo "DHCPV6C=yes"
|
||||
echo "BOOTPROTO=dhcp"
|
||||
cp /tmp/net.$netif.lease /tmp/ifcfg-leases/dhclient-$uuid-$netif.lease
|
||||
else
|
||||
echo "BOOTPROTO=none"
|
||||
# If we've booted with static ip= lines, the override file is there
|
||||
# If we've booted with static ip= lines, the override file is there
|
||||
[ -e /tmp/net.$netif.override ] && . /tmp/net.$netif.override
|
||||
echo "IPADDR=$ip"
|
||||
echo "NETMASK=$mask"
|
||||
[ -n "$gw" ] && echo "GATEWAY=$gw"
|
||||
if strstr "$ip" '*:*:*'; then
|
||||
echo "IPV6_AUTOCONF=no"
|
||||
echo "IPV6ADDR=$ip/$mask"
|
||||
else
|
||||
echo "BOOTPROTO=none"
|
||||
echo "IPADDR=$ip"
|
||||
if strstr "$mask" "."; then
|
||||
echo "NETMASK=$mask"
|
||||
else
|
||||
echo "PREFIX=$mask"
|
||||
fi
|
||||
fi
|
||||
if strstr "$gw" '*:*:*'; then
|
||||
echo "IPV6_DEFAULTGW=$gw"
|
||||
elif [ -n "$gw" ]; then
|
||||
echo "GATEWAY=$gw"
|
||||
fi
|
||||
fi
|
||||
} > /tmp/ifcfg/ifcfg-$netif
|
||||
|
||||
@@ -53,9 +135,15 @@ for netif in $IFACES ; do
|
||||
if [ -z "$bridge" ] && [ -z "$bond" ]; then
|
||||
# standard interface
|
||||
{
|
||||
echo "HWADDR=$(cat /sys/class/net/$netif/address)"
|
||||
if [ -n "$macaddr" ]; then
|
||||
echo "MACADDR=$macaddr"
|
||||
else
|
||||
echo "HWADDR=\"$(cat /sys/class/net/$netif/address)\""
|
||||
fi
|
||||
print_s390 $netif
|
||||
echo "TYPE=Ethernet"
|
||||
echo "NAME=\"Boot Disk\""
|
||||
[ -n "$mtu" ] && echo "MTU=$mtu"
|
||||
} >> /tmp/ifcfg/ifcfg-$netif
|
||||
fi
|
||||
|
||||
@@ -131,14 +219,21 @@ for netif in $IFACES ; do
|
||||
} >> /tmp/ifcfg/ifcfg-$ethname
|
||||
fi
|
||||
fi
|
||||
i=1
|
||||
for ns in $(getargs nameserver); do
|
||||
echo "DNS${i}=${ns}" >> /tmp/ifcfg/ifcfg-$netif
|
||||
i=$((i+1))
|
||||
done
|
||||
done
|
||||
|
||||
# Pass network opts
|
||||
[ -d /run/initramfs ] || mkdir -m 0755 -p /run/initramfs
|
||||
cp /tmp/net.* /run/initramfs/ >/dev/null 2>&1
|
||||
for i in /run/initramfs/state /run/initramfs/state/etc/ /run/initramfs/state/etc/sysconfig /run/initramfs/state/etc/sysconfig/network-scripts; do
|
||||
[ -d $i ] || mkdir -m 0755 -p $i
|
||||
done
|
||||
cp /tmp/net.$netif.resolv.conf /run/initramfs/state/etc/ >/dev/null 2>&1
|
||||
echo "files /etc/sysconfig/network-scripts" > /run/initramfs/rwtab
|
||||
cp -a -t /run/initramfs/state/etc/sysconfig/network-scripts/ /tmp/ifcfg/* >/dev/null 2>&1
|
||||
mkdir -m 0755 -p /run/initramfs/state/etc/sysconfig/network-scripts
|
||||
mkdir -m 0755 -p /run/initramfs/state/var/lib/dhclient
|
||||
echo "files /etc/sysconfig/network-scripts" >> /run/initramfs/rwtab
|
||||
echo "files /var/lib/dhclient" >> /run/initramfs/rwtab
|
||||
{
|
||||
cp /tmp/net.* /run/initramfs/
|
||||
cp /tmp/net.$netif.resolv.conf /run/initramfs/state/etc/resolv.conf
|
||||
copytree /tmp/ifcfg /run/initramfs/state/etc/sysconfig/network-scripts
|
||||
cp /tmp/ifcfg-leases/* /run/initramfs/state/var/lib/dhclient
|
||||
} > /dev/null 2>&1
|
||||
|
24
modules.d/45url-lib/module-setup.sh
Executable file
24
modules.d/45url-lib/module-setup.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
# module-setup for url-lib
|
||||
|
||||
check() {
|
||||
command -v curl >/dev/null || return 1
|
||||
return 255
|
||||
}
|
||||
|
||||
depends() {
|
||||
echo network
|
||||
return 0
|
||||
}
|
||||
|
||||
install() {
|
||||
inst_simple "$moddir/url-lib.sh" "/lib/url-lib.sh"
|
||||
dracut_install curl
|
||||
mkdir -m 0755 -p "$initdir/etc/ssl/certs"
|
||||
if ! inst_any -t /etc/ssl/certs/ca-bundle.crt \
|
||||
/etc/ssl/certs/ca-bundle.crt \
|
||||
/etc/ssl/certs/ca-certificates.crt; then
|
||||
dwarn "Couldn't find SSL CA cert bundle; HTTPS won't work."
|
||||
fi
|
||||
}
|
||||
|
118
modules.d/45url-lib/url-lib.sh
Executable file
118
modules.d/45url-lib/url-lib.sh
Executable file
@@ -0,0 +1,118 @@
|
||||
#!/bin/sh
|
||||
# url-lib.sh - functions for handling URLs (file fetching etc.)
|
||||
#
|
||||
# Authors:
|
||||
# Will Woods <wwoods@redhat.com>
|
||||
|
||||
type mkuniqdir >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
|
||||
# fetch_url URL [OUTFILE]
|
||||
# fetch the given URL to a locally-visible location.
|
||||
# if OUTFILE is given, the URL will be fetched to that filename,
|
||||
# overwriting it if present.
|
||||
# If the URL is something mountable (e.g. nfs://) and no OUTFILE is given,
|
||||
# the server will be left mounted until pre-pivot.
|
||||
# the return values are as follows:
|
||||
# 0: success
|
||||
# 253: unknown error (file missing)
|
||||
# 254: unhandled URL scheme / protocol
|
||||
# 255: bad arguments / unparseable URLs
|
||||
# other: fetch command failure (whatever curl/mount/etc return)
|
||||
fetch_url() {
|
||||
local url="$1" outloc="$2"
|
||||
local handler="$(get_url_handler $url)"
|
||||
[ -n "$handler" ] || return 254
|
||||
[ -n "$url" ] || return 255
|
||||
$handler "$url" "$outloc"
|
||||
}
|
||||
|
||||
# get_url_handler URL
|
||||
# returns the first HANDLERNAME corresponding to the URL's scheme
|
||||
get_url_handler() {
|
||||
local scheme="${1%%:*}" item=""
|
||||
for item in $url_handler_map; do
|
||||
[ "$scheme" = "${item%%:*}" ] && echo "${item#*:}" && return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# add_url_handler HANDLERNAME SCHEME [SCHEME...]
|
||||
# associate the named handler with the named scheme(s).
|
||||
add_url_handler() {
|
||||
local handler="$1"; shift
|
||||
local schemes="$@" scheme=""
|
||||
set --
|
||||
for scheme in $schemes; do
|
||||
[ "$(get_url_handler $scheme)" = "$handler" ] && continue
|
||||
set -- "$@" "$scheme:$handler"
|
||||
done
|
||||
set -- $@ $url_handler_map # add new items to *front* of list
|
||||
url_handler_map="$@"
|
||||
}
|
||||
|
||||
### HTTP, HTTPS, FTP #################################################
|
||||
|
||||
export CURL_HOME="/run/initramfs/url-lib"
|
||||
mkdir -p $CURL_HOME
|
||||
curl_args="--location --retry 3 --fail --show-error"
|
||||
|
||||
curl_fetch_url() {
|
||||
local url="$1" outloc="$2"
|
||||
echo "$url" > /proc/self/fd/0
|
||||
if [ -n "$outloc" ]; then
|
||||
curl $curl_args --output "$outloc" "$url" || return $?
|
||||
else
|
||||
local outdir="$(mkuniqdir /tmp curl_fetch_url)"
|
||||
( cd "$outdir"; curl $curl_args --remote-name "$url" || return $? )
|
||||
outloc="$outdir/$(ls -A $outdir)"
|
||||
fi
|
||||
[ -f "$outloc" ] || return 253
|
||||
if [ -z "$2" ]; then echo "$outloc" ; fi
|
||||
}
|
||||
add_url_handler curl_fetch_url http https ftp
|
||||
|
||||
set_http_header() {
|
||||
echo "header = \"$1: $2\"" >> $CURL_HOME/.curlrc
|
||||
}
|
||||
|
||||
### NFS ##############################################################
|
||||
|
||||
[ -e /lib/nfs-lib.sh ] && . /lib/nfs-lib.sh
|
||||
|
||||
nfs_already_mounted() {
|
||||
local server="$1" path="$2" localdir="" s="" p=""
|
||||
cat /proc/mounts | while read src mnt rest; do
|
||||
splitsep ":" "$src" s p
|
||||
if [ "$server" = "$s" ]; then
|
||||
if [ "$path" = "$p" ]; then
|
||||
echo $mnt
|
||||
elif str_starts "$path" "$p"; then
|
||||
echo $mnt/${path#$p/}
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
nfs_fetch_url() {
|
||||
local url="$1" outloc="$2" nfs="" server="" path="" options=""
|
||||
nfs_to_var "$url" || return 255
|
||||
local filepath="${path%/*}" filename="${path##*/}" mntdir=""
|
||||
|
||||
# skip mount if server:/filepath is already mounted
|
||||
mntdir=$(nfs_already_mounted $server $path)
|
||||
if [ -z "$mntdir" ]; then
|
||||
local mntdir="$(mkuniqdir /run nfs_mnt)"
|
||||
mount_nfs $nfs:$server:$filepath${options:+:$options} $mntdir
|
||||
# lazy unmount during pre-pivot hook
|
||||
inst_hook --hook pre-pivot --name 99url-lib-umount-nfs umount -l $mntdir
|
||||
fi
|
||||
|
||||
if [ -z "$outloc" ]; then
|
||||
outloc="$mntdir/$filename"
|
||||
else
|
||||
cp -f "$mntdir/$filename" "$outloc" || return $?
|
||||
fi
|
||||
[ -f "$outloc" ] || return 253
|
||||
if [ -z "$2" ]; then echo "$outloc" ; fi
|
||||
}
|
||||
command -v nfs_to_var >/dev/null && add_url_handler nfs_fetch_url nfs nfs4
|
@@ -3,10 +3,6 @@
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
if getargbool 1 rd.splash -n rd_NO_SPLASH; then
|
||||
[ -c /dev/null ] || mknod /dev/null c 1 3
|
||||
[ -c /dev/console ] || mknod /dev/console c 5 1
|
||||
[ -c /dev/tty0 ] || mknod /dev/tty0 c 4 0
|
||||
|
||||
info "Starting Gentoo Splash"
|
||||
|
||||
[ -x /lib/udev/console_init ] && /lib/udev/console_init /dev/tty0
|
||||
|
@@ -14,23 +14,52 @@ depends() {
|
||||
installkernel() {
|
||||
local _modname
|
||||
# Include KMS capable drm drivers
|
||||
for _modname in $(find "$srcmods/kernel/drivers/gpu/drm" "$srcmods/extra" \( -name '*.ko' -o -name '*.ko.gz' -o -name '*.ko.xz' \) 2>/dev/null); do
|
||||
case $_modname in
|
||||
*.ko) grep -q drm_crtc_init $_modname ;;
|
||||
*.ko.gz) zgrep -q drm_crtc_init $_modname ;;
|
||||
*.ko.xz) xzgrep -q drm_crtc_init $_modname ;;
|
||||
esac
|
||||
if test $? -eq 0; then
|
||||
# if the hardware is present, include module even if it is not currently loaded,
|
||||
# as we could e.g. be in the installer; nokmsboot boot parameter will disable
|
||||
# loading of the driver if needed
|
||||
if [[ $hostonly ]] && modinfo -F alias $_modname | sed -e 's,\?,\.,g' -e 's,\*,\.\*,g' \
|
||||
| grep -qxf - /sys/bus/pci/devices/*/modalias; then
|
||||
hostonly='' instmods $_modname
|
||||
continue
|
||||
fi
|
||||
instmods $_modname
|
||||
|
||||
drm_module_filter() {
|
||||
local _drm_drivers='drm_crtc_init'
|
||||
local _ret
|
||||
# subfunctions inherit following FDs
|
||||
local _merge=8 _side2=9
|
||||
function nmf1() {
|
||||
local _fname _fcont
|
||||
while read _fname; do
|
||||
case "$_fname" in
|
||||
*.ko) _fcont="$(< $_fname)" ;;
|
||||
*.ko.gz) _fcont="$(gzip -dc $_fname)" ;;
|
||||
*.ko.xz) _fcont="$(xz -dc $_fname)" ;;
|
||||
esac
|
||||
[[ $_fcont =~ $_drm_drivers
|
||||
&& ! $_fcont =~ iw_handler_get_spy ]] \
|
||||
&& echo "$_fname"
|
||||
done
|
||||
}
|
||||
function rotor() {
|
||||
local _f1 _f2
|
||||
while read _f1; do
|
||||
echo "$_f1"
|
||||
if read _f2; then
|
||||
echo "$_f2" 1>&${_side2}
|
||||
fi
|
||||
done | nmf1 1>&${_merge}
|
||||
}
|
||||
# Use two parallel streams to filter alternating modules.
|
||||
set +x
|
||||
eval "( ( rotor ) ${_side2}>&1 | nmf1 ) ${_merge}>&1"
|
||||
[[ $debug ]] && set -x
|
||||
return 0
|
||||
}
|
||||
|
||||
for _modname in $(find_kernel_modules_by_path drivers/gpu/drm \
|
||||
| drm_module_filter) ; do
|
||||
# if the hardware is present, include module even if it is not currently loaded,
|
||||
# as we could e.g. be in the installer; nokmsboot boot parameter will disable
|
||||
# loading of the driver if needed
|
||||
if [[ $hostonly ]] && modinfo -F alias $_modname | sed -e 's,\?,\.,g' -e 's,\*,\.\*,g' \
|
||||
| grep -qxf - /sys/bus/pci/devices/*/modalias; then
|
||||
hostonly='' instmods $_modname
|
||||
continue
|
||||
fi
|
||||
instmods $_modname
|
||||
done
|
||||
}
|
||||
|
||||
@@ -38,7 +67,7 @@ install() {
|
||||
if grep -q nash /usr/libexec/plymouth/plymouth-populate-initrd \
|
||||
|| ! grep -q PLYMOUTH_POPULATE_SOURCE_FUNCTIONS /usr/libexec/plymouth/plymouth-populate-initrd \
|
||||
|| [ ! -x /usr/libexec/plymouth/plymouth-populate-initrd ]; then
|
||||
. "$moddir"/plymouth-populate-initrd
|
||||
. "$moddir"/plymouth-populate-initrd.sh
|
||||
else
|
||||
PLYMOUTH_POPULATE_SOURCE_FUNCTIONS="$dracutfunctions" \
|
||||
/usr/libexec/plymouth/plymouth-populate-initrd -t $initdir
|
||||
@@ -46,8 +75,7 @@ install() {
|
||||
|
||||
inst_hook pre-pivot 90 "$moddir"/plymouth-newroot.sh
|
||||
inst_hook pre-trigger 10 "$moddir"/plymouth-pretrigger.sh
|
||||
inst_hook cleanup 10 "$moddir"/plymouth-cleanup.sh
|
||||
inst_hook emergency 50 "$moddir"/plymouth-emergency.sh
|
||||
inst readlink
|
||||
dracut_install readlink
|
||||
}
|
||||
|
||||
|
@@ -1,5 +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
|
||||
|
||||
rm -fr /usr/share/plymouth /usr/lib/plymouth /usr/lib64/plymouth /usr/share/pixmaps
|
@@ -11,9 +11,10 @@ dracut_install /bin/plymouth \
|
||||
|
||||
mkdir -m 0755 -p "${initdir}/usr/share/plymouth"
|
||||
|
||||
inst_libdir_file "plymouth/text.so" "plymouth/details.so"
|
||||
|
||||
if [[ $hostonly ]]; then
|
||||
dracut_install "${usrlibdir}/plymouth/text.so" \
|
||||
"${usrlibdir}/plymouth/details.so" \
|
||||
dracut_install \
|
||||
"/usr/share/plymouth/themes/details/details.plymouth" \
|
||||
"/usr/share/plymouth/themes/text/text.plymouth" \
|
||||
|
||||
@@ -28,7 +29,7 @@ if [[ $hostonly ]]; then
|
||||
inst /usr/share/plymouth/themes/default.plymouth
|
||||
# Install plugin for this theme
|
||||
PLYMOUTH_PLUGIN=$(grep "^ModuleName=" /usr/share/plymouth/themes/default.plymouth | while read a b c; do echo $b; done;)
|
||||
inst "${usrlibdir}/plymouth/${PLYMOUTH_PLUGIN}.so"
|
||||
inst_libdir_file "plymouth/${PLYMOUTH_PLUGIN}.so"
|
||||
fi
|
||||
else
|
||||
for x in /usr/share/plymouth/themes/{text,details}/* ; do
|
||||
@@ -37,11 +38,6 @@ else
|
||||
mkdir -m 0755 -p "${initdir}/$THEME_DIR"
|
||||
dracut_install "$x"
|
||||
done
|
||||
for x in "${usrlibdir}"/plymouth/{text,details}.so ; do
|
||||
[[ -f "$x" ]] || continue
|
||||
[[ "$x" != "${x%%/label.so}" ]] && continue
|
||||
dracut_install "$x"
|
||||
done
|
||||
(
|
||||
cd ${initdir}/usr/share/plymouth/themes;
|
||||
ln -s text/text.plymouth default.plymouth 2>&1;
|
@@ -2,27 +2,23 @@
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
if getargbool 1 plymouth.enable && getargbool 1 rd.plymouth -n rd_NO_PLYMOUTH; then
|
||||
[ -c /dev/null ] || mknod -m 0666 /dev/null c 1 3
|
||||
# first trigger graphics subsystem
|
||||
udevadm trigger --action=add --attr-match=class=0x030000 >/dev/null 2>&1
|
||||
# first trigger graphics and tty subsystem
|
||||
udevadm trigger --action=add --subsystem-match=graphics --subsystem-match=drm --subsystem-match=tty >/dev/null 2>&1
|
||||
if [ -x /bin/plymouthd ]; then
|
||||
if getargbool 1 plymouth.enable && getargbool 1 rd.plymouth -n rd_NO_PLYMOUTH; then
|
||||
# first trigger graphics subsystem
|
||||
udevadm trigger --action=add --attr-match=class=0x030000 >/dev/null 2>&1
|
||||
# first trigger graphics and tty subsystem
|
||||
udevadm trigger --action=add --subsystem-match=graphics --subsystem-match=drm --subsystem-match=tty >/dev/null 2>&1
|
||||
|
||||
udevadm settle --timeout=30 2>&1 | vinfo
|
||||
[ -c /dev/zero ] || mknod -m 0666 /dev/zero c 1 5
|
||||
[ -c /dev/tty0 ] || mknod -m 0620 /dev/tty0 c 4 0
|
||||
[ -e /dev/systty ] || ln -s tty0 /dev/systty
|
||||
[ -c /dev/fb0 ] || mknod -m 0660 /dev/fb0 c 29 0
|
||||
[ -e /dev/fb ] || ln -s fb0 /dev/fb
|
||||
udevadm settle --timeout=30 2>&1 | vinfo
|
||||
|
||||
info "Starting plymouth daemon"
|
||||
mkdir -m 0755 /run/plymouth
|
||||
consoledev=$(getarg console= | sed -e 's/,.*//')
|
||||
consoledev=${consoledev:-tty0}
|
||||
[ -x /lib/udev/console_init ] && /lib/udev/console_init "/dev/$consoledev"
|
||||
[ -x /bin/plymouthd ] && /bin/plymouthd --attach-to-session --pid-file /run/plymouth/pid
|
||||
/bin/plymouth --show-splash 2>&1 | vinfo
|
||||
# reset tty after plymouth messed with it
|
||||
[ -x /lib/udev/console_init ] && /lib/udev/console_init /dev/tty0
|
||||
info "Starting plymouth daemon"
|
||||
mkdir -m 0755 /run/plymouth
|
||||
read consoledev rest < /sys/class/tty/console/active
|
||||
consoledev=${consoledev:-tty0}
|
||||
[ -x /lib/udev/console_init -a -e "/dev/$consoledev" ] && /lib/udev/console_init "/dev/$consoledev"
|
||||
[ -x /bin/plymouthd ] && /bin/plymouthd --attach-to-session --pid-file /run/plymouth/pid
|
||||
/bin/plymouth --show-splash 2>&1 | vinfo
|
||||
# reset tty after plymouth messed with it
|
||||
[ -x /lib/udev/console_init -a -e "/dev/$consoledev" ] && /lib/udev/console_init "/dev/$consoledev"
|
||||
fi
|
||||
fi
|
||||
|
104
modules.d/80cms/cms-write-ifcfg.sh
Executable file
104
modules.d/80cms/cms-write-ifcfg.sh
Executable file
@@ -0,0 +1,104 @@
|
||||
#!/bin/bash
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
|
||||
mkdir -m 0755 -p /run/initramfs/state/etc/sysconfig/network-scripts
|
||||
|
||||
function cms_write_config()
|
||||
{
|
||||
. /tmp/cms.conf
|
||||
OLDIFS=$IFS
|
||||
IFS=,
|
||||
read -a subch_array <<< "indexzero,$SUBCHANNELS"
|
||||
IFS=$OLDIFS
|
||||
devbusid=${subch_array[1]}
|
||||
if [ "$NETTYPE" = "ctc" ]; then
|
||||
driver="ctcm"
|
||||
else
|
||||
driver=$NETTYPE
|
||||
fi
|
||||
|
||||
DEVICE=$(cd /sys/devices/${driver}/$devbusid/net/ && set -- * && [ "$1" != "*" ] && echo $1)
|
||||
|
||||
uuid=$(cat /proc/sys/kernel/random/uuid)
|
||||
|
||||
IFCFGFILE=/run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-$DEVICE
|
||||
|
||||
strstr "$IPADDR" '*:*:*' && ipv6=1
|
||||
|
||||
# to please NetworkManager on startup in loader before loader reconfigures net
|
||||
cat > /etc/sysconfig/network << EOF
|
||||
HOSTNAME=$HOSTNAME
|
||||
EOF
|
||||
if [ "$ipv6" ]; then
|
||||
echo "NETWORKING_IPV6=yes" >> /etc/sysconfig/network
|
||||
else
|
||||
echo "NETWORKING=yes" >> /etc/sysconfig/network
|
||||
fi
|
||||
|
||||
cat > $IFCFGFILE << EOF
|
||||
DEVICE=$DEVICE
|
||||
UUID=$uuid
|
||||
ONBOOT=yes
|
||||
BOOTPROTO=static
|
||||
MTU=$MTU
|
||||
SUBCHANNELS=$SUBCHANNELS
|
||||
EOF
|
||||
if [ "$ipv6" ]; then
|
||||
cat >> $IFCFGFILE << EOF
|
||||
IPV6INIT=yes
|
||||
IPV6_AUTOCONF=no
|
||||
IPV6ADDR=$IPADDR/$NETMASK
|
||||
IPV6_DEFAULTGW=$GATEWAY
|
||||
EOF
|
||||
else
|
||||
cat >> $IFCFGFILE << EOF
|
||||
IPADDR=$IPADDR
|
||||
NETMASK=$NETMASK
|
||||
BROADCAST=$BROADCAST
|
||||
GATEWAY=$GATEWAY
|
||||
EOF
|
||||
fi
|
||||
if [ "$ipv6" ]; then
|
||||
DNS1=$(set -- ${DNS/,/ }; echo $1)
|
||||
DNS2=$(set -- ${DNS/,/ }; echo $2)
|
||||
else
|
||||
DNS1=$(set -- ${DNS/:/ }; echo $1)
|
||||
DNS2=$(set -- ${DNS/:/ }; echo $2)
|
||||
fi
|
||||
# real DNS config for NetworkManager to generate /etc/resolv.conf
|
||||
[ "$DNS1" != "" ] && echo "DNS1=$DNS1" >> $IFCFGFILE
|
||||
[ "$DNS2" != "" ] && echo "DNS2=$DNS2" >> $IFCFGFILE
|
||||
# just to please loader's readNetInfo && writeEnabledNetInfo
|
||||
# which eats DNS1,DNS2,... and generates it themselves based on DNS
|
||||
if [ "$ipv6" ]; then
|
||||
[ "$DNS" != "" ] && echo "DNS=\"$DNS\"" >> $IFCFGFILE
|
||||
else
|
||||
[ "$DNS" != "" ] && echo "DNS=\"${DNS/:/,}\"" >> $IFCFGFILE
|
||||
fi
|
||||
# colons in SEARCHDNS already replaced with spaces above for /etc/resolv.conf
|
||||
[ "$SEARCHDNS" != "" ] && echo "DOMAIN=\"$SEARCHDNS\"" >> $IFCFGFILE
|
||||
[ "$NETTYPE" != "" ] && echo "NETTYPE=$NETTYPE" >> $IFCFGFILE
|
||||
[ "$PEERID" != "" ] && echo "PEERID=$PEERID" >> $IFCFGFILE
|
||||
[ "$PORTNAME" != "" ] && echo "PORTNAME=$PORTNAME" >> $IFCFGFILE
|
||||
[ "$CTCPROT" != "" ] && echo "CTCPROT=$CTCPROT" >> $IFCFGFILE
|
||||
[ "$MACADDR" != "" ] && echo "MACADDR=$MACADDR" >> $IFCFGFILE
|
||||
optstr=""
|
||||
for option in LAYER2 PORTNO; do
|
||||
[ -z "${!option}" ] && continue
|
||||
[ -n "$optstr" ] && optstr=${optstr}" "
|
||||
optstr=${optstr}$(echo ${option} | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/')"="${!option}
|
||||
done
|
||||
# write single quotes since network.py removes double quotes but we need quotes
|
||||
echo "OPTIONS='$optstr'" >> $IFCFGFILE
|
||||
unset option
|
||||
unset optstr
|
||||
unset DNS1
|
||||
unset DNS2
|
||||
echo "files /etc/sysconfig/network-scripts" >> /run/initramfs/rwtab
|
||||
echo "files /var/lib/dhclient" >> /run/initramfs/rwtab
|
||||
}
|
||||
|
||||
[ -f /tmp/cms.conf ] && cms_write_config
|
41
modules.d/80cms/cmsifup.sh
Executable file
41
modules.d/80cms/cmsifup.sh
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
|
||||
DEVICE=$1
|
||||
|
||||
. /tmp/cms.conf
|
||||
|
||||
strstr "$IPADDR" '*:*:*' && ipv6=1
|
||||
|
||||
if [ "$ipv6" ] && ! str_starts "$IPADDR" "["; then
|
||||
IPADDR="[$IPADDR]"
|
||||
fi
|
||||
|
||||
if [ "$ipv6" ] && ! str_starts "$GATEWAY" "["; then
|
||||
GATEWAY="[$GATEWAY]"
|
||||
fi
|
||||
|
||||
if [ "$ipv6" ]; then
|
||||
DNS1=$(set -- ${DNS/,/ }; echo $1)
|
||||
DNS2=$(set -- ${DNS/,/ }; echo $2)
|
||||
else
|
||||
DNS1=$(set -- ${DNS/:/ }; echo $1)
|
||||
DNS2=$(set -- ${DNS/:/ }; echo $2)
|
||||
fi
|
||||
|
||||
{
|
||||
echo "ip=$IPADDR::$GATEWAY:$NETMASK:$HOSTNAME:$DEVICE:none:$MACADDR"
|
||||
for i in $DNS1 $DNS2; do
|
||||
echo "nameserver=$i"
|
||||
done
|
||||
} > /etc/cmdline.d/80-cms.conf
|
||||
unset CMDLINE
|
||||
|
||||
[ -e "/tmp/net.ifaces" ] && read IFACES < /tmp/net.ifaces
|
||||
IFACES="$IFACES $DEVICE"
|
||||
echo "$IFACES" >> /tmp/net.ifaces
|
||||
|
||||
ifup $DEVICE -m
|
202
modules.d/80cms/cmssetup.sh
Executable file
202
modules.d/80cms/cmssetup.sh
Executable file
@@ -0,0 +1,202 @@
|
||||
#!/bin/bash
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
|
||||
function sysecho () {
|
||||
file="$1"
|
||||
shift
|
||||
local i=1
|
||||
while [ $i -le 10 ] ; do
|
||||
if [ ! -f "$file" ]; then
|
||||
sleep 1
|
||||
i=$((i+1))
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
local status
|
||||
read status < "$file"
|
||||
if [[ ! $status == $* ]]; then
|
||||
[ -f "$file" ] && echo $* > "$file"
|
||||
fi
|
||||
}
|
||||
|
||||
function dasd_settle() {
|
||||
local dasd_status=/sys/bus/ccw/devices/$1/status
|
||||
if [ ! -f $dasd_status ]; then
|
||||
return 1
|
||||
fi
|
||||
local i=1
|
||||
while [ $i -le 60 ] ; do
|
||||
local status
|
||||
read status < $dasd_status
|
||||
case $status in
|
||||
online|unformatted)
|
||||
return 0 ;;
|
||||
*)
|
||||
sleep 0.1
|
||||
i=$((i+1)) ;;
|
||||
esac
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
function dasd_settle_all() {
|
||||
for dasdccw in $(while read line; do echo ${line%%(*}; done < /proc/dasd/devices) ; do
|
||||
if ! dasd_settle $dasdccw ; then
|
||||
echo $"Could not access DASD $dasdccw in time"
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
# prints a canonocalized device bus ID for a given devno of any format
|
||||
function canonicalize_devno()
|
||||
{
|
||||
case ${#1} in
|
||||
3) echo "0.0.0${1}" ;;
|
||||
4) echo "0.0.${1}" ;;
|
||||
*) echo "${1}" ;;
|
||||
esac
|
||||
return 0
|
||||
}
|
||||
|
||||
# read file from CMS and write it to /tmp
|
||||
function readcmsfile() # $1=dasdport $2=filename
|
||||
{
|
||||
local dev
|
||||
local numcpus
|
||||
local devname
|
||||
local ret=0
|
||||
if [ $# -ne 2 ]; then return; fi
|
||||
# precondition: udevd created dasda block device node
|
||||
if ! dasd_cio_free -d $1 ; then
|
||||
echo $"DASD $1 could not be cleared from device blacklist"
|
||||
return 1
|
||||
fi
|
||||
|
||||
modprobe dasd_mod dasd=$CMSDASD
|
||||
modprobe dasd_eckd_mod
|
||||
udevadm settle
|
||||
|
||||
# precondition: dasd_eckd_mod driver incl. dependencies loaded,
|
||||
# dasd_mod must be loaded without setting any DASD online
|
||||
dev=$(canonicalize_devno $1)
|
||||
numcpus=$(
|
||||
while read line; do
|
||||
if strstr "$line" "# processors"; then
|
||||
echo ${line##*:};
|
||||
break;
|
||||
fi;
|
||||
done < /proc/cpuinfo
|
||||
)
|
||||
|
||||
if [ ${numcpus} -eq 1 ]; then
|
||||
echo 1 > /sys/bus/ccw/devices/$dev/online
|
||||
else
|
||||
if ! sysecho /sys/bus/ccw/devices/$dev/online 1; then
|
||||
echo $"DASD $dev could not be set online"
|
||||
return 1
|
||||
fi
|
||||
udevadm settle
|
||||
if ! dasd_settle $dev ; then
|
||||
echo $"Could not access DASD $dev in time"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
udevadm settle
|
||||
|
||||
devname=$(cd /sys/bus/ccw/devices/$dev/block; set -- *; [ -b /dev/$1 ] && echo $1)
|
||||
devname=${devname:-dasda}
|
||||
|
||||
[[ -d /mnt ]] || mkdir /mnt
|
||||
if cmsfs-fuse --to=UTF-8 -a /dev/$devname /mnt; then
|
||||
cat /mnt/$2 > /run/initramfs/$2
|
||||
umount /mnt || umount -l /mnt
|
||||
udevadm settle
|
||||
else
|
||||
echo $"Could not read conf file $2 on CMS DASD $1."
|
||||
ret=1
|
||||
fi
|
||||
|
||||
if ! sysecho /sys/bus/ccw/devices/$dev/online 0; then
|
||||
echo $"DASD $dev could not be set offline again"
|
||||
#return 1
|
||||
fi
|
||||
udevadm settle
|
||||
|
||||
# unbind all dasds to unload the dasd modules for a clean start
|
||||
( cd /sys/bus/ccw/drivers/dasd-eckd; for i in *.*; do echo $i > unbind;done)
|
||||
udevadm settle
|
||||
modprobe -r dasd_eckd_mod
|
||||
udevadm settle
|
||||
modprobe -r dasd_diag_mod
|
||||
udevadm settle
|
||||
modprobe -r dasd_mod
|
||||
udevadm settle
|
||||
return $ret
|
||||
}
|
||||
|
||||
processcmsfile()
|
||||
{
|
||||
source /tmp/cms.conf
|
||||
|
||||
if [[ $NETTYPE ]]; then
|
||||
(
|
||||
echo -n $NETTYPE,$SUBCHANNELS
|
||||
[[ $PORTNAME ]] && echo ",portname=$PORTNAME"
|
||||
[[ $LAYER2 ]] && echo ",layer2=$LAYER"
|
||||
[[ "$NETTYPE" = "ctc" ]] && [[ $CTCPROT ]] && echo ",protocol=$CTCPROT"
|
||||
echo
|
||||
) >> /etc/ccw.conf
|
||||
|
||||
OLDIFS=$IFS
|
||||
IFS=,
|
||||
read -a subch_array <<< "indexzero,$SUBCHANNELS"
|
||||
IFS=$OLDIFS
|
||||
devbusid=${subch_array[1]}
|
||||
if [ "$NETTYPE" = "ctc" ]; then
|
||||
driver="ctcm"
|
||||
else
|
||||
driver=$NETTYPE
|
||||
fi
|
||||
|
||||
printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="%s", KERNELS=="%s", ENV{INTERFACE}=="?*", RUN+="/sbin/initqueue --onetime --unique --name cmsifup-$env{INTERFACE} /sbin/cmsifup $env{INTERFACE}"\n' "$driver" "$devbusid" > /etc/udev/rules.d/99-cms.rules
|
||||
# remove the default net rules
|
||||
rm -f /etc/udev/rules.d/61-default-net.rules
|
||||
[[ -f /etc/udev/rules.d/60-net.rules ]] \
|
||||
|| printf 'SUBSYSTEM=="net", ACTION=="online", RUN+="/sbin/initqueue --onetime --env netif=$env{INTERFACE} source_hook initqueue/online"\n' >> /etc/udev/rules.d/99-cms.rules
|
||||
|
||||
znet_cio_free
|
||||
fi
|
||||
|
||||
if [[ $DASD ]]; then
|
||||
echo $DASD | normalize_dasd_arg > /etc/dasd.conf
|
||||
echo "options dasd_mod dasd=$DASD" > /etc/modprobe.d/dasd_mod.conf
|
||||
dasd_cio_free
|
||||
fi
|
||||
|
||||
unset _do_zfcp
|
||||
for i in ${!FCP_*}; do
|
||||
echo "${!i}" >> /etc/zfcp.conf
|
||||
_do_zfcp=1
|
||||
done
|
||||
[[ $_do_zfcp ]] && zfcp_cio_free
|
||||
unset _do_zfcp
|
||||
}
|
||||
|
||||
[[ $CMSDASD ]] || CMSDASD=$(getarg "CMSDASD=")
|
||||
[[ $CMSCONFFILE ]] || CMSCONFFILE=$(getarg "CMSCONFFILE=")
|
||||
|
||||
# Parse configuration
|
||||
if [ -n "$CMSDASD" -a -n "$CMSCONFFILE" ]; then
|
||||
if readcmsfile $CMSDASD $CMSCONFFILE; then
|
||||
ln -s /run/initramfs/$CMSCONFFILE /tmp/$CMSCONFFILE
|
||||
ln -s /run/initramfs/$CMSCONFFILE /tmp/cms.conf
|
||||
processcmsfile
|
||||
fi
|
||||
fi
|
32
modules.d/80cms/module-setup.sh
Executable file
32
modules.d/80cms/module-setup.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
check() {
|
||||
arch=$(uname -m)
|
||||
[ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1
|
||||
return 255
|
||||
}
|
||||
|
||||
depends() {
|
||||
arch=$(uname -m)
|
||||
[ "$arch" = "s390" -o "$arch" = "s390x" ] || return 1
|
||||
echo znet zfcp dasd dasd_mod
|
||||
return 0
|
||||
}
|
||||
|
||||
installkernel() {
|
||||
instmods zfcp
|
||||
}
|
||||
|
||||
install() {
|
||||
inst_hook pre-trigger 30 "$moddir/cmssetup.sh"
|
||||
inst_hook pre-pivot 95 "$moddir/cms-write-ifcfg.sh"
|
||||
inst_script "$moddir/cmsifup.sh" /sbin/cmsifup
|
||||
dracut_install /etc/cmsfs-fuse/filetypes.conf /etc/udev/rules.d/99-fuse.rules /etc/fuse.conf \
|
||||
cmsfs-fuse fusermount ulockmgr_server bash insmod rmmod cat normalize_dasd_arg sed \
|
||||
$(rpm -ql s390utils-base)
|
||||
|
||||
inst_libdir_file "gconv/*"
|
||||
#inst /usr/lib/locale/locale-archive
|
||||
}
|
@@ -8,9 +8,6 @@ check() {
|
||||
# no point in trying to support it in the initramfs.
|
||||
type -P btrfs >/dev/null || return 1
|
||||
|
||||
. $dracutfunctions
|
||||
[[ $debug ]] && set -x
|
||||
|
||||
[[ $hostonly ]] || [[ $mount_needs ]] && {
|
||||
local _found
|
||||
for fs in ${host_fs_types[@]}; do
|
||||
@@ -34,8 +31,8 @@ installkernel() {
|
||||
|
||||
install() {
|
||||
inst_rules "$moddir/80-btrfs.rules"
|
||||
inst "$moddir/btrfs_finished.sh" /sbin/btrfs_finished
|
||||
inst "$moddir/btrfs_timeout.sh" /sbin/btrfs_timeout
|
||||
inst_script "$moddir/btrfs_finished.sh" /sbin/btrfs_finished
|
||||
inst_script "$moddir/btrfs_timeout.sh" /sbin/btrfs_timeout
|
||||
dracut_install btrfs btrfsck
|
||||
}
|
||||
|
||||
|
@@ -32,9 +32,12 @@ else
|
||||
device="$1"
|
||||
fi
|
||||
|
||||
# number of tries
|
||||
numtries=${3:-10}
|
||||
|
||||
# TODO: improve to support what cmdline does
|
||||
if [ -f /etc/crypttab ] && getargbool 1 rd.luks.crypttab -n rd_NO_CRYPTTAB; then
|
||||
while read name dev luksfile rest; do
|
||||
while read name dev luksfile luksoptions; do
|
||||
# ignore blank lines and comments
|
||||
if [ -z "$name" -o "${name#\#}" != "$name" ]; then
|
||||
continue
|
||||
@@ -57,17 +60,59 @@ if [ -f /etc/crypttab ] && getargbool 1 rd.luks.crypttab -n rd_NO_CRYPTTAB; then
|
||||
fi
|
||||
fi
|
||||
done < /etc/crypttab
|
||||
unset name dev rest
|
||||
unset name dev
|
||||
fi
|
||||
|
||||
#
|
||||
# Open LUKS device
|
||||
#
|
||||
|
||||
info "luksOpen $device $luksname $luksfile"
|
||||
info "luksOpen $device $luksname $luksfile $luksoptions"
|
||||
|
||||
OLD_IFS="$IFS"
|
||||
IFS=,
|
||||
set -- $luksoptions
|
||||
IFS="$OLD_IFS"
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
noauto)
|
||||
# skip this
|
||||
exit 0
|
||||
;;
|
||||
swap)
|
||||
# skip this
|
||||
exit 0
|
||||
;;
|
||||
tmp)
|
||||
# skip this
|
||||
exit 0
|
||||
;;
|
||||
allow-discards)
|
||||
allowdiscards="--allow-discards"
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# parse for allow-discards
|
||||
if strstr "$(cryptsetup --help)" "allow-discards"; then
|
||||
if discarduuids=$(getargs "rd.luks.allow-discards"); then
|
||||
if strstr " $discarduuids " " ${luksdev##luks-}"; then
|
||||
allowdiscards="--allow-discards"
|
||||
fi
|
||||
elif getargbool rd.luks.allow-discards; then
|
||||
allowdiscards="--allow-discards"
|
||||
fi
|
||||
fi
|
||||
|
||||
if strstr "$(cryptsetup --help)" "allow-discards"; then
|
||||
cryptsetupopts="$cryptsetupopts $allowdiscards"
|
||||
fi
|
||||
|
||||
unset allowdiscards
|
||||
|
||||
if [ -n "$luksfile" -a "$luksfile" != "none" -a -e "$luksfile" ]; then
|
||||
if cryptsetup --key-file "$luksfile" luksOpen "$device" "$luksname"; then
|
||||
if cryptsetup --key-file "$luksfile" $cryptsetupopts luksOpen "$device" "$luksname"; then
|
||||
ask_passphrase=0
|
||||
fi
|
||||
else
|
||||
@@ -76,26 +121,22 @@ else
|
||||
keydev="${tmp%%:*}"
|
||||
keypath="${tmp#*:}"
|
||||
else
|
||||
if [ $# -eq 3 ]; then
|
||||
if [ $3 -eq 0 ]; then
|
||||
info "No key found for $device. Fallback to passphrase mode."
|
||||
break
|
||||
fi
|
||||
info "No key found for $device. Will try $3 time(s) more later."
|
||||
set -- "$1" "$2" "$(($3 - 1))"
|
||||
else
|
||||
info "No key found for $device. Will try later."
|
||||
if [ $numtries -eq 0 ]; then
|
||||
warn "No key found for $device. Fallback to passphrase mode."
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
info "No key found for $device. Will try $numtries time(s) more later."
|
||||
initqueue --unique --onetime --settled \
|
||||
--name cryptroot-ask-$luksname \
|
||||
$(command -v cryptroot-ask) "$@"
|
||||
$(command -v cryptroot-ask) "$device" "$luksname" "$(($numtries-1))"
|
||||
exit 0
|
||||
fi
|
||||
unset tmp
|
||||
|
||||
info "Using '$keypath' on '$keydev'"
|
||||
readkey "$keypath" "$keydev" "$device" \
|
||||
| cryptsetup -d - luksOpen "$device" "$luksname"
|
||||
| cryptsetup -d - $cryptsetupopts luksOpen "$device" "$luksname"
|
||||
unset keypath keydev
|
||||
ask_passphrase=0
|
||||
break
|
||||
@@ -103,7 +144,7 @@ else
|
||||
fi
|
||||
|
||||
if [ $ask_passphrase -ne 0 ]; then
|
||||
luks_open="$(command -v cryptsetup) luksOpen"
|
||||
luks_open="$(command -v cryptsetup) $cryptsetupopts luksOpen"
|
||||
ask_for_password --ply-tries 5 \
|
||||
--ply-cmd "$luks_open -T1 $device $luksname" \
|
||||
--ply-prompt "Password ($device)" \
|
||||
@@ -117,6 +158,7 @@ unset device luksname luksfile
|
||||
# mark device as asked
|
||||
>> /tmp/cryptroot-asked-$2
|
||||
|
||||
need_shutdown
|
||||
udevsettle
|
||||
|
||||
exit 0
|
||||
|
@@ -7,11 +7,9 @@ check() {
|
||||
# if cryptsetup is not installed, then we cannot support encrypted devices.
|
||||
type -P cryptsetup >/dev/null || return 1
|
||||
|
||||
. $dracutfunctions
|
||||
|
||||
check_crypt() {
|
||||
local dev=$1 fs=$2
|
||||
[[ $fs = "crypto_LUKS" ]] || continue
|
||||
[[ $fs = "crypto_LUKS" ]] || return 1
|
||||
ID_FS_UUID=$(udevadm info --query=property --name=$dev \
|
||||
| while read line; do
|
||||
[[ ${line#ID_FS_UUID} = $line ]] && continue
|
||||
@@ -19,13 +17,15 @@ check() {
|
||||
echo $ID_FS_UUID
|
||||
break
|
||||
done)
|
||||
[[ ${ID_FS_UUID} ]] || continue
|
||||
echo " rd.luks.uuid=luks-${ID_FS_UUID} " >> "${initdir}/etc/cmdline.d/90crypt.conf"
|
||||
[[ ${ID_FS_UUID} ]] || return 1
|
||||
if ! [[ $kernel_only ]]; then
|
||||
echo " rd.luks.uuid=luks-${ID_FS_UUID} " >> "${initdir}/etc/cmdline.d/90crypt.conf"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
[[ $hostonly ]] || [[ $mount_needs ]] && {
|
||||
for_each_host_dev_fs check_crypt
|
||||
[ -f "${initdir}/etc/cmdline.d/90crypt.conf" ] || return 1
|
||||
for_each_host_dev_fs check_crypt || return 1
|
||||
}
|
||||
|
||||
return 0
|
||||
@@ -42,12 +42,12 @@ installkernel() {
|
||||
|
||||
install() {
|
||||
dracut_install cryptsetup rmdir readlink umount
|
||||
inst "$moddir"/cryptroot-ask.sh /sbin/cryptroot-ask
|
||||
inst "$moddir"/probe-keydev.sh /sbin/probe-keydev
|
||||
inst_script "$moddir"/cryptroot-ask.sh /sbin/cryptroot-ask
|
||||
inst_script "$moddir"/probe-keydev.sh /sbin/probe-keydev
|
||||
inst_hook cmdline 10 "$moddir/parse-keydev.sh"
|
||||
inst_hook cmdline 30 "$moddir/parse-crypt.sh"
|
||||
inst_hook pre-pivot 30 "$moddir/crypt-cleanup.sh"
|
||||
inst_hook cleanup 30 "$moddir/crypt-cleanup.sh"
|
||||
inst_simple /etc/crypttab
|
||||
inst "$moddir/crypt-lib.sh" "/lib/dracut-crypt-lib.sh"
|
||||
inst_simple "$moddir/crypt-lib.sh" "/lib/dracut-crypt-lib.sh"
|
||||
}
|
||||
|
||||
|
@@ -24,21 +24,10 @@ else
|
||||
printf -- '$env{DEVNAME} luks-$env{ID_FS_UUID} %s"\n' $tout
|
||||
} >> /etc/udev/rules.d/70-luks.rules.new
|
||||
|
||||
|
||||
[ -e $hookdir/initqueue/finished/90-crypt.sh ] || \
|
||||
{
|
||||
printf -- 'UUIDS=:\n'
|
||||
printf -- 'for dm in /dev/dm-*; do\n'
|
||||
printf -- '[ -e "$dm" ] || exit 1\n'
|
||||
printf -- 'dmid=`/sbin/dmsetup info -c -o uuid --noheadings "$dm"`\n'
|
||||
printf -- 'uuid=${dmid#CRYPT-LUKS*-}\n'
|
||||
printf -- '[ "x$uuid" = "x$dmid" ] && continue\n'
|
||||
printf -- 'UUIDS="${UUIDS}${uuid%%%%-*}:"\n'
|
||||
printf -- 'done\n'
|
||||
} > $hookdir/initqueue/finished/90-crypt.sh
|
||||
uuid=$luksid
|
||||
while [ "$uuid" != "${uuid#*-}" ]; do uuid=${uuid%%-*}${uuid#*-}; done
|
||||
printf -- '[ "x${UUIDS#*:%s*:}" != "x$UUIDS" ] || exit 1\n' $uuid >> $hookdir/initqueue/finished/90-crypt.sh
|
||||
printf -- '[ -e /dev/disk/by-id/dm-uuid-CRYPT-LUKS?-*%s*-* ] || exit 1\n' $uuid \
|
||||
>> $hookdir/initqueue/finished/90-crypt.sh
|
||||
|
||||
{
|
||||
printf -- '[ -e /dev/disk/by-uuid/*%s* ] || ' $luksid
|
||||
|
@@ -13,4 +13,9 @@ _do_dm_shutdown() {
|
||||
fi
|
||||
return $ret
|
||||
}
|
||||
_do_dm_shutdown $1
|
||||
|
||||
if command -v dmsetup >/dev/null; then
|
||||
_do_dm_shutdown $1
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
@@ -3,6 +3,7 @@
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
check() {
|
||||
type -P dmsetup >/dev/null || return 1
|
||||
return 255
|
||||
}
|
||||
|
||||
@@ -18,13 +19,10 @@ install() {
|
||||
modinfo -k $kernel dm_mod >/dev/null 2>&1 && \
|
||||
inst_hook pre-udev 30 "$moddir/dm-pre-udev.sh"
|
||||
|
||||
inst dmsetup
|
||||
dracut_install dmsetup
|
||||
dracut_install -o dmeventd
|
||||
|
||||
type -P dmeventd >/dev/null && dracut_install dmeventd
|
||||
|
||||
for _i in {"$libdir","$usrlibdir"}/libdevmapper-event.so*; do
|
||||
[ -e "$_i" ] && dracut_install "$_i"
|
||||
done
|
||||
inst_libdir_file "libdevmapper-event.so*"
|
||||
|
||||
inst_rules 10-dm.rules 13-dm-disk.rules 95-dm-notify.rules
|
||||
# Gentoo ebuild for LVM2 prior to 2.02.63-r1 doesn't install above rules
|
||||
|
@@ -40,3 +40,4 @@ else
|
||||
done
|
||||
fi
|
||||
|
||||
need_shutdown
|
||||
|
@@ -8,13 +8,9 @@ check() {
|
||||
# in trying to support it in the initramfs.
|
||||
type -P dmraid >/dev/null || return 1
|
||||
|
||||
. $dracutfunctions
|
||||
[[ $debug ]] && set -x
|
||||
|
||||
check_dmraid() {
|
||||
local dev=$1 fs=$2 holder DEVPATH DM_NAME
|
||||
[[ "$fs" = "linux_raid_member" ]] && continue
|
||||
[[ "$fs" = "${fs%%_raid_member}" ]] && continue
|
||||
[[ "$fs" = "${fs%%_raid_member}" ]] && return 1
|
||||
|
||||
DEVPATH=$(udevadm info --query=property --name=$dev \
|
||||
| while read line; do
|
||||
@@ -34,13 +30,15 @@ check() {
|
||||
done)
|
||||
done
|
||||
|
||||
[[ ${DM_NAME} ]] || continue
|
||||
echo " rd.dm.uuid=${DM_NAME} " >> "${initdir}/etc/cmdline.d/90dmraid.conf"
|
||||
[[ ${DM_NAME} ]] || return 1
|
||||
if ! [[ $kernel_only ]]; then
|
||||
echo " rd.dm.uuid=${DM_NAME} " >> "${initdir}/etc/cmdline.d/90dmraid.conf"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
[[ $hostonly ]] || [[ $mount_needs ]] && {
|
||||
for_each_host_dev_fs check_dmraid
|
||||
[ -f "${initdir}/etc/cmdline.d/90dmraid.conf" ] || return 1
|
||||
for_each_host_dev_fs check_dmraid || return 1
|
||||
}
|
||||
|
||||
return 0
|
||||
@@ -57,13 +55,9 @@ install() {
|
||||
|
||||
inst "$moddir/dmraid.sh" /sbin/dmraid_scan
|
||||
|
||||
if [ ! -x /lib/udev/vol_id ]; then
|
||||
inst_rules 64-md-raid.rules
|
||||
fi
|
||||
inst_rules 64-md-raid.rules
|
||||
|
||||
for _i in {"$libdir","$usrlibdir"}/libdmraid-events*.so*; do
|
||||
[ -e "$_i" ] && dracut_install "$_i"
|
||||
done
|
||||
inst_libdir_file "libdmraid-events*.so*"
|
||||
|
||||
inst_rules "$moddir/61-dmraid-imsm.rules"
|
||||
#inst "$moddir/dmraid-cleanup.sh" /sbin/dmraid-cleanup
|
||||
|
@@ -1,9 +1,15 @@
|
||||
#!/bin/sh
|
||||
if [ -b /dev/mapper/live-rw ]; then
|
||||
if [ -d /updates ]; then
|
||||
echo "Applying updates to live image..."
|
||||
|
||||
if [ -b /dev/mapper/live-rw ] && [ -d /updates ]; then
|
||||
info "Applying updates to live image..."
|
||||
# avoid overwriting symlinks (e.g. /lib -> /usr/lib) with directories
|
||||
(
|
||||
cd /updates
|
||||
/bin/cp -a -t $NEWROOT .
|
||||
cd -
|
||||
fi
|
||||
find . -depth -type d | while read dir; do
|
||||
[ -d "$NEWROOT/$dir" ] || mkdir -p "$NEWROOT/$dir"
|
||||
done
|
||||
find . -depth \! -type d | while read file; do
|
||||
cp -a "$file" "$NEWROOT/$file"
|
||||
done
|
||||
)
|
||||
fi
|
||||
|
@@ -3,9 +3,6 @@
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
type det_fs >/dev/null 2>&1 || . /lib/fs-lib.sh
|
||||
|
||||
[ -f /tmp/root.info ] && . /tmp/root.info
|
||||
|
||||
PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
@@ -35,7 +32,7 @@ fi
|
||||
getarg rd.live.check check || check=""
|
||||
if [ -n "$check" ]; then
|
||||
[ -x /bin/plymouth ] && /bin/plymouth --hide-splash
|
||||
checkisomd5 --verbose $livedev || :
|
||||
checkisomd5 --verbose $livedev
|
||||
if [ $? -ne 0 ]; then
|
||||
die "CD check failed!"
|
||||
exit 1
|
||||
@@ -43,6 +40,8 @@ if [ -n "$check" ]; then
|
||||
[ -x /bin/plymouth ] && /bin/plymouth --show-splash
|
||||
fi
|
||||
|
||||
ln -s $livedev /run/initramfs/livedev
|
||||
|
||||
# determine filesystem type for a filesystem image
|
||||
det_img_fs() {
|
||||
blkid -s TYPE -u noraid -o value "$1"
|
||||
@@ -204,6 +203,8 @@ if [ -b "$BASE_LOOPDEV" ]; then
|
||||
ln -s $BASE_LOOPDEV /run/initramfs/live-baseloop
|
||||
fi
|
||||
ln -s /dev/mapper/live-rw /dev/root
|
||||
printf '/bin/mount %s /dev/mapper/live-rw %s\n' "$ROOTFLAGS" "$NEWROOT" > $hookdir/mount/01-$$-live.sh
|
||||
printf 'mount %s /dev/mapper/live-rw %s\n' "$ROOTFLAGS" "$NEWROOT" > $hookdir/mount/01-$$-live.sh
|
||||
|
||||
need_shutdown
|
||||
|
||||
exit 0
|
@@ -20,22 +20,13 @@ installkernel() {
|
||||
}
|
||||
|
||||
install() {
|
||||
dracut_install umount
|
||||
inst dmsetup
|
||||
inst blkid
|
||||
inst dd
|
||||
inst losetup
|
||||
inst grep
|
||||
|
||||
dracut_install -o eject
|
||||
|
||||
inst blockdev
|
||||
type -P checkisomd5 >/dev/null && inst checkisomd5
|
||||
dracut_install umount dmsetup blkid dd losetup grep blockdev
|
||||
dracut_install -o eject checkisomd5
|
||||
inst_hook cmdline 30 "$moddir/parse-dmsquash-live.sh"
|
||||
inst_hook pre-udev 30 "$moddir/dmsquash-live-genrules.sh"
|
||||
inst_hook pre-udev 30 "$moddir/dmsquash-liveiso-genrules.sh"
|
||||
inst_hook pre-pivot 20 "$moddir/apply-live-updates.sh"
|
||||
inst "$moddir/dmsquash-live-root" "/sbin/dmsquash-live-root"
|
||||
inst_script "$moddir/dmsquash-live-root.sh" "/sbin/dmsquash-live-root"
|
||||
# should probably just be generally included
|
||||
inst_rules 60-cdrom_id.rules
|
||||
}
|
||||
|
@@ -1,5 +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
|
||||
|
||||
rm -fr /lib/modules /lib/firmware
|
@@ -16,6 +16,7 @@ installkernel() {
|
||||
*.ko.xz) [[ $(xz -dc <$_f) =~ $_blockfuncs ]] && echo "$_f" ;;
|
||||
esac
|
||||
done
|
||||
return 0
|
||||
}
|
||||
function rotor() {
|
||||
local _f1 _f2
|
||||
@@ -25,18 +26,24 @@ installkernel() {
|
||||
echo "$_f2" 1>&${_side2}
|
||||
fi
|
||||
done | bmf1 1>&${_merge}
|
||||
return 0
|
||||
}
|
||||
# Use two parallel streams to filter alternating modules.
|
||||
set +x
|
||||
eval "( ( rotor ) ${_side2}>&1 | bmf1 ) ${_merge}>&1"
|
||||
[[ $debug ]] && set -x
|
||||
return 0
|
||||
}
|
||||
hostonly='' instmods sr_mod sd_mod scsi_dh scsi_dh_rdac scsi_dh_emc
|
||||
|
||||
hostonly='' instmods sr_mod sd_mod scsi_dh scsi_dh_rdac scsi_dh_emc ata_piix
|
||||
hostonly='' instmods pcmcia firewire-ohci
|
||||
hostonly='' instmods usb_storage sdhci sdhci-pci
|
||||
|
||||
# arm specific modules
|
||||
hostonly='' instmods sdhci_esdhc_imx mmci sdhci_tegra mvsdio omap omapdrm sdhci_dove ahci_platform pata_imx sata_mv
|
||||
|
||||
# install keyboard support
|
||||
hostonly='' instmods atkbd i8042 usbhid hid-apple hid-sunplus hid-cherry hid-logitech hid-logitech-dj hid-microsoft ehci-hcd ohci-hcd uhci-hcd
|
||||
hostonly='' instmods atkbd i8042 usbhid hid-apple hid-sunplus hid-cherry hid-logitech hid-logitech-dj hid-microsoft ehci-hcd ohci-hcd uhci-hcd xhci-hcd
|
||||
# install unix socket support
|
||||
hostonly='' instmods unix
|
||||
instmods "=drivers/pcmcia" =ide "=drivers/usb/storage"
|
||||
@@ -45,10 +52,7 @@ installkernel() {
|
||||
# if the required list is not set via the filesystems variable
|
||||
if ! [[ $hostonly ]]; then
|
||||
if [[ -z $filesystems ]]; then
|
||||
instmods '=fs'
|
||||
# hardcoded list of exceptions
|
||||
# to save a lot of space
|
||||
rm -fr ${initdir}/lib/modules/*/kernel/fs/ocfs2
|
||||
omit_drivers="$omit_drivers|kernel/fs/nfs|kernel/fs/nfsd|kernel/fs/lockd" omit_drivers="${omit_drivers##|}" instmods '=fs'
|
||||
fi
|
||||
else
|
||||
inst_fs() {
|
||||
@@ -61,31 +65,19 @@ installkernel() {
|
||||
hostonly='' instmods $drivers
|
||||
fi
|
||||
|
||||
[[ $add_drivers ]] && hostonly='' instmods $add_drivers
|
||||
[[ $filesystems ]] && hostonly='' instmods $filesystems
|
||||
if [[ $add_drivers ]]; then
|
||||
hostonly='' instmods -c $add_drivers || return 1
|
||||
fi
|
||||
if [[ $filesystems ]]; then
|
||||
hostonly='' instmods -c $filesystems || return 1
|
||||
fi
|
||||
|
||||
# force install of scsi_wait_scan
|
||||
hostonly='' instmods scsi_wait_scan
|
||||
}
|
||||
|
||||
install() {
|
||||
local _f i
|
||||
[ -f /etc/modprobe.conf ] && dracut_install /etc/modprobe.conf
|
||||
for i in $(find -L /etc/modprobe.d/ -maxdepth 1 -type f -name '*.conf'); do
|
||||
inst_simple "$i"
|
||||
done
|
||||
dracut_install $(find -L /etc/modprobe.d/ -maxdepth 1 -type f -name '*.conf')
|
||||
inst_hook cmdline 01 "$moddir/parse-kernel.sh"
|
||||
inst_hook cleanup 20 "$moddir/kernel-cleanup.sh"
|
||||
inst_simple "$moddir/insmodpost.sh" /sbin/insmodpost.sh
|
||||
|
||||
for _f in modules.builtin.bin modules.builtin; do
|
||||
[[ $srcmods/$_f ]] && break
|
||||
done || {
|
||||
dfatal "No modules.builtin.bin and modules.builtin found!"
|
||||
return 1
|
||||
}
|
||||
|
||||
for _f in modules.builtin.bin modules.builtin modules.order; do
|
||||
[[ $srcmods/$_f ]] && inst_simple "$srcmods/$_f" "/lib/modules/$kernel/$_f"
|
||||
done
|
||||
}
|
||||
|
31
modules.d/90livenet/fetch-liveupdate.sh
Executable file
31
modules.d/90livenet/fetch-liveupdate.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
# fetch-liveupdate - fetch an update image for dmsquash-live media.
|
||||
# this gets called by the "initqueue/online" hook for each network interface
|
||||
# that comes online.
|
||||
|
||||
# no updates requested? we're not needed.
|
||||
[ -e /tmp/liveupdates.info ] || return 0
|
||||
|
||||
command -v getarg >/dev/null || . /lib/dracut-lib.sh
|
||||
command -v fetch_url >/dev/null || . /lib/url-lib.sh
|
||||
command -v unpack_img >/dev/null || . /lib/img-lib.sh
|
||||
|
||||
read url < /tmp/liveupdates.info
|
||||
|
||||
info "fetching live updates from $url"
|
||||
|
||||
fetch_url "$url" /tmp/updates.img
|
||||
if [ $? != 0 ]; then
|
||||
warn "failed to fetch update image!"
|
||||
warn "url: $url"
|
||||
return 1
|
||||
fi
|
||||
|
||||
unpack_img /tmp/updates.img /updates.tmp.$$
|
||||
if [ $? != 0 ]; then
|
||||
warn "failed to unpack update image!"
|
||||
warn "url: $url"
|
||||
return 1
|
||||
fi
|
||||
copytree /updates.tmp.$$ /updates
|
||||
mv /tmp/liveupdates.info /tmp/liveupdates.done
|
@@ -1,41 +0,0 @@
|
||||
#!/bin/bash
|
||||
# livenetroot - fetch a live image from the network and run it
|
||||
#
|
||||
# TODO:
|
||||
# * HTTPS: arg to use --no-check-certificate with https (boo)
|
||||
# args for --certificate, --ca-certificate
|
||||
# * NFS support?
|
||||
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
[ -f /tmp/root.info ] && . /tmp/root.info
|
||||
|
||||
PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
# args get passed from 40network/netroot
|
||||
netroot=$2
|
||||
|
||||
liveurl=${netroot#livenet:}
|
||||
|
||||
if [ ${liveurl##*.} == "iso" ]; then
|
||||
imgfile="/run/live.iso"
|
||||
else
|
||||
imgfile="/run/rootfs.img"
|
||||
fi
|
||||
|
||||
|
||||
case "$liveurl" in
|
||||
http://*|https://*|ftp://*)
|
||||
wget -O $imgfile "$liveurl"
|
||||
;;
|
||||
*) die "don't know how to handle URL: $liveurl" ;;
|
||||
esac
|
||||
[ $? == 0 ] || die "failed to download live image"
|
||||
|
||||
|
||||
if [ ${imgfile##*.} == "iso" ]; then
|
||||
root=$(losetup -f)
|
||||
losetup $root $imgfile
|
||||
else
|
||||
root=$imgfile
|
||||
fi
|
||||
exec /sbin/dmsquash-live-root $root
|
25
modules.d/90livenet/livenetroot.sh
Executable file
25
modules.d/90livenet/livenetroot.sh
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
# livenetroot - fetch a live image from the network and run it
|
||||
|
||||
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
|
||||
|
||||
. /lib/url-lib.sh
|
||||
|
||||
PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
# args get passed from 40network/netroot
|
||||
netroot="$2"
|
||||
liveurl="${netroot#livenet:}"
|
||||
info "fetching $liveurl"
|
||||
imgfile=$(fetch_url "$liveurl")
|
||||
[ $? = 0 ] || die "failed to download live image: error $?"
|
||||
|
||||
# TODO: couldn't dmsquash-live-root handle this?
|
||||
if [ ${imgfile##*.} = "iso" ]; then
|
||||
root=$(losetup -f)
|
||||
losetup $root $imgfile
|
||||
else
|
||||
root=$imgfile
|
||||
fi
|
||||
|
||||
exec /sbin/dmsquash-live-root $root
|
@@ -2,27 +2,17 @@
|
||||
# module-setup.sh for livenet
|
||||
|
||||
check() {
|
||||
# a live, host-only image doesn't really make a lot of sense
|
||||
[[ $hostonly ]] && return 1
|
||||
command -v wget >/dev/null || return 1
|
||||
return 255
|
||||
}
|
||||
|
||||
depends() {
|
||||
echo network dmsquash-live
|
||||
echo network url-lib dmsquash-live
|
||||
return 0
|
||||
}
|
||||
|
||||
install() {
|
||||
dracut_install wget
|
||||
mkdir -m 0755 -p "$initdir/etc/ssl/certs"
|
||||
if ! inst_any -t /etc/ssl/certs/ca-bundle.crt \
|
||||
/etc/ssl/certs/ca-bundle.crt \
|
||||
/etc/ssl/certs/ca-certificates.crt; then
|
||||
dwarn "Couldn't find SSL CA cert bundle; HTTPS won't work."
|
||||
fi
|
||||
|
||||
inst_hook cmdline 29 "$moddir/parse-livenet.sh"
|
||||
inst "$moddir/livenetroot" "/sbin/livenetroot"
|
||||
inst_hook initqueue/online 95 "$moddir/fetch-liveupdate.sh"
|
||||
inst_script "$moddir/livenetroot.sh" "/sbin/livenetroot"
|
||||
}
|
||||
|
||||
|
@@ -1,19 +1,34 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
# live net images - just like live images, but specified like:
|
||||
# root=live:[url-to-backing-file]
|
||||
|
||||
[ -z "$root" ] && root=$(getarg root=)
|
||||
. /lib/url-lib.sh
|
||||
|
||||
str_starts $root "live:" && liveurl=$root
|
||||
str_starts $liveurl "live:" || return
|
||||
# live updates
|
||||
updates=$(getarg live.updates=)
|
||||
if [ -n "$updates" ]; then
|
||||
# make sure network comes up even if we're doing a local live device
|
||||
if [ -z "$netroot" ]; then
|
||||
echo > /tmp/net.ifaces
|
||||
unset CMDLINE
|
||||
fi
|
||||
echo "$updates" > /tmp/liveupdates.info
|
||||
echo '[ -e /tmp/liveupdates.done ]' > \
|
||||
$hookdir/initqueue/finished/liveupdates.sh
|
||||
fi
|
||||
|
||||
str_starts "$root" "live:" && liveurl="$root"
|
||||
str_starts "$liveurl" "live:" || return
|
||||
liveurl="${liveurl#live:}"
|
||||
|
||||
# setting netroot to "livenet:..." makes "livenetroot" get run after ifup
|
||||
case "$liveurl" in
|
||||
http://*|https://*|ftp://*)
|
||||
netroot="livenet:$liveurl"
|
||||
root="livenet" # quiet complaints from init
|
||||
rootok=1 ;;
|
||||
esac
|
||||
|
||||
wait_for_dev /dev/root
|
||||
if get_url_handler "$liveurl" >/dev/null; then
|
||||
info "livenet: root image at $liveurl"
|
||||
netroot="livenet:$liveurl"
|
||||
root="livenet" # quiet complaints from init
|
||||
rootok=1
|
||||
wait_for_dev /dev/root
|
||||
else
|
||||
info "livenet: no url handler for $liveurl"
|
||||
fi
|
||||
|
@@ -35,10 +35,12 @@ if [ ! -e /etc/lvm/lvm.conf ]; then
|
||||
if [ -n $SNAPSHOT ]; then
|
||||
echo 'global {';
|
||||
echo ' locking_type = 1';
|
||||
echo ' use_lvmetad = 0';
|
||||
echo '}';
|
||||
else
|
||||
echo 'global {';
|
||||
echo ' locking_type = 4';
|
||||
echo ' use_lvmetad = 0';
|
||||
echo '}';
|
||||
fi
|
||||
} > /etc/lvm/lvm.conf
|
||||
@@ -126,3 +128,5 @@ if [ "$lvmwritten" ]; then
|
||||
rm -f /etc/lvm/lvm.conf
|
||||
fi
|
||||
unset lvmwritten
|
||||
|
||||
need_shutdown
|
||||
|
@@ -3,24 +3,26 @@
|
||||
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
||||
|
||||
check() {
|
||||
local _rootdev
|
||||
local _rootdev _activated
|
||||
# No point trying to support lvm if the binaries are missing
|
||||
type -P lvm >/dev/null || return 1
|
||||
|
||||
. $dracutfunctions
|
||||
[[ $debug ]] && set -x
|
||||
|
||||
check_lvm() {
|
||||
unset DM_VG_NAME
|
||||
unset DM_LV_NAME
|
||||
eval $(udevadm info --query=property --name=$1|egrep '(DM_VG_NAME|DM_LV_NAME)=')
|
||||
[[ ${DM_VG_NAME} ]] && [[ ${DM_LV_NAME} ]] || return
|
||||
echo " rd.lvm.lv=${DM_VG_NAME}/${DM_LV_NAME} " >> "${initdir}/etc/cmdline.d/90lvm.conf"
|
||||
local DM_VG_NAME DM_LV_NAME DM_UDEV_DISABLE_DISK_RULES_FLAG
|
||||
eval $(udevadm info --query=property --name=$1|egrep '(DM_VG_NAME|DM_LV_NAME|DM_UDEV_DISABLE_DISK_RULES_FLAG)=')
|
||||
[[ "$DM_UDEV_DISABLE_DISK_RULES_FLAG" = "1" ]] && return 1
|
||||
[[ ${DM_VG_NAME} ]] && [[ ${DM_LV_NAME} ]] || return 1
|
||||
if ! strstr " ${_activated[*]} " " ${DM_VG_NAME}/${DM_LV_NAME} "; then
|
||||
if ! [[ $kernel_only ]]; then
|
||||
echo " rd.lvm.lv=${DM_VG_NAME}/${DM_LV_NAME} " >> "${initdir}/etc/cmdline.d/90lvm.conf"
|
||||
fi
|
||||
push _activated "${DM_VG_NAME}/${DM_LV_NAME}"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
[[ $hostonly ]] || [[ $mount_needs ]] && {
|
||||
for_each_host_dev_fs check_lvm
|
||||
[ -f "${initdir}/etc/cmdline.d/90lvm.conf" ] || return 1
|
||||
for_each_host_dev_fs check_lvm || return 1
|
||||
}
|
||||
|
||||
return 0
|
||||
@@ -44,6 +46,7 @@ install() {
|
||||
# FIXME: near-term hack to establish read-only locking;
|
||||
# use command-line lvm.conf editor once it is available
|
||||
sed -i -e 's/\(^[[:space:]]*\)locking_type[[:space:]]*=[[:space:]]*[[:digit:]]/\1locking_type = 4/' ${initdir}/etc/lvm/lvm.conf
|
||||
sed -i -e 's/\(^[[:space:]]*\)use_lvmetad[[:space:]]*=[[:space:]]*[[:digit:]]/\1use_lvmetad = 0/' ${initdir}/etc/lvm/lvm.conf
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -52,11 +55,9 @@ install() {
|
||||
# files, but provides the one below:
|
||||
inst_rules 64-device-mapper.rules
|
||||
|
||||
inst "$moddir/lvm_scan.sh" /sbin/lvm_scan
|
||||
inst_script "$moddir/lvm_scan.sh" /sbin/lvm_scan
|
||||
inst_hook cmdline 30 "$moddir/parse-lvm.sh"
|
||||
|
||||
for _i in {"$libdir","$usrlibdir"}/libdevmapper-event-lvm*.so; do
|
||||
[ -e "$_i" ] && dracut_install "$_i"
|
||||
done
|
||||
inst_libdir_file "libdevmapper-event-lvm*.so"
|
||||
}
|
||||
|
||||
|
@@ -35,6 +35,6 @@ RUN+="/sbin/initqueue --timeout --name 50-mdraid_start --onetime --unique /sbin/
|
||||
#
|
||||
LABEL="md_incremental"
|
||||
|
||||
RUN+="/sbin/mdadm -I $env{DEVNAME}"
|
||||
RUN+="/sbin/mdadm $env{rd_MD_OFFROOT} -I $env{DEVNAME}"
|
||||
|
||||
LABEL="md_end"
|
||||
|
@@ -4,14 +4,22 @@
|
||||
_do_md_shutdown() {
|
||||
local ret
|
||||
local final=$1
|
||||
info "Disassembling mdraid devices."
|
||||
mdadm -v --stop --scan
|
||||
local _offroot=$(strstr "$(mdadm --help-options 2>&1)" offroot && echo --offroot)
|
||||
info "Waiting for mdraid devices to be clean."
|
||||
mdadm $_offroot -vv --wait-clean --scan| vinfo
|
||||
ret=$?
|
||||
info "Disassembling mdraid devices."
|
||||
mdadm $_offroot -vv --stop --scan | vinfo
|
||||
ret=$(($ret+$?))
|
||||
if [ "x$final" != "x" ]; then
|
||||
info "cat /proc/mdstat"
|
||||
cat /proc/mdstat | vinfo
|
||||
info "/proc/mdstat:"
|
||||
vinfo < /proc/mdstat
|
||||
fi
|
||||
return $ret
|
||||
}
|
||||
|
||||
_do_md_shutdown $1
|
||||
if command -v mdadm >/dev/null; then
|
||||
_do_md_shutdown $1
|
||||
else
|
||||
:
|
||||
fi
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user