Compare commits

..

119 Commits
018 ... 019

Author SHA1 Message Date
Harald Hoyer
784df1e4e3 version 019 2012-06-04 14:24:25 +02:00
Harald Hoyer
6d82d7bcd5 NEWS: dracut-019 2012-06-04 14:23:54 +02:00
Harald Hoyer
2614421601 dracut.sh: precopy some essential device nodes 2012-06-04 14:00:49 +02:00
Harald Hoyer
200e235dee systemd/dracut-pre-trigger.sh: fixed rd.udev.{debug|info} 2012-06-04 13:56:55 +02:00
Harald Hoyer
0636ce1a7f systemd/module-setup.sh: package udev in sysinit.target 2012-06-04 13:12:07 +02:00
Harald Hoyer
6042b30c58 udev-rules: check for systemd-udevd symlink already present 2012-06-04 13:11:38 +02:00
Harald Hoyer
604d1eb21a use pkg-config to determine the udev directory 2012-06-04 12:58:42 +02:00
Harald Hoyer
14b43bcaee systemd: use pkg-config to determine the systemd directories 2012-06-04 12:55:32 +02:00
Harald Hoyer
c79f3883cd test/TEST-16-DMSQUASH: add check for python-imgcreate 2012-06-04 11:35:31 +02:00
Harald Hoyer
df42cd3dbd test/test-functions: check with test_check() if test is suitable 2012-06-04 11:35:02 +02:00
Harald Hoyer
01bbe8311a dracut.sh: do not rely on the presence of lib64, check with ldd 2012-06-04 11:33:29 +02:00
Cong Wang
21928b97b0 Handle multiple underlying devices of a bridge
A bridge device with only one underlying ethernet device is almost
useless, for sure we want to support a bridge with multiple
underlying devices.

This patch adds the support by extending <ethname> in the original
bridge= cmdline to a comma-separated list of ethernet interfaces.

Cc: Harald Hoyer <harald@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
2012-06-04 11:06:53 +02:00
Jesse Keating
e82e54df2c Don't set an already set attribute (#826357)
Depending on how the dasd_mod module was loaded, our device could have
already been marked as online or offline.  We need to make the sysecho
sensitive to this and not fail if the attribute we're trying to set has
already been set.
2012-06-04 11:06:13 +02:00
Harald Hoyer
ecc6da6bf5 99base/init.sh: kill systemd-udevd instead of udevd 2012-06-04 10:04:19 +02:00
Harald Hoyer
b35ff065ec base/loginit.sh: revert "quiet" patch 2012-06-04 03:09:09 -04:00
Harald Hoyer
187c355bf4 systemd: mkdir basic.target.wants 2012-06-04 03:08:24 -04:00
Harald Hoyer
70516a04fe TODO: update 2012-06-04 03:07:43 -04:00
Harald Hoyer
fcd65d2418 add README.testsuite 2012-06-01 18:51:47 +02:00
Harald Hoyer
9073ff54c1 fix return value of some installkernel() functions 2012-06-01 17:09:51 +02:00
Harald Hoyer
840d8e4733 add filesystem options to fsck_single()
if we have e.g. special btrfs options for "/" and "/usr", we want to use
those for the test mount to determine if the filesystem is corrupted.
2012-05-31 12:57:23 +02:00
Harald Hoyer
5ad3803dac crypt: add rd.luks.allow-discards and honor options in crypttab
also fixed the retry loop for rd.luks.key
2012-05-31 12:01:19 +02:00
Harald Hoyer
e04d02cc3a dracut-shutdown.service: do not unpack old initramfs on shutdown
Do not unpack the initramfs, if the old initramfs still exists.
2012-05-31 10:09:50 +02:00
Harald Hoyer
51153fb18c removed scsi_wait_scan from standard install 2012-05-31 09:14:17 +02:00
Harald Hoyer
2268e3a32a dasd_mod/parse-dasd-mod.sh: fixed dasd_mod param generation 2012-05-31 09:13:24 +02:00
Harald Hoyer
8b88dc7f71 network: do not arping with qeth layer3 interfaces
https://bugzilla.redhat.com/show_bug.cgi?id=825783
2012-05-29 17:39:17 +02:00
Harald Hoyer
eecb3d5552 url-lib/url-lib.sh: disable curl progress bar
https://bugzilla.redhat.com/show_bug.cgi?id=817301
https://bugzilla.redhat.com/show_bug.cgi?id=824883
2012-05-29 16:18:22 +02:00
Will Woods
f629355b2f add anaconda-style option parsing to ip_to_var
Anaconda used arguments of the form:

  ip=<ip> gateway=<gw> netmask=<nm>

for static IP configuration. So if we get a value for "ip" that's an IP
address, look for gateway= and netmask= and related args to fill in the
ip config vars.
2012-05-29 11:32:45 +02:00
Will Woods
78274fe2b4 do emergency_shell in die() if rd.debug=1
If I said 'rd.debug=1' I should get to debug the system before it dies,
right?
2012-05-29 11:32:45 +02:00
Will Woods
4744e27350 don't wait_for_loginit in emergency_shell()
wait_for_loginit ends the log; this is unhelpful if you're using
emergency_shell to do debugging.

Just leave loginit running. It doesn't hurt anything.
2012-05-29 11:32:45 +02:00
Will Woods
31cfc9aa5e dracut-lib.sh: add copytree(), use it where applicable
copytree() recursively copies the contents of SRC into DEST.

If DEST doesn't exist it is created; if it exists the contents of SRC
get merged into it (duplicate files are overwritten).
2012-05-29 11:32:44 +02:00
Cong Wang
a2ead9a486 Update the documentation of ifname= cmdline
The documentation about ifname= needs to update.

Cc: Harald Hoyer <harald@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
2012-05-29 11:18:51 +02:00
Cong Wang
db2b12fa91 Remove rd.neednet cmdline
rd.neednet could be removed, as we can check /tmp/net.ifaces.
After this patch, kdump can bring up the NIC without
rd.neednet.

Cc: Harald Hoyer <harald@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
2012-05-29 11:18:51 +02:00
Cong Wang
cbf66c5f06 Do not use ifenslave
ifenslave is an old tool, and could be dropped,
we can use the /sys interface.

Cc: Harald Hoyer <harald@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
2012-05-29 11:18:51 +02:00
Cong Wang
037984c80e Remove netroot check in cmdline parsing code
Relax the rules for kdump, we don't specify netroot in kdump.

Cc: Harald Hoyer <harald@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
2012-05-29 11:18:51 +02:00
Cong Wang
9337c692bc Add doc for birdge= cmdline
Document bridge= cmdline in dracut.cmdline(7).

Cc: Harald Hoyer <harald@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
2012-05-29 11:18:51 +02:00
Cong Wang
c438bdb0d2 Add doc for bond= cmdline
Document bond= cmdline in dracut.cmdline(7).

Cc: Harald Hoyer <harald@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
2012-05-29 11:18:51 +02:00
Cong Wang
144787fe30 Add doc for vlan= cmdline
Document vlan= cmdline in dracut.cmdline(7).

Cc: Dave Young <dyoung@redhat.com>
Cc: Harald Hoyer <harald@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
2012-05-29 11:18:51 +02:00
Cong Wang
8eb81d482c Add vlan support in network module
This patch adds basic vlan support in network module.

The cmdline syntax for vlan is:

	vlan=<vlanname>:<phydevice>

for an example:

	vlan=eth0.2:eth0

or
	vlan=vlan2:eth0

See also patch 2/8.

Cc: Harald Hoyer <harald@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
2012-05-29 11:18:51 +02:00
Harald Hoyer
0363998d0a base/init.sh: use info() instead of vinfo() for version info
Thanks to Cong Wang for the hint
2012-05-29 10:19:02 +02:00
Harald Hoyer
806572d058 systemd/module-setup.sh: add journalctl and systemctl 2012-05-29 09:17:43 +02:00
Cong Wang
81ea383998 Relax the rules for kdump, we don't specify netroot in kdump. 2012-05-29 09:17:01 +02:00
Juan RP
8442dc45b6 dmsquash-live: do not hardcode path to mount(8) in generated hook.
In some cases (at least in mine) mount(8) is in /usr/bin/mount and
not in /bin/mount as dmsquash-live-root.sh expects. PATH is set to
/usr/bin:/usr/sbin:/sbin:/bin in that script anyway.
2012-05-29 09:15:34 +02:00
Juan RP
cfede42fc3 modules.d/99base/init.sh: check for a valid init in case INIT is a symlink.
Obviously we have to test if it's executable with the PATH to NEWROOT.
2012-05-29 09:15:34 +02:00
Harald Hoyer
982d59afea drop 10rpmversion module and introduce /etc/initrd-release 2012-05-22 15:22:35 +02:00
Harald Hoyer
ca024e3378 renamed switch-root.{service,target} -> initrd-switch-root 2012-05-22 14:50:19 +02:00
Harald Hoyer
dbf8f6ba0e add dracut-version.sh 2012-05-22 14:32:36 +02:00
Harald Hoyer
02805bd1fc ifcfg/write-ifcfg.sh: fixed IFS resetting 2012-05-22 11:36:41 +02:00
Jesse Keating
965d14726a Normalize dasd argument content for dasd.conf
Also overwrite any existing files, contents from CMSCONFFILE override
any boot arguments.
2012-05-21 14:19:07 -07:00
Jesse Keating
b0772db56a Translate dasd arg contents into proper dasd.conf
This uses a (new) s390utils utility to normalize the range we might get
in a dasd argument and generates a properly formatted output for
dasd.conf.
2012-05-21 14:19:07 -07:00
Jesse Keating
d695143329 Use the right argument for dasd module options
The legacy argument is DASD=, and the new arguments should be the same
as the arguments for populating dasd.conf.  If multiple arguments are
passed we can stack them by inserting a ',' between them.
2012-05-21 14:19:00 -07:00
Dennis Gilmore
59aa65c9b2 ARM: make sure that we get the storage modules into the initramfs 2012-05-21 11:11:31 +02:00
WANG Cong
ffc5bf686d check ifenslave instead of brctl in parse-bond.sh
This is obviously wrong, ifenslave instead of brctl is needed for bonding.

Cc: Harald Hoyer <harald@redhat.com>
Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>
2012-05-21 11:11:11 +02:00
Dave Young
ec3c59518d add option --printsize
Add --printsize for measuring module installed size to initramfs

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-05-21 11:11:03 +02:00
Harald Hoyer
cfe32ef5ba TEST-01-BASIC: sync after creating the root disk 2012-05-16 11:51:26 +02:00
Vivek Goyal
8be5a0fa94 dracut:fstab-sys: Wait for devices specified using --mount option
dracut allows passing --mount option which mounts the specified devices.
But it does not wait for these devices to show up and mounting will fail
if devices do not show up by the time "mount" was called.

I am writing some patches to support kdump on iscsi target and I noticed
that one of the initqueue script was not called as we found the root
device and broke out of main loop.

There are two possible enancements to this patch.

- Introduce a time limited wait (rd.timeout something along the lines of
  rd.retry). That will allow kdump to try to dump to a backup target if
  primary targets fails to come up.

- Wait for UUID= and LABEL= to show up too. Right now kdump converts
  UUID= and LABEL= to respective devices and passes /dev/* to dracut
  --mount option. So I am not introducing the wait for UUID= or LABEL=
 in this patch.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
2012-05-16 11:44:21 +02:00
Cong Wang
bd4be59fb2 check install files passed by cmdline
We should not trust cmdline passed by users, always
check the install files passed from cmdline. This restores
the old behaviour which was changed by:

	commit c6c6a08850
	Author: Harald Hoyer <harald@redhat.com>
	Date:   Tue Feb 7 18:26:30 2012 +0100

	    add "install_items" to dracut.conf

Reported-by: Dave Young <dyoung@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Harald Hoyer <harald@redhat.com>
2012-05-16 11:43:25 +02:00
Cong Wang
a6d3be9dd5 check kernel module existance
This patch adds check of kernel module existance and
propagate errors to upper callers.

In case of break other callers of instmods(), this patch
adds an option '-c' to it, only when "-c" is specified
we fail, otherwise, errors are ignored.

Reported-by: Dave Young <dyoung@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Harald Hoyer <harald@redhat.com>
2012-05-16 11:43:25 +02:00
Olivier Blin
40913ad219 90kernel-modules/module-setup.sh: install xhci-hcd
to allow booting and using kbd devices from USB 3.0
2012-05-16 11:43:25 +02:00
Harald Hoyer
afd1fd8d41 Makefile: install dracut service files from systemd dracut module 2012-05-16 11:29:48 +02:00
Harald Hoyer
38111b9622 systemd: store switch-root.conf in /run/initramfs
Store switch-root.conf in /run/initramfs/switch-root.conf, so that the
service does not fail in ExecPost after switching to the real root.
2012-05-16 11:24:42 +02:00
Harald Hoyer
41153ca4f2 systemd/switch-root.service: do not require shutdown and isolate to default
do not require shutdown.target and final.target

After switch-root isolate to the default target. This will load the
default target in the real root after systemd deserializes.
2012-05-16 11:22:28 +02:00
Harald Hoyer
3df2306981 systemd/switch-root.target: run target before switch-root.service 2012-05-16 11:21:33 +02:00
Harald Hoyer
022c5a802f systemd/dracut-pre-pivot.sh: s/udevd.service/systemd-udev.service/ 2012-05-16 11:20:59 +02:00
Harald Hoyer
832d85cbbc base/module-setup.sh: link /proc/self/mounts to $initdir/etc/mtab 2012-05-15 19:03:50 +02:00
Harald Hoyer
f72318243c systemd: adapt to new switch-root mechanism 2012-05-15 18:57:29 +02:00
Harald Hoyer
a82d207b8d ifcfg/write-ifcfg.sh: add s390 specific configuration options
https://bugzilla.redhat.com/show_bug.cgi?id=811521
2012-05-10 14:34:53 +02:00
Harald Hoyer
53e3244dba Makefile: call git2spec.pl with LANG=C 2012-05-10 14:30:31 +02:00
Brian C. Lane
37427748d1 Fail to boot if mediacheck fails (#817419)
The return value of checkisomd5 was being ignored.
2012-05-10 11:52:45 +02:00
Harald Hoyer
6e26f9b447 dracut.spec: add 98systemd module 2012-05-09 15:13:28 +02:00
Harald Hoyer
5bfbfbfc22 ifcfg/write-ifcfg.sh: use PREFIX for prefix netmask form
https://bugzilla.redhat.com/show_bug.cgi?id=820185
2012-05-09 14:58:52 +02:00
Harald Hoyer
2c431e8ec4 add systemd module 2012-05-09 13:36:07 +02:00
Harald Hoyer
8aeec251e3 rootfs-block/block-genrules.sh: install systemd mount unit 2012-05-09 13:15:32 +02:00
Harald Hoyer
f2d887d7d5 dracut.sh: install var/run and var/lock 2012-05-09 13:15:32 +02:00
Harald Hoyer
fe98cfee37 base/dracut-lib.sh: export UDEVVERSION 2012-05-09 13:15:32 +02:00
Harald Hoyer
cad10a7f80 base/init.sh: set DRACUT_QUIET only in dracut-lib.sh 2012-05-09 13:15:32 +02:00
Harald Hoyer
3734f4ae48 plymouth/plymouth-pretrigger.sh: get consoledev from /sys/class/tty/console/active 2012-05-09 11:05:40 +02:00
Harald Hoyer
4b13b2e2bf test/TEST-01-BASIC/test.sh: fix cleanup of overlay dir 2012-05-07 16:32:28 +02:00
Harald Hoyer
f6a58604a0 dracut.spec: require "file" 2012-05-07 16:28:44 +02:00
Harald Hoyer
65ceb56dd5 plymouth/plymouth-pretrigger.sh: check for tty dev existence 2012-05-07 16:28:16 +02:00
Harald Hoyer
cce69be668 removed old udev "vol_id" 2012-05-07 16:27:48 +02:00
Harald Hoyer
a54658c158 TODO: update 2012-05-04 11:32:48 +02:00
Will Woods
335bb5a35b ifcfg: fix resolv.conf
/etc/net.*.resolv.conf is not a useful filename; copy it to resolv.conf
2012-05-02 14:41:37 +02:00
Will Woods
982161e062 fix _getcmdline arg-duplicating bug with /etc/cmdline*
If you unset CMDLINE to make _getcmdline re-read /etc/cmdline and
/etc/cmdline.d/*, CMDLINE_ETC and CMDLINE_ETC_D would keep their
contents.

This is a serious problem if you have (e.g.) "ip=eth0:dhcp" in
/etc/cmdline.d/net.conf, because getargs ip= will return
"ip=eth0:dhcp ip=eth0:dhcp" and then parse-ip-opts.sh will die() because
you have two configurations for eth0.
2012-05-02 14:41:37 +02:00
Harald Hoyer
5a81678219 TEST-15-BTRFSRAID: add one more partition to the btrfs raid10 2012-04-25 15:58:40 +02:00
Harald Hoyer
168952cea6 udev-rules/module-setup.sh: fixed udevd location 2012-04-25 15:58:40 +02:00
Harald Hoyer
5dc1be1df8 multipath/module-setup.sh: fix host-only/mount checks 2012-04-25 15:58:40 +02:00
Harald Hoyer
cb08b0132f iscsi/module-setup.sh: fix host-only/mount checks 2012-04-25 15:58:40 +02:00
Harald Hoyer
eb6e141adb ifcfg: write DNS1=... for nameserver= args (RHBZ#815369)
If you're using a static network config, you'll want to keep your
nameservers around when NM starts. Write DNS1 (and DNS2, DNS3, etc..)
into the ifcfg file.

Thanks to Mark Hamzy <hamzy@us.ibm.com>
and Will Woods <wwoods@redhat.com> for the patch.
2012-04-24 13:08:57 +02:00
Harald Hoyer
c6c704fda6 network: fix ifup and netroot calling 2012-04-23 11:32:45 +02:00
Harald Hoyer
eef7649e71 merge "cleanup" and "pre-pivot-cleanup" hooks 2012-04-23 11:32:45 +02:00
Harald Hoyer
f8d50f60b3 base/dracut-lib.sh: add arguments for source_hook() and source_all() 2012-04-23 11:32:45 +02:00
Harald Hoyer
476eb1b345 base: add export_n() function
resembles export -n for dash
2012-04-23 11:32:45 +02:00
Harald Hoyer
c32908cee3 base: add debug_on() and debug_off() functions 2012-04-23 11:32:45 +02:00
Will Woods
dc1504121b url-lib: don't use --progress-bar if TERM=dumb (RHBZ#814713)
Basically, s390 is the only place I've ever seen TERM=dumb, and it's too
dumb to handle '\r', so --progress-bar produces waaaaay too much output.

The normal progress meter only prints something once per second, so
that's reasonable on terminals where '\r' doesn't work.

See also: https://bugzilla.redhat.com/show_bug.cgi?id=814713
2012-04-23 11:25:20 +02:00
Will Woods
c6a91ec992 url-lib: don't add existing handlers multiple times
Every time url-lib gets imported we end up making the list of handlers
longer with redundant entries. That's silly - we shouldn't add items
that already exist.

Note that this means you'll have to manipulate the handler list yourself
if you want to change the position/priority of existing handlers.
2012-04-23 11:25:20 +02:00
Harald Hoyer
689c3e1fcd network/parse-ip-opts.sh: remove check for netroot
with anaconda and all other kind of stuff, we might want network, even
for root not on the network
2012-04-19 16:41:04 +02:00
Dave Young
1bd76bf981 move cleanup scripts to pre-pivot-cleanup hook
below cleanup scripts is moved:
40network: kill-dhclient.sh
90crypt: crypt-cleanup.sh
90multipath: multipathd-stop.sh
95iscsi: cleanup-iscsi.sh
95nfs: nfsroot-cleanup.sh

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-04-19 11:59:45 +02:00
Dave Young
2e7257a2e3 add pre-pivot-cleanup hook
Sometimes some hook script will need to be before the cleanup hook scripts
For example dhclient killing, nfs cleanup, etc. must not happen before kdump
because it will use their fuctionalities.

So here introduce a new hook pre-pivot-cleanup, all cleanup scripts will go there.
that means pre-pivot hook is splited to two hooks pre-pivot and pre-pivot-cleanup

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-04-19 11:59:45 +02:00
Harald Hoyer
76b83902dc network/module-setup.sh: include all kernel/drivers/net/phy drivers 2012-04-19 11:59:39 +02:00
Harald Hoyer
2de297334b Makefile: do not install systemd service in reboot
shutdown is enough. It is pulled in on reboot.
2012-04-19 11:59:39 +02:00
Harald Hoyer
b4664769dc 99shutdown/shutdown.sh: export PATH 2012-04-19 11:59:39 +02:00
Harald Hoyer
7f217d7726 base/init.sh: mount tmpfs with strictatime 2012-04-19 11:59:38 +02:00
Harald Hoyer
8a1a2f6ca4 udevd moved to /lib/systemd/systemd-udevd 2012-04-19 11:59:38 +02:00
Colin Guthrie
bd66d2b59a man: Fix --add-fstab option in man page 2012-04-17 13:19:56 +02:00
Colin Guthrie
9f630a1889 Do not run plymouth hook if the binary is missing.
There is a remove-boot-splash script in Mageia that can
strip plymouth from an initrd. Make this script a noop
if that has happened.
2012-04-17 13:18:45 +02:00
Harald Hoyer
04ab68a4dd dracut.spec: do not include IMA and selinux modules with systemd 2012-04-17 12:13:40 +02:00
Lennert Buytenhek
a7c9cbe1a2 virtfs root filesystem support
Qemu/KVM provides virtfs, a paravirtualised filesystem that is
implemented by running the Plan 9 folder sharing protocol over
virtio.

Make booting with root=virtfs:foobar use the virtfs filesystem
with mount tag 'foobar' as root filesystem, to allow booting
virtual machines off virtfs.

Note that this only handles 9p over virtio (i.e. virtfs), and
doesn't attempt to handle mounting 9p filesystems over TCP/IP,
for example.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>
2012-04-17 12:07:14 +02:00
Harald Hoyer
97903dfc47 dracut.cmdline.7.asc: document "resume=" option 2012-04-17 12:07:13 +02:00
Nikoli
25ff71b0c7 lsinitrd: support symlinks 2012-04-17 11:54:27 +02:00
Harald Hoyer
324be70f80 udev-rules: remove 01-ignore.rules 2012-04-17 11:54:27 +02:00
Peter Rajnoha
b8a81fb885 lvm: disable lvmetad
Currently dracut uses lvm.conf as found in the system and modifies only
global/locking_type setting. As there's a new feature introduced - the lvmetad
daemon, dracut should disable its use as well by setting "global/use_lvmetad=0"
(patch attached).

Otherwise, there's a warning message issued:

dracut: WARNING: Failed to connect to lvmetad: No such file or directory.
Falling back to internal scanning.

@@ -, +, @@
 modules.d/90lvm/lvm_scan.sh     |    2 ++
 modules.d/90lvm/module-setup.sh |    1 +
 2 files changed, 3 insertions(+), 0 deletions(-)
2012-04-16 14:46:53 +02:00
Harald Hoyer
0a35a80b93 dracut.sh: log installed modules to $initdir/lib/dracut/modules.txt 2012-04-16 14:46:53 +02:00
Jon Ander Hernandez
c9143a63fe Debian multiarch support
Another solution could be searching in directories found at
/etc/ld.so.conf.d/*.conf or adding a new parameter. Here is a patch
which adds a new --libdirs parameter, and also a new inst_libdir_file
function which will try to expand metacharacters on each lib
directory:

    inst_libdir_file "libdevmapper-event-lvm*.so"
2012-04-16 14:46:53 +02:00
Daniel Drake
6625b74e90 rootfs-block: avoid remount when options don't change
Mounting, unmounting and then mounting a disk partition takes some
time.

On embedded systems such as OLPC XO where we disable fsck and fstab
reading, the root options are not going to change throughout the
mount_root() function, so remounting is time consuming and without
change.

Detect and optimize for this case so that the filesystem is only
mounted once.
2012-04-16 11:53:04 +02:00
Will Woods
bd3bf2ce41 shutdown: use emergency_shell from dracut-lib 2012-04-16 11:53:04 +02:00
Will Woods
f7cadaa843 Make splitsep work as documented with less vars than fields
According to its comment in dracut-lib.sh:

    splitsep ":" "one:all:the:rest" one two

should set two="all:the:rest". But there's no check to see if the
current field is the last field, so it just gets "all".
2012-04-16 11:53:04 +02:00
Will Woods
e173f0b384 network: add save_netinfo, fix problems with nfs->NM takeover
For NetworkManager to properly take over a NFS-root system, we need to
have the interface name(s) in /tmp/net.ifaces and save the dhclient
lease. This lets the ifcfg module do its magic.

save_netinfo should properly write out /tmp/net.ifaces when needed, and
copies the dhclient files into place.
2012-04-16 11:53:04 +02:00
Will Woods
1e4a880125 run setup_net at start of initqueue/online hook
This makes sure the network is active and ready to use during the
initqueue/online hook.

It also makes it so you can run setup_net repeatedly without causing
error messages.
2012-04-16 11:53:04 +02:00
Will Woods
d8f0e320c2 dracut-lib: add str_ends, to go along with str_starts 2012-04-16 11:53:04 +02:00
97 changed files with 1945 additions and 548 deletions

1
.gitignore vendored
View File

@@ -10,3 +10,4 @@
test*.img
/.buildpath
/.project
/dracut-version.sh

View File

@@ -1,4 +1,4 @@
VERSION=018
VERSION=019
GITVERSION=$(shell [ -d .git ] && git rev-list --abbrev-commit -n 1 HEAD |cut -b 1-8)
prefix ?= /usr
@@ -13,7 +13,7 @@ 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
all: syncheck dracut-version.sh
doc: $(manpages) dracut.html
@@ -32,7 +32,7 @@ dracut.html: dracut.asc $(manpages)
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)
@@ -45,6 +45,7 @@ install: doc
install -m 0644 dracut.conf $(DESTDIR)$(sysconfdir)/dracut.conf
mkdir -p $(DESTDIR)$(sysconfdir)/dracut.conf.d
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
@@ -56,15 +57,24 @@ install: doc
ln -s dracut.cmdline.7 $(DESTDIR)$(mandir)/man7/dracut.kernel.7
if [ -n "$(systemdsystemunitdir)" ]; then \
mkdir -p $(DESTDIR)$(systemdsystemunitdir); \
install -m 0644 dracut-shutdown.service $(DESTDIR)$(systemdsystemunitdir); \
mkdir -p $(DESTDIR)$(systemdsystemunitdir)/reboot.target.wants; \
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)/reboot.target.wants/dracut-shutdown.service; \
ln -s ../dracut-shutdown.service \
$(DESTDIR)$(systemdsystemunitdir)/shutdown.target.wants/dracut-shutdown.service; \
fi
dracut-version.sh:
@echo "DRACUT_VERSION=$(VERSION)-$(GITVERSION)" > dracut-version.sh
clean:
$(RM) *~
$(RM) */*~
@@ -90,7 +100,7 @@ dracut-$(VERSION).tar.bz2: doc
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; ) && \

27
NEWS
View File

@@ -1,3 +1,30 @@
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

View File

@@ -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
View 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

3
TODO
View File

@@ -6,6 +6,8 @@ Items are ordered in priority.
INITRAMFS TODO
- 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
@@ -15,6 +17,7 @@ INITRAMFS TODO
GENERATOR TODO
- remove /proc/modules use /sys/module
- 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)

View File

@@ -36,8 +36,8 @@ fi
[[ $hookdirs ]] || {
hookdirs="cmdline pre-udev pre-trigger netroot "
hookdirs+="initqueue initqueue/settled initqueue/online initqueue/finished initqueue/timeout "
hookdirs+="pre-mount pre-pivot mount "
hookdirs+="emergency shutdown-emergency shutdown cleanup "
hookdirs+="pre-mount pre-pivot cleanup mount "
hookdirs+="emergency shutdown-emergency shutdown "
export hookdirs
}
@@ -183,17 +183,6 @@ get_fs_env() {
return 1
fi
# Fallback, for the old vol_id
if [[ -x /lib/udev/vol_id ]]; then
if evalstr=$(/lib/udev/vol_id --export $1 \
| while read line; do
strstr "$line" "ID_FS_TYPE=" && { echo $line; exit 0;}
done;) ; then
eval $evalstr
[[ $ID_FS_TYPE ]] && return 0
fi
fi
# Fallback, if we don't have udev information
if find_binary blkid >/dev/null; then
eval $(blkid -o udev $1 \
@@ -542,14 +531,50 @@ inst_symlink() {
ln -sfn $(convert_abs_rel "${_target}" "${_realsrc}") "$initdir/$_target"
}
udevdir=$(pkg-config udev --variable=udevdir)
if ! [[ -d "$udevdir" ]]; then
[[ -d /lib/udev ]] && udevdir=/lib/udev
[[ -d /usr/lib/udev ]] && udevdir=/usr/lib/udev
fi
# attempt to install any programs specified in a udev rule
inst_rule_programs() {
local _prog _bin
if grep -qE 'PROGRAM==?"[^ "]+' "$1"; then
for _prog in $(grep -E 'PROGRAM==?"[^ "]+' "$1" | sed -r 's/.*PROGRAM==?"([^ "]+).*/\1/'); do
if [ -x /lib/udev/$_prog ]; then
_bin=/lib/udev/$_prog
if [ -x ${udevdir}/$_prog ]; then
_bin=${udevdir}/$_prog
else
_bin=$(find_binary "$_prog") || {
dinfo "Skipping program $_prog using in udev rule $(basename $1) as it cannot be found"
continue;
}
fi
#dinfo "Installing $_bin due to it's use in the udev rule $(basename $1)"
dracut_install "$_bin"
done
fi
if grep -qE 'RUN==?"[^ "]+' "$1"; then
for _prog in $(grep -E 'RUN==?"[^ "]+' "$1" | sed -r 's/.*RUN==?"([^ "]+).*/\1/'); do
if [ -x ${udevdir}/$_prog ]; then
_bin=${udevdir}/$_prog
else
_bin=$(find_binary "$_prog") || {
dinfo "Skipping program $_prog using in udev rule $(basename $1) as it cannot be found"
continue;
}
fi
#dinfo "Installing $_bin due to it's use in the udev rule $(basename $1)"
dracut_install "$_bin"
done
fi
if grep -qE 'PROGRAM==?"[^ "]+' "$1"; then
for _prog in $(grep -E 'IMPORT==?"[^ "]+' "$1" | sed -r 's/.*IMPORT==?"([^ "]+).*/\1/'); do
if [ -x ${udevdir}/$_prog ]; then
_bin=${udevdir}/$_prog
else
_bin=$(find_binary "$_prog") || {
dinfo "Skipping program $_prog using in udev rule $(basename $1) as it cannot be found"
@@ -568,23 +593,23 @@ inst_rule_programs() {
inst_rules() {
local _target=/etc/udev/rules.d _rule _found
inst_dir "/lib/udev/rules.d"
inst_dir "${udevdir}/rules.d"
inst_dir "$_target"
for _rule in "$@"; do
if [ "${rule#/}" = "$rule" ]; then
for r in /lib/udev/rules.d /etc/udev/rules.d; do
for r in ${udevdir}/rules.d /etc/udev/rules.d; do
if [[ -f $r/$_rule ]]; then
_found="$r/$_rule"
inst_simple "$_found"
inst_rule_programs "$_found"
inst_simple "$_found"
fi
done
fi
for r in '' ./ $dracutbasedir/rules.d/; do
if [[ -f ${r}$_rule ]]; then
_found="${r}$_rule"
inst_simple "$_found" "$_target/${_found##*/}"
inst_rule_programs "$_found"
inst_simple "$_found" "$_target/${_found##*/}"
fi
done
[[ $_found ]] || dinfo "Skipping udev rule: $_rule"
@@ -677,6 +702,34 @@ dracut_install() {
done
}
# inst_libdir_file [-n <pattern>] <file> [<file>...]
# Install a <file> located on a lib directory to the initramfs image
# -n <pattern> install non-matching files
inst_libdir_file() {
if [[ "$1" == "-n" ]]; then
local _pattern=$1
shift 2
for _dir in $libdirs; do
for _i in "$@"; do
for _f in "$_dir"/$_i; do
[[ "$_i" =~ $_pattern ]] || continue
[[ -e "$_i" ]] && dracut_install "$_i"
done
done
done
else
for _dir in $libdirs; do
for _i in "$@"; do
for _f in "$_dir"/$_i; do
[[ -e "$_f" ]] && dracut_install "$_f"
done
done
done
fi
}
# install function decompressing the target and handling symlinks
# $@ = list of compressed (gz or bz2) files or symlinks pointing to such files
#
@@ -1091,17 +1144,22 @@ find_kernel_modules () {
find_kernel_modules_by_path drivers
}
# instmods <kernel module> [<kernel module> ... ]
# instmods <kernel subsystem>
# instmods [-c] <kernel module> [<kernel module> ... ]
# instmods [-c] <kernel subsystem>
# install kernel modules along with all their dependencies.
# <kernel subsystem> can be e.g. "=block" or "=drivers/usb/storage"
instmods() {
[[ $no_kernel = yes ]] && return
# called [sub]functions inherit _fderr
local _fderr=9
local _check=no
if [[ $1 = '-c' ]]; then
_check=yes
shift
fi
function inst1mod() {
local _mod="$1"
local _ret=0 _mod="$1"
case $_mod in
=*)
if [ -f $srcmods/modules.${_mod#=} ]; then
@@ -1145,26 +1203,40 @@ instmods() {
((_ret+=$?))
;;
esac
}
function instmods_1() {
local _ret=0 _mod _mpargs
if (($# == 0)); then # filenames from stdin
while read _mod; do
inst1mod "${_mod%.ko*}"
done
fi
while (($# > 0)); do # filenames as arguments
inst1mod ${1%.ko*}
shift
done
return $_ret
}
local _filter_not_found='FATAL: Module .* not found.'
function instmods_1() {
local _mod _mpargs
if (($# == 0)); then # filenames from stdin
while read _mod; do
inst1mod "${_mod%.ko*}" || {
if [ "$_check" = "yes" ]; then
dfatal "Failed to install $_mod"
return 1
fi
}
done
fi
while (($# > 0)); do # filenames as arguments
inst1mod ${1%.ko*} || {
if [ "$_check" = "yes" ]; then
dfatal "Failed to install $1"
return 1
fi
}
shift
done
return 0
}
local _ret _filter_not_found='FATAL: Module .* not found.'
set -o pipefail
# Capture all stderr from modprobe to _fderr. We could use {var}>...
# redirections, but that would make dracut require bash4 at least.
eval "( instmods_1 \"\$@\" ) ${_fderr}>&1" \
| while read line; do [[ "$line" =~ $_filter_not_found ]] || echo $line;done | derror
return $?
_ret=$?
set +o pipefail
return $_ret
}

View File

@@ -11,6 +11,7 @@ After=getty@tty1.service prefdm.service
Before=reboot.service
DefaultDependencies=no
ConditionPathExists=/run/initramfs/.need_shutdown
ConditionPathExists=!/run/initramfs/bin/sh
[Service]
ExecStart=/usr/lib/dracut/dracut-initramfs-restore

View File

@@ -247,7 +247,7 @@ provide a valid _/etc/fstab_.
**--fstab**::
Use _/etc/fstab_ instead of _/proc/self/mountinfo_.
**--add_fstab** _<filename>_ ::
**--add-fstab** _<filename>_ ::
Add entries of _<filename>_ to the initramfs /etc/fstab.
**--mount** "_<device>_ _<mountpoint>_ _<filesystem type>_ _<filesystem options>_"::

View File

@@ -478,8 +478,7 @@ command
# dmsetup ls --tree
----
+
* A list of block device attributes including vol_id compatible mode. This can
be obtained by running the commands:
* A list of block device attributes. This can be obtained by running the commands:
+
----
# blkid -p
@@ -854,12 +853,17 @@ This hook is mainly to mount the real root device.
=== Hook: pre-pivot
This hook is called before cleanup hook, This is a good place for
actions other than cleanups which need to be called before pivot.
=== Hook: cleanup
This hook is the last hook and is called before init finally switches root to
the real root device. This is a good place to clean up and kill processes not
needed anymore.
=== Cleanup and switch_root
Init kills all udev processes, cleans up the environment, sets up the arguments

View File

@@ -64,6 +64,17 @@ rootfstype=ext3
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>,...]_::
@@ -94,7 +105,7 @@ Debug
**rd.break**::
drop to a shell at the end
**rd.break=**_{cmdline|pre-udev|pre-trigger|initqueue|pre-mount|mount|pre-pivot}_::
**rd.break=**_{cmdline|pre-udev|pre-trigger|initqueue|pre-mount|mount|pre-pivot|cleanup}_::
drop to a shell on defined breakpoint
**rd.udev.info**::
@@ -180,6 +191,16 @@ crypto LUKS
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_
@@ -277,8 +298,10 @@ auto6::: do IPv6 autoconfiguration
**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. This parameter can be specified
multiple times.
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.
@@ -290,8 +313,23 @@ auto6::: do IPv6 autoconfiguration
**biosdevname=0**::
boolean, turn off biosdevname network interface renaming
**rd.neednet=1**::
boolean, bring up network even without netroot set
**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
~~~

View File

@@ -2,9 +2,9 @@
# 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/.* "
stdloglvl=3
realinitpath="/usr/lib/systemd/systemd"
install_items+=" vi /etc/virc ps grep cat rm "
prefix="/"

View File

@@ -27,9 +27,17 @@
dracut_args="$@"
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.
@@ -123,6 +131,7 @@ 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)
If [LIST] has multiple arguments, then you have to put these in quotes.
@@ -221,6 +230,7 @@ while (($# > 0)); do
--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;;
@@ -247,7 +257,11 @@ while (($# > 0)); do
--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" ;;
@@ -267,6 +281,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
@@ -310,9 +325,6 @@ unset GREP_OPTIONS
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
[[ $allowlocal && -f "$(readlink -f ${0%/*})/dracut-functions.sh" ]] && \
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" || \
@@ -400,6 +412,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))
@@ -450,6 +469,10 @@ else
exit 1
fi
if [[ -f $dracutbasedir/dracut-version.sh ]]; then
. $dracutbasedir/dracut-version.sh
fi
# Verify bash version, curret minimum is 3.1
if (( ${BASH_VERSINFO[0]} < 3 ||
( ${BASH_VERSINFO[0]} == 3 && ${BASH_VERSINFO[1]} < 1 ) )); then
@@ -504,16 +527,23 @@ ddebug "Executing $0 $dracut_args"
}
# 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!'
if ! [[ $libdir ]] || ! [[ $usrlibdir ]] ; then
if strstr "$(ldd /bin/sh)" "/lib64/" &>/dev/null \
&& [[ -d /lib64 ]]; then
libdir=/lib64
usrlibdir=/usr/lib64
else
libdir=/lib
usrlibdir=/usr/lib
fi
for i in $libdir $usrlibdir; do
if [[ -d $i ]]; then
libdirs+=" $i"
else
dwarn 'No $i directory??!!'
fi
done
fi
# This is kinda legacy -- eventually it should go away.
case $dracutmodules in
@@ -632,7 +662,8 @@ export initdir dracutbasedir dracutmodules drivers \
add_drivers omit_drivers mdadmconf lvmconf filesystems \
use_fstab fstab_lines libdir usrlibdir fscks nofscks \
stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
debug host_fs_types host_devs sshkey add_fstab
debug host_fs_types host_devs sshkey add_fstab \
DRACUT_VERSION
# Create some directory structure first
[[ $prefix ]] && mkdir -m 0755 -p "${initdir}${prefix}"
@@ -647,7 +678,7 @@ if [[ $prefix ]]; then
fi
if [[ $kernel_only != yes ]]; then
for d in usr/bin usr/sbin bin etc lib "$libdir" sbin tmp usr var var/log; do
for d in usr/bin usr/sbin bin etc lib "$libdir" sbin tmp usr var var/log var/run var/lock; do
[[ -e "${initdir}${prefix}/$d" ]] && continue
if [ -L "/$d" ]; then
inst_symlink "/$d" "${prefix}/$d"
@@ -682,6 +713,9 @@ if [[ $kernel_only != yes ]]; then
for _d in $hookdirs; do
mkdir -m 0755 -p ${initdir}/lib/dracut/hooks/$_d
done
if [[ "$UID" = "0" ]]; then
cp -a /dev/kmsg /dev/null /dev/console $initdir/dev
fi
fi
mkdir -p "$initdir/.kernelmodseen"
@@ -692,6 +726,7 @@ mods_to_load=""
for_each_module_dir check_module
for_each_module_dir check_mount
_isize=0 #initramfs size
modules_loaded=" "
# source our modules.
for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
@@ -700,18 +735,37 @@ 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
echo "$i" >> $initdir/lib/dracut/modules.txt
done
dinfo "*** Including modules done ***"
## final stuff that has to happen
@@ -751,7 +805,7 @@ done
if [[ $kernel_only != yes ]]; then
for item in $install_items; do
dracut_install -o "$item"
dracut_install "$item"
done
unset item

View File

@@ -76,6 +76,7 @@ Requires: hardlink
Requires: gzip xz
Requires: module-init-tools >= 3.7-9
Requires: sed
Requires: file
Requires: udev > 166
%if 0%{?fedora} || 0%{?rhel} > 6
Requires: util-linux >= 2.21
@@ -177,7 +178,7 @@ make install DESTDIR=$RPM_BUILD_ROOT \
%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
@@ -187,6 +188,14 @@ 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
@@ -231,6 +240,7 @@ rm -rf $RPM_BUILD_ROOT
%dir %{dracutlibdir}/modules.d
%{dracutlibdir}/dracut-functions.sh
%{dracutlibdir}/dracut-functions
%{dracutlibdir}/dracut-version.sh
%{dracutlibdir}/dracut-logger.sh
%{dracutlibdir}/dracut-initramfs-restore
%config(noreplace) /etc/dracut.conf
@@ -246,7 +256,6 @@ rm -rf $RPM_BUILD_ROOT
%{dracutlibdir}/modules.d/00dash
%{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
@@ -270,14 +279,18 @@ 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/98pollcdrom
%{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
@@ -288,6 +301,7 @@ rm -rf $RPM_BUILD_ROOT
%dir %{_sharedstatedir}/initramfs
%if %{defined _unitdir}
%{_unitdir}/*.service
%{_unitdir}/*.target
%{_unitdir}/*/*.service
%endif

View File

@@ -34,7 +34,7 @@ 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 >/dev/null 2>&1; then
XZ_SINGLE_STREAM="--single-stream"

View File

@@ -19,11 +19,12 @@ installkernel() {
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() {
@@ -34,12 +35,11 @@ install() {
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
inst_libdir_file libsoftokn3.so
inst_libdir_file libsoftokn3.chk
inst_libdir_file libfreebl3.so
inst_libdir_file libfreebl3.chk
dracut_install $usrlibdir/hmaccalc/sha512hmac.hmac
if command -v prelink >/dev/null; then

View File

@@ -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"
}

View File

@@ -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

View File

@@ -31,19 +31,28 @@ 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
# disable manual ifup while netroot is set for simplifying our logic
# in netroot case we prefer netroot to bringup $netif automaticlly
[ -n "$2" -a "$2" = "-m" ] && [ -z "$netroot" ] && manualup="$2"
@@ -72,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
@@ -88,30 +95,20 @@ 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
[ -n "$macaddr" ] && echo ip link set address $macaddr
[ -n "$mtu" ] && echo ip link set mtu $mtu
# 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
# do not flush addr for ipv6
strstr $ip '*:*:*' || \
ip addr flush dev $netif
ip addr add $ip/$mask brd + dev $netif
[ -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
@@ -122,20 +119,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
@@ -169,7 +158,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
@@ -188,18 +177,40 @@ 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
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
ip link set "$phydevice" up
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
@@ -238,6 +249,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

View File

@@ -27,6 +27,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() {
@@ -55,24 +56,29 @@ installkernel() {
# Use two parallel streams to filter alternating modules.
set +x
eval "( ( rotor ) ${_side2}>&1 | nmf1 ) ${_merge}>&1"
_ret=$?
[[ $debug ]] && set -x
return $_ret
}
{ find_kernel_modules_by_path drivers/net; find_kernel_modules_by_path drivers/s390/net; } \
| 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
dracut_install -o brctl
inst "$moddir/ifup.sh" "/sbin/ifup"
inst "$moddir/netroot.sh" "/sbin/netroot"
inst "$moddir/dhclient-script.sh" "/sbin/dhclient-script"
@@ -81,20 +87,16 @@ install() {
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.*"
inst_libdir_file {"tls/$_arch/",tls/,"$_arch/",}"libnss_mdns4_minimal.so.*"
}

View File

@@ -14,14 +14,14 @@ fix_bootif() {
}
# 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)
@@ -31,6 +31,11 @@ fix_bootif() {
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"
@@ -51,7 +56,4 @@ fix_bootif() {
printf 'SUBSYSTEM=="net", RUN+="%s"\n' "/sbin/initqueue --onetime $ifup"
fi
# Run the "online" hook
printf 'SUBSYSTEM=="net", ACTION=="online", RUN+="/sbin/initqueue --onetime --env netif=$env{INTERFACE} source_hook initqueue/online"\n'
} > /etc/udev/rules.d/60-net.rules

View File

@@ -59,17 +59,15 @@ ifdown() {
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.up ] || return 1
[ -e /tmp/net.$netif.did-setup ] && return
[ -e "/tmp/net.ifaces" ] && read IFACES < /tmp/net.ifaces
[ -z "$IFACES" ] && IFACES="$netif"
for iface in $IFACES ; do
. /tmp/net.$iface.up
done
# run the scripts written by ifup
[ -e /tmp/net.$netif.gw ] && . /tmp/net.$netif.gw
[ -e /tmp/net.$netif.hostname ] && . /tmp/net.$netif.hostname
@@ -97,9 +95,34 @@ setup_net() {
else
dest="$gw_ip"
fi
if [ -n "$dest" ] && ! arping -q -f -w 60 -I $netif $dest ; then
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() {
@@ -251,4 +274,18 @@ ip_to_var() {
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
}

View File

@@ -13,24 +13,13 @@ command -v setup_net >/dev/null || . /lib/net-lib.sh
# 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
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
all_ifaces_up || exit 1
[ -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
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
@@ -72,29 +61,13 @@ if [ -z "$2" ]; then
fi
fi
# We're here, so we can assume that upping interfaces is now ok
setup_net $netif
# exit in case manually bring up network
[ -n "$2" ] && exit 0
# Source netroot hooks before we start the handler
source_hook netroot
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
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.
[ -z "$BOOTDEV" ] && ifdown $netif
# Network rootfs mount successful - save interface info for ifcfg etc.
save_netinfo $netif
fi
exit 0

View File

@@ -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

View File

@@ -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=$(echo $2|tr "," " ") ;;
*) 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

View File

@@ -17,14 +17,6 @@
command -v getarg >/dev/null || . /lib/dracut-lib.sh
command -v ibft_to_cmdline >/dev/null || . /lib/net-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
# Don't mix BOOTIF=macaddr from pxelinux and ip= lines
getarg ip= >/dev/null && getarg BOOTIF= >/dev/null && \
die "Mixing BOOTIF and ip= lines is dangerous"

View 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

View File

@@ -20,6 +20,70 @@ 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
@@ -38,7 +102,6 @@ for netif in $IFACES ; do
echo "ONBOOT=yes"
echo "NETBOOT=yes"
echo "UUID=$uuid"
[ -n "$macaddr" ] && echo "MACADDR=$macaddr"
[ -n "$mtu" ] && echo "MTU=$mtu"
if [ -f /tmp/net.$netif.lease ]; then
strstr "$ip" '*:*:*' &&
@@ -50,7 +113,11 @@ for netif in $IFACES ; do
# 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"
if strstr "$mask" "."; then
echo "NETMASK=$mask"
else
echo "PREFIX=$mask"
fi
[ -n "$gw" ] && echo "GATEWAY=$gw"
fi
} > /tmp/ifcfg/ifcfg-$netif
@@ -59,7 +126,12 @@ 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"
@@ -138,6 +210,11 @@ 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
@@ -147,7 +224,7 @@ 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/
cp -a -t /run/initramfs/state/etc/sysconfig/network-scripts/ /tmp/ifcfg/*
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

View File

@@ -43,6 +43,7 @@ add_url_handler() {
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
@@ -53,7 +54,8 @@ add_url_handler() {
export CURL_HOME="/run/initramfs/url-lib"
mkdir -p $CURL_HOME
curl_args="--location --retry 3 --fail --show-error --progress-bar"
curl_args="--location --retry 3 --fail --show-error"
curl_fetch_url() {
local url="$1" outloc="$2"
echo "$url" > /proc/self/fd/0

View File

@@ -2,27 +2,29 @@
# -*- 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
[ -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
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
[ -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
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

View File

@@ -5,7 +5,7 @@
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
function sysecho () {
file=$1
file="$1"
shift
local i=1
while [ $i -le 10 ] ; do
@@ -16,7 +16,11 @@ function sysecho () {
break
fi
done
[ -f "$file" ] && echo $* > $file
local status
read status < "$file"
if [[ ! $status == $* ]]; then
[ -f "$file" ] && echo $* > "$file"
fi
}
function dasd_settle() {
@@ -169,8 +173,8 @@ processcmsfile()
fi
if [[ $DASD ]]; then
echo $DASD >> /etc/dasd.conf
echo "options dasd_mod dasd=$DASD" >> /etc/modprobe.d/dasd_mod.conf
echo $DASD | normalize_dasd_arg > /etc/dasd.conf
echo "options dasd_mod dasd=$DASD" > /etc/modprobe.d/dasd_mod.conf
dasd_cio_free
fi

View File

@@ -31,10 +31,8 @@ install() {
[[ -f $file ]] && inst $file
done
for file in {"$usrlibdir","$libdir"}/gconv/*; do
[[ -f $file ]] && inst $file
done
inst_libdir_file "gconv/*"
#inst /usr/lib/locale/locale-archive
dracut_install cmsfs-fuse fusermount ulockmgr_server bash tr insmod rmmod cat
dracut_install cmsfs-fuse fusermount ulockmgr_server bash tr insmod rmmod cat normalize_dasd_arg
}

View File

@@ -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)" \

View File

@@ -48,7 +48,7 @@ install() {
inst "$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"
}

View File

@@ -22,9 +22,7 @@ install() {
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

View File

@@ -58,13 +58,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

View File

@@ -33,7 +33,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
@@ -204,7 +204,7 @@ 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

View File

@@ -35,8 +35,11 @@ installkernel() {
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 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"
@@ -58,11 +61,12 @@ installkernel() {
hostonly='' instmods $drivers
fi
[[ $add_drivers ]] && hostonly='' instmods $add_drivers
[[ $filesystems ]] && hostonly='' instmods $filesystems
# force install of scsi_wait_scan
hostonly='' instmods scsi_wait_scan
if [[ $add_drivers ]]; then
hostonly='' instmods -c $add_drivers || return 1
fi
if [[ $filesystems ]]; then
hostonly='' instmods -c $filesystems || return 1
fi
for _f in modules.builtin.bin modules.builtin; do
[[ $srcmods/$_f ]] && break

View File

@@ -27,6 +27,5 @@ if [ $? != 0 ]; then
warn "url: $url"
return 1
fi
rm -rf /updates
mv -f /updates.tmp.$$ /updates
copytree /updates.tmp.$$ /updates
mv /tmp/liveupdates.info /tmp/liveupdates.done

View File

@@ -10,7 +10,7 @@ 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 "rd.neednet=1" > /etc/cmdline.d/90livenet.conf
echo > /tmp/net.ifaces
unset CMDLINE
fi
echo "$updates" > /tmp/liveupdates.info

View File

@@ -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

View File

@@ -49,6 +49,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
@@ -60,8 +61,6 @@ install() {
inst "$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"
}

View File

@@ -57,14 +57,12 @@ install() {
# inst /etc/passwd
# inst /etc/group
if [ ! -x /lib/udev/vol_id ]; then
inst_rules 64-md-raid.rules
# remove incremental assembly from stock rules, so they don't shadow
# 65-md-inc*.rules and its fine-grained controls, or cause other problems
# when we explicitly don't want certain components to be incrementally
# assembled
sed -i -r -e '/RUN\+?="[[:alpha:]/]*mdadm[[:blank:]]+(--incremental|-I)[[:blank:]]+(\$env\{DEVNAME\}|\$tempnode)"/d' "${initdir}/lib/udev/rules.d/64-md-raid.rules"
fi
inst_rules 64-md-raid.rules
# remove incremental assembly from stock rules, so they don't shadow
# 65-md-inc*.rules and its fine-grained controls, or cause other problems
# when we explicitly don't want certain components to be incrementally
# assembled
sed -i -r -e '/RUN\+?="[[:alpha:]/]*mdadm[[:blank:]]+(--incremental|-I)[[:blank:]]+(\$env\{DEVNAME\}|\$tempnode)"/d' "${initdir}${udevdir}/rules.d/64-md-raid.rules"
inst_rules "$moddir/65-md-incremental-imsm.rules"

View File

@@ -11,18 +11,16 @@ check() {
[[ $debug ]] && set -x
is_mpath() {
[ -e /sys/dev/block/$1/dm/uuid ] || return 1
[[ $(cat /sys/dev/block/$1/dm/uuid) =~ ^mpath- ]] && return 0
local _dev
_dev=$(get_maj_min $1)
[ -e /sys/dev/block/$_dev/dm/uuid ] || return 1
[[ $(cat /sys/dev/block/$_dev/dm/uuid) =~ ^mpath- ]] && return 0
return 1
}
if [[ $hostonly ]]; then
_rootdev=$(find_root_block_device)
if [[ $_rootdev ]]; then
check_block_and_slaves is_mpath "$_rootdev" && return 0
fi
return 1
fi
[[ $hostonly ]] || [[ $mount_needs ]] && {
for_each_host_dev_fs is_mpath || return 1
}
return 0
}
@@ -33,6 +31,7 @@ depends() {
}
installkernel() {
local _ret
set +x
mp_mod_filter() {
local _mpfuncs='scsi_register_device_handler|dm_dirty_log_type_register|dm_register_path_selector|dm_register_target'
@@ -47,7 +46,9 @@ installkernel() {
( find_kernel_modules_by_path drivers/scsi; find_kernel_modules_by_path drivers/s390/scsi ;
find_kernel_modules_by_path drivers/md ) | mp_mod_filter | instmods
_ret=$?
[[ $debug ]] && set -x
return $_ret
}
install() {
@@ -62,13 +63,15 @@ install() {
/sbin/xdrgetprio \
/etc/xdrdevices.conf \
/etc/multipath.conf \
/etc/multipath/* \
"$libdir"/libmultipath* "$libdir"/multipath/*; do
/etc/multipath/*; do
[ -e "$_f" ] && inst "$_f"
done
inst_libdir_file "libmultipath*"
inst_libdir_file "multipath/*"
inst_hook pre-trigger 02 "$moddir/multipathd.sh"
inst_hook pre-pivot 02 "$moddir/multipathd-stop.sh"
inst_hook cleanup 02 "$moddir/multipathd-stop.sh"
inst_rules 40-multipath.rules
}

View File

@@ -18,7 +18,7 @@ installkernel() {
install() {
inst_hook cmdline 30 "$moddir/parse-dasd.sh"
dracut_install tr dasdinfo dasdconf.sh
dracut_install tr dasdinfo dasdconf.sh normalize_dasd_arg
if [[ $hostonly ]]; then
inst /etc/dasd.conf
fi

View File

@@ -1,10 +1,10 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
for dasd_arg in $(getargs rd.dasd 'rd_DASD='); do
for dasd_arg in $(getargs rd.dasd= rd_DASD= DASD=); do
(
IFS=","
set $dasd_arg
echo "$@" >> /etc/dasd.conf
echo "$@" | normalize_dasd_arg >> /etc/dasd.conf
)
done

View File

@@ -1,12 +1,52 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
[ -d /etc/modprobe.d ] || mkdir -m 0755 -p /etc/modprobe.d
mod_args=""
dasd_arg=$(getarg rd.dasd_mod.dasd rd_DASD_MOD=)
if [ -n "$dasd_arg" ]; then
echo "options dasd_mod dasd=$dasd_arg" >> /etc/modprobe.d/dasd_mod.conf
convert_dasd_param() {
local bus_id params
params=""
bus_id=$1; shift
while [ $# -gt 0 ]; do
case "$1" in
use_diag\=1)
params="$params,diag"
;;
readonly\=1)
params="$params,ro"
;;
erplog\=1)
params="$params,erplog"
;;
failfast\=1)
params="$params,failfast"
;;
esac
shift
done
params="${params#*,}"
if [ -n "$params" ]; then
echo "$bus_id($params)"
else
echo "$bus_id"
fi
}
for dasd_arg in $(getargs rd.dasd= rd_DASD= DASD=); do
OLD_IFS=$IFS
IFS=","
set -- $dasd_arg
IFS=$OLD_IFS
dasd_arg=$(convert_dasd_param "$@")
mod_args="$mod_args,$dasd_arg"
done
mod_args="${mod_args#*,}"
if [ -n "$mod_args" ]; then
[ -d /etc/modprobe.d ] || mkdir -m 0755 -p /etc/modprobe.d
echo "options dasd_mod dasd=$mod_args" >> /etc/modprobe.d/dasd_mod.conf
fi
unset dasd_arg
unset dasd_arg
dasd_cio_free

View File

@@ -13,4 +13,5 @@ depends() {
install() {
[ -f /etc/fstab.sys ] && inst /etc/fstab.sys
inst_hook pre-pivot 00 "$moddir/mount-sys.sh"
inst_hook cmdline 00 "$moddir/wait-mount-dev.sh"
}

View File

@@ -12,7 +12,7 @@ fstab_mount() {
while read _dev _mp _fs _opts _dump _pass _rest; do
[ -z "${_dev%%#*}" ] && continue # Skip comment lines
if [ "$_pass" -gt 0 ] && ! strstr "$_opts" _netdev; then
fsck_single "$_dev" "$_fs"
fsck_single "$_dev" "$_fs" "$_opts"
fi
_fs=$(det_fs "$_dev" "$_fs")
info "Mounting $_dev"

View File

@@ -0,0 +1,22 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
type det_fs >/dev/null 2>&1 || . /lib/fs-lib.sh
fstab_wait_dev() {
local _dev _mp _fs _opts _dump _pass _rest
test -e "$1" || return 1
while read _dev _mp _fs _opts _dump _pass _rest; do
[ -z "${_dev%%#*}" ] && continue # Skip comment lines
case "$_dev" in
/dev/?*)
wait_for_dev $_dev;;
*) ;;
esac
done < $1
return 0
}
[ -f /etc/fstab ] && fstab_wait_dev /etc/fstab

View File

@@ -15,8 +15,11 @@ check() {
[[ $debug ]] && set -x
is_iscsi() (
[[ -L /sys/dev/block/$1 ]] || return
cd "$(readlink -f /sys/dev/block/$1)"
local _dev
_dev=$(get_maj_min $1)
[[ -L /sys/dev/block/$_dev ]] || return
cd "$(readlink -f /sys/dev/block/$_dev)"
until [[ -d sys || -d iscsi_session ]]; do
cd ..
done
@@ -24,14 +27,7 @@ check() {
)
[[ $hostonly ]] || [[ $mount_needs ]] && {
_rootdev=$(find_root_block_device)
if [[ $_rootdev ]]; then
# root lives on a block device, so we can be more precise about
# hostonly checking
check_block_and_slaves is_iscsi "$_rootdev" || return 1
else
return 1
fi
for_each_host_dev_fs is_iscsi || return 1
}
return 0
}
@@ -63,7 +59,7 @@ install() {
inst hostname
inst iscsi-iname
inst_hook cmdline 90 "$moddir/parse-iscsiroot.sh"
inst_hook pre-pivot 90 "$moddir/cleanup-iscsi.sh"
inst_hook cleanup 90 "$moddir/cleanup-iscsi.sh"
inst "$moddir/iscsiroot.sh" "/sbin/iscsiroot"
inst "$moddir/mount-lun.sh" "/bin/mount-lun.sh"
}

View File

@@ -54,15 +54,11 @@ install() {
_nsslibs=${_nsslibs#|}
_nsslibs=${_nsslibs%|}
for _i in {/usr,}$libdir/libnss*.so; do
[[ -e $_i ]] || continue
[[ "$_i" =~ $_nsslibs ]] || continue
dracut_install "$_i"
done
inst_libdir_file -n "$_nsslibs" "libnss*.so"
inst_hook cmdline 90 "$moddir/parse-nfsroot.sh"
inst_hook pre-udev 99 "$moddir/nfs-start-rpc.sh"
inst_hook pre-pivot 99 "$moddir/nfsroot-cleanup.sh"
inst_hook cleanup 99 "$moddir/nfsroot-cleanup.sh"
inst "$moddir/nfsroot.sh" "/sbin/nfsroot"
inst "$moddir/nfs-lib.sh" "/lib/nfs-lib.sh"
mkdir -m 0755 -p "$initdir/var/lib/nfs/rpc_pipefs"

View File

@@ -13,5 +13,22 @@ if [ "${root%%:*}" = "block" ]; then
printf '[ -e "%s" ] && { ln -s "%s" /dev/root 2>/dev/null; rm "$job"; }\n' \
"${root#block:}" "${root#block:}" > $hookdir/initqueue/settled/blocksymlink.sh
if [ -d /lib/systemd/system/ ]; then
echo "${root#block:} $NEWROOT ${fstype:-auto} ${rflags:-defaults} 1 1" >> /etc/fstab
{
echo '[Unit]'
echo 'Description=New Root File System'
echo 'DefaultDependencies=no'
echo 'Before=switch-root.service'
echo '[Mount]'
echo "What=${root#block:}"
echo "Where=$NEWROOT"
} >/lib/systemd/system/${NEWROOT#/}.mount
mkdir -p /lib/systemd/system/switch-root.target.wants
ln -s ../${NEWROOT#/}.mount /lib/systemd/system/switch-root.target.wants/${NEWROOT#/}.mount
fi
wait_for_dev "${root#block:}"
fi

View File

@@ -98,20 +98,24 @@ mount_root() {
# them; rflags is guaranteed to not be empty
rflags="${rootopts:+"${rootopts},"}${rflags}"
umount "$NEWROOT"
# backslashes are treated as escape character in fstab
# esc_root=$(echo ${root#block:} | sed 's,\\,\\\\,g')
# printf '%s %s %s %s 1 1 \n' "$esc_root" "$NEWROOT" "$rootfs" "$rflags" >/etc/fstab
ran_fsck=0
if [ -z "$fastboot" -a "$READONLY" != "yes" ] && ! strstr "${rflags},${rootopts}" _netdev; then
fsck_single "${root#block:}" "$rootfs" "$fsckoptions"
umount "$NEWROOT"
fsck_single "${root#block:}" "$rootfs" "$rflags" "$fsckoptions"
_ret=$?
[ $_ret -ne 255 ] && echo $_ret >/run/initramfs/root-fsck
ran_fsck=1
fi
info "Remounting ${root#block:} with -o ${rflags}"
mount -t "$rootfs" -o "$rflags" "${root#block:}" "$NEWROOT" 2>&1 | vinfo
if [ -n "$rootopts" -o "$ran_fsck" = "1" ]; then
info "Remounting ${root#block:} with -o ${rflags}"
umount "$NEWROOT" &>/dev/null
mount -t "$rootfs" -o "$rflags" "${root#block:}" "$NEWROOT" 2>&1 | vinfo
fi
[ -f "$NEWROOT"/forcefsck ] && rm -f "$NEWROOT"/forcefsck 2>/dev/null
[ -f "$NEWROOT"/.autofsck ] && rm -f "$NEWROOT"/.autofsck 2>/dev/null

View File

@@ -1 +0,0 @@
KERNEL=="ram[0-9]*", OPTIONS+="ignore_device", OPTIONS+="last_rule"

View File

@@ -1,7 +0,0 @@
SUBSYSTEM!="block", GOTO="psv_end"
ACTION!="add|change", GOTO="psv_end"
ACTION=="change", KERNEL=="dm-[0-9]*", ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}!="1", IMPORT{program}="vol_id --export $tempnode"
KERNEL=="cciss[0-9]*", IMPORT{program}="vol_id --export $tempnode"
KERNEL=="nbd[0-9]*", IMPORT{program}="vol_id --export $tempnode"
KERNEL=="md[0-9]*|md_d[0-9]*|md/*", IMPORT{program}="vol_id --export $tempnode"
LABEL="psv_end"

View File

@@ -4,25 +4,46 @@
install() {
local _i
# FIXME: would be nice if we didn't have to know which rules to grab....
systemdutildir=$(pkg-config systemd --variable=systemdutildir)
if ! [[ -d "$systemdutildir" ]]; then
[[ -d /lib/systemd ]] && systemdutildir=/lib/systemd
[[ -d /usr/lib/systemd ]] && systemdutildir=/usr/lib/systemd
fi
udevdir=$(pkg-config udev --variable=udevdir)
if ! [[ -d "$udevdir" ]]; then
[[ -d /lib/udev ]] && udevdir=/lib/udev
[[ -d /usr/lib/udev ]] && udevdir=/usr/lib/udev
fi
# Fixme: would be nice if we didn't have to know which rules to grab....
# ultimately, /lib/initramfs/rules.d or somesuch which includes links/copies
# of the rules we want so that we just copy those in would be best
dracut_install udevadm
[ -x /sbin/udevd ] && dracut_install udevd
[ -d ${initdir}/lib/systemd ] || mkdir -p ${initdir}/lib/systemd
for _i in ${systemdutildir}/systemd-udevd ${udevdir}/udevd /sbin/udevd; do
[ -x "$_i" ] || continue
inst "$_i"
if ! [[ -f ${initdir}/lib/systemd/systemd-udevd ]]; then
ln -s "$_i" ${initdir}/lib/systemd/systemd-udevd
fi
break
done
for i in /etc/udev/udev.conf /etc/group; do
inst_simple $i
done
dracut_install basename
inst_rules 50-udev-default.rules 60-persistent-storage.rules \
61-persistent-storage-edd.rules 80-drivers.rules 95-udev-late.rules \
60-pcmcia.rules
#Some debian udev rules are named differently
inst_rules 50-udev.rules 95-late.rules
# ignore some devices in the initrd
inst_rules "$moddir/01-ignore.rules"
# for firmware loading
inst_rules 50-firmware.rules
dracut_install cat uname
@@ -31,12 +52,8 @@ install() {
inst_dir /run/udev
inst_dir /run/udev/rules.d
if [ ! -x /lib/udev/vol_id ]; then
dracut_install blkid
inst_rules "$moddir/59-persistent-storage.rules"
else
inst_rules "$moddir/59-persistent-storage-volid.rules"
fi
dracut_install blkid
inst_rules "$moddir/59-persistent-storage.rules"
inst_rules "$moddir/61-persistent-storage.rules"
for _i in \
@@ -54,28 +71,15 @@ install() {
input_id \
scsi_id \
usb_id \
vol_id \
pcmcia-socket-startup \
pcmcia-check-broken-cis \
udevd \
; do
[ -e /lib/udev/$_i ] && dracut_install /lib/udev/$_i
[ -e /usr/lib/udev/$_i ] && dracut_install /usr/lib/udev/$_i
[ -e ${udevdir}/$_i ] && dracut_install ${udevdir}/$_i
done
if ! [ -e "$initdir/sbin/udevd" ]; then
if [ -x /usr/lib/udev/udevd ]; then
ln -s /usr/lib/udev/udevd "$initdir/sbin/udevd"
elif [ -x /lib/udev/udevd ]; then
ln -s /lib/udev/udevd "$initdir/sbin/udevd"
fi
fi
[ -f /etc/arch-release ] && \
inst "$moddir/load-modules.sh" /lib/udev/load-modules.sh
for _i in {"$libdir","$usrlibdir"}/libnss_files*; do
[ -e "$_i" ] && dracut_install "$_i"
done
inst_libdir_file "libnss_files*"
}

View 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() {
[[ $hostonly ]] || [[ $mount_needs ]] && {
for fs in ${host_fs_types[@]}; do
strstr "$fs" "\|9p" && return 0
done
return 1
}
return 0
}
depends() {
return 0
}
installkernel() {
instmods 9p 9pnet_virtio
}
install() {
inst_hook cmdline 95 "$moddir/parse-virtfs.sh"
inst_hook mount 99 "$moddir/mount-virtfs.sh"
}

View File

@@ -0,0 +1,75 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
filter_rootopts() {
rootopts=$1
# strip ro and rw options
local OLDIFS="$IFS"
IFS=,
set -- $rootopts
IFS="$OLDIFS"
local v
while [ $# -gt 0 ]; do
case $1 in
rw|ro);;
defaults);;
*)
v="$v,${1}";;
esac
shift
done
rootopts=${v#,}
echo $rootopts
}
mount_root() {
local _ret
rootfs="9p"
rflags="trans=virtio,version=9p2000.L"
modprobe 9pnet_virtio
mount -t ${rootfs} -o "$rflags",ro "${root#virtfs:}" "$NEWROOT"
rootopts=
if getargbool 1 rd.fstab -n rd_NO_FSTAB \
&& ! getarg rootflags \
&& [ -f "$NEWROOT/etc/fstab" ] \
&& ! [ -L "$NEWROOT/etc/fstab" ]; then
# if $NEWROOT/etc/fstab contains special mount options for
# the root filesystem,
# remount it with the proper options
rootopts="defaults"
while read dev mp fs opts rest; do
# skip comments
[ "${dev%%#*}" != "$dev" ] && continue
if [ "$mp" = "/" ]; then
rootopts=$opts
break
fi
done < "$NEWROOT/etc/fstab"
rootopts=$(filter_rootopts $rootopts)
fi
# we want rootflags (rflags) to take precedence so prepend rootopts to
# them; rflags is guaranteed to not be empty
rflags="${rootopts:+"${rootopts},"}${rflags}"
umount "$NEWROOT"
info "Remounting ${root#virtfs:} with -o ${rflags}"
mount -t ${rootfs} -o "$rflags" "${root#virtfs:}" "$NEWROOT" 2>&1 | vinfo
[ -f "$NEWROOT"/forcefsck ] && rm -f "$NEWROOT"/forcefsck 2>/dev/null
[ -f "$NEWROOT"/.autofsck ] && rm -f "$NEWROOT"/.autofsck 2>/dev/null
}
if [ -n "$root" -a -z "${root%%virtfs:*}" ]; then
mount_root
fi

View File

@@ -1,9 +1,9 @@
#!/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
if [ "${root%%:*}" = "virtfs" ] ; then
modprobe 9pnet_virtio
rootok=1
fi

View File

@@ -16,11 +16,9 @@ install() {
local _installs
if type -P rsyslogd >/dev/null; then
_installs="rsyslogd"
for _i in {"$libdir","$usrlibdir"}/rsyslog/lmnet.so \
{"$libdir","$usrlibdir"}/rsyslog/imklog.so \
{"$libdir","$usrlibdir"}/rsyslog/imuxsock.so ; do
[ -e "$_i" ] && _installs="$_installs $_i"
done
inst_libdir_file rsyslog/lmnet.so
inst_libdir_file rsyslog/imklog.so
inst_libdir_file rsyslog/imuxsock.so
elif type -P syslogd >/dev/null; then
_installs="syslogd"
elif type -P syslog-ng >/dev/null; then

View File

@@ -0,0 +1,27 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
NEWROOT="/sysroot"
[ -d $NEWROOT ] || mkdir -p -m 0755 $NEWROOT
[ -d /run/initramfs ] || mkdir -p -m 0755 /run/initramfs
[ -d /run/lock ] || mkdir -p -m 0755 /run/lock
exec </dev/console >/dev/console 2>&1
if [ -f /dracut-state.sh ]; then
. /dracut-state.sh || :
fi
. /lib/dracut-lib.sh
source_conf /etc/conf.d
# run scriptlets to parse the command line
getarg 'rd.break=cmdline' 'rdbreak=cmdline' && emergency_shell -n cmdline "Break before cmdline"
source_hook cmdline
[ -z "$root" ] && die "No or empty root= argument"
[ -z "$rootok" ] && die "Don't know how to handle 'root=$root'"
export root rflags fstype netroot NEWROOT
export -p > /dracut-state.sh

View File

@@ -0,0 +1,27 @@
# This file is part of systemd.
#
# 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.
# See systemd.special(7) for details
[Unit]
Description=Dracut initqueue hook
DefaultDependencies=no
After=systemd-udev-trigger.service
[Service]
Environment=HOME=/
WorkingDirectory=/
ExecStart=-/bin/dracut-initqueue
Type=simple
StandardInput=tty-force
StandardOutput=inherit
StandardError=inherit
KillMode=process
# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash
# terminates cleanly.
KillSignal=SIGHUP

View File

@@ -0,0 +1,112 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
exec </dev/console >/dev/console 2>&1
if [ -f /dracut-state.sh ]; then
. /dracut-state.sh || :
fi
. /lib/dracut-lib.sh
source_conf /etc/conf.d
source_hook pre-trigger
getarg 'rd.break=initqueue' 'rdbreak=initqueue' && emergency_shell -n initqueue "Break before initqueue"
RDRETRY=$(getarg rd.retry 'rd_retry=')
RDRETRY=${RDRETRY:-20}
RDRETRY=$(($RDRETRY*2))
export RDRETRY
main_loop=0
export main_loop
while :; do
check_finished && break
udevsettle
check_finished && break
if [ -f $hookdir/initqueue/work ]; then
rm $hookdir/initqueue/work
fi
for job in $hookdir/initqueue/*.sh; do
[ -e "$job" ] || break
job=$job . $job
check_finished && break 2
done
$UDEV_QUEUE_EMPTY >/dev/null 2>&1 || continue
for job in $hookdir/initqueue/settled/*.sh; do
[ -e "$job" ] || break
job=$job . $job
check_finished && break 2
done
$UDEV_QUEUE_EMPTY >/dev/null 2>&1 || continue
# no more udev jobs and queues empty.
sleep 0.5
if [ $main_loop -gt $(($RDRETRY/2)) ]; then
for job in $hookdir/initqueue/timeout/*.sh; do
[ -e "$job" ] || break
job=$job . $job
main_loop=0
done
fi
main_loop=$(($main_loop+1))
[ $main_loop -gt $RDRETRY ] \
&& { flock -s 9 ; emergency_shell "Unable to process initqueue"; } 9>/.console_lock
done
unset job
unset queuetriggered
unset main_loop
unset RDRETRY
# pre-mount happens before we try to mount the root filesystem,
# and happens once.
getarg 'rd.break=pre-mount' 'rdbreak=pre-mount' && emergency_shell -n pre-mount "Break pre-mount"
source_hook pre-mount
getarg 'rd.break=mount' 'rdbreak=mount' && emergency_shell -n mount "Break mount"
# mount scripts actually try to mount the root filesystem, and may
# be sourced any number of times. As soon as one suceeds, no more are sourced.
i=0
while :; do
if ismounted "$NEWROOT"; then
usable_root "$NEWROOT" && break;
umount "$NEWROOT"
fi
for f in $hookdir/mount/*.sh; do
[ -f "$f" ] && . "$f"
if ismounted "$NEWROOT"; then
usable_root "$NEWROOT" && break;
warn "$NEWROOT has no proper rootfs layout, ignoring and removing offending mount hook"
umount "$NEWROOT"
rm -f "$f"
fi
done
i=$(($i+1))
[ $i -gt 20 ] \
&& { flock -s 9 ; emergency_shell "Can't mount root filesystem"; } 9>/.console_lock
done
{
echo -n "Mounted root filesystem "
while read dev mp rest; do [ "$mp" = "$NEWROOT" ] && echo $dev; done < /proc/mounts
} | vinfo
export -p > /dracut-state.sh
systemctl isolate initrd-switch-root.target

View File

@@ -0,0 +1,27 @@
# This file is part of systemd.
#
# 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.
# See systemd.special(7) for details
[Unit]
Description=Dracut pre-pivot and cleanup hook
DefaultDependencies=no
Before=initrd-switch-root.service
[Service]
Environment=HOME=/
WorkingDirectory=/
ExecStart=-/bin/dracut-pre-pivot
Type=oneshot
StandardInput=tty-force
StandardOutput=inherit
StandardError=inherit
KillMode=process
# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash
# terminates cleanly.
KillSignal=SIGHUP

View File

@@ -0,0 +1,47 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
exec </dev/console >/dev/console 2>&1
if [ -f /dracut-state.sh ]; then
. /dracut-state.sh || :
fi
. /lib/dracut-lib.sh
source_conf /etc/conf.d
# pre pivot scripts are sourced just before we doing cleanup and switch over
# to the new root.
getarg 'rd.break=pre-pivot' 'rdbreak=pre-pivot' && emergency_shell -n pre-pivot "Break pre-pivot"
source_hook pre-pivot
# pre pivot cleanup scripts are sourced just before we switch over to the new root.
getarg 'rd.break=cleanup' 'rdbreak=cleanup' && emergency_shell -n cleanup "Break cleanup"
source_hook cleanup
# By the time we get here, the root filesystem should be mounted.
# Try to find init.
for i in "$(getarg real_init=)" "$(getarg init=)"; do
[ -n "$i" ] || continue
__p=$(readlink -f "${NEWROOT}/${i}")
if [ -x "$__p" ]; then
INIT="$i"
echo "NEWINIT=\"$INIT\"" > /run/initramfs/switch-root.conf
break
fi
done
echo "NEWROOT=\"$NEWROOT\"" >> /run/initramfs/switch-root.conf
udevadm control --stop-exec-queue
systemctl stop systemd-udev.service
udevadm info --cleanup-db
# remove helper symlink
[ -h /dev/root ] && rm -f /dev/root
getarg rd.break rdbreak && emergency_shell -n switch_root "Break before switch_root"
info "Switching root"
export -p > /dracut-state.sh

View File

@@ -0,0 +1,28 @@
# This file is part of systemd.
#
# 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.
# See systemd.special(7) for details
[Unit]
Description=Dracut pre-trigger hook
DefaultDependencies=no
After=systemd-udev.service
Before=systemd-udev-trigger.service
[Service]
Environment=HOME=/
WorkingDirectory=/
ExecStart=-/bin/dracut-pre-trigger
Type=oneshot
StandardInput=tty-force
StandardOutput=inherit
StandardError=inherit
KillMode=process
# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash
# terminates cleanly.
KillSignal=SIGHUP

View File

@@ -0,0 +1,20 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
exec </dev/console >/dev/console 2>&1
if [ -f /dracut-state.sh ]; then
. /dracut-state.sh || :
fi
. /lib/dracut-lib.sh
source_conf /etc/conf.d
getargbool 0 rd.udev.info -y rdudevinfo && udevadm control --log-priority=info
getargbool 0 rd.udev.debug -y rdudevdebug && udevadm control --log-priority=debug
udevproperty "hookdir=$hookdir"
source_hook pre-trigger
udevadm control --reload >/dev/null 2>&1 || :
export -p > /dracut-state.sh

View File

@@ -0,0 +1,27 @@
# This file is part of systemd.
#
# 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.
# See systemd.special(7) for details
[Unit]
Description=Dracut pre-trigger hook
DefaultDependencies=no
Before=systemd-udev.service
[Service]
Environment=HOME=/
WorkingDirectory=/
ExecStart=-/bin/dracut-pre-udev
Type=oneshot
StandardInput=tty-force
StandardOutput=inherit
StandardError=inherit
KillMode=process
# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash
# terminates cleanly.
KillSignal=SIGHUP

View File

@@ -0,0 +1,17 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
exec </dev/console >/dev/console 2>&1
if [ -f /dracut-state.sh ]; then
. /dracut-state.sh || :
fi
. /lib/dracut-lib.sh
source_conf /etc/conf.d
# pre pivot scripts are sourced just before we doing cleanup and switch over
# to the new root.
getarg 'rd.break=pre-udev' 'rdbreak=pre-udev' && emergency_shell -n pre-udev "Break pre-udev"
source_hook pre-udev
export -p > /dracut-state.sh

View File

@@ -0,0 +1,30 @@
# This file is part of systemd.
#
# 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.
# See systemd.special(7) for details
[Unit]
Description=Emergency Shell
DefaultDependencies=no
Conflicts=shutdown.target
Before=shutdown.target
[Service]
Environment=HOME=/
WorkingDirectory=/
ExecStart=-/bin/sh -i -l
ExecStopPost=-/usr/bin/systemctl --fail --no-block default
Type=idle
StandardInput=tty-force
StandardOutput=inherit
StandardError=inherit
KillMode=process
IgnoreSIGPIPE=no
# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash
# terminates cleanly.
KillSignal=SIGHUP

View File

@@ -0,0 +1,16 @@
# This file is part of systemd.
#
# 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.
[Unit]
Description=Switch Root
DefaultDependencies=no
[Service]
Type=oneshot
EnvironmentFile=/run/initramfs/switch-root.conf
ExecStart=/usr/bin/systemctl --force switch-root ${NEWROOT} ${NEWINIT}
ExecStopPost=-/usr/bin/systemctl isolate default.target

View File

@@ -0,0 +1,16 @@
# This file is part of systemd.
#
# 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.
# See systemd.special(7) for details
[Unit]
Description=Switch Root
DefaultDependencies=no
Requires=initrd-switch-root.service
Before=initrd-switch-root.service
AllowIsolate=yes

View File

@@ -0,0 +1,162 @@
#!/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
if [[ -x /lib/systemd/systemd ]] || [[ -x /usr/lib/systemd/systemd ]]; then
return 255
fi
pkg-config systemd --variable=systemdutildir >/dev/null && return 255
return 1
}
depends() {
return 0
}
install() {
local systemdutildir systemdsystemunitdir
systemdutildir=$(pkg-config systemd --variable=systemdutildir)
systemdsystemunitdir=$(pkg-config systemd --variable=systemdsystemunitdir)
if ! [[ -d "$systemdutildir" ]]; then
[[ -d /lib/systemd ]] && systemdutildir=/lib/systemd
[[ -d /usr/lib/systemd ]] && systemdutildir=/usr/lib/systemd
fi
[[ -d "$systemdsystemunitdir" ]] || systemdsystemunitdir=${systemdutildir}/system
dracut_install -o "$i" \
$systemdutildir/systemd \
$systemdutildir/systemd-cgroups-agent \
$systemdutildir/systemd-initctl \
$systemdutildir/systemd-shutdownd \
$systemdutildir/systemd-shutdown \
$systemdutildir/systemd-modules-load \
$systemdutildir/systemd-remount-fs \
$systemdutildir/systemd-reply-password \
$systemdutildir/systemd-fsck \
$systemdutildir/systemd-timestamp \
$systemdutildir/systemd-ac-power \
$systemdutildir/systemd-sysctl \
$systemdutildir/systemd-udevd \
$systemdutildir/systemd-journald \
$systemdutildir/systemd-coredump \
$systemdutildir/systemd-vconsole-setup \
$systemdutildir/systemd-cryptsetup \
$systemdutildir/systemd-localed \
$systemdsystemunitdir/emergency.target \
$systemdsystemunitdir/sysinit.target \
$systemdsystemunitdir/basic.target \
$systemdsystemunitdir/halt.target \
$systemdsystemunitdir/kexec.target \
$systemdsystemunitdir/local-fs.target \
$systemdsystemunitdir/local-fs-pre.target \
$systemdsystemunitdir/remote-fs.target \
$systemdsystemunitdir/remote-fs-pre.target \
$systemdsystemunitdir/network.target \
$systemdsystemunitdir/nss-lookup.target \
$systemdsystemunitdir/nss-user-lookup.target \
$systemdsystemunitdir/poweroff.target \
$systemdsystemunitdir/reboot.target \
$systemdsystemunitdir/rescue.target \
$systemdsystemunitdir/rpcbind.target \
$systemdsystemunitdir/shutdown.target \
$systemdsystemunitdir/final.target \
$systemdsystemunitdir/sigpwr.target \
$systemdsystemunitdir/sockets.target \
$systemdsystemunitdir/swap.target \
$systemdsystemunitdir/systemd-initctl.socket \
$systemdsystemunitdir/systemd-shutdownd.socket \
$systemdsystemunitdir/bluetooth.target \
$systemdsystemunitdir/systemd-ask-password-console.path \
$systemdsystemunitdir/systemd-udev-control.socket \
$systemdsystemunitdir/systemd-udev-kernel.socket \
$systemdsystemunitdir/systemd-ask-password-plymouth.path \
$systemdsystemunitdir/systemd-journald.socket \
$systemdsystemunitdir/cryptsetup.target \
$systemdsystemunitdir/console-shell.service \
$systemdsystemunitdir/console-getty.service \
$systemdsystemunitdir/systemd-initctl.service \
$systemdsystemunitdir/systemd-shutdownd.service \
$systemdsystemunitdir/systemd-modules-load.service \
$systemdsystemunitdir/systemd-remount-fs.service \
$systemdsystemunitdir/systemd-ask-password-console.service \
$systemdsystemunitdir/halt.service \
$systemdsystemunitdir/poweroff.service \
$systemdsystemunitdir/reboot.service \
$systemdsystemunitdir/kexec.service \
$systemdsystemunitdir/fsck@.service \
$systemdsystemunitdir/systemd-udev.service \
$systemdsystemunitdir/systemd-udev-trigger.service \
$systemdsystemunitdir/systemd-udev-settle.service \
$systemdsystemunitdir/systemd-ask-password-plymouth.service \
$systemdsystemunitdir/systemd-journald.service \
$systemdsystemunitdir/systemd-vconsole-setup.service \
$systemdsystemunitdir/systemd-localed.service \
$systemdsystemunitdir/sysinit.target.wants/systemd-modules-load.service \
$systemdsystemunitdir/sysinit.target.wants/systemd-ask-password-console.path \
$systemdsystemunitdir/sysinit.target.wants/systemd-journald.service \
$systemdsystemunitdir/sysinit.target.wants/systemd-vconsole-setup.service \
$systemdsystemunitdir/sysinit.target.wants/cryptsetup.target \
$systemdsystemunitdir/sockets.target.wants/systemd-initctl.socket \
$systemdsystemunitdir/sockets.target.wants/systemd-shutdownd.socket \
$systemdsystemunitdir/sockets.target.wants/systemd-udev-control.socket \
$systemdsystemunitdir/sockets.target.wants/systemd-udev-kernel.socket \
$systemdsystemunitdir/sockets.target.wants/systemd-journald.socket \
$systemdsystemunitdir/sysinit.target.wants/systemd-udev.service \
$systemdsystemunitdir/sysinit.target.wants/systemd-udev-trigger.service \
$systemdsystemunitdir/local-fs.target.wants/systemd-remount-fs.service \
$systemdsystemunitdir/local-fs.target.wants/fsck-root.service \
$systemdsystemunitdir/local-fs.target.wants/tmp.mount \
$systemdsystemunitdir/ctrl-alt-del.target \
$systemdsystemunitdir/autovt@.service \
$systemdsystemunitdir/single.service \
$systemdsystemunitdir/syslog.socket \
$systemdsystemunitdir/syslog.target \
$systemdsystemunitdir/initrd-switch-root.target \
$systemdsystemunitdir/initrd-switch-root.service \
$systemdsystemunitdir/umount.target \
for i in /etc/systemd/*.conf; do
dracut_install "$i"
done
dracut_install journalctl systemctl
ln -fs $systemdutildir/systemd "$initdir/init"
rm -f "${initdir}${systemdsystemunitdir}/emergency.service"
inst "$moddir/emergency.service" ${systemdsystemunitdir}/emergency.service
rm -f "${initdir}${systemdsystemunitdir}/rescue.service"
inst "$moddir/rescue.service" ${systemdsystemunitdir}/rescue.service
inst "$moddir/initrd-switch-root.target" ${systemdsystemunitdir}/initrd-switch-root.target
inst "$moddir/initrd-switch-root.service" ${systemdsystemunitdir}/initrd-switch-root.service
ln -s basic.target "${initdir}${systemdsystemunitdir}/default.target"
inst "$moddir/dracut-cmdline.sh" ${systemdsystemunitdir}-generators/dracut-cmdline.sh
mkdir -p "${initdir}${systemdsystemunitdir}/basic.target.wants"
inst "$moddir/dracut-pre-udev.sh" /bin/dracut-pre-udev
inst "$moddir/dracut-pre-udev.service" ${systemdsystemunitdir}/dracut-pre-udev.service
ln -s ../dracut-pre-udev.service "${initdir}${systemdsystemunitdir}/basic.target.wants/dracut-pre-udev.service"
inst "$moddir/dracut-pre-trigger.sh" /bin/dracut-pre-trigger
inst "$moddir/dracut-pre-trigger.service" ${systemdsystemunitdir}/dracut-pre-trigger.service
ln -s ../dracut-pre-trigger.service "${initdir}${systemdsystemunitdir}/basic.target.wants/dracut-pre-trigger.service"
inst "$moddir/dracut-initqueue.sh" /bin/dracut-initqueue
inst "$moddir/dracut-initqueue.service" ${systemdsystemunitdir}/dracut-initqueue.service
ln -s ../dracut-initqueue.service "${initdir}${systemdsystemunitdir}/basic.target.wants/dracut-initqueue.service"
inst "$moddir/dracut-pre-pivot.sh" /bin/dracut-pre-pivot
inst "$moddir/dracut-pre-pivot.service" ${systemdsystemunitdir}/dracut-pre-pivot.service
mkdir -p "${initdir}${systemdsystemunitdir}/initrd-switch-root.target.wants"
ln -s ../dracut-pre-pivot.service "${initdir}${systemdsystemunitdir}/initrd-switch-root.target.wants/dracut-pre-pivot.service"
> "$initdir/etc/machine-id"
}

View File

@@ -0,0 +1,31 @@
# This file is part of systemd.
#
# 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.
# See systemd.special(7) for details
[Unit]
Description=Rescue Shell
DefaultDependencies=no
Conflicts=shutdown.target
After=basic.target plymouth-start.service
Before=shutdown.target
[Service]
Environment=HOME=/
WorkingDirectory=/
ExecStart=-/bin/sh -i -l
#ExecStopPost=-/usr/bin/systemctl --fail --no-block switch-root /sysroot /sbin/init
ExecStopPost=-/usr/bin/systemctl --fail --no-block default
Type=idle
StandardInput=tty-force
StandardOutput=inherit
StandardError=inherit
KillMode=process
# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash
# terminates cleanly.
KillSignal=SIGHUP

View File

@@ -9,6 +9,7 @@ fsck_usr()
{
local _dev=$1
local _fs=$2
local _fsopts=$3
local _fsckoptions
if [ -f "$NEWROOT"/fsckoptions ]; then
@@ -31,7 +32,7 @@ fsck_usr()
_fsckoptions="$AUTOFSCK_OPT $_fsckoptions"
fi
fsck_single "$_dev" "$_fs" "$_fsckoptions"
fsck_single "$_dev" "$_fs" "$_fsopts" "$_fsckoptions"
}
mount_usr()
@@ -60,7 +61,7 @@ mount_usr()
if [ "x$_usr_found" != "x" ]; then
# we have to mount /usr
if [ "0" != "${_passno:-0}" ]; then
fsck_usr "$_dev" "$_fs"
fsck_usr "$_dev" "$_fs" "$_opts"
else
:
fi

View File

@@ -2,6 +2,14 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
debug_off() {
set +x
}
debug_on() {
[ "$RD_DEBUG" = "yes" ] && set -x
}
# returns OK if $1 contains $2
strstr() {
[ "${1#*$2*}" != "$1" ]
@@ -12,6 +20,11 @@ str_starts() {
[ "${1#$2*}" != "$1" ]
}
# returns OK if $1 contains $2 at the end
str_ends() {
[ "${1%*$2}" != "$1" ]
}
# replaces all occurrences of 'search' in 'str' with 'replacement'
#
# str_replace str search replacement
@@ -35,6 +48,7 @@ _getcmdline() {
local _i
unset _line
if [ -z "$CMDLINE" ]; then
unset CMDLINE_ETC CMDLINE_ETC_D
if [ -e /etc/cmdline ]; then
while read -r _line; do
CMDLINE_ETC="$CMDLINE_ETC $_line";
@@ -88,29 +102,29 @@ _dogetarg() {
}
getarg() {
set +x
debug_off
while [ $# -gt 0 ]; do
case $1 in
-y) if _dogetarg $2 >/dev/null; then
echo 1
[ "$RD_DEBUG" = "yes" ] && set -x
debug_on
return 0
fi
shift 2;;
-n) if _dogetarg $2 >/dev/null; then
echo 0;
[ "$RD_DEBUG" = "yes" ] && set -x
debug_on
return 1
fi
shift 2;;
*) if _dogetarg $1; then
[ "$RD_DEBUG" = "yes" ] && set -x
debug_on
return 0;
fi
shift;;
esac
done
[ "$RD_DEBUG" = "yes" ] && set -x
debug_on
return 1
}
@@ -130,7 +144,7 @@ getargbool() {
}
_dogetargs() {
set +x
debug_off
local _o _found _key
unset _o
unset _found
@@ -153,7 +167,7 @@ _dogetargs() {
}
getargs() {
set +x
debug_off
local _val _i _args _gfound
unset _val
unset _gfound
@@ -170,10 +184,10 @@ getargs() {
else
echo -n 1
fi
[ "$RD_DEBUG" = "yes" ] && set -x
debug_on
return 0
fi
[ "$RD_DEBUG" = "yes" ] && set -x
debug_on
return 1;
}
@@ -216,17 +230,19 @@ getoptcomma() {
#
# TODO: ':' inside fields.
splitsep() {
debug_off
local sep="$1"; local str="$2"; shift 2
local tmp
while [ -n "$str" -a -n "$*" ]; do
while [ -n "$str" -a "$#" -gt 1 ]; do
tmp="${str%%$sep*}"
eval "$1=${tmp}"
str="${str#$tmp}"
str="${str#$sep}"
shift
done
[ -n "$str" -a -n "$1" ] && eval "$1=$str"
debug_on
return 0
}
@@ -242,22 +258,26 @@ setdebug() {
fi
export RD_DEBUG
fi
[ "$RD_DEBUG" = "yes" ] && set -x
debug_on
}
setdebug
source_all() {
local f
[ "$1" ] && [ -d "/$1" ] || return
for f in "/$1"/*.sh; do [ -e "$f" ] && . "$f"; done
local _dir
_dir=$1; shift
[ "$_dir" ] && [ -d "/$_dir" ] || return
for f in "/$_dir"/*.sh; do [ -e "$f" ] && . "$f" "$@"; done
}
hookdir=/lib/dracut/hooks
export hookdir
source_hook() {
source_all "/lib/dracut/hooks/$1"
local _dir
_dir=$1; shift
source_all "/lib/dracut/hooks/$_dir" "$@"
}
check_finished() {
@@ -287,6 +307,7 @@ die() {
} >> $hookdir/emergency/01-die.sh
> /run/initramfs/.die
emergency_shell
exit 1
}
@@ -296,6 +317,9 @@ check_quiet() {
getargbool 0 rd.info -y rdinfo && DRACUT_QUIET="no"
getargbool 0 rd.debug -y rdinitdebug && DRACUT_QUIET="no"
getarg quiet || DRACUT_QUIET="yes"
a=$(getarg loglevel=)
[ -n "$a" ] && [ $a -ge 28 ] && DRACUT_QUIET="yes"
export DRACUT_QUIET
fi
}
@@ -341,6 +365,7 @@ check_occurances() {
}
incol2() {
debug_off
local dummy check;
local file="$1";
local str="$2";
@@ -349,13 +374,17 @@ incol2() {
[ -z "$str" ] && return 1;
while read dummy check restofline; do
[ "$check" = "$str" ] && return 0
if [ "$check" = "$str" ]; then
debug_on
return 0
fi
done < $file
debug_on
return 1
}
udevsettle() {
[ -z "$UDEVVERSION" ] && UDEVVERSION=$(udevadm --version)
[ -z "$UDEVVERSION" ] && export UDEVVERSION=$(udevadm --version)
if [ $UDEVVERSION -ge 143 ]; then
udevadm settle --exit-if-exists=$hookdir/initqueue/work $settle_exit_if_exists
@@ -365,7 +394,7 @@ udevsettle() {
}
udevproperty() {
[ -z "$UDEVVERSION" ] && UDEVVERSION=$(udevadm --version)
[ -z "$UDEVVERSION" ] && export UDEVVERSION=$(udevadm --version)
if [ $UDEVVERSION -ge 143 ]; then
for i in "$@"; do udevadm control --property=$i; done
@@ -504,6 +533,17 @@ mkuniqdir() {
echo "${retdir}"
}
# Copy the contents of SRC into DEST, merging the contents of existing
# directories (kinda like rsync, or cpio -p).
# Creates DEST if it doesn't exist. Overwrites files with the same names.
#
# copytree SRC DEST
copytree() {
local src="$1" dest="$2"
mkdir -p "$dest"; dest=$(readlink -e -q "$dest")
( cd "$src"; cp -af . -t "$dest" )
}
# Evaluates command for UUIDs either given as arguments for this function or all
# listed in /dev/disk/by-uuid. UUIDs doesn't have to be fully specified. If
# beginning is given it is expanded to all matching UUIDs. To pass full UUID to
@@ -713,6 +753,7 @@ cancel_wait_for_dev()
}
killproc() {
debug_off
local _exe="$(command -v $1)"
local _sig=$2
local _i
@@ -723,6 +764,7 @@ killproc() {
kill $_sig ${_i##*/}
fi
done
debug_on
}
need_shutdown() {
@@ -733,7 +775,7 @@ wait_for_loginit()
{
[ "$RD_DEBUG" = "yes" ] || return
[ -e /run/initramfs/loginit.pipe ] || return
set +x
debug_off
echo "DRACUT_LOG_END"
exec 0<>/dev/console 1<>/dev/console 2<>/dev/console
# wait for loginit
@@ -761,18 +803,18 @@ emergency_shell()
{
local _ctty
set +e
local _rdshell_name="dracut" action="Boot" hook="emergency"
if [ "$1" = "-n" ]; then
_rdshell_name=$2
shift 2
else
_rdshell_name=dracut
elif [ "$1" = "--shutdown" ]; then
_rdshell_name=$2; action="Shutdown"; hook="shutdown-emergency"
shift 2
fi
echo ; echo
warn $@
source_hook emergency
source_hook "$hook"
echo
wait_for_loginit
[ -e /run/initramfs/.die ] && exit 1
if getargbool 1 rd.shell -y rdshell || getarg rd.break rdbreak; then
echo "Dropping to debug shell."
echo
@@ -792,8 +834,22 @@ emergency_shell()
strstr "$(setsid --help 2>/dev/null)" "ctty" && CTTY="-c"
setsid $CTTY /bin/sh -i -l 0<$_ctty 1>$_ctty 2>&1
else
warn "Boot has failed. To debug this issue add \"rdshell\" to the kernel command line."
warn "$action has failed. To debug this issue add \"rd.shell\" to the kernel command line."
# cause a kernel panic
exit 1
fi
[ -e /run/initramfs/.die ] && exit 1
}
# Retain the values of these variables but ensure that they are unexported
# This is a POSIX-compliant equivalent of bash's "export -n"
export_n()
{
local var
local val
for var in "$@"; do
eval val=\$$var
unset $var
[ -n "$val" ] && eval $var=\"$val\"
done
}

View File

@@ -19,6 +19,7 @@ export PATH
RD_DEBUG=""
. /lib/dracut-lib.sh
trap "emergency_shell Signal caught!" 0
[ -c /dev/null ] || mknod -m 0666 /dev/null c 1 3
@@ -39,14 +40,8 @@ fi
setdebug
if [ "$RD_DEBUG" = "yes" ]; then
getarg quiet && DRACUT_QUIET="yes"
a=$(getarg loglevel=)
[ -n "$a" ] && [ $a -ge 8 ] && unset DRACUT_QUIET
fi
if ! ismounted /dev; then
mount -t devtmpfs -o mode=0755,nosuid devtmpfs /dev >/dev/null
mount -t devtmpfs -o mode=0755,nosuid,strictatime devtmpfs /dev >/dev/null
fi
# prepare the /dev directory
@@ -62,12 +57,12 @@ fi
if ! ismounted /dev/shm; then
mkdir -m 0755 /dev/shm
mount -t tmpfs -o mode=1777,nosuid,nodev tmpfs /dev/shm >/dev/null
mount -t tmpfs -o mode=1777,nosuid,nodev,strictatime tmpfs /dev/shm >/dev/null
fi
if ! ismounted /run; then
mkdir -m 0755 /newrun
mount -t tmpfs -o mode=0755,nosuid,nodev tmpfs /newrun >/dev/null
mount -t tmpfs -o mode=0755,nosuid,nodev,strictatime tmpfs /newrun >/dev/null
cp -a /run/* /newrun >/dev/null 2>&1
mount --move /newrun /run
rm -fr /newrun
@@ -94,6 +89,9 @@ else
exec 0<>/dev/console 1<>/dev/console 2<>/dev/console
fi
[ -f /etc/initrd-release ] && . /etc/initrd-release
[ -n "$VERSION" ] && info "dracut-$VERSION"
source_conf /etc/conf.d
# run scriptlets to parse the command line
@@ -110,7 +108,7 @@ getarg 'rd.break=pre-udev' 'rdbreak=pre-udev' && emergency_shell -n pre-udev "Br
source_hook pre-udev
# start up udev and trigger cold plugs
udevd --daemon --resolve-names=never
/lib/systemd/systemd-udevd --daemon --resolve-names=never
UDEV_LOG_PRIO_ARG=--log-priority
UDEV_QUEUE_EMPTY="udevadm settle --timeout=0"
@@ -224,17 +222,22 @@ done
while read dev mp rest; do [ "$mp" = "$NEWROOT" ] && echo $dev; done < /proc/mounts
} | vinfo
# pre pivot scripts are sourced just before we switch over to the new root.
# pre pivot scripts are sourced just before we doing cleanup and switch over
# to the new root.
getarg 'rd.break=pre-pivot' 'rdbreak=pre-pivot' && emergency_shell -n pre-pivot "Break pre-pivot"
source_hook pre-pivot
# pre pivot cleanup scripts are sourced just before we switch over to the new root.
getarg 'rd.break=cleanup' 'rdbreak=cleanup' && emergency_shell -n cleanup "Break cleanup"
source_hook cleanup
# By the time we get here, the root filesystem should be mounted.
# Try to find init.
for i in "$(getarg real_init=)" "$(getarg init=)" $(getargs rd.distroinit=) /sbin/init; do
[ -n "$i" ] || continue
__p=$(readlink -f "${NEWROOT}/${i}")
if [ -x "$__p" ]; then
if [ -x "$__p" -o -x "${NEWROOT}/${__p}" ]; then
INIT="$i"
break
fi
@@ -246,14 +249,13 @@ done
emergency_shell
}
if [ $UDEVVERSION -lt 168 ]; then
# stop udev queue before killing it
udevadm control --stop-exec-queue
HARD=""
while pidof udevd >/dev/null 2>&1; do
for pid in $(pidof udevd); do
while pidof systemd-udevd >/dev/null 2>&1; do
for pid in $(pidof systemd-udevd); do
kill $HARD $pid >/dev/null 2>&1
done
HARD="-9"
@@ -263,16 +265,12 @@ else
udevadm info --cleanup-db
fi
# Retain the values of these variables but ensure that they are unexported
# This is a POSIX-compliant equivalent of bash's "export -n"
for var in root rflags fstype netroot NEWROOT; do
eval tmp=\$$var
unset $var
[ -n "$tmp" ] && eval $var=\"$tmp\"
done
debug_off # Turn off debugging for this section
# unexport some vars
export_n root rflags fstype netroot NEWROOT
export RD_TIMESTAMP
set +x # Turn off debugging for this section
# Clean up the environment
for i in $(export -p); do
i=${i#declare -x}
@@ -293,7 +291,6 @@ rm -f /tmp/export.orig
initargs=""
read CLINE </proc/cmdline
if getarg init= >/dev/null ; then
set +x # Turn off debugging for this section
ignoreargs="console BOOT_IMAGE"
# only pass arguments after init= to the init
CLINE=${CLINE#*init=}
@@ -307,7 +304,7 @@ if getarg init= >/dev/null ; then
done
unset CLINE
else
set +x # Turn off debugging for this section
debug_off # Turn off debugging for this section
set -- $CLINE
for x in "$@"; do
case "$x" in
@@ -317,7 +314,7 @@ else
esac
done
fi
[ "$RD_DEBUG" = "yes" ] && set -x
debug_on
if ! [ -d "$NEWROOT"/run ]; then
NEWRUN=/dev/.initramfs
@@ -333,7 +330,6 @@ wait_for_loginit
getarg rd.break rdbreak && emergency_shell -n switch_root "Break before switch_root"
info "Switching root"
source_hook cleanup
unset PS4

View File

@@ -19,6 +19,6 @@ while read line; do
fi
echo "<31>dracut: $line" >&5
# if "quiet" is specified we output to /dev/console
[ -n "$QUIET" ] && echo "dracut: $line"
[ -n "$QUIET" ] || echo "dracut: $line"
echo "$line" >&6
done

View File

@@ -48,5 +48,31 @@ install() {
done > "${initdir}/etc/cmdline.d/distroinit.conf"
fi
}
ln -s /proc/self/mounts "$initdir/etc/mtab"
if [ -e /etc/os-release ]; then
. /etc/os-release
VERSION+=" "
PRETTY_NAME+=" "
else
VERSION=""
PRETTY_NAME=""
fi
NAME=Dracut
ID=dracut
VERSION+="dracut-$DRACUT_VERSION"
PRETTY_NAME+="dracut-$DRACUT_VERSION (Initramfs)"
VERSION_ID=$DRACUT_VERSION
ANSI_COLOR="0;34"
{
echo NAME=\"$NAME\"
echo VERSION=\"$VERSION\"
echo ID=$ID
echo VERSION_ID=$VERSION_ID
echo PRETTY_NAME=\"$PRETTY_NAME\"
echo ANSI_COLOR=\"$ANSI_COLOR\"
} > $initdir/etc/initrd-release
echo dracut-$DRACUT_VERSION > $initdir/lib/dracut/dracut-$DRACUT_VERSION
ln -s initrd-release $initdir/etc/os-release
}

View File

@@ -113,7 +113,7 @@ mount_root() {
# printf '%s %s %s %s 1 1 \n' "$esc_root" "$NEWROOT" "$rootfs" "$rflags" >/etc/fstab
if [ -z "$fastboot" -a "$READONLY" != "yes" ] && ! strstr "${rflags},${rootopts}" _netdev; then
fsck_single "${root#block:}" "$rootfs" "$fsckoptions"
fsck_single "${root#block:}" "$rootfs" "$rflags" "$fsckoptions"
_ret=$?
[ $_ret -ne 255 ] && echo $_ret >/run/initramfs/root-fsck
fi

View File

@@ -89,7 +89,7 @@ fsck_drv_xfs() {
mkdir -p /tmp/.xfs
info "trying to mount $_dev"
if mount -t xfs "$_dev" "/tmp/.xfs" >/dev/null 2>&1; then
if mount -t xfs ${_fsopts+-o $_fsopts} "$_dev" "/tmp/.xfs" >/dev/null 2>&1; then
_ret=0
info "xfs: $_dev is clean"
umount "$_dev" >/dev/null 2>&1
@@ -119,7 +119,7 @@ fsck_drv_btrfs() {
mkdir -p /tmp/.btrfs
info "trying to mount $_dev"
if mount -t btrfs "$_dev" "/tmp/.btrfs" >/dev/null 2>&1; then
if mount -t btrfs ${_fsopts+-o $_fsopts} "$_dev" "/tmp/.btrfs" >/dev/null 2>&1; then
_ret=0
info "btrfs: $_dev is clean"
umount "$_dev" >/dev/null 2>&1
@@ -177,7 +177,7 @@ fsck_drv_std() {
# checks single filesystem, relying on specific "driver"; we don't rely on
# automatic checking based on fstab, so empty one is passed;
# takes 3 arguments - device, filesystem, additional fsck options;
# takes 4 arguments - device, filesystem, filesystem options, additional fsck options;
# first 2 arguments are mandatory (fs may be auto or "")
# returns 255 if filesystem wasn't checked at all (e.g. due to lack of
# necessary tools or insufficient options)
@@ -185,7 +185,8 @@ fsck_single() {
local FSTAB_FILE=/etc/fstab.empty
local _dev="$1"
local _fs="${2:-auto}"
local _fop="$3"
local _fsopts="$3"
local _fop="$4"
local _drv
[ $# -lt 2 ] && return 255

View File

@@ -53,7 +53,7 @@ unpack_fs() {
local img="$1" outdir="$2" mnt="$(mkuniqdir /tmp unpack_fs.)"
mount -o loop $img $mnt || { rmdir $mnt; return 1; }
mkdir -p $outdir; outdir="$(cd $outdir; pwd)"
( cd $mnt; cp -a -t $outdir . )
copytree $mnt $outdir
umount $mnt
rmdir $mnt
}

View File

@@ -7,54 +7,12 @@
# Copyright 2011, Red Hat, Inc.
# Harald Hoyer <harald@redhat.com>
#!/bin/sh
. /lib/dracut-lib.sh
export TERM=linux
PATH=/usr/sbin:/usr/bin:/sbin:/bin
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
. /lib/dracut-lib.sh
emergency_shell()
{
local _ctty
set +e
if [ "$1" = "-n" ]; then
_rdshell_name=$2
shift 2
else
_rdshell_name=dracut
fi
echo ; echo
warn $@
source_hook shutdown-emergency
echo
if getargbool 1 rd.shell -y rdshell || getarg rd.break rdbreak; then
echo "Dropping to debug shell."
echo
export PS1="$_rdshell_name:\${PWD}# "
[ -e /.profile ] || >/.profile
_ctty="$(getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
if [ -z "$_ctty" ]; then
_ctty=console
while [ -f /sys/class/tty/$_ctty/active ]; do
_ctty=$(cat /sys/class/tty/$_ctty/active)
_ctty=${_ctty##* } # last one in the list
done
_ctty=/dev/$_ctty
fi
[ -c "$_ctty" ] || _ctty=/dev/tty1
strstr "$(setsid --help)" "control" && CTTY="-c"
setsid $CTTY /bin/sh -i -l 0<$_ctty 1>$_ctty 2>&1
else
exec /lib/systemd/systemd-shutdown "$@"
warn "Shutdown has failed. To debug this issue add \"rdshell\" to the kernel command line."
# cause a kernel panic
exit 1
fi
}
trap "emergency_shell Signal caught!" 0
getarg 'rd.break=pre-shutdown' && emergency_shell -n cmdline "Break before pre-shutdown"
trap "emergency_shell --shutdown shutdown Signal caught!" 0
getarg 'rd.break=pre-shutdown' && emergency_shell --shutdown pre-shutdown "Break before pre-shutdown"
umount_a() {
local _did_umount="n"
@@ -97,7 +55,7 @@ while _check_shutdown; do
done
_check_shutdown final
getarg 'rd.break=shutdown' && emergency_shell -n cmdline "Break before shutdown"
getarg 'rd.break=shutdown' && emergency_shell --shutdown shutdown "Break before shutdown"
[ "$1" = "reboot" ] && reboot -f -d -n --no-wall
[ "$1" = "poweroff" ] && poweroff -f -d -n --no-wall
[ "$1" = "halt" ] && halt -f -d -n --no-wall

View File

@@ -19,5 +19,6 @@ cp -a -t /root /source/*
mkdir -p /root/run
umount /root
echo "dracut-root-block-created" >/dev/sda1
sync
poweroff -f

View File

@@ -48,7 +48,7 @@ test_setup() {
(
initdir=$TESTDIR/overlay
. $basedir/dracut-functions.sh
dracut_install sfdisk mkfs.ext3 poweroff cp umount
dracut_install sfdisk mkfs.ext3 poweroff cp umount sync
inst_hook initqueue 01 ./create-root.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
@@ -61,7 +61,7 @@ test_setup() {
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
--nomdadmconf \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf overlay
rm -rf $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \

View File

@@ -0,0 +1,8 @@
ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hda", SYMLINK+="sda"
ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hda*", SYMLINK+="sda$env{MINOR}"
ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdb", SYMLINK+="sdb"
ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdb*", SYMLINK+="sdb$env{MINOR}"
ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdc", SYMLINK+="sdc"
ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdc*", SYMLINK+="sdc$env{MINOR}"
ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdd", SYMLINK+="sdd"
ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdd*", SYMLINK+="sdd$env{MINOR}"

View File

@@ -0,0 +1,10 @@
all:
@make -s --no-print-directory -C ../.. all
@basedir=../.. testdir=../ ./test.sh --all
setup:
@make --no-print-directory -C ../.. all
@basedir=../.. testdir=../ ./test.sh --setup
clean:
@basedir=../.. testdir=../ ./test.sh --clean
run:
@basedir=../.. testdir=../ ./test.sh --run

View File

@@ -0,0 +1,23 @@
#!/bin/sh
# don't let udev and this script step on eachother's toes
for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
> "/etc/udev/rules.d/$x"
done
rm /etc/lvm/lvm.conf
udevadm control --reload-rules
set -e
# save a partition at the beginning for future flagging purposes
sfdisk -C 1280 -H 2 -S 32 -L /dev/sda <<EOF
,16
,
EOF
mkfs.ext3 -L dracut /dev/sda2
mkdir -p /root
mount /dev/sda2 /root
cp -a -t /root /source/*
mkdir -p /root/run
umount /root
echo "dracut-root-block-created" >/dev/sda1
poweroff -f

View File

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

View File

@@ -0,0 +1,3 @@
#!/bin/sh
getarg rd.shell || poweroff -f
getarg failme && poweroff -f

View File

@@ -0,0 +1,20 @@
#!/bin/sh
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
strstr() { [ "${1#*$2*}" != "$1" ]; }
CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
plymouth --quit
exec </dev/console >/dev/console 2>&1
echo "dracut-root-block-success" >/dev/sda1
export TERM=linux
export PS1='initramfs-test:\w\$ '
[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab
[ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
stty sane
echo "made it to the rootfs!"
if strstr "$CMDLINE" "rd.shell"; then
strstr "$(setsid --help)" "control" && CTTY="-c"
setsid $CTTY sh -i
fi
echo "Powering down."
mount -n -o remount,ro /
poweroff -f

95
test/TEST-02-SYSTEMD/test.sh Executable file
View File

@@ -0,0 +1,95 @@
#!/bin/bash
TEST_DESCRIPTION="root filesystem on a ext3 filesystem"
KVERSION=${KVERSION-$(uname -r)}
# Uncomment this to debug failures
#DEBUGFAIL="rd.shell"
test_run() {
$testdir/run-qemu \
-hda $TESTDIR/root.ext3 \
-m 256M -nographic \
-net none -kernel /boot/vmlinuz-$KVERSION \
-append "root=LABEL=dracut rw loglevel=77 systemd.log_level=debug systemd.log_target=console rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug init=/sbin/init $DEBUGFAIL" \
-initrd $TESTDIR/initramfs.testing
grep -m 1 -q dracut-root-block-success $TESTDIR/root.ext3 || return 1
}
test_setup() {
rm -f $TESTDIR/root.ext3
# Create the blank file to use as a root filesystem
dd if=/dev/null of=$TESTDIR/root.ext3 bs=1M seek=40
kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay
(
initdir=$TESTDIR/overlay/source
mkdir -p $initdir
. $basedir/dracut-functions.sh
dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \
mount dmesg ifconfig dhclient mkdir cp ping dhclient \
umount strace less setsid
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
dracut_install -o ${_terminfodir}/l/linux
inst "$basedir/modules.d/40network/dhclient-script" "/sbin/dhclient-script"
inst "$basedir/modules.d/40network/ifup" "/sbin/ifup"
dracut_install grep
inst ./test-init.sh /sbin/init
find_binary plymouth >/dev/null && dracut_install plymouth
(cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
cp -a /etc/ld.so.conf* $initdir/etc
sudo ldconfig -r "$initdir"
)
# second, install the files needed to make the root filesystem
(
initdir=$TESTDIR/overlay
. $basedir/dracut-functions.sh
dracut_install sfdisk mkfs.ext3 poweroff cp umount
inst_hook initqueue 01 ./create-root.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
# create an initramfs that will create the target root filesystem.
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
$basedir/dracut.sh -l -i $TESTDIR/overlay / \
-m "dash udev-rules base rootfs-block kernel-modules" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
--nomdadmconf \
-f $TESTDIR/initramfs.makeroot $KVERSION || return 1
rm -rf $TESTDIR/overlay
# Invoke KVM and/or QEMU to actually create the target filesystem.
$testdir/run-qemu \
-hda $TESTDIR/root.ext3 \
-m 256M -nographic -net none \
-kernel "/boot/vmlinuz-$kernel" \
-append "root=/dev/dracut/root rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
-initrd $TESTDIR/initramfs.makeroot || return 1
grep -m 1 -q dracut-root-block-created $TESTDIR/root.ext3 || return 1
(
initdir=$TESTDIR/overlay
. $basedir/dracut-functions.sh
dracut_install poweroff shutdown
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
)
sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
-a "debug systemd" \
-o "network" \
-d "piix ide-gd_mod ata_piix ext3 sd_mod" \
-f $TESTDIR/initramfs.testing $KVERSION || return 1
# -o "plymouth network md dmraid multipath fips caps crypt btrfs resume dmsquash-live dm"
}
test_cleanup() {
return 0
}
. $testdir/test-functions

View File

@@ -5,17 +5,23 @@ for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
done
udevadm control --reload-rules
# save a partition at the beginning for future flagging purposes
sfdisk -C 524288 -H 2 -S 32 -L /dev/sda <<EOF
sfdisk -C 655600 -H 2 -S 32 -L /dev/sda <<EOF
,16
,,E
;
;
,10240
,10240
,10240
,10240
EOF
mkfs.btrfs -mraid10 -L root /dev/sda2 /dev/sda3 /dev/sda4
mkfs.btrfs -draid10 -mraid10 -L root /dev/sda5 /dev/sda6 /dev/sda7 /dev/sda8
udevadm settle
btrfs device scan
udevadm settle
set -e
mkdir -p /sysroot
mount /dev/sda4 /sysroot
mount -t btrfs /dev/sda8 /sysroot
cp -a -t /sysroot /source/*
umount /sysroot
echo "dracut-root-block-created" >/dev/sda1

View File

@@ -20,7 +20,7 @@ test_setup() {
# Create the blank file to use as a root filesystem
DISKIMAGE=$TESTDIR/TEST-15-BTRFSRAID-root.img
rm -f $DISKIMAGE
dd if=/dev/null of=$DISKIMAGE bs=1M seek=1024
dd if=/dev/null of=$DISKIMAGE bs=2M seek=1024
kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay

View File

@@ -6,6 +6,14 @@ KVERSION=${KVERSION-$(uname -r)}
# Uncomment this to debug failures
#DEBUGFAIL="rd.shell rd.break"
test_check() {
if ! [ -d "/usr/lib/python2.7/site-packages/imgcreate" ]; then
echo "python-imgcreate not installed"
return 1
fi
return 0
}
test_run() {
$testdir/run-qemu \
-boot order=d \

View File

@@ -1,3 +1,6 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH
@@ -8,15 +11,19 @@ fi
echo "TESTDIR=\"$TESTDIR\"" > .testdir
export TESTDIR
command -v test_check &>/dev/null || test_check() {
:
}
while (($# > 0)); do
case $1 in
--run)
echo "TEST RUN: $TEST_DESCRIPTION"
test_run
test_check && test_run
exit $?;;
--setup)
echo "TEST SETUP: $TEST_DESCRIPTION"
test_setup
test_check && test_setup
exit $?;;
--clean)
echo "TEST CLEANUP: $TEST_DESCRIPTION"
@@ -26,6 +33,10 @@ while (($# > 0)); do
exit $?;;
--all)
echo -n "TEST: $TEST_DESCRIPTION ";
if ! test_check 2&>test.log ; then
echo "[SKIPPED]"
exit 0;
fi
(
test_setup && test_run
ret=$?