Compare commits

...

183 Commits
014 ... 017

Author SHA1 Message Date
Harald Hoyer
f5a9e45923 Version 017 2012-02-24 15:38:08 +01:00
Harald Hoyer
1701d7adc8 30convertfs/convertfs.sh: add check for /usr/bin
Check if /usr is mounted, by checking for /usr/bin
2012-02-24 14:59:18 +01:00
Harald Hoyer
d18bc9070d dracut-functions.sh: optimize ldd 2012-02-24 14:59:18 +01:00
Harald Hoyer
86bf239ede dracut-functions.sh: only call ldd in find_binary() for "*.so*" 2012-02-24 14:59:18 +01:00
Harald Hoyer
d433da4473 dracut.sh: first install /usr dirs, then toplevel
This saves some checks in inst_dir.
2012-02-24 14:58:21 +01:00
Harald Hoyer
3249c257a0 dracut-functions.sh: optimized
get rid off lots of duplicated checks and code
2012-02-24 14:56:40 +01:00
Harald Hoyer
a6b63f9192 dracut.spec,Makefile: backward compat symlink for dracut-functions.sh 2012-02-23 12:26:16 +01:00
Harald Hoyer
b019d405d9 dracut.spec: changes for RHEL-6 2012-02-22 19:53:07 +01:00
Harald Hoyer
004fd0557d host-only checks corrected and kernel_only mode
In kernel_only mode, we don't want to write /etc/cmdline.d

Correctly return the check functions, so we have a valid return of
for_each_host_dev_fs().

mdraid and dmraid functions had wrong checkings for the filesystem
type.
2012-02-22 19:29:57 +01:00
Harald Hoyer
2efa546f26 dracut-functions.sh:for_each_host_dev_fs() return a value
for_each_host_dev_fs() now returns 0 if one func returned with 0
2012-02-22 19:06:00 +01:00
Colin Guthrie
0330b91987 lvm: Only activate a given vg+lv once.
Due to the way the main loop runs to detect partions, the same one
might be included twice (albeit via different symlinks.

This code simply prevents the same combo being activated twice.

A better fix might simply be to not include duplicate (after
resolving symlinks) entries in the host_fs_types variable.
2012-02-22 18:30:58 +01:00
Colin Guthrie
e0a38de881 mount-usr: Calculate and pass full fsck options when mounting /usr.
Edited-By: Harald Hoyer <harald@redhat.com>
2012-02-22 18:11:27 +01:00
Colin Guthrie
d06580986b fs-lib: No need to pass in _dev and _fop as they are inherited, not used as arguments. 2012-02-22 18:04:43 +01:00
Harald Hoyer
03a44f0bf0 git2spec.pl: detect renames 2012-02-22 16:14:38 +01:00
Harald Hoyer
8b6e099892 90kernel-modules/module-setup.sh: exclude nfs* lockd from standard
do not install nfs* lockd filesystems for the standard kernel modules
2012-02-22 16:14:38 +01:00
Harald Hoyer
34248c926c change omit_drivers to support regexp expressions 2012-02-22 16:14:38 +01:00
Harald Hoyer
14c47b0ee4 dracut.sh: do not install some files in installkernel
/etc/cmdline.d
/etc/fstab
2012-02-22 16:14:23 +01:00
Harald Hoyer
edd3262efd 40network/parse-ip-opts.sh: "local" can only be used in functions 2012-02-22 16:13:20 +01:00
Harald Hoyer
9cb8447c90 dracut-functions.sh:inst_library(): readlink source dir first
read link of the source dir, before convert_abs_to_rel()
2012-02-22 16:13:20 +01:00
Harald Hoyer
cc227886c6 dracut-functions.sh:inst_simple(): no inst_dir if dir exists 2012-02-22 16:13:20 +01:00
Harald Hoyer
6d2a7942aa dracut-functions.sh: set IFS only for variable setting 2012-02-22 16:13:20 +01:00
Harald Hoyer
43dfbeec7b dracut-functions.sh: turn off regexp for strstr() 2012-02-22 16:13:20 +01:00
Harald Hoyer
3335ed0ef4 dracut.sh: skip symlink dirs for prelink unlink 2012-02-22 16:13:20 +01:00
Harald Hoyer
b6e244f794 90kernel-modules/module-setup.sh: install modules.* in installkernel()
modules.* should be in the kernel initramfs
2012-02-22 15:15:22 +01:00
Harald Hoyer
14669e3a86 95nfs/module-setup.sh: whitespace fixup 2012-02-22 15:15:22 +01:00
Harald Hoyer
552ecca6db Renamed all shell scripts to *.sh 2012-02-22 15:15:21 +01:00
Harald Hoyer
9373aec650 TEST-30-ISCSI/test.sh: factor out client runs 2012-02-22 11:32:59 +01:00
Harald Hoyer
30befb85e3 .gitignore: add eclipse directories 2012-02-22 11:32:40 +01:00
Will Woods
ed293f6d0c url-lib: fix fetch_url return value for dotfiles
If you do "fetch_url $url/.somefile", fetch_url would return failure,
because "$outdir/*" wouldn't match the file.

Use ls -A (which busybox ls supports) to actually find possible dotfiles
in the created output dir.

Signed-off-by: Will Woods <wwoods@redhat.com>
2012-02-21 10:11:11 +01:00
Harald Hoyer
cd9592385d 98usrmount/mount-usr.sh: honor fs_passno in /etc/fstab
If the sixth field in /etc/fstab is "0" or not present for /usr, do not
run fsck.

This prevents fsck for nfs /usr also.
2012-02-20 17:28:58 +01:00
Harald Hoyer
7e2bca4820 dracut-functions: documentation and restructuring 2012-02-16 11:49:19 +01:00
Harald Hoyer
c4e48eaea1 dracut-functions: factor out all get_maj_min() variants 2012-02-16 11:48:17 +01:00
Harald Hoyer
3905f6695e TEST-30-ISCSI: add test case for "root=iscsi:...." and untabify 2012-02-16 11:37:21 +01:00
Harald Hoyer
2a3faa2df9 95iscsi: fix "root=iscsi:...." case
install udev rules and wait for /dev/root
2012-02-16 11:34:37 +01:00
Dave Young
86de902e35 ssh-client module install fix
commit 38164332e1 try to
disallow ssh-client install for without proper options.
But ssh-client will fail installation with --sshkey for
publickey mode

Fix it by refusing to install only when both --ctty and --sshkey
are not added in options.

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-02-16 11:21:34 +01:00
Will Woods
c1df00d2c6 livenet: avoid spurious error message / wait_for_dev
If the user didn't request a livenet boot, don't print an error
and don't do wait_for_dev.

Signed-off-by: Will Woods <wwoods@redhat.com>
2012-02-16 11:21:34 +01:00
Dave Young
75cade1216 add function wait_for_route_ok
Manually setuping nic through udev is not always done when
we want network access. Here add a function wait_for_route_ok to
wait and make sure the network is accesible

[v1 -> v2]:
Harald: don't use bash syntax
Add check for [ -n "$li" ] because `ip route show` will show nothing probably

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-02-16 11:19:07 +01:00
Harald Hoyer
a2c631c0a3 Makefile: also link dracut-shutdown.service to shutdown target 2012-02-16 09:37:11 +01:00
Harald Hoyer
6bee336909 Version 16 2012-02-15 18:05:34 +01:00
Harald Hoyer
5c4bb360e3 dracut.spec: add missing modules 2012-02-15 17:59:46 +01:00
Harald Hoyer
969394f503 95nfs/nfs-lib.sh: do not bail out at sourcing in nfsroot_from_dhcp()
nfsroot_from_dhcp() returned with failure if one of
/tmp/net.$iface.override /tmp/dhclient.$iface.dhcpopts was missing
2012-02-15 16:39:41 +01:00
Harald Hoyer
4977febf46 s/bash/sh for all new *-lib.sh 2012-02-15 15:46:24 +01:00
Will Woods
285e81c9e2 add img-lib: a library for handling filesystem images
img-lib handles identifying and unpacking archives (uncompressed or
compressed) and filesystem images.

Currently tar and gzip are required; cpio and xz are optional, and bzip2
is supported but unused.

Signed-off-by: Will Woods <wwoods@redhat.com>
2012-02-15 15:46:24 +01:00
Will Woods
d663f5aeb0 add set_http_header to url-lib
This allows you to set custom headers for curl to send with HTTP
requests.

Signed-off-by: Will Woods <wwoods@redhat.com>
2012-02-15 15:46:24 +01:00
Will Woods
370329ca3b url-lib: add support for NFS
This adds nfs_fetch_url to allow fetching arbitrary files from NFS.

This means that livenet can now run using an NFS-mounted live image,
which reduces memory usage by a lot.

Signed-off-by: Will Woods <wwoods@redhat.com>
2012-02-15 15:46:24 +01:00
Will Woods
5978983b30 90livenet: port to url-lib
This makes the livenetroot module use url-lib for fetching its root
image/filesystem. There's also some minor tweaks for POSIX compliance.

Signed-off-by: Will Woods <wwoods@redhat.com>
2012-02-15 15:46:24 +01:00
Will Woods
753c82d0e6 add module 45url-lib
url-lib adds some functions for dealing with URLs (mostly for fetching
files, for the moment).

It uses curl to handle http/https/ftp URLs, but it can be extended by other
modules at runtime by using the "add_url_handler" function.

Signed-off-by: Will Woods <wwoods@redhat.com>
2012-02-15 15:46:24 +01:00
Will Woods
9fcfa04ca9 port nfsroot to nfs-lib
Rewrite nfsroot to use nfs-lib. The functionality should be unchanged.

Signed-off-by: Will Woods <wwoods@redhat.com>
2012-02-15 15:46:24 +01:00
Will Woods
9c463909d6 95nfs: add nfs-lib.sh
nfs-lib.sh contains a bunch of functions used to parse NFS "url"s of
various types, pull nfs information out of dhcp info, and actually
perform nfs mounts sanely.

Signed-off-by: Will Woods <wwoods@redhat.com>
2012-02-15 15:46:24 +01:00
Will Woods
9d169a07ce 40network: add net-lib.sh
net-lib.sh is a library of useful functions for network stuff.

More things may get added/moved here in the future.

Signed-off-by: Will Woods <wwoods@redhat.com>
2012-02-15 15:46:24 +01:00
Harald Hoyer
dee929cded 99base/init: removed redirection of mount errors to /dev/null 2012-02-15 15:46:24 +01:00
Harald Hoyer
e0e2fb26c9 90kernel-modules: removed hard-removal of "ocfs2"
put omit_driver+=" ocfs2 " in the distribution configuration file
2012-02-15 15:46:23 +01:00
Harald Hoyer
fcbcb2521c dracut: add "--omit-driver" 2012-02-15 15:46:23 +01:00
Harald Hoyer
28f0b27fb9 TEST-40-NBD: correct symlinks by rerunning ldconfig 2012-02-15 15:08:34 +01:00
Harald Hoyer
0ddc098eb0 TEST-12-RAID-DEG: improve test case 2012-02-15 15:08:29 +01:00
Harald Hoyer
11c0e7d44e 99base/init: reload udev rules after "pre-trigger" hook 2012-02-15 11:32:21 +01:00
Harald Hoyer
dfb08e9f1c removed now useless cleanup hooks
in Fedora 17, we unpack /boot/initramfs-$(uname -r).img
on shutdown for a pivot root to disassemble the root device
2012-02-15 10:08:59 +01:00
Harald Hoyer
e539fa9980 90mdraid: add "--offroot" support 2012-02-13 21:16:31 +01:00
Harald Hoyer
e76921a58e 95terminfo/module-setup.sh: check for terminfo/l/linux
on Fedora 17 the old check found /etc/terminfo, but this directory is
emtpy.
2012-02-13 21:15:51 +01:00
Harald Hoyer
96d22bd7d6 test: fixed terminfo location 2012-02-13 21:15:22 +01:00
Harald Hoyer
927d9273c4 Makefile: s/dracut-initramfs-backup.sh/dracut-initramfs-restore.sh/ 2012-02-13 18:20:12 +01:00
Harald Hoyer
56a4cffd30 98integrity/module-setup.sh: depend on selinux dracut module 2012-02-13 18:17:40 +01:00
Harald Hoyer
682a2a9d1a 90kernel-modules/module-setup.sh: add "ata_piix" to hardcoded modules 2012-02-13 18:16:48 +01:00
Harald Hoyer
0b1296aa4f dracut.xml: mention log_buf_len=1M for rd.debug 2012-02-13 18:16:28 +01:00
Harald Hoyer
fb67e4aa36 shutdown on demand
Do not save and restore the initramfs, but instead, just unpack the
default initramfs for shutdown on shutdown.
2012-02-13 07:08:08 +01:00
Harald Hoyer
4cfd24d179 Backup and restore /run/initramfs via systemd services
This saves the space /run/initramfs is taking for the shutdown
2012-02-10 11:14:31 +01:00
Harald Hoyer
81dcf7c90a 99shutdown/shutdown: don't do console_init on shutdown emergency 2012-02-09 14:16:31 +01:00
Harald Hoyer
075de7be45 98usrmount/mount-usr.sh: remove extra slash
otherwise we have /sysroot//usr in fstab
2012-02-09 13:58:49 +01:00
Harald Hoyer
7b2d3d995c dracut: honor binaries in sbin first 2012-02-09 13:58:13 +01:00
Harald Hoyer
d20d307d69 lsinitrd: silence xz test 2012-02-09 11:36:21 +01:00
Harald Hoyer
12018c91ea TEST-15-BTRFSRAID: write diskimage to tmp dir 2012-02-08 17:02:57 +01:00
Harald Hoyer
68910ba4a5 dracut: setup clean PATH w/o existing one 2012-02-08 17:02:17 +01:00
Harald Hoyer
a74eae77ac Version 15 2012-02-07 20:57:12 +01:00
Harald Hoyer
ce18bc4e97 30convertfs/convertfs.sh: call setfiles w/o path & check for existence 2012-02-07 20:57:12 +01:00
Harald Hoyer
567cc5d814 40network/net-genrules.sh: increase udev timeout 2012-02-07 20:52:14 +01:00
Harald Hoyer
56ac6c7e76 move all file removal cleanups to "cleanup" hook 2012-02-07 19:44:03 +01:00
Harald Hoyer
59feafc6c7 use "openvt" for emergency shell 2012-02-07 19:44:03 +01:00
Harald Hoyer
5ccc88a742 omit dash for fedora 2012-02-07 19:28:59 +01:00
Harald Hoyer
de247618e7 init/shutdown: use "command -v" instead of "type" 2012-02-07 19:28:59 +01:00
Harald Hoyer
c6c6a08850 add "install_items" to dracut.conf 2012-02-07 19:28:58 +01:00
Harald Hoyer
204db8a134 90btrfs/btrfs_finished.sh: put check in a function 2012-02-07 18:48:04 +01:00
Harald Hoyer
96b8d60a9b dracut: precreate "${initdir}/etc/cmdline.d" 2012-02-07 18:48:04 +01:00
Harald Hoyer
4951a1199d 99base/init: predefine path to init
if you add realinitpath="<path1> <path2>" to dracut.conf, then it will
be written to $initdir/etc/cmdline.d/distroinit.conf with
"rd.distroinit=<path1> rd.distroinit=<path2>" and evaluated by
99base/init, when it searches for init.
2012-02-07 18:48:03 +01:00
Harald Hoyer
76a80dff18 dracut-functions: handle relative symlinks with symlinked directories
"inst_symlink /bin/sh" was not correctly working if:

/bin -> /usr/bin
/bin/sh -> bash

it produced

/usr/bin/sh -> ../usr/bin/bash
2012-02-07 17:15:11 +01:00
Harald Hoyer
9ea901191e dracut-functions: simplify nosegneg path 2012-02-07 17:14:54 +01:00
Harald Hoyer
3bdc01c9a5 dracut-functions:inst_binary() bail out early if target exists 2012-02-07 17:13:32 +01:00
Harald Hoyer
e29d0b8b85 dracut-functions: use normal PATH for find_binary 2012-02-07 17:13:07 +01:00
Harald Hoyer
65fe8ae8a5 dracut: construct PATH with resolved symlinks 2012-02-07 17:11:58 +01:00
Harald Hoyer
4b691cccbe 95ssh-client/module-setup.sh: add executable bit 2012-02-07 12:18:52 +01:00
Dave Young
935b37ee8b auto setup network without netroot
Current dracut network only will be setup when netroot is used. But there are
some cases we need network even without netroot. For example kdump will need
copy vmcore to remote machine via scp or nfs mount. OTOH, if we use dracut as
a recovery system the network is helpful even root is not a network device.

This implementation is based on the manually bring up method. Here add a kernel
cmdline argument rd.neednet. If rd.neednet is set dracut will bring up network
with ifup $INTERFACE -m. If netroot is used we still keep original behavior.

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-02-07 12:14:22 +01:00
Dave Young
fe266c6c69 do not check dev node exist for fstab-sys mounting
in case nfs mounting do not check if $_dev exist

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-02-07 12:14:22 +01:00
Dave Young
c6655c4115 split nfs rpc daemons startup script
fstab-sys will mount nonroot nfs as well, so we need to split the necessary
code from nfsroot to start rpc daemon as hook script.

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-02-07 12:14:21 +01:00
Dave Young
65bb31a405 source dracut-lib.sh in nfs cleanup script
nfsroot-cleanup.sh need source dracut-lib.sh for function incol2

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-02-07 12:14:21 +01:00
Dave Young
cc78087b83 add nobody group for rpc.idmapd
Add nobody group due to rpc.idmapd will fail to startup without nobody group

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-02-07 12:14:21 +01:00
Dave Young
0fc2080294 fix fstab-sys module check
If /etc/fstab.sys does not exist installing fstab-sys module will fail.
Fix this by checking use_fstab and fstab_lines as well

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-02-07 12:14:21 +01:00
Dave Young
957bc5c92f allow ifup bring up network manually even without netroot
For kdump we need scp vmcore to remote machine, the nic to be used is
not limited to netroot one. we need a feature for manually bringing up
 network interface. Also it is useful for emergency shell with
ssh-client for recovery or test purpose

I implement this by adding one argument to ifup script, user can use
`/sbin/ifup eth0 -m` to bring up eth0, note ifup will regard it a
manual operation for the nic specified in 1st argument if there's
the 2nd argument.

If same nic is used for netroot the 2nd argument will be ignored,
in this case we will leave netroot bring up it automatically to
avoid side effect. And in this case hooks such as kdump will need to
execute after netroot mounted.

`ifup eth0 -m` will create /tmp/net.eth0.manualup stamp file,
later dhclient-script can check this and pass $2 to netroot,
then netroot script will bring eth0 up

Thanks for comments and suggestions from David Dillow.

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-02-07 12:14:21 +01:00
Cong Wang
418febfc44 btrfs: fix two bugs in module-setup.sh
First, $host_fs_types is an array.
Second, use strstr to match btrfs type.

Cc: Harald Hoyer <harald@redhat.com>
Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>
2012-02-07 12:14:21 +01:00
Harald Hoyer
6aafdc5c04 90crypt/crypt-cleanup.sh: send unneeded output to /dev/null 2012-02-07 11:23:42 +01:00
Harald Hoyer
a178ca6b5c more cleanup in pre-pivot 2012-02-07 10:32:35 +01:00
Harald Hoyer
9d5e3ed740 30convertfs/convertfs.sh: move /var/run and /var/lock fix to the start
Even, if the system is already converted, we want to fix /var/run and
/var/lock.
2012-02-07 10:24:10 +01:00
Harald Hoyer
415d268051 btrfs_finished.sh: fix udevadm query 2012-02-07 10:23:29 +01:00
Harald Hoyer
43a8f6133d kernel-modules: add hid-logitech-dj to hardcoded hid devices
https://bugzilla.redhat.com/show_bug.cgi?id=786303
2012-02-03 12:03:36 +01:00
Harald Hoyer
437cecb967 dracut.spec: s/usrmove/convertfs 2012-02-03 11:56:15 +01:00
Harald Hoyer
61ad49e7d3 30convertfs/convertfs.sh: fix check for /var/run and /var/lock 2012-02-02 19:18:48 +01:00
Harald Hoyer
2cf328ad0a renamed usrmove to convertfs 2012-02-02 18:50:26 +01:00
Harald Hoyer
dfbb922ddb dracut-functions: install nosegneg libs additionally to standard ones 2012-02-02 18:25:49 +01:00
Harald Hoyer
fe51c4ab3c 30usrmove/usrmove-convert.sh: do not force selinux autorelabel 2012-01-30 14:06:39 +01:00
Harald Hoyer
e684ee786a fix kernel modules search for s390
forgot last ; in {}
2012-01-26 18:08:46 +01:00
Harald Hoyer
c416b1de5a fix kernel modules search for s390
find_kernel_modules_by_path only takes one parameter

fixes c254ac796f
and 4fcd5409e0
2012-01-26 17:30:06 +01:00
Harald Hoyer
e4d85a77aa dracut.spec: create compat symlink, instead of %ghost 2012-01-26 16:41:35 +01:00
Harald Hoyer
5ebad51b84 30usrmove/usrmove-convert.sh: rename duplicate libraries
ldconfig does not ignore the duplicate leftover libs with a .usrmove~
suffix, so we rename ".so" to "_so".
2012-01-26 15:37:50 +01:00
Harald Hoyer
6334ffdbb0 usrmove: install missing binaries and "set -x" only for rd.debug 2012-01-26 13:55:50 +01:00
Harald Hoyer
4cbc0c79ac dracut.spec: add compat symlinks to /sbin 2012-01-26 12:52:17 +01:00
Harald Hoyer
ae8b82e395 add usrmove module 2012-01-26 12:21:45 +01:00
Harald Hoyer
38164332e1 95ssh-client/module-setup.sh: do not install ssh-client by default
Do not install ssh-client by default and report the missing ctty in the
install section.
2012-01-25 10:02:29 +01:00
Harald Hoyer
92dc0adca2 95ssh-client/module-setup.sh: spell corrections 2012-01-25 09:59:12 +01:00
Cong Wang
7f347723d8 let some modules to respect $mount_needs
Cc: Harald Hoyer <harald@redhat.com>
Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>
2012-01-25 09:45:54 +01:00
Will Woods
a2a74022e2 netroot: actually run netroot hooks
The line "source_all netroot" was trying to source netroot hooks from
/netroot, which doesn't exist, so netroot hooks were never executed.

Signed-off-by: Will Woods <wwoods@redhat.com>
2012-01-25 09:45:54 +01:00
Harald Hoyer
ba7fa583bf 99base/init: remove tmpfs on /dev
tmpfs on /dev is not supported anymore and devtmpfs is supported in
kernels for a long time.
2012-01-23 16:08:46 +01:00
Harald Hoyer
5f282199c8 90crypt/module-setup.sh: prepend "luks-" to hostonly cmdline file 2012-01-23 13:50:27 +01:00
Harald Hoyer
74132a10f3 dracut-functions: get_maj_min() major and minor was swapped 2012-01-23 13:50:05 +01:00
Harald Hoyer
4f10ae2b86 dracut: _get_fs_type() also handle /dev/block/maj:min 2012-01-23 13:49:39 +01:00
Harald Hoyer
4fcd5409e0 iscsi/multipath: also search in drivers/s390/scsi 2012-01-23 12:35:41 +01:00
Cong Wang
a29cf54c02 fix rpm build error after adding ssh-client module
This patch fixes the following error when building rpm,

      error: Installed (but unpackaged) file(s) found:
       /usr/lib/dracut/modules.d/95ssh-client/module-setup.sh

Based on my kdump tree.

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
2012-01-23 11:43:18 +01:00
Harald Hoyer
c254ac796f 40network: also look in drivers/s390/net for network drivers
https://bugzilla.redhat.com/show_bug.cgi?id=782074
2012-01-23 11:41:44 +01:00
Harald Hoyer
1b91369455 98usrmount/mount-usr.sh: do not mount /usr read-only
https://bugzilla.redhat.com/show_bug.cgi?id=782897
2012-01-23 11:32:29 +01:00
Harald Hoyer
ccaa9bee2e dracut, dracut.8.xml: added more documentation about "[LIST]"
added examples on how to use [LIST] on the shell command line.

https://bugzilla.redhat.com/show_bug.cgi?id=767736
2012-01-23 11:26:17 +01:00
Harald Hoyer
6769292c0d AUTHORS: updated and fixed .mailmap 2012-01-23 11:06:16 +01:00
Ian Dall
da55af4763 network/dhclient-script: set FQDN
When booting with nfsroot, dracut doesn't necessarily set the initial
hostname correctly.

According to dhcp-options(5), the name may or may not be qualified with
the local domain. It goes on to say "it is preferable to use the
domain-name option to specify the domain name".

So dhclient-script needs to be able to handle the cases: a) where
host-name is fully qualified and domain name is also specified; b)
where hostname is fully qualified and the domain is not separately
specified; c) where host-name is "short" and domain-name is also
specified; and d) do its best where host-name is short but domain-name
is not specified.

The dhclient-script in initramfs does not handle case "c", apparently
the preferred situation properly, setting hostname to "short".

https://bugzilla.redhat.com/show_bug.cgi?id=756347
2012-01-23 10:47:38 +01:00
Harald Hoyer
39339512e2 plymouth/kernel: cleanup not needed parts for shutdown
remove plymouth and kernel parts from /run/initramfs, which are not
needed at shutdown.

https://bugzilla.redhat.com/show_bug.cgi?id=751189
2012-01-23 10:41:41 +01:00
Harald Hoyer
c96425c364 lsinitrd: use xz with --single-stream, if available
The F16 installation image is two concatenated cpio images:
[xz-compressed dracut initramfs][uncompressed cpio with /squashfs.img]

So to show the contents, use xz with the "--single-stream" option.

https://bugzilla.redhat.com/show_bug.cgi?id=742299
2012-01-23 10:35:26 +01:00
Harald Hoyer
1fcf2d2f4a dracut: unset GREP_OPTIONS
GREP_OPTIONS can influence the image creation, if set to user defined
values, so unset it.

https://bugzilla.redhat.com/show_bug.cgi?id=676712
2012-01-23 10:11:04 +01:00
Cong Wang
3ea5d2e28f lsinitrd: add '-s' option to sort the initrd output by file size
This is useful to analyse which files consume the space of initrd.

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
2012-01-23 10:00:43 +01:00
James Buren
7fffc9f11f add xz compression for kernel modules 2012-01-23 09:59:39 +01:00
James Buren
e38fcc8608 plymouth: add xz support for kernel modules
This rewrites a portion of the module to support xz, as well as allow
an easier expansion should future compression methods for kernel
modules ever materialize.
2012-01-23 09:59:35 +01:00
Dave Young
b93aaba84f --ctty: add help line in usage
Adding missed help line in usage

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-01-23 09:48:35 +01:00
Dave Young
cdfeb278ab Add ssh client module code
Add ssh client module which support ssh key mode and interactive mode.
with --sshkey option you can provide the ssh key to be installed

>why not call it "ssh" module?
ssh-client is better, maybe future there will be ssh-server come in.
In debian these are also two different packages.

Usage:
1. sshkey mode:
transfer your public key to remote machine with ssh-copy-id or do it mannaully
example of options:
./dracut -l -H -a ssh-client --sshkey /root/.ssh/id_rsa i.img
2. interactive mode:
need use --ctty option, ie.:
./dracut -l -H -a ssh-client --ctty i.img

[v2 changes]:
per wangcong: add patch description about module name
add help line in usage()
remove useless comment

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-01-23 09:48:35 +01:00
Dave Young
85bb744dfe change root home dir to /root
ssh need to read knownhosts from home directory, so change root home to /root

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-01-23 09:48:35 +01:00
Michal Soltys
4401925c82 Add job control support to emergency shell
Option --ctty will optionally add setsid binary to dracut's image.

During runtime, if rd.ctty is set and is a character device,
emergency shells will be spawned with job control.

in case no ctty was provided, shell was spawned without caring about
/dev/console. Also, the ctty is more opportunistic. If the image was
generated with --ctty, we will fallback to /dev/tty1 if rc.ctty is
invalid or missing. Otherwise we spawn standard shell on /dev/console

[dyoung@redhat.com: Rebased to usrmove branch]

Signed-off-by: Michal Soltys <soltys@ziu.info>
Signed-off-by: Dave Young <dyoung@redhat.com>
2012-01-23 09:48:35 +01:00
Dave Young
59ee80764e deal common part of etc passwd in 99base
ssh module will need root user in /etc/passwd, so add root and nobody
to /etc/passwd in 99base instead of nfs module

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-01-23 09:48:35 +01:00
Cong Wang
8e1ffb1859 remove extra semicolons in dracut.8.xml
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
2012-01-23 09:48:35 +01:00
Anton Blanchard
e7cbf8fd30 ip= server-id should be server-IP
From looking at the code it seems like server-id should really
be named server-IP.
2012-01-23 09:48:35 +01:00
Anton Blanchard
b3d838e5d0 server-id in ip= is not optional
The documentation suggests that server-id is an optional argument
but ip_to_var fails if it is not specified. Fix the documentation.
2012-01-23 09:48:35 +01:00
Anton Blanchard
acfab3733f Handle upper case MAC addresses in ifname option
While the documentation states that ifname MAC addresses must be
lower case, we silently accept upper case ones and fail later on
when udev doesn't rename the device.

Instead of adding sanity checking on the MAC address just convert
it to lower case and remove the requirement completely.
2012-01-23 09:48:34 +01:00
Harald Hoyer
2e7b661681 90kernel-modules/module-setup.sh: install modules.order
Also install modules.order and all modules.builtin*
2012-01-20 12:06:41 +01:00
Harald Hoyer
027dbc9f85 dmsquash-live: really changed /dev/live-baseloop to /run/initramfs/
Forgot to amend my change to ce32e32f2a
2012-01-20 12:02:15 +01:00
Peter Robinson
e263867f6b mktemp was long obsoleted by coreutils
commit 2e55bb35640c5c2b3b5604e06232cc679559defa
Author: Peter Robinson <pbrobinson@gmail.com>
Date:   Wed Jan 11 10:28:05 2012 +0000

    mktemp was long obsoleted by coreutils

 dracut.spec |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
2012-01-17 10:55:35 +01:00
Hermann Gausterer
0de93fa1da typo fix
Signed-off-by: Hermann Gausterer <git-dracut-2012@mrq1.org>
2012-01-17 10:55:35 +01:00
Dave Young
a996d703e9 fstab-sys: mount it in initramfs instead of newroot if mount point is not found
fstab-sys now also handles device passed by dracut argument "--mount"
The "--mount" mount point is possible not exist in $NEWROOT. Thus mount it
in initramfs if mount point is not exist in real rootfs
2012-01-13 11:50:53 +01:00
Will Woods
a75c3afe68 minor cleanups in parsing for dmsquash-live and livenet
- use wait_for_dev in livenet
- clarify log message and fix missing newline in dmsquash-live

Signed-off-by: Will Woods <wwoods@redhat.com>
2012-01-13 11:50:53 +01:00
Will Woods
1cc57edaf5 interpret 'off' as false in getargbool
Signed-off-by: Will Woods <wwoods@redhat.com>
2012-01-13 11:50:53 +01:00
Brian C. Lane
ce32e32f2a Create a symlink for the live image's base loop device
It is useful to know that loop device that the live image's / is mounted
from. Make a /run/initramfs/live-baseloop symlink that points to it.

Edited-By: harald@redhat.com: changed /dev/live-baseloop
                              to /run/initramfs/live-baseloop
2012-01-13 11:38:48 +01:00
Cong Wang
a72cae66dc lvm: pass the correct rd.lvm.lv parameter
rd.lvm.lv accepts ${DM_VG_NAME}/${DM_LV_NAME}, not ${DM_LV_NAME}.

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
2012-01-13 11:35:49 +01:00
Cong Wang
eead773204 nfs: fix regex patterns in check()
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
2012-01-13 11:35:49 +01:00
Cong Wang
d0096de764 Pass device name instead of major:minor in for_each_host_dev_fs()
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
2012-01-13 11:35:49 +01:00
Cong Wang
426b68b20a Fix get_maj_min() to follow symlink
Otherwise get_maj_min /dev/mapper/vg_cr0-lv_home will return 0:0.

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
2012-01-13 11:35:49 +01:00
Cong Wang
1b7fd0fa3e Check module dependencies of mount points
Like -H, we need to poll every module to check if it is needed
to mount a specific device in '--mount'.

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
2012-01-13 11:35:49 +01:00
Cong Wang
cd7ff122a4 Allow to add mount points even not in hostonly mode
Don't force --mount only working in hostonly mode, let users decide.
With this patch, people can still combine -H --mount '...' if they
want to use it in hostonly mode.

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
2012-01-13 11:35:49 +01:00
Harald Hoyer
cf5229190d TEST-10-RAID: fixed TESTDIR handling 2012-01-13 11:33:22 +01:00
Duane Griffin
345f9fa77e 98usrmount/mount-usr.sh: Don't pass mount options to fsck 2012-01-13 10:23:45 +01:00
Colin Guthrie
62073c3048 udev: Attempt to install any programs used by udev rules. 2012-01-09 13:34:51 +01:00
Colin Guthrie
54f1a77fb6 init: Fix bogus message about invalid root device.
When the initqueue cannot be processed, it might be about an invalid
root device (in which case a separate message produced via
wait_for_dev() should be displayed anyway), but it could also
be for any other reason (e.g. /dev/resume not existing).

Therefore, it is best to use a more generic error message.

Also a minor tab->space conversion in the near vacinity of
the real change.
2012-01-09 13:34:40 +01:00
Colin Guthrie
09ee7234b6 dmsquash: Ensure the 'loop' kernel module is included and loaded. 2012-01-09 13:34:17 +01:00
Colin Guthrie
f65b874bda resume: Fix failure when invalid device passed via 'resume='
This commit allows the waiting for a device to be cancelled.
When the resume partition does not exist, it becomes quite hard
to work out what to do (you have to either create the
/dev/resume symlink manually, or remove the 'finished' job
that is waiting for it). Additionally dracut incorrectly
displays a message about not being able to find the root
device, which is bogus and misleading.

This commit should just bail on the whole resume thing
if the device cannot be found and proceed with a normal boot.
2012-01-09 13:33:13 +01:00
Colin Guthrie
5d55ceb75c btrfs: Ensure crc32c module is installed.
As outlined here:
 https://bugs.mageia.org/show_bug.cgi?id=3214
and:
 https://bugs.launchpad.net/ubuntu/+source/linux-linaro-omap/+bug/715835
the btrfs module needs a CRC implementation.
2012-01-09 13:32:36 +01:00
Colin Guthrie
fa20c18525 kernel-modules: Find (and ulitmately dereference) any symlinks in modprobe.d dir.
Also only do the top level of files (ignore any subdirs and files within)
2012-01-09 13:29:24 +01:00
Anssi Hannula
5fae9d9a20 plymouth: Include kms modules even if they are not currently loaded.
This should fix initial initrd generation during install.
If the modules are not desired to be used, the nokmsboot kernel
command line should disable them.
2012-01-09 13:28:29 +01:00
Colin Guthrie
482c573d9e Only install files from /etc/ld.so.conf.d/ directory
When calling inst_simple() it will ignore anything that
is not a file, so harden the check done before the calling.
2012-01-09 13:26:57 +01:00
Colin Guthrie
7835e1465f Handle compressed kmods.
This was orignally from Mandriva patch: dracut-011-plymouth-compressed-kmod.patch
2012-01-09 13:26:06 +01:00
Colin Guthrie
95023eb325 Fix Unicode keytable.
This patch was originally from Mandriva: dracut-013-fix_unicode_keytable.patch
2012-01-09 13:25:12 +01:00
Colin Guthrie
39f87ab2ab mkinitrd: Mention the --nocompress option in help output
Originally from Mandriva patch: dracut-010-mkinitrd.patch
2012-01-09 13:23:47 +01:00
Harald Hoyer
dcba56cafa Makefile: dash does not like {} expansion
removed {} expansion for mandir mkdir for users, which have dash as
/bin/sh
2012-01-05 14:48:57 +01:00
Harald Hoyer
5e90d26658 Makefile: set bindir to ${prefix}/bin rather than sbin 2012-01-05 14:36:45 +01:00
Brian C. Lane
14599cd760 Fix live update script (#769970)
pushd and popd are not available in the shell used by dracut.
2012-01-05 11:02:04 +01:00
Harald Hoyer
e74167bd6a mkinitrd-dracut.sh: s/read_args/read_arg/g
https://bugzilla.redhat.com/show_bug.cgi?id=771106
2012-01-05 10:51:00 +01:00
Harald Hoyer
70cb8a686f dracut: add --add-fstab and --mount option
--add-fstab [FILE]    Add file to the initramfs fstab
--mount "[DEV] [MP] [FSTYPE] [FSOPTS]"
                      Mount device [DEV] on mountpoint [MP] with filesystem
                      [FSTYPE] and options [FSOPTS] in the initramfs
2011-12-15 14:49:20 +01:00
Harald Hoyer
bb61d657c1 99base/dracut-lib.sh: added inst_mount_hook add_mount_point
inst_mount_hook <mountpoint> <prio> <name> <script>

Install a mount hook with priority <prio>,
which executes <script> as soon as <mountpoint> is mounted.

add_mount_point <dev> <mountpoint> <filesystem> <fsopts>

Mount <dev> on <mountpoint> with <filesystem> and <fsopts>
and call any mount hooks, as soon, as it is mounted
2011-12-15 14:49:05 +01:00
Harald Hoyer
5112bfc8cc TEST-12-RAID-DEG: mkdir /run 2011-12-15 14:49:05 +01:00
Harald Hoyer
828feae4f1 dracut.spec: remove unnecessary dependencies
Since the initramfs generation is done in %postrans of the kernel rpm,
we can drop all hard requirements.

Also make some requirements a conflict to express the version
dependency.
2011-12-15 14:49:04 +01:00
Harald Hoyer
4d63882615 99base/dracut-lib.sh: killproc, prefix local variables 2011-12-15 14:49:04 +01:00
Harald Hoyer
43f2185221 95iscsi/iscsiroot: unset used variables before starting
If iscsiroot is called multiple times, then some variables can hold the
values of a previous call, so unset all variables before using them.

https://bugzilla.redhat.com/show_bug.cgi?id=752066
2011-12-15 14:49:04 +01:00
Harald Hoyer
480d772f22 */module-setup.sh: use host_fs_types host_devs
For the $hostonly case, use $host_fs_types and $host_devs to determine,
if a module has to be included in the initramfs.
2011-12-15 14:49:03 +01:00
Harald Hoyer
7ae5d9d11d dracut: export host_fs_types host_devs
Determine devices and filesystems to be included in the host-only
initramfs image.

To get a minimal initramfs, which can mount
 /
 /etc
 /usr
 /usr/bin
 /usr/sbin
 /usr/lib
 /usr/lib64
 /boot
we look in fstab for the corresponding devices and determine their and
their slaves' filesystem type and put all that in $host_fs_types
and $host_devs.
2011-12-15 10:33:26 +01:00
143 changed files with 2644 additions and 1036 deletions

2
.gitignore vendored
View File

@@ -8,3 +8,5 @@
/modules.d/99base/switch_root
/test/*/test.log
test*.img
/.buildpath
/.project

View File

@@ -6,4 +6,7 @@ Harald Hoyer <harald@redhat.com> <harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Harald Hoyer <harald@redhat.com> <harald@eeepc.(none)>
Mike Snitzer <snitzer@redhat.com> <msnitzer@redhat.com>
Amerigo Wang <amwang@redhat.com> <xiyou.wangcong@gmail.com>
Andrey Borzenkov <arvidjaar@gmail.com> <arvidjaar@mail.ru>
Dan Horák <dhorak@redhat.com> <dan@danny.cz>
John Reiser <jreiser@bitwagon.com> <jreiser@BitWagon.com>
Luca Berra <bluca@vodka.it> <bluca@comedia.it>

30
AUTHORS
View File

@@ -7,45 +7,55 @@ Jeremy Katz <katzj@redhat.com>
David Dillow <dave@thedillows.org>
Michal Soltys <soltys@ziu.info>
Will Woods <wwoods@redhat.com>
Andrey Borzenkov <arvidjaar@gmail.com>
Andreas Thienemann <andreas@bawue.net>
Hans de Goede <hdegoede@redhat.com>
Peter Jones <pjones@redhat.com>
Luca Berra <bluca@comedia.it>
Andrey Borzenkov <arvidjaar@mail.ru>
Andrey Borzenkov <arvidjaar@gmail.com>
Marc Grimme <grimme@atix.de>
Daniel Drake <dsd@laptop.org>
Roberto Sassu <roberto.sassu@polito.it>
Amerigo Wang <amwang@redhat.com>
Colin Guthrie <colin@mageia.org>
John Reiser <jreiser@bitwagon.com>
Luca Berra <bluca@vodka.it>
Dave Young <dyoung@redhat.com>
Daniel Drake <dsd@laptop.org>
Marc Grimme <grimme@atix.de>
Roberto Sassu <roberto.sassu@polito.it>
Anton Blanchard <anton@samba.org>
Bill Nottingham <notting@redhat.com>
Brian C. Lane <bcl@redhat.com>
Dan Horák <dhorak@redhat.com>
David Cantrell <dcantrell@redhat.com>
Lance Albertson <lance@osuosl.org>
Marian Ganisin <mganisin@redhat.com>
Michael Ploujnikov <plouj@somanetworks.com>
Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Alan Pevec <apevec@redhat.com>
Dan Horák <dan@danny.cz>
Ian Dall <ian@beware.dropbear.id.au>
James Buren <ryuo@frugalware.org>
Joey Boggs <jboggs@redhat.com>
Jon Ander Hernandez <jonan.h@gmail.com>
Mike Snitzer <snitzer@redhat.com>
Peter Rajnoha <prajnoha@redhat.com>
Przemysław Rudy <prudy1@o2.pl>
Vladislav Bogdanov <bubble@hoster-ok.com>
Alexander Todorov <atodorov@redhat.com>
Andy Lutomirski <luto@mit.edu>
Anssi Hannula <anssi@mageia.org>
Christian Heinz <christian.ch.heinz@gmail.com>
Dan Horák <dhorak@redhat.com>
Dave Jones <davej@redhat.com>
Duane Griffin <duaneg@dghda.com>
Frederic Crozat <fcrozat@mandriva.com>
Glen Gray <slaine@slaine.org>
Ian Dall <ian@beware.dropbear.id.au>
Hermann Gausterer <git-dracut-2012@mrq1.org>
James Laska <jlaska@redhat.com>
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Leho Kraav <leho@kraav.com>
Lubomir Rintel <lkundrak@v3.sk>
Luca Berra <bluca@vodka.it>
Matt <smoothsailing72@hotmail.com>
Matt Smith <shadowfax@gmx.com>
Michal Schmidt <mschmidt@redhat.com>
Munehiro Matsuda <haro@kgt.co.jp>
Paolo Bonzini <pbonzini@redhat.com>
Peter Robinson <pbrobinson@fedoraproject.org>
Pádraig Brady <P@draigBrady.com>
Quentin Armitage <quentin@armitage.org.uk>
Sergey Fionov <fionov@gmail.com>

View File

@@ -1,4 +1,4 @@
VERSION=014
VERSION=017
GITVERSION=$(shell [ -d .git ] && git rev-list --abbrev-commit -n 1 HEAD |cut -b 1-8)
prefix ?= /usr
@@ -6,7 +6,7 @@ libdir ?= ${prefix}/lib
datadir ?= ${prefix}/share
pkglibdir ?= ${libdir}/dracut
sysconfdir ?= ${prefix}/etc
bindir ?= ${prefix}/sbin
bindir ?= ${prefix}/bin
mandir ?= ${prefix}/share/man
manpages = dracut.8 dracut.cmdline.7 dracut.conf.5 dracut-catimages.8 dracut-gencmdline.8
@@ -30,16 +30,18 @@ install: doc
mkdir -p $(DESTDIR)$(bindir)
mkdir -p $(DESTDIR)$(sysconfdir)
mkdir -p $(DESTDIR)$(pkglibdir)/modules.d
mkdir -p $(DESTDIR)$(mandir)/man{5,7,8}
install -m 0755 dracut $(DESTDIR)$(bindir)/dracut
install -m 0755 dracut-gencmdline $(DESTDIR)$(bindir)/dracut-gencmdline
install -m 0755 dracut-catimages $(DESTDIR)$(bindir)/dracut-catimages
mkdir -p $(DESTDIR)$(mandir)/man5 $(DESTDIR)$(mandir)/man7 $(DESTDIR)$(mandir)/man8
install -m 0755 dracut.sh $(DESTDIR)$(bindir)/dracut
install -m 0755 dracut-gencmdline.sh $(DESTDIR)$(bindir)/dracut-gencmdline
install -m 0755 dracut-catimages.sh $(DESTDIR)$(bindir)/dracut-catimages
install -m 0755 mkinitrd-dracut.sh $(DESTDIR)$(bindir)/mkinitrd
install -m 0755 lsinitrd $(DESTDIR)$(bindir)/lsinitrd
install -m 0755 lsinitrd.sh $(DESTDIR)$(bindir)/lsinitrd
install -m 0644 dracut.conf $(DESTDIR)$(sysconfdir)/dracut.conf
mkdir -p $(DESTDIR)$(sysconfdir)/dracut.conf.d
install -m 0755 dracut-functions $(DESTDIR)$(pkglibdir)/dracut-functions
install -m 0755 dracut-logger $(DESTDIR)$(pkglibdir)/dracut-logger
install -m 0755 dracut-functions.sh $(DESTDIR)$(pkglibdir)/dracut-functions.sh
ln -s dracut-functions.sh $(DESTDIR)$(pkglibdir)/dracut-functions
install -m 0755 dracut-logger.sh $(DESTDIR)$(pkglibdir)/dracut-logger.sh
install -m 0755 dracut-initramfs-restore.sh $(DESTDIR)$(pkglibdir)/dracut-initramfs-restore
cp -arx modules.d $(DESTDIR)$(pkglibdir)
install -m 0644 dracut.8 $(DESTDIR)$(mandir)/man8/dracut.8
install -m 0644 dracut-catimages.8 $(DESTDIR)$(mandir)/man8/dracut-catimages.8
@@ -47,6 +49,14 @@ install: doc
install -m 0644 dracut.conf.5 $(DESTDIR)$(mandir)/man5/dracut.conf.5
install -m 0644 dracut.cmdline.7 $(DESTDIR)$(mandir)/man7/dracut.cmdline.7
ln -s dracut.cmdline.7 $(DESTDIR)$(mandir)/man7/dracut.kernel.7
if [ -n "$(systemdsystemunitdir)" ]; then \
mkdir -p $(DESTDIR)$(systemdsystemunitdir); \
install -m 0644 dracut-shutdown.service $(DESTDIR)$(systemdsystemunitdir); \
mkdir -p $(DESTDIR)$(systemdsystemunitdir)/reboot.target.wants; \
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
clean:
$(RM) *~
@@ -77,12 +87,14 @@ rpm: dracut-$(VERSION).tar.bz2
( mv "$$rpmbuild"/noarch/*.rpm .; mv "$$rpmbuild"/*.src.rpm .;rm -fr "$$rpmbuild"; ls *.rpm )
syncheck:
@ret=0;for i in dracut-logger modules.d/99base/init modules.d/*/*.sh; do \
@ret=0;for i in dracut-initramfs-restore.sh dracut-logger.sh \
modules.d/99base/init.sh modules.d/*/*.sh; do \
[ "$${i##*/}" = "module-setup.sh" ] && continue; \
[ "$${i##*/}" = "caps.sh" ] && continue; \
dash -n "$$i" ; ret=$$(($$ret+$$?)); \
done;exit $$ret
@ret=0;for i in dracut modules.d/02caps/caps.sh modules.d/*/module-setup.sh; do \
@ret=0;for i in *.sh mkinitrd-dracut.sh modules.d/02caps/caps.sh \
modules.d/*/module-setup.sh; do \
bash -n "$$i" ; ret=$$(($$ret+$$?)); \
done;exit $$ret
@@ -90,17 +102,17 @@ check: all syncheck
$(MAKE) -C test check
testimage: all
./dracut -l -a debug -f test-$(shell uname -r).img $(shell uname -r)
./dracut.sh -l -a debug -f test-$(shell uname -r).img $(shell uname -r)
@echo wrote test-$(shell uname -r).img
testimages: all
./dracut -l -a debug --kernel-only -f test-kernel-$(shell uname -r).img $(shell uname -r)
./dracut.sh -l -a debug --kernel-only -f test-kernel-$(shell uname -r).img $(shell uname -r)
@echo wrote test-$(shell uname -r).img
./dracut -l -a debug --no-kernel -f test-dracut.img $(shell uname -r)
./dracut.sh -l -a debug --no-kernel -f test-dracut.img $(shell uname -r)
@echo wrote test-dracut.img
hostimage: all
./dracut -H -l -a debug -f test-$(shell uname -r).img $(shell uname -r)
./dracut.sh -H -l -a debug -f test-$(shell uname -r).img $(shell uname -r)
@echo wrote test-$(shell uname -r).img
AUTHORS:

42
NEWS
View File

@@ -1,3 +1,45 @@
dracut-017
==========
- a _lot_ faster than dracut-016 in image creation
- systemd service dracut-shutdown.service
- livenet fixes
- ssh-client module install fix
- root=iscsi:... fixed
- lots of restructuring and optimizing in dracut-functions.sh
- usrmount: honor fs_passno in /etc/fstab
- renamed all shell scripts to .sh
- new option "--omit-drivers" and config option "omit_drivers"
- hostonly mode fixups
dracut-016
==========
- fixed lsinitrd
- honor binaries in sbin first
- fixed usrmount module
- added systemd service for shutdown
- fixed terminfo on distros with /usr/share/terminfo
- reload udev rules after "pre-trigger" hook
- improved test suite
- new parameter "--omit-drivers" and new conf param omit_drivers
- "--offroot" support for mdraid
- new libs: net-lib.sh, nfs-lib.sh, url-lib.sh, img-lib.sh
full of functions to use in your dracut module
dracut-015
==========
- hostonly mode automatically adds command line options for root and /usr
- --add-fstab --mount parameters
- ssh-client module
- --ctty option: add job control
- cleanup /run/initramfs
- convertfs module
- /sbin/ifup can be called directly
- support kernel modules compressed with xz
- s390 iscsi modules added
- terminfo module
- lsinitrd can handle concatened images
- lsinitrd can sort by size
dracut-014
==========
- new dracut arguments:

View File

@@ -28,12 +28,19 @@ if ! [[ $dracutbasedir ]]; then
fi
if ! type dinfo >/dev/null 2>&1; then
. "$dracutbasedir/dracut-logger"
. "$dracutbasedir/dracut-logger.sh"
dlog_init
fi
# export standard hookdirs
[[ $hookdirs ]] || {
hookdirs="cmdline pre-udev pre-trigger netroot initqueue pre-mount"
hookdirs+=" pre-pivot mount emergency shutdown-emergency shutdown cleanup"
export hookdirs
}
# Generic substring function. If $2 is in $1, return 0.
strstr() { [[ $1 =~ $2 ]]; }
strstr() { [ "${1#*$2*}" != "$1" ]; }
# Create all subdirectories for given path without creating the last element.
# $1 = path
@@ -66,6 +73,8 @@ vercmp() {
esac
}
# is_func <command>
# Check whether $1 is a function.
is_func() {
[[ $(type -t $1) = "function" ]]
}
@@ -82,6 +91,12 @@ print_vars() {
done
}
# normalize_path <path>
# Prints the normalized path, where it removes any duplicated
# and trailing slashes.
# Example:
# $ normalize_path ///test/test//
# /test/test
normalize_path() {
shopt -q -s extglob
set -- "${1//+(\/)//}"
@@ -89,10 +104,15 @@ normalize_path() {
echo "${1%/}"
}
# convert_abs_rel <from> <to>
# Prints the relative path, when creating a symlink to <to> from <from>.
# Example:
# $ convert_abs_rel /usr/bin/test /bin/test-2
# ../../bin/test-2
# $ ln -s $(convert_abs_rel /usr/bin/test /bin/test-2) /usr/bin/test
convert_abs_rel() {
local __current __absolute __abssize __cursize __newpath __oldifs
local __current __absolute __abssize __cursize __newpath
local -i __i __level
# PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): ';
set -- "$(normalize_path "$1")" "$(normalize_path "$2")"
@@ -102,11 +122,8 @@ convert_abs_rel() {
# corner case #2 - own dir link
[[ "${1%/*}" == "$2" ]] && { echo "."; return; }
__oldifs="$IFS"
IFS="/"
__current=($1)
__absolute=($2)
IFS="$__oldifs"
IFS="/" __current=($1)
IFS="/" __absolute=($2)
__abssize=${#__absolute[@]}
__cursize=${#__current[@]}
@@ -141,6 +158,12 @@ convert_abs_rel() {
echo "$__newpath"
}
# get_fs_env <device>
# Get and set the ID_FS_TYPE and ID_FS_UUID variable from udev for a device.
# Example:
# $ get_fs_env /dev/sda2; echo $ID_FS_TYPE; echo $ID_FS_UUID
# ext4
# 551a39aa-4ae9-4e70-a262-ef665cadb574
get_fs_env() {
[[ $1 ]] || return
unset ID_FS_TYPE
@@ -157,6 +180,21 @@ get_fs_env() {
fi
}
# get_fs_uuid <device>
# Prints the filesystem UUID for a device.
# Example:
# $ get_fs_uuid /dev/sda2
# 551a39aa-4ae9-4e70-a262-ef665cadb574
get_fs_uuid() (
get_fs_env $1 || return
echo $ID_FS_UUID
)
# get_fs_type <device>
# Prints the filesystem type for a device.
# Example:
# $ get_fs_type /dev/sda1
# ext4
get_fs_type() (
[[ $1 ]] || return
if [[ $1 != ${1#/dev/block/nfs:} ]] \
@@ -165,31 +203,48 @@ get_fs_type() (
echo "nfs"
return
fi
get_fs_env $1 || return
echo $ID_FS_TYPE
if get_fs_env $1; then
echo $ID_FS_TYPE
return
fi
find_dev_fstype $1
)
get_fs_uuid() (
get_fs_env $1 || return
echo $ID_FS_UUID
)
# get_maj_min <device>
# Prints the major and minor of a device node.
# Example:
# $ get_maj_min /dev/sda2
# 8:2
get_maj_min() {
local _dev
_dev=$(stat -L -c '$((0x%t)):$((0x%T))' "$1" 2>/dev/null)
_dev=$(eval "echo $_dev")
echo $_dev
}
# finds the major:minor of the block device backing the root filesystem.
# find_block_device <mountpoint>
# Prints the major and minor number of the block device
# for a given mountpoint.
# Unless $use_fstab is set to "yes" the functions
# uses /proc/self/mountinfo as the primary source of the
# information and only falls back to /etc/fstab, if the mountpoint
# is not found there.
# Example:
# $ find_block_device /usr
# 8:4
find_block_device() {
local _x _mpt _majmin _dev _fs _maj _min
if [[ $use_fstab != yes ]]; then
while read _x _x _majmin _x _mpt _x _x _fs _dev _x; do
[[ $_mpt = $1 ]] || continue
[[ $_fs = nfs ]] && { echo $_dev; return 0;}
[[ $_fs = nfs3 ]] && { echo $_dev; return 0;}
[[ $_fs = nfs4 ]] && { echo $_dev; return 0;}
[[ $_fs = btrfs ]] && {
ls -nLl "$_dev" | {
read _x _x _x _x _maj _min _x
_maj=${_maj//,/}
echo $_maj:$_min
} && return 0
get_maj_min $_dev
return 0;
}
if [[ $_mpt = $1 ]] && [[ ${_majmin#0:} = $_majmin ]]; then
if [[ ${_majmin#0:} = $_majmin ]]; then
echo $_majmin
return 0 # we have a winner!
fi
@@ -204,19 +259,64 @@ find_block_device() {
[[ $_dev != ${_dev#UUID=} ]] && _dev=/dev/disk/by-uuid/${_dev#UUID=}
[[ $_dev != ${_dev#LABEL=} ]] && _dev=/dev/disk/by-label/${_dev#LABEL=}
[[ -b $_dev ]] || return 1 # oops, not a block device.
ls -nLl "$_dev" | {
read _x _x _x _x _maj _min _x
_maj=${_maj//,/}
echo $_maj:$_min
} && return 0
get_maj_min "$_dev" && return 0
fi
done < /etc/fstab
return 1
}
# find_dev_fstype <device>
# Echo the filesystem type for a given device.
# /proc/self/mountinfo is taken as the primary source of information
# and /etc/fstab is used as a fallback.
# No newline is appended!
# Example:
# $ find_dev_fstype /dev/sda2;echo
# ext4
find_dev_fstype() {
local _x _mpt _majmin _dev _fs _maj _min
while read _x _x _majmin _x _mpt _x _x _fs _dev _x; do
[[ $_dev = $1 ]] || continue
echo -n $_fs;
return 0;
done < /proc/self/mountinfo
# fall back to /etc/fstab
while read _dev _mpt _fs _x; do
[[ $_dev = $1 ]] || continue
echo -n $_fs;
return 0;
done < /etc/fstab
return 1
}
# finds the major:minor of the block device backing the root filesystem.
find_root_block_device() { find_block_device /; }
# for_each_host_dev_fs <func>
# Execute "<func> <dev> <filesystem>" for every "<dev>|<fs>" pair found
# in ${host_fs_types[@]}
for_each_host_dev_fs()
{
local _func="$1"
local _dev
local _fs
local _ret=1
for f in ${host_fs_types[@]}; do
OLDIFS="$IFS"
IFS="|"
set -- $f
IFS="$OLDIFS"
_dev="$1"
[[ -b "$_dev" ]] || continue
_fs="$2"
$_func $_dev $_fs && _ret=0
done
return $_ret
}
# Walk all the slave relationships for a given block device.
# Stop when our helper function returns success
# $1 = function to call on every found block device
@@ -237,11 +337,6 @@ check_block_and_slaves() {
return 1
}
get_numeric_dev() {
local _x _maj _min
ls -lH "$1" | { read _x _x _x _x _maj _min _x; printf "%d:%d" ${_maj%%,} $_min; }
}
# ugly workaround for the lvm design
# There is no volume group device,
# so, there are no slave devices for volume groups.
@@ -251,7 +346,7 @@ get_numeric_dev() {
check_vol_slaves() {
local _lv _vg _pv
for i in /dev/mapper/*; do
_lv=$(get_numeric_dev $i)
_lv=$(get_maj_min $i)
if [[ $_lv = $2 ]]; then
_vg=$(lvm lvs --noheadings -o vg_name $i 2>/dev/null)
# strip space
@@ -259,7 +354,7 @@ check_vol_slaves() {
if [[ $_vg ]]; then
for _pv in $(lvm vgs --noheadings -o pv_name "$_vg" 2>/dev/null)
do
check_block_and_slaves $1 $(get_numeric_dev $_pv) && return 0
check_block_and_slaves $1 $(get_maj_min $_pv) && return 0
done
fi
fi
@@ -282,21 +377,14 @@ inst_dir() {
# iterate over parent directories
for _file in $_dir; do
[[ -e "${initdir}/$_file" ]] && continue
if [[ -L $_file ]]; then
# create link as the original
local target=$(readlink -f "$_file")
# resolve relative path and recursively install destination
[[ $target == ${target#/} ]] && target="$(dirname "$_file")/$target"
inst_dir "$target"
inst_symlink "$_file"
else
[[ -h ${initdir}/$_file ]] && _file=$(readlink "${initdir}/$_file")
# create directory
[[ -e "${initdir}/$_file" ]] || mkdir -m 0755 -p "${initdir}/$_file" || return 1
if [[ -d "$_file" ]]; then
chmod --reference="$_file" "${initdir}/$_file"
chmod u+w "${initdir}/$_file"
fi
mkdir -m 0755 -p "${initdir}/$_file" || return 1
[[ -e "$_file" ]] && chmod --reference="$_file" "${initdir}/$_file"
chmod u+w "${initdir}/$_file"
fi
done
}
@@ -312,15 +400,15 @@ inst_simple() {
local _src=$1 target="${2:-$1}"
if ! [[ -d ${initdir}/$target ]]; then
[[ -e ${initdir}/$target ]] && return 0
[[ -h ${initdir}/$target ]] && return 0
inst_dir "${target%/*}"
[[ -L ${initdir}/$target ]] && return 0
[[ -d "${initdir}/${target%/*}" ]] || inst_dir "${target%/*}"
fi
# install checksum files also
if [[ -e "${_src%/*}/.${_src##*/}.hmac" ]]; then
inst "${_src%/*}/.${_src##*/}.hmac" "${target%/*}/.${target##*/}.hmac"
fi
ddebug "Installing $_src"
cp --sparse=always -pfL "$_src" "${initdir}/$target"
cp --sparse=always -pfL "$_src" "${initdir}/$target"
}
# find symlinks linked to given library file
@@ -363,6 +451,7 @@ inst_library() {
_reallib=$(readlink -f "$_src")
inst_simple "$_reallib" "$_reallib"
inst_dir "${_dest%/*}"
[[ -d "${_dest%/*}" ]] && _dest=$(readlink -f "${_dest%/*}")/${_dest##*/}
ln -sfn $(convert_abs_rel "${_dest}" "${_reallib}") "${initdir}/${_dest}"
else
inst_simple "$_src" "$_dest"
@@ -381,61 +470,45 @@ inst_library() {
# search in the usual places to find the binary.
find_binary() {
if [[ -z ${1##/*} ]]; then
if [[ -x $1 ]] || ldd $1 &>/dev/null; then
if [[ -x $1 ]] || { strstr "$1" ".so" && ldd $1 &>/dev/null; }; then
echo $1
return 0
fi
fi
PATH="/usr/sbin:/sbin:/usr/bin:/bin" type -P $1
type -P $1
}
# Same as above, but specialized to install binary executables.
# Install binary executable, and all shared library dependencies, if any.
inst_binary() {
local _bin _target _f _self _so_regex _lib_regex _tlibdir _base _file _line
local _bin _target
_bin=$(find_binary "$1") || return 1
_target=${2:-$_bin}
inst_symlink $_bin $_target && return 0
[[ -e $initdir/$_target ]] && return 0
# If the binary being installed is also a library, add it to the loop.
_so_regex='([^ ]*/lib[^/]*/[^ ]*\.so[^ ]*)'
[[ $_bin =~ $_so_regex ]] && _self="\t${_bin##*/} => ${_bin} (0x0)\n"
_lib_regex='^(/lib[^/]*).*'
[[ -L $_bin ]] && inst_symlink $_bin $_target && return 0
local _file _line
local _so_regex='([^ ]*/lib[^/]*/[^ ]*\.so[^ ]*)'
# I love bash!
{ LC_ALL=C ldd $_bin 2>/dev/null; echo -en "$_self"; } | while read _line; do
[[ $_line = 'not a dynamic executable' ]] && return 1
LC_ALL=C ldd "$_bin" 2>/dev/null | while read _line; do
[[ $_line = 'not a dynamic executable' ]] && break
if [[ $_line =~ $_so_regex ]]; then
_file=${BASH_REMATCH[1]}
[[ -e ${initdir}/$_file ]] && continue
inst_library "$_file"
continue
fi
if [[ $_line =~ not\ found ]]; then
dfatal "Missing a shared library required by $_bin."
dfatal "Run \"ldd $_bin\" to find out what it is."
dfatal "$_line"
dfatal "dracut cannot create an initrd."
exit 1
fi
[[ $_line =~ $_so_regex ]] || continue
_file=${BASH_REMATCH[1]}
[[ -e ${initdir}/$_file ]] && continue
# See if we are loading an optimized version of a shared lib.
if [[ $_file =~ $_lib_regex ]]; then
_tlibdir=${BASH_REMATCH[1]}
_base=${_file##*/}
# Prefer nosegneg libs to unoptimized ones.
for _f in "$_tlibdir/i686/nosegneg" "$_tlibdir"; do
[[ -e $_f/$_base ]] || continue
_file=$_f/$_base
break
done
inst_library "$_file" "$_tlibdir/$_base"
else
inst_library "$_file"
fi
done
# Install the binary if it wasn't handled in the above loop.
[[ -z $_self ]] && inst_simple "$_bin" "$_target"
inst_simple "$_bin" "$_target"
}
# same as above, except for shell scripts.
@@ -455,21 +528,40 @@ inst_script() {
# same as above, but specialized for symlinks
inst_symlink() {
local _src=$1 _target=$initdir/${2:-$1} _realsrc
local _src=$1 _target=${2:-$1} _realsrc
strstr "$1" "/" || return 1
[[ -L $1 ]] || return 1
[[ -L $_target ]] && return 0
[[ -L $initdir/$_target ]] && return 0
_realsrc=$(readlink -f "$_src")
[[ $_realsrc = ${_realsrc##*/} ]] && _realsrc=${_src%/*}/$_realsrc
if [[ -d $_realsrc ]]; then
inst_dir "$_realsrc"
else
inst "$_realsrc" && mkdir -m 0755 -p "${_target%/*}"
if ! [[ -e $initdir/$_realsrc ]]; then
if [[ -d $_realsrc ]]; then
inst_dir "$_realsrc"
else
inst "$_realsrc"
fi
fi
if [[ -e "${_src}" ]]; then
ln -sfn $(convert_abs_rel "${_src}" "${_realsrc}") "$_target"
else
ln -sfn "$_realsrc" "$_target"
[[ -d ${_target%/*} ]] && _target=$(readlink -f ${_target%/*})/${_target##*/}
ln -sfn $(convert_abs_rel "${_target}" "${_realsrc}") "$initdir/$_target"
}
# 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
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
}
@@ -486,6 +578,7 @@ inst_rules() {
if [[ -f $r/$_rule ]]; then
_found="$r/$_rule"
inst_simple "$_found"
inst_rule_programs "$_found"
fi
done
fi
@@ -493,6 +586,7 @@ inst_rules() {
if [[ -f ${r}$_rule ]]; then
_found="${r}$_rule"
inst_simple "$_found" "$_target/${_found##*/}"
inst_rule_programs "$_found"
fi
done
[[ $_found ]] || dinfo "Skipping udev rule: $_rule"
@@ -519,12 +613,6 @@ inst() {
return 1
}
[[ $hookdirs ]] || {
hookdirs="cmdline pre-udev pre-trigger netroot initqueue pre-mount"
hookdirs+=" pre-pivot mount emergency shutdown-emergency shutdown"
export hookdirs
}
# install function specialized for hooks
# $1 = type of hook, $2 = hook priority (lower runs first), $3 = hook
# All hooks should be POSIX/SuS compliant, they will be sourced by init.
@@ -568,6 +656,9 @@ inst_any() {
return 1
}
# dracut_install [-o ] <file> [<file> ... ]
# Install <file> to the initramfs image
# -o optionally install the <file> and don't fail, if it is not there
dracut_install() {
local _optional=no
if [[ $1 = '-o' ]]; then
@@ -635,6 +726,10 @@ inst_opt_decompress() {
done
}
# module_check <dracut module>
# execute the check() function of module-setup.sh of <dracut module>
# or the "check" script, if module-setup.sh is not found
# "check $hostonly" is called
module_check() {
local _moddir=$(echo ${dracutbasedir}/modules.d/??${1})
local _ret
@@ -661,6 +756,35 @@ module_check() {
return $_ret
}
# module_check_mount <dracut module>
# execute the check() function of module-setup.sh of <dracut module>
# or the "check" script, if module-setup.sh is not found
# "mount_needs=1 check 0" is called
module_check_mount() {
local _moddir=$(echo ${dracutbasedir}/modules.d/??${1})
local _ret
mount_needs=1
[[ -d $_moddir ]] || return 1
if [[ ! -f $_moddir/module-setup.sh ]]; then
# if we do not have a check script, we are unconditionally included
[[ -x $_moddir/check ]] || return 0
mount_needs=1 $_moddir/check 0
_ret=$?
else
unset check depends install installkernel
. $_moddir/module-setup.sh
is_func check || return 1
check 0
_ret=$?
unset check depends install installkernel
fi
unset mount_needs
return $_ret
}
# module_depends <dracut module>
# execute the depends() function of module-setup.sh of <dracut module>
# or the "depends" script, if module-setup.sh is not found
module_depends() {
local _moddir=$(echo ${dracutbasedir}/modules.d/??${1})
local _ret
@@ -681,6 +805,9 @@ module_depends() {
fi
}
# module_install <dracut module>
# execute the install() function of module-setup.sh of <dracut module>
# or the "install" script, if module-setup.sh is not found
module_install() {
local _moddir=$(echo ${dracutbasedir}/modules.d/??${1})
local _ret
@@ -699,6 +826,9 @@ module_install() {
fi
}
# module_installkernel <dracut module>
# execute the installkernel() function of module-setup.sh of <dracut module>
# or the "installkernel" script, if module-setup.sh is not found
module_installkernel() {
local _moddir=$(echo ${dracutbasedir}/modules.d/??${1})
local _ret
@@ -717,6 +847,52 @@ module_installkernel() {
fi
}
# check_mount <dracut module>
# check_mount checks, if a dracut module is needed for the given
# device and filesystem types in "${host_fs_types[@]}"
check_mount() {
local _mod=$1
local _moddir=$(echo ${dracutbasedir}/modules.d/??${1})
local _ret
local _moddep
# If we are already scheduled to be loaded, no need to check again.
strstr " $mods_to_load " " $_mod " && return 0
strstr " $mods_checked_as_dep " " $_mod " && return 1
# This should never happen, but...
[[ -d $_moddir ]] || return 1
[[ $2 ]] || mods_checked_as_dep+=" $_mod "
strstr " $omit_dracutmodules " " $_mod " && return 1
if [ "${#host_fs_types[*]}" -gt 0 ]; then
module_check_mount $_mod || return 1
else
# skip this module
return 1
fi
for _moddep in $(module_depends $_mod); do
# handle deps as if they were manually added
strstr " $add_dracutmodules " " $_moddep " || \
add_dracutmodules+=" $_moddep "
strstr " $force_add_dracutmodules " " $_moddep " || \
force_add_dracutmodules+=" $_moddep "
# if a module we depend on fail, fail also
check_module $_moddep || return 1
done
strstr " $mods_to_load " " $_mod " || \
mods_to_load+=" $_mod "
return 0
}
# check_module <dracut module> [<use_as_dep>]
# check if a dracut module is to be used in the initramfs process
# if <use_as_dep> is set, then the process also keeps track
# that the modules were checked for the dependency tracking process
check_module() {
local _mod=$1
local _moddir=$(echo ${dracutbasedir}/modules.d/??${1})
@@ -768,14 +944,17 @@ check_module() {
return 0
}
check_module_dir() {
# for_each_module_dir <func>
# execute "<func> <dracut module> 1"
for_each_module_dir() {
local _modcheck
local _mod
local _moddir
mods_to_load=""
local _func
_func=$1
for _moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
_mod=${_moddir##*/}; _mod=${_mod#[0-9][0-9]}
check_module $_mod 1
$_func $_mod 1
done
# Report any missing dracut modules, the user has specified
@@ -794,6 +973,21 @@ install_kmod_with_fw() {
# no need to go further if the module is already installed
[[ -e "${initdir}/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" ]] \
&& return 0
if [[ $omit_drivers ]]; then
local _kmod=${1##*/}
_kmod=${_kmod%.ko}
_kmod=${_kmod/-/_}
if [[ "$_kmod" =~ $omit_drivers ]]; then
dinfo "Omitting driver $_kmod"
return 1
fi
if [[ "${1##*/lib/modules/$kernel/}" =~ $omit_drivers ]]; then
dinfo "Omitting driver $_kmod"
return 1
fi
fi
inst_simple "$1" "/lib/modules/$kernel/${1##*/lib/modules/$kernel/}" \
|| return $?
@@ -855,6 +1049,7 @@ filter_kernel_modules_by_path () (
if ! [[ $hostonly ]]; then
_filtercmd='find "$srcmods/kernel/$1" "$srcmods/extra"'
_filtercmd+=' "$srcmods/weak-updates" -name "*.ko" -o -name "*.ko.gz"'
_filtercmd+=' -o -name "*.ko.xz"'
_filtercmd+=' 2>/dev/null'
else
_filtercmd='cut -d " " -f 1 </proc/modules|xargs modinfo -F filename '
@@ -867,13 +1062,17 @@ filter_kernel_modules_by_path () (
$2 $initdir/$$.ko && echo "$_modname"
rm -f $initdir/$$.ko
;;
*.ko.xz) xz -dc "$_modname" > $initdir/$$.ko
$2 $initdir/$$.ko && echo "$_modname"
rm -f $initdir/$$.ko
;;
esac
done
)
find_kernel_modules_by_path () (
if ! [[ $hostonly ]]; then
find "$srcmods/kernel/$1" "$srcmods/extra" "$srcmods/weak-updates" \
-name "*.ko" -o -name "*.ko.gz" 2>/dev/null
-name "*.ko" -o -name "*.ko.gz" -o -name "*.ko.xz" 2>/dev/null
else
cut -d " " -f 1 </proc/modules \
| xargs modinfo -F filename -k $kernel 2>/dev/null
@@ -888,7 +1087,10 @@ find_kernel_modules () {
find_kernel_modules_by_path drivers
}
# instmods <kernel module> [<kernel module> ... ]
# instmods <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
@@ -916,12 +1118,17 @@ instmods() {
;;
--*) _mpargs+=" $_mod" ;;
i2o_scsi) return ;; # Do not load this diagnostic-only module
*) _mod=${_mod##*/}
*)
# if we are already installed, skip this module and go on
# to the next one.
[[ -f $initdir/$1 ]] && return
if [[ $omit_drivers ]] && [[ "$1" =~ $omit_drivers ]]; then
dinfo "Omitting driver ${_mod##$srcmods}"
return
fi
_mod=${_mod##*/}
# If we are building a host-specific initramfs and this
# module is not already loaded, move on to the next one.
[[ $hostonly ]] && ! grep -qe "\<${_mod//-/_}\>" /proc/modules \

View File

@@ -0,0 +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
set -e
cd /run/initramfs
IMG="/boot/initramfs-$(uname -r).img"
[ -f .need_shutdown -a -f "$IMG" ] || exit 1
zcat "$IMG" | cpio -id >/dev/null 2>&1
rm .need_shutdown

18
dracut-shutdown.service Normal file
View File

@@ -0,0 +1,18 @@
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
[Unit]
Description=Restore /run/initramfs
After=getty@tty1.service prefdm.service
Before=reboot.service
DefaultDependencies=no
ConditionPathExists=/run/initramfs/.need_shutdown
[Service]
ExecStart=/usr/lib/dracut/dracut-initramfs-restore
Type=oneshot
RemainAfterExit=yes

View File

@@ -18,18 +18,6 @@
<surname>Lowther</surname>
<email>victor.lowther@gmail.com</email>
</author>
<author>
<contrib>Developer</contrib>
<firstname>Warren</firstname>
<surname>Togami</surname>
<email>wtogami@redhat.com</email>
</author>
<author>
<contrib>Developer</contrib>
<firstname>Jeremy</firstname>
<surname>Katz</surname>
<email>katzj@redhat.com</email>
</author>
<author>
<contrib>Developer</contrib>
<firstname>Philippe</firstname>
@@ -38,9 +26,8 @@
</author>
<author>
<contrib>Developer</contrib>
<firstname>David</firstname>
<surname>Dillow</surname>
<email>dave@thedillows.org</email>
<firstname>Warren</firstname>
<surname>Togami</surname>
</author>
<author>
<contrib>Developer</contrib>
@@ -48,6 +35,17 @@
<surname>Żołnowski</surname>
<email>aidecoe@aidecoe.name</email>
</author>
<author>
<contrib>Developer</contrib>
<firstname>Jeremy</firstname>
<surname>Katz</surname>
</author>
<author>
<contrib>Developer</contrib>
<firstname>David</firstname>
<surname>Dillow</surname>
<email>dave@thedillows.org</email>
</author>
</authorgroup>
</refentryinfo>
<refmeta>
@@ -113,6 +111,11 @@ For a complete list of kernel command line options see
when building the initramfs.
Modules are located in
<filename>/usr/lib/dracut/modules.d</filename>. This parameter can be specified multiple times.</para>
<para>
If [LIST] has multiple arguments, then you have to put these in quotes.
For example:
<screen># dracut --modules "module1 module2" ...</screen>
</para>
</listitem>
</varlistentry>
<varlistentry>
@@ -124,6 +127,11 @@ Modules are located in
</term>
<listitem>
<para>omit a space-separated list of dracut modules. This parameter can be specified multiple times.</para>
<para>
If [LIST] has multiple arguments, then you have to put these in quotes.
For example:
<screen># dracut --omit "module1 module2" ...</screen>
</para>
</listitem>
</varlistentry>
<varlistentry>
@@ -135,6 +143,11 @@ Modules are located in
</term>
<listitem>
<para>add a space-separated list of dracut modules to the default set of modules. This parameter can be specified multiple times.</para>
<para>
If [LIST] has multiple arguments, then you have to put these in quotes.
For example:
<screen># dracut --add "module1 module2" ...</screen>
</para>
</listitem>
</varlistentry>
<varlistentry>
@@ -143,6 +156,11 @@ Modules are located in
</term>
<listitem>
<para>force to add a space-separated list of dracut modules to the default set of modules, when -H is specified. This parameter can be specified multiple times.</para>
<para>
If [LIST] has multiple arguments, then you have to put these in quotes.
For example:
<screen># dracut --force-add "module1 module2" ...</screen>
</para>
</listitem>
</varlistentry>
@@ -157,6 +175,11 @@ Modules are located in
<para>specify a space-separated list of kernel modules to exclusively include
in the initramfs.
The kernel modules have to be specified without the &quot;.ko&quot; suffix. This parameter can be specified multiple times.</para>
<para>
If [LIST] has multiple arguments, then you have to put these in quotes.
For example:
<screen># dracut --drivers "kmodule1 kmodule2" ...</screen>
</para>
</listitem>
</varlistentry>
<varlistentry>
@@ -166,6 +189,25 @@ The kernel modules have to be specified without the &quot;.ko&quot; suffix. This
<listitem>
<para>specify a space-separated list of kernel modules to add to the initramfs.
The kernel modules have to be specified without the &quot;.ko&quot; suffix. This parameter can be specified multiple times.</para>
<para>
If [LIST] has multiple arguments, then you have to put these in quotes.
For example:
<screen># dracut --add-drivers "kmodule1 kmodule2" ...</screen>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--omit-drivers&nbsp;<replaceable>&lt;list of kernel modules&gt;</replaceable></option>
</term>
<listitem>
<para>specify a space-separated list of kernel modules not to add to the initramfs.
The kernel modules have to be specified without the &quot;.ko&quot; suffix. This parameter can be specified multiple times.</para>
<para>
If [LIST] has multiple arguments, then you have to put these in quotes.
For example:
<screen># dracut --omit-drivers "kmodule1 kmodule2" ...</screen>
</para>
</listitem>
</varlistentry>
<varlistentry>
@@ -175,6 +217,11 @@ The kernel modules have to be specified without the &quot;.ko&quot; suffix. This
<listitem>
<para>specify a space-separated list of kernel filesystem modules to exclusively
include in the generic initramfs. This parameter can be specified multiple times.</para>
<para>
If [LIST] has multiple arguments, then you have to put these in quotes.
For example:
<screen># dracut --filesystems "filesystem1 filesystem2" ...</screen>
</para>
</listitem>
</varlistentry>
<varlistentry>
@@ -253,6 +300,11 @@ include in the generic initramfs. This parameter can be specified multiple times
<filename>dracut.conf</filename>'s specification; the
installation is opportunistic (non-existing tools are ignored)
</para>
<para>
If [LIST] has multiple arguments, then you have to put these in quotes.
For example:
<screen># dracut --fscks "fsck.foo barfsck" ...</screen>
</para>
</listitem>
</varlistentry>
<varlistentry>
@@ -295,6 +347,15 @@ include in the generic initramfs. This parameter can be specified multiple times
<para>do not prefix initramfs files (default)</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--ctty</option>
</term>
<listitem>
<para>if possible, try to spawn an emergency shell on a terminal
with job control</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>-h</option>
@@ -359,6 +420,14 @@ Default:
<filename>/etc/dracut.conf.d</filename></para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--sshkey&nbsp;<replaceable>&lt;sshkey file&gt;</replaceable></option>
</term>
<listitem>
<para>ssh key file used with ssh-client module.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>-l</option>
@@ -398,7 +467,7 @@ the local host instead of a generic host.
</varlistentry>
<varlistentry>
<term>
<option>--add_fstab;&nbsp;<replaceable>&lt;filename&gt;</replaceable>&nbsp;</option>
<option>--add_fstab&nbsp;<replaceable>&lt;filename&gt;</replaceable>&nbsp;</option>
</term>
<listitem>
<para>Add entries of <replaceable>&lt;filename&gt;</replaceable> to the initramfs /etc/fstab.</para>
@@ -406,7 +475,7 @@ the local host instead of a generic host.
</varlistentry>
<varlistentry>
<term>
<option>--mount;&nbsp;&quot;<replaceable>&lt;device&gt;</replaceable> <replaceable>&lt;mountpoint&gt;</replaceable> <replaceable>&lt;filesystem type&gt;</replaceable> <replaceable>&lt;filesystem options&gt;</replaceable>&quot;</option>
<option>--mount&nbsp;&quot;<replaceable>&lt;device&gt;</replaceable> <replaceable>&lt;mountpoint&gt;</replaceable> <replaceable>&lt;filesystem type&gt;</replaceable> <replaceable>&lt;filesystem options&gt;</replaceable>&quot;</option>
</term>
<listitem>
<para>Add entries of <replaceable>&lt;filename&gt;</replaceable> to the initramfs /etc/fstab.</para>
@@ -433,6 +502,11 @@ TARGET directory in the final initramfs. If SOURCE is a file, it will be install
</term>
<listitem>
<para>install the space separated list of files into the initramfs.</para>
<para>
If [LIST] has multiple arguments, then you have to put these in quotes.
For example:
<screen># dracut --install "/bin/foo /sbin/bar" ...</screen>
</para>
</listitem>
</varlistentry>
<varlistentry>

View File

@@ -109,6 +109,20 @@ This parameter can be specified multiple times.</para>
<para>force loading kernel module &lt;drivername&gt; after all automatic loading modules have been loaded. This parameter can be specified multiple times.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<envar>rd.ctty=<replaceable>&lt;terminal&gt;</replaceable></envar>
</term>
<listitem>
<para>
if the dracut image was generated with --ctty option, try to
spawn an emergency shell on the specified terminal; if
<envar>rd.ctty</envar> is specified without a value or not
provided at all, the default is /dev/tty1. The '/dev' prefix
can be omitted.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect2>
<refsect2 id="dracut-kernel-debug">
@@ -452,9 +466,9 @@ with a valid DHCP root-path.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><envar>ip=</envar><replaceable>&lt;client-IP&gt;</replaceable>:<optional>
<replaceable>&lt;server-id&gt;</replaceable>
</optional>:<replaceable>&lt;gateway-IP&gt;</replaceable>:<replaceable>&lt;netmask&gt;</replaceable>:<replaceable>&lt;client_hostname&gt;</replaceable>:<replaceable>&lt;interface&gt;</replaceable>:<replaceable>{none|off}</replaceable></term>
<term><envar>ip=</envar><replaceable>&lt;client-IP&gt;</replaceable>:
<replaceable>&lt;server-IP&gt;</replaceable>
:<replaceable>&lt;gateway-IP&gt;</replaceable>:<replaceable>&lt;netmask&gt;</replaceable>:<replaceable>&lt;client_hostname&gt;</replaceable>:<replaceable>&lt;interface&gt;</replaceable>:<replaceable>{none|off}</replaceable></term>
<listitem>
<para>explicit network configuration. If you want do define a IPv6 address, put it in brackets (e.g. [2001:DB8::1]).
This parameter can be specified multiple times.</para>
@@ -464,7 +478,6 @@ This parameter can be specified multiple times.</para>
<term><envar>ifname=</envar><replaceable>&lt;interface&gt;</replaceable>:<replaceable>&lt;MAC&gt;</replaceable></term>
<listitem>
<para>Assign network device name &lt;interface&gt; (ie eth0) to the NIC with MAC &lt;MAC&gt;.
Note letters in the MAC-address must be lowercase!
<remark>Note: If you use this option you <emphasis remap="B">must</emphasis> specify an ifname= argument for all interfaces used in ip= or fcoe= arguments.</remark>
This parameter can be specified multiple times.</para>
</listitem>
@@ -494,6 +507,14 @@ Required if multiple ip= lines are used.</para>
<para>turn on/off biosdevname network interface renaming</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<envar>rd.neednet=</envar><replaceable>&lt;0|1&gt;</replaceable>
</term>
<listitem>
<para>boolean, bring up network even without netroot set</para>
</listitem>
</varlistentry>
</variablelist>
</refsect2>
<refsect2>

View File

@@ -85,6 +85,24 @@ modules to add to the initramfs.
The kernel modules have to be specified without the &quot;.ko&quot; suffix.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<envar>omit_drivers+=&quot;&nbsp;<replaceable>&lt;kernel modules&gt;</replaceable>&nbsp;&quot;</envar>
</term>
<listitem>
<para>Specify a space-separated list of kernel
modules not to add to the initramfs.
The kernel modules have to be specified without the &quot;.ko&quot; suffix.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<envar>install_items+=&quot;&nbsp;<replaceable>&lt;kernel modules&gt;</replaceable>&nbsp;&quot;</envar>
</term>
<listitem>
<para>Specify a space-separated list of files, which are added to the initramfs image.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<envar>filesystems+=&quot;&nbsp;<replaceable>&lt;filesystem names&gt;</replaceable>&nbsp;&quot;</envar>

View File

@@ -3,5 +3,8 @@
# 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
prefix=/run/initramfs
realinitpath="/usr/lib/systemd/systemd"
install_items+=" vi /etc/virc ps grep cat rm openvt "

View File

@@ -40,8 +40,10 @@ Creates initial ramdisk images for preloading modules
-a, --add [LIST] Add a space-separated list of dracut modules.
-d, --drivers [LIST] Specify a space-separated list of kernel modules to
exclusively include in the initramfs.
--add-drivers [LIST] Specify a space-separated list of kernel
--add-drivers [LIST] Specify a space-separated list of kernel
modules to add to the initramfs.
--omit-drivers [LIST] Specify a space-separated list of kernel
modules not to add to the initramfs.
--filesystems [LIST] Specify a space-separated list of kernel filesystem
modules to exclusively include in the generic
initramfs.
@@ -85,6 +87,10 @@ Creates initial ramdisk images for preloading modules
-H, --hostonly Host-Only mode: Install only what is needed for
booting the local host instead of a generic host.
--fstab Use /etc/fstab to determine the root device.
--add-fstab [FILE] Add file to the initramfs fstab
--mount "[DEV] [MP] [FSTYPE] [FSOPTS]"
Mount device [DEV] on mountpoint [MP] with filesystem
[FSTYPE] and options [FSOPTS] in the initramfs
-i, --include [SOURCE] [TARGET]
Include the files in the SOURCE directory into the
Target directory in the final initramfs.
@@ -114,6 +120,12 @@ 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
--sshkey [SSHKEY] Add ssh key to initramfs (use with ssh-client module)
--ctty Add control tty for emergency shells
If [LIST] has multiple arguments, then you have to put these in quotes.
For example:
# dracut --add-drivers "module1 module2" ...
EOF
}
@@ -200,6 +212,7 @@ while (($# > 0)); do
-a|--add) push_arg add_dracutmodules_l "$@" || shift;;
--force-add) push_arg force_add_dracutmodules_l "$@" || shift;;
--add-drivers) push_arg add_drivers_l "$@" || shift;;
--omit-drivers) push_arg omit_drivers_l "$@" || shift;;
-m|--modules) push_arg dracutmodules_l "$@" || shift;;
-o|--omit) push_arg omit_dracutmodules_l "$@" || shift;;
-d|--drivers) push_arg drivers_l "$@" || shift;;
@@ -207,6 +220,8 @@ while (($# > 0)); do
-I|--install) push_arg install_items_l "$@" || shift;;
--fwdir) push_arg fw_dir_l "$@" || shift;;
--fscks) push_arg fscks_l "$@" || shift;;
--add-fstab) push_arg add_fstab_l "$@" || shift;;
--mount) push_arg fstab_lines "$@" || shift;;
--nofscks) nofscks_l="yes";;
-k|--kmoddir) read_arg drivers_dir_l "$@" || shift;;
-c|--conf) read_arg conffile "$@" || shift;;
@@ -226,6 +241,8 @@ while (($# > 0)); do
--nolvmconf) lvmconf_l="no";;
--debug) debug="yes";;
--profile) profile="yes";;
--ctty) cttyhack="yes";;
--sshkey) read_arg sshkey "$@" || shift;;
-v|--verbose) ((verbosity_mod_l++));;
-q|--quiet) ((verbosity_mod_l--));;
-l|--local) allowlocal="yes" ;;
@@ -265,9 +282,17 @@ if ! [[ $kernel ]]; then
fi
[[ $outfile ]] || outfile="/boot/initramfs-$kernel.img"
PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH
for i in /usr/sbin /sbin /usr/bin /bin; do
rl=$i
if [ -L "$i" ]; then
rl=$(readlink -f $i)
fi
NPATH+=":$rl"
done
export PATH="${NPATH#:}"
unset NPATH
unset LD_LIBRARY_PATH
unset GREP_OPTIONS
[[ $debug ]] && {
export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): ';
@@ -282,7 +307,7 @@ unset LD_LIBRARY_PATH
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
[[ $allowlocal && -f "$(readlink -f ${0%/*})/dracut-functions" ]] && \
[[ $allowlocal && -f "$(readlink -f ${0%/*})/dracut-functions.sh" ]] && \
dracutbasedir="$(readlink -f ${0%/*})"
# if we were not passed a config file, try the default one
@@ -319,22 +344,27 @@ if (( ${#force_add_dracutmodules_l[@]} )); then
done
fi
if (( ${#add_drivers_l[@]} )); then
while pop add_drivers_l val; do
add_drivers+=" $val "
done
fi
if (( ${#fscks_l[@]} )); then
while pop fscks_l val; do
fscks+=" $val "
done
fi
if (( ${#add_fstab_l[@]} )); then
while pop add_fstab_l val; do
add_fstab+=" $val "
done
fi
if (( ${#fstab_lines_l[@]} )); then
while pop fstab_lines_l val; do
push fstab_lines $val
done
fi
if (( ${#install_items_l[@]} )); then
while pop install_items_l val; do
push install_items $val
install_items+=" $val "
done
fi
@@ -353,13 +383,6 @@ if (( ${#omit_dracutmodules_l[@]} )); then
done
fi
if (( ${#drivers_l[@]} )); then
drivers=''
while pop drivers_l val; do
drivers+="$val "
done
fi
if (( ${#filesystems_l[@]} )); then
filesystems=''
while pop filesystems_l val; do
@@ -413,10 +436,10 @@ fi
[[ $hostonly = yes ]] && hostonly="-h"
[[ $hostonly != "-h" ]] && unset hostonly
if [[ -f $dracutbasedir/dracut-functions ]]; then
. $dracutbasedir/dracut-functions
if [[ -f $dracutbasedir/dracut-functions.sh ]]; then
. $dracutbasedir/dracut-functions.sh
else
echo "Cannot find $dracutbasedir/dracut-functions." >&2
echo "Cannot find $dracutbasedir/dracut-functions.sh." >&2
echo "Are you running from a git checkout?" >&2
echo "Try passing -l as an argument to $0" >&2
exit 1
@@ -429,9 +452,40 @@ if (( ${BASH_VERSINFO[0]} < 3 ||
exit 1
fi
dracutfunctions=$dracutbasedir/dracut-functions
dracutfunctions=$dracutbasedir/dracut-functions.sh
export dracutfunctions
if (( ${#drivers_l[@]} )); then
drivers=''
while pop drivers_l val; do
drivers+="$val "
done
fi
drivers=${drivers/-/_}
if (( ${#add_drivers_l[@]} )); then
while pop add_drivers_l val; do
add_drivers+=" $val "
done
fi
add_drivers=${add_drivers/-/_}
if (( ${#omit_drivers_l[@]} )); then
while pop omit_drivers_l val; do
omit_drivers+=" $val "
done
fi
omit_drivers=${omit_drivers/-/_}
omit_drivers_corrected=""
for d in $omit_drivers; do
strstr " $drivers $add_drivers " " $d " && continue
omit_drivers_corrected+="$d|"
done
omit_drivers="${omit_drivers_corrected%|}"
unset omit_drivers_corrected
ddebug "Executing $0 $dracut_args"
[[ $do_list = yes ]] && {
@@ -507,12 +561,73 @@ trap 'exit 1;' SIGINT
# Need to be able to have non-root users read stuff (rpcbind etc)
chmod 755 "$initdir"
for line in "${fstab_lines[@]}"; do
set -- $line
#dev mp fs fsopts
push host_devs "$1"
push host_fs_types "$1|$3"
done
for f in $add_fstab; do
[ -e $f ] || continue
while read dev rest; do
push host_devs $dev
done < $f
done
if [[ $hostonly ]]; then
# in hostonly mode, determine all devices, which have to be accessed
# and examine them for filesystem types
push host_mp \
"/" \
"/etc" \
"/usr" \
"/usr/bin" \
"/usr/sbin" \
"/usr/lib" \
"/usr/lib64" \
"/boot"
for mp in "${host_mp[@]}"; do
mountpoint "$mp" >/dev/null 2>&1 || continue
push host_devs $(readlink -f "/dev/block/$(find_block_device "$mp")")
done
fi
_get_fs_type() (
[[ $1 ]] || return
if [[ -b $1 ]] && get_fs_env $1; then
echo "$1|$ID_FS_TYPE"
return 1
fi
if [[ -b /dev/block/$1 ]] && get_fs_env /dev/block/$1; then
echo "/dev/block/$1|$ID_FS_TYPE"
return 1
fi
if fstype=$(find_dev_fstype $1); then
echo "$1|$fstype"
return 1
fi
return 1
)
for dev in "${host_devs[@]}"; do
unset fs_type
for fstype in $(_get_fs_type $dev) \
$(check_block_and_slaves _get_fs_type $(get_maj_min $dev)); do
if ! strstr " ${host_fs_types[*]} " " $fstype ";then
push host_fs_types "$fstype"
fi
done
done
export initdir dracutbasedir dracutmodules drivers \
fw_dir drivers_dir debug no_kernel kernel_only \
add_drivers mdadmconf lvmconf filesystems \
use_fstab libdir usrlibdir fscks nofscks \
add_drivers omit_drivers mdadmconf lvmconf filesystems \
use_fstab fstab_lines libdir usrlibdir fscks nofscks cttyhack \
stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
debug
debug host_fs_types host_devs sshkey
# Create some directory structure first
[[ $prefix ]] && mkdir -m 0755 -p "${initdir}${prefix}"
@@ -527,18 +642,18 @@ if [[ $prefix ]]; then
fi
if [[ $kernel_only != yes ]]; then
for d in bin etc lib "$libdir" sbin tmp usr var var/log usr/bin usr/sbin; do
for d in usr/bin usr/sbin bin etc lib "$libdir" sbin tmp usr var var/log; do
[[ -e "${initdir}${prefix}/$d" ]] && continue
if [ -h "/$d" ]; then
inst "/$d" "${prefix}/$d"
if [ -L "/$d" ]; then
inst_symlink "/$d" "${prefix}/$d"
else
mkdir -m 0755 -p "${initdir}${prefix}/$d"
fi
done
for d in dev proc sys sysroot root run run/lock run/initramfs; do
if [ -h "/$d" ]; then
inst "/$d"
if [ -L "/$d" ]; then
inst_symlink "/$d"
else
mkdir -m 0755 -p "$initdir/$d"
fi
@@ -557,9 +672,16 @@ else
done
fi
if [[ $kernel_only != yes ]]; then
mkdir -p "${initdir}/etc/cmdline.d"
fi
mods_to_load=""
# check all our modules to see if they should be sourced.
# This builds a list of modules that we will install next.
check_module_dir
for_each_module_dir check_module
for_each_module_dir check_mount
modules_loaded=" "
# source our modules.
for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
@@ -617,18 +739,23 @@ while pop include_src src && pop include_target tgt; do
fi
done
while pop install_items items; do
for item in $items; do
dracut_install "$item"
done
done
unset item
if [[ $kernel_only != yes ]]; then
for item in $install_items; do
dracut_install -o "$item"
done
unset item
while pop fstab_lines line; do
echo "$line 0 0" >> "${initdir}/etc/fstab"
done
for f in $add_fstab; do
cat $f >> "${initdir}/etc/fstab"
done
# make sure that library links are correct and up to date
for f in /etc/ld.so.conf /etc/ld.so.conf.d/*; do
[[ -e $f ]] && inst_simple "$f"
[[ -f $f ]] && inst_simple "$f"
done
if ! ldconfig -r "$initdir"; then
if [[ $UID = 0 ]]; then
@@ -668,11 +795,14 @@ type hardlink &>/dev/null && {
}
if strstr "$modules_loaded" " fips " && command -v prelink >/dev/null; then
for i in $initdir/bin/* \
$initdir/sbin/* \
$initdir/usr/bin/* \
$initdir/usr/sbin/*; do
[ -x $i ] && prelink -u $i &>/dev/null
for dir in "$initdir/bin" \
"$initdir/sbin" \
"$initdir/usr/bin" \
"$initdir/usr/sbin"; do
[[ -L "$dir" ]] && continue
for i in "$dir"/*; do
[[ -x $i ]] && prelink -u $i &>/dev/null
done
done
fi

View File

@@ -13,7 +13,7 @@ Version: xxx
Release: xxx
Summary: Initramfs generator using udev
%if 0%{?fedora} || 0%{?rhel} > 6
%if 0%{?fedora} || 0%{?rhel}
Group: System Environment/Base
%endif
%if 0%{?suse_version}
@@ -27,14 +27,15 @@ Source0: http://www.kernel.org/pub/linux/utils/boot/dracut/dracut-%{version}.tar
BuildArch: noarch
BuildRequires: dash bash git
%if 0%{?fedora} || 0%{?rhel} > 6
%if 0%{?fedora} || 0%{?rhel}
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%endif
%if 0%{?suse_version}
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
%if 0%{?fedora} || 0%{?rhel} > 6
%if 0%{?fedora} || 0%{?rhel}
BuildRequires: docbook-style-xsl docbook-dtds libxslt
%endif
@@ -42,7 +43,7 @@ BuildRequires: docbook-style-xsl docbook-dtds libxslt
BuildRequires: docbook-xsl-stylesheets libxslt
%endif
%if 0%{?fedora} > 12 || 0%{?rhel} >= 6
%if 0%{?fedora} > 12 || 0%{?rhel}
# no "provides", because dracut does not offer
# all functionality of the obsoleted packages
Obsoletes: mkinitrd <= 6.0.93
@@ -51,6 +52,10 @@ Obsoletes: nash <= 6.0.93
Obsoletes: libbdevid-python <= 6.0.93
%endif
%if 0%{?fedora} > 16 || 0%{?rhel} > 6
BuildRequires: systemd-units
%endif
%if 0%{?suse_version} > 9999
Obsoletes: mkinitrd < 2.6.1
Provides: mkinitrd = 2.6.1
@@ -63,22 +68,22 @@ Requires: bash
Requires: bzip2
Requires: coreutils
Requires: cpio
Requires: dash
Requires: filesystem >= 2.1.0
Requires: findutils
Requires: grep
Requires: gzip
Requires: kbd
Requires: mktemp >= 1.5-5
Requires: module-init-tools >= 3.7-9
Requires: sed
Requires: tar
Requires: udev
%if 0%{?fedora} || 0%{?rhel} > 6
Requires: util-linux >= 2.20
%else
Requires: util-linux-ng >= 2.17.2
%endif
%if 0%{?fedora} || 0%{?rhel} > 6
Requires: initscripts >= 8.63-1
Requires: plymouth >= 0.8.0-0.2009.29.09.19.1
Conflicts: initscripts < 8.63-1
Conflicts: plymouth < 0.8.0-0.2009.29.09.19.1
%endif
%description
@@ -91,24 +96,6 @@ NFS, iSCSI, NBD, FCoE with the dracut-network package.
%package network
Summary: Dracut modules to build a dracut initramfs with network support
Requires: %{name} = %{version}-%{release}
Requires: rpcbind
%if %{with_nbd}
Requires: nbd
%endif
Requires: iproute
Requires: bridge-utils
%if 0%{?fedora} || 0%{?rhel} > 6
Requires: iscsi-initiator-utils
Requires: nfs-utils
Requires: dhclient
%endif
%if 0%{?suse_version}
Requires: dhcp-client
Requires: nfs-client
Requires: vlan
%endif
Obsoletes: dracut-generic < 008
Provides: dracut-generic = %{version}-%{release}
@@ -116,7 +103,7 @@ Provides: dracut-generic = %{version}-%{release}
This package requires everything which is needed to build a generic
all purpose initramfs with network support with dracut.
%if 0%{?fedora} || 0%{?rhel} > 6
%if 0%{?fedora} || 0%{?rhel} >= 6
%package fips
Summary: Dracut modules to build a dracut initramfs with an integrity check
Requires: %{name} = %{version}-%{release}
@@ -140,7 +127,7 @@ Requires: %{name}-fips = %{version}-%{release}
%description fips-aesni
This package requires everything which is needed to build an
all purpose initramfs with dracut, which does an integrity check
all purpose initramfs with dracut, which does an integrity check
and adds the aesni-intel kernel module.
%package caps
@@ -177,12 +164,15 @@ git am -p1 %{patches}
make
%install
%if 0%{?fedora} || 0%{?rhel} > 6
%if 0%{?fedora} || 0%{?rhel}
rm -rf $RPM_BUILD_ROOT
%endif
make install DESTDIR=$RPM_BUILD_ROOT \
libdir=%{_prefix}/lib \
bindir=%{_bindir} \
%if %{defined _unitdir}
systemdsystemunitdir=%{_unitdir} \
%endif
sysconfdir=/etc mandir=%{_mandir}
echo %{name}-%{version}-%{release} > $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/10rpmversion/dracut-version
@@ -201,7 +191,7 @@ mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/log
touch $RPM_BUILD_ROOT%{_localstatedir}/log/dracut.log
mkdir -p $RPM_BUILD_ROOT%{_sharedstatedir}/initramfs
%if 0%{?fedora} || 0%{?rhel} > 6
%if 0%{?fedora} || 0%{?rhel}
install -m 0644 dracut.conf.d/fedora.conf.example $RPM_BUILD_ROOT/etc/dracut.conf.d/01-dist.conf
install -m 0644 dracut.conf.d/fips.conf.example $RPM_BUILD_ROOT/etc/dracut.conf.d/40-fips.conf
%endif
@@ -218,6 +208,10 @@ rm $RPM_BUILD_ROOT%{_bindir}/lsinitrd
mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d
install -m 0644 dracut.logrotate $RPM_BUILD_ROOT/etc/logrotate.d/dracut_log
# create compat symlink
mkdir -p $RPM_BUILD_ROOT/sbin
ln -s /usr/bin/dracut $RPM_BUILD_ROOT/sbin/dracut
%clean
rm -rf $RPM_BUILD_ROOT
@@ -225,16 +219,20 @@ rm -rf $RPM_BUILD_ROOT
%defattr(-,root,root,0755)
%doc README HACKING TODO COPYING AUTHORS NEWS dracut.html dracut.png dracut.svg
%{_bindir}/dracut
# compat symlink
/sbin/dracut
%if 0%{?fedora} > 12 || 0%{?rhel} >= 6 || 0%{?suse_version} > 9999
%{_bindir}/mkinitrd
%{_bindir}/lsinitrd
%endif
%dir %{dracutlibdir}
%dir %{dracutlibdir}/modules.d
%{dracutlibdir}/dracut-functions.sh
%{dracutlibdir}/dracut-functions
%{dracutlibdir}/dracut-logger
%{dracutlibdir}/dracut-logger.sh
%{dracutlibdir}/dracut-initramfs-restore
%config(noreplace) /etc/dracut.conf
%if 0%{?fedora} || 0%{?suse_version} || 0%{?rhel} > 6
%if 0%{?fedora} || 0%{?suse_version} || 0%{?rhel}
%config /etc/dracut.conf.d/01-dist.conf
%endif
%dir /etc/dracut.conf.d
@@ -247,6 +245,8 @@ rm -rf $RPM_BUILD_ROOT
%{dracutlibdir}/modules.d/05busybox
%{dracutlibdir}/modules.d/10i18n
%{dracutlibdir}/modules.d/10rpmversion
%{dracutlibdir}/modules.d/30convertfs
%{dracutlibdir}/modules.d/45url-lib
%{dracutlibdir}/modules.d/50plymouth
%{dracutlibdir}/modules.d/90btrfs
%{dracutlibdir}/modules.d/90crypt
@@ -277,10 +277,15 @@ rm -rf $RPM_BUILD_ROOT
%{dracutlibdir}/modules.d/98usrmount
%{dracutlibdir}/modules.d/99base
%{dracutlibdir}/modules.d/99fs-lib
%{dracutlibdir}/modules.d/99img-lib
%{dracutlibdir}/modules.d/99shutdown
%config(noreplace) /etc/logrotate.d/dracut_log
%attr(0644,root,root) %ghost %config(missingok,noreplace) %{_localstatedir}/log/dracut.log
%dir %{_sharedstatedir}/initramfs
%if %{defined _unitdir}
%{_unitdir}/*.service
%{_unitdir}/*/*.service
%endif
%files network
%defattr(-,root,root,0755)
@@ -290,10 +295,11 @@ rm -rf $RPM_BUILD_ROOT
%{dracutlibdir}/modules.d/90livenet
%{dracutlibdir}/modules.d/95nbd
%{dracutlibdir}/modules.d/95nfs
%{dracutlibdir}/modules.d/95ssh-client
%{dracutlibdir}/modules.d/45ifcfg
%{dracutlibdir}/modules.d/95znet
%if 0%{?fedora} || 0%{?rhel} > 6
%if 0%{?fedora} || 0%{?rhel}
%files fips
%defattr(-,root,root,0755)
%{dracutlibdir}/modules.d/01fips

View File

@@ -301,7 +301,7 @@ rd.live.overlay/
</para>
</listitem>
<listitem>
<para>Add &apos;&apos;rd.shell rd.debug&apos;&apos; to the kernel command line so that dracut shell commands are printed as they are executed
<para>Add &apos;&apos;rd.shell rd.debug log_buf_len=1M&apos;&apos; to the kernel command line so that dracut shell commands are printed as they are executed
</para>
</listitem>
<listitem>

View File

@@ -20,7 +20,7 @@ sub create_patches {
my $tag=shift;
my $pdir=shift;
my $num=0;
open( GIT, 'git format-patch -N --no-signature -o "'.$pdir.'" '.$tag.' |');
open( GIT, 'git format-patch -M -N --no-signature -o "'.$pdir.'" '.$tag.' |');
@lines=<GIT>;
close GIT; # be done
return @lines;

View File

@@ -19,19 +19,33 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
[[ $# -le 2 ]] || { echo "Usage: $(basename $0) [<initramfs file> [<filename>]]" ; exit 1 ; }
[[ $# -le 2 ]] || { echo "Usage: $(basename $0) [-s] [<initramfs file> [<filename>]]" ; exit 1 ; }
sorted=0
while getopts "s" opt; do
case $opt in
s) sorted=1;;
\?) exit 1;;
esac
done
shift $((OPTIND-1))
image="${1:-/boot/initramfs-$(uname -r).img}"
[[ -f "$image" ]] || { echo "$image does not exist" ; exit 1 ; }
CAT=zcat
FILE_T=$(file "$image")
if echo "test"|xz|xz -dc --single-stream >/dev/null 2>&1; then
XZ_SINGLE_STREAM="--single-stream"
fi
if [[ "$FILE_T" =~ ": gzip compressed data" ]]; then
CAT=zcat
elif [[ "$FILE_T" =~ ": xz compressed data" ]]; then
CAT=xzcat
CAT="xzcat $XZ_SINGLE_STREAM"
elif [[ "$FILE_T" =~ ": XZ compressed data" ]]; then
CAT=xzcat
CAT="xzcat $XZ_SINGLE_STREAM"
elif [[ "$FILE_T" =~ ": data" ]]; then
CAT=lzcat
fi
@@ -45,5 +59,9 @@ echo "$image: $(du -h $image | awk '{print $1}')"
echo "========================================================================"
$CAT "$image" | cpio --extract --verbose --quiet --to-stdout 'lib/dracut/dracut-*' 2>/dev/null
echo "========================================================================"
$CAT "$image" | cpio --extract --verbose --quiet --list
if [ "$sorted" -eq 1 ]; then
$CAT "$image" | cpio --extract --verbose --quiet --list | sort -n -k5
else
$CAT "$image" | cpio --extract --verbose --quiet --list
fi
echo "========================================================================"

View File

@@ -8,6 +8,7 @@ usage () {
$cmd "usage: ${0##*/} [--version] [--help] [-v] [-f] [--preload <module>]"
$cmd " [--image-version] [--with=<module>]"
$cmd " [--nocompress]"
$cmd " <initrd-image> <kernel-version>"
$cmd ""
$cmd " (ex: ${0##*/} /boot/initramfs-$kver.img $kver)"
@@ -49,10 +50,10 @@ while (($# > 0)); do
exit 0;;
-v|--verbose) dracut_args="${dracut_args} -v";;
-f|--force) dracut_args="${dracut_args} -f";;
--preload) read_args modname "$@" || shift
--preload) read_arg modname "$@" || shift
basicmodules="$basicmodules $modname";;
--image-version) img_vers=yes;;
--rootfs) read_args rootfs "$@" || shift
--rootfs) read_arg rootfs "$@" || shift
dracut_args="${dracut_args} --filesystems $rootfs";;
--nocompress) dracut_args="$dracut_args --no-compress";;
--help) usage -n;;

View File

@@ -3,6 +3,7 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
[[ "$mount_needs" ]] && return 1
[ -x /sbin/bootchartd ] || return 1
return 255
}

View File

@@ -47,6 +47,8 @@ The following variables are used by i18n install script and at initramfs
runtime:
KEYMAP - keyboard translation table loaded by loadkeys
KEYTABLE - base name for keyboard translation table; if UNICODE is
true, Unicode version will be loaded. Overrides KEYMAP.
EXT_KEYMAPS - list of extra keymaps to bo loaded (sep. by space)
UNICODE - boolean, indicating UTF-8 mode
FONT - console font

View File

@@ -3,6 +3,7 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
[[ "$mount_needs" ]] && return 1
return 0
}
@@ -83,7 +84,7 @@ install() {
install_base() {
dracut_install setfont loadkeys kbd_mode stty
inst ${moddir}/console_init /lib/udev/console_init
inst ${moddir}/console_init.sh /lib/udev/console_init
inst_rules ${moddir}/10-console.rules
inst_hook cmdline 20 "${moddir}/parse-i18n.sh"
}
@@ -110,8 +111,38 @@ install() {
[ -f $I18N_CONF ] && . $I18N_CONF
[ -f $VCONFIG_CONF ] && . $VCONFIG_CONF
shopt -q -s nocasematch
if [[ ${UNICODE} ]]
then
if [[ ${UNICODE} = YES || ${UNICODE} = 1 ]]
then
UNICODE=1
elif [[ ${UNICODE} = NO || ${UNICODE} = 0 ]]
then
UNICODE=0
else
UNICODE=''
fi
fi
if [[ ! ${UNICODE} && ${LANG} =~ .*\.UTF-?8 ]]
then
UNICODE=1
fi
shopt -q -u nocasematch
# Gentoo user may have KEYMAP set to something like "-u pl2",
KEYMAP=${KEYMAP#-* }
# KEYTABLE is a bit special - it defines base keymap name and UNICODE
# determines whether non-UNICODE or UNICODE version is used
if [[ ${KEYTABLE} ]]; then
if [[ ${UNICODE} == 1 ]]; then
[[ ${KEYTABLE} =~ .*\.uni.* ]] || KEYTABLE=${KEYTABLE%.map*}.uni
fi
KEYMAP=${KEYTABLE}
fi
# I'm not sure of the purpose of UNIKEYMAP and GRP_TOGGLE. They were in
# original redhat-i18n module. Anyway it won't hurt.
EXT_KEYMAPS+=\ ${UNIKEYMAP}\ ${GRP_TOGGLE}
@@ -150,25 +181,6 @@ install() {
inst_simple ${kbddir}/unimaps/${FONT_UNIMAP}.uni
fi
shopt -q -s nocasematch
if [[ ${UNICODE} ]]
then
if [[ ${UNICODE} = YES || ${UNICODE} = 1 ]]
then
UNICODE=1
elif [[ ${UNICODE} = NO || ${UNICODE} = 0 ]]
then
UNICODE=0
else
UNICODE=''
fi
fi
if [[ ! ${UNICODE} && ${LANG} =~ .*\.UTF-?8 ]]
then
UNICODE=1
fi
shopt -q -u nocasematch
mksubdirs ${initdir}${I18N_CONF}
mksubdirs ${initdir}${VCONFIG_CONF}
print_vars LC_ALL LANG >> ${initdir}${I18N_CONF}

View File

@@ -3,6 +3,7 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
[[ "$mount_needs" ]] && return 1
[ -f /etc/redhat-release ]
}

View File

@@ -0,0 +1,181 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
ROOT="$1"
if [[ ! -d "$ROOT" ]]; then
echo "Usage: $0 <rootdir>"
exit 1
fi
if [[ "$ROOT" -ef / ]]; then
echo "Can't convert the running system."
echo "Please boot with 'rd.convertfs' on the kernel command line,"
echo "to update with the help of the initramfs,"
echo "or run this script from a rescue system."
exit 1
fi
while [[ "$ROOT" != "${ROOT%/}" ]]; do
ROOT=${ROOT%/}
done
if [ ! -L $ROOT/var/run ]; then
echo "Converting /var/run to symlink"
mv -f $ROOT/var/run $ROOT/var/run.runmove~
ln -sfn ../run $ROOT/var/run
fi
if [ ! -L $ROOT/var/lock ]; then
echo "Converting /var/lock to symlink"
mv -f $ROOT/var/lock $ROOT/var/lock.lockmove~
ln -sfn ../run/lock $ROOT/var/lock
fi
needconvert() {
for dir in "$ROOT/bin" "$ROOT/sbin" "$ROOT/lib" "$ROOT/lib64"; do
if [[ -e "$dir" ]]; then
[[ -L "$dir" ]] || return 0
fi
done
return 1
}
if ! needconvert; then
echo "Your system is already converted."
exit 0
fi
if [ -e "$ROOT/usr/bin" ]; then
echo "$ROOT/usr/bin does not exist"
exit 1
fi
testfile="$ROOT/.usrmovecheck$$"
rm -f "$testfile"
> "$testfile"
if [[ ! -e "$testfile" ]]; then
echo "Cannot write to $ROOT/"
exit 1
fi
rm -f "$testfile"
testfile="$ROOT/usr/.usrmovecheck$$"
rm -f "$testfile"
> "$testfile"
if [[ ! -e "$testfile" ]]; then
echo "Cannot write to $ROOT/usr/"
exit 1
fi
rm -f "$testfile"
ismounted() {
while read a m a; do
[[ "$m" = "$1" ]] && return 0
done < /proc/mounts
return 1
}
# clean up after ourselves no matter how we die.
cleanup() {
echo "Something failed. Move back to the original state"
for dir in "$ROOT/bin" "$ROOT/sbin" "$ROOT/lib" "$ROOT/lib64" \
"$ROOT/usr/bin" "$ROOT/usr/sbin" "$ROOT/usr/lib" \
"$ROOT/usr/lib64"; do
[[ -d "${dir}.usrmove-new" ]] && rm -fr "${dir}.usrmove-new"
if [[ -d "${dir}.usrmove-old" ]]; then
mv "$dir" "${dir}.del~"
mv "${dir}.usrmove-old" "$dir"
rm -fr "${dir}.del~"
fi
done
}
trap 'ret=$?; [[ $ret -ne 0 ]] && cleanup;exit $ret;' EXIT
trap 'exit 1;' SIGINT
ismounted "$ROOT/usr" || CP_HARDLINK="-l"
set -e
# merge / and /usr in new dir in /usr
for dir in bin sbin lib lib64; do
rm -rf "$ROOT/usr/${dir}.usrmove-new"
[[ -L "$ROOT/$dir" ]] && continue
[[ -d "$ROOT/$dir" ]] || continue
echo "Make a copy of \`$ROOT/usr/$dir'."
[[ -d "$ROOT/usr/$dir" ]] \
&& cp -ax $CP_HARDLINK "$ROOT/usr/$dir" "$ROOT/usr/${dir}.usrmove-new"
echo "Merge the copy with \`$ROOT/$dir'."
[[ -d "$ROOT/usr/${dir}.usrmove-new" ]] \
|| mkdir -p "$ROOT/usr/${dir}.usrmove-new"
cp -axT $CP_HARDLINK --backup --suffix=.usrmove~ "$ROOT/$dir" "$ROOT/usr/${dir}.usrmove-new"
echo "Clean up duplicates in \`$ROOT/usr/$dir'."
# delete all symlinks that have been backed up
find "$ROOT/usr/${dir}.usrmove-new" -type l -name '*.usrmove~' -delete || :
# replace symlink with backed up binary
find "$ROOT/usr/${dir}.usrmove-new" \
-name '*.usrmove~' \
-type f \
-exec bash -c 'p="{}";o=${p%%%%.usrmove~};
[[ -L "$o" ]] && mv -f "$p" "$o"' ';' || :
done
# switch over merged dirs in /usr
for dir in bin sbin lib lib64; do
[[ -d "$ROOT/usr/${dir}.usrmove-new" ]] || continue
echo "Switch to new \`$ROOT/usr/$dir'."
rm -fr "$ROOT/usr/${dir}.usrmove-old"
mv "$ROOT/usr/$dir" "$ROOT/usr/${dir}.usrmove-old"
mv "$ROOT/usr/${dir}.usrmove-new" "$ROOT/usr/$dir"
done
# replace dirs in / with links to /usr
for dir in bin sbin lib lib64; do
[[ -L "$ROOT/$dir" ]] && continue
[[ -d "$ROOT/$dir" ]] || continue
echo "Create \`$ROOT/$dir' symlink."
rm -rf "$ROOT/${dir}.usrmove-old" || :
mv "$ROOT/$dir" "$ROOT/${dir}.usrmove-old"
ln -sfn usr/$dir "$ROOT/$dir"
done
echo "Clean up backup files."
# everything seems to work; cleanup
for dir in bin sbin lib lib64; do
# if we get killed in the middle of "rm -rf", ensure not to leave
# an incomplete directory, which is moved back by cleanup()
[[ -d "$ROOT/usr/${dir}.usrmove-old" ]] \
&& mv "$ROOT/usr/${dir}.usrmove-old" "$ROOT/usr/${dir}.usrmove-old~"
[[ -d "$ROOT/${dir}.usrmove-old" ]] \
&& mv "$ROOT/${dir}.usrmove-old" "$ROOT/${dir}.usrmove-old~"
done
for dir in bin sbin lib lib64; do
[[ -d "$ROOT/usr/${dir}.usrmove-old~" ]] \
&& rm -rf "$ROOT/usr/${dir}.usrmove-old~" || :
[[ -d "$ROOT/${dir}.usrmove-old~" ]] \
&& rm -rf "$ROOT/${dir}.usrmove-old~" || :
done
for dir in lib lib64; do
[[ -d "$ROOT/$dir" ]] || continue
for lib in "$ROOT"/usr/${dir}/lib*.so*.usrmove~; do
[[ -f $lib ]] || continue
mv $lib ${lib/.so/_so}
done
done
set +e
echo "Run ldconfig."
ldconfig -r "$ROOT"
. $ROOT/etc/selinux/config
if [ -n "$(command -v setfiles)" ] && [ "$SELINUX" != "disabled" ] && [ -f /etc/selinux/${SELINUXTYPE}/contexts/files/file_contexts ]; then
echo "Fixing SELinux labels"
setfiles -r $ROOT -p /etc/selinux/${SELINUXTYPE}/contexts/files/file_contexts $ROOT/sbin $ROOT/bin $ROOT/lib $ROOT/lib64 $ROOT/usr/lib $ROOT/usr/lib64 $ROOT/etc/ld.so.cache $ROOT/var/cache/ldconfig || :
fi
echo "Done."
exit 0

View File

@@ -0,0 +1,11 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
if getargbool 0 rd.convertfs; then
if getargbool 0 rd.debug; then
bash -x convertfs "$NEWROOT" 2>&1 | vinfo
else
convertfs "$NEWROOT" 2>&1 | vinfo
fi
fi

View File

@@ -0,0 +1,20 @@
#!/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
return 255
}
depends() {
return 0
}
install() {
dracut_install bash
dracut_install find ldconfig mv rm cp ln
inst_hook pre-pivot 99 "$moddir/do-convertfs.sh"
inst "$moddir/convertfs.sh" /usr/bin/convertfs
}

View File

@@ -41,7 +41,9 @@ setup_interface() {
done
fi >> /tmp/net.$netif.resolv.conf
[ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
# Note: hostname can be fqdn OR short hostname, so chop off any
# trailing domain name and explicity add any domain if set.
[ -n "$hostname" ] && echo "echo ${hostname%.$domain}${domain+.$domain} > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
}
PATH=/usr/sbin:/usr/bin:/sbin:/bin
@@ -74,7 +76,13 @@ case $reason in
echo "$line"
done >/tmp/dhclient.$netif.dhcpopts
echo online > /sys/class/net/$netif/uevent
initqueue --onetime --name netroot-$netif netroot $netif
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 "dhcp: $reason";;
esac

View File

@@ -5,9 +5,54 @@
# We don't need to check for ip= errors here, that is handled by the
# cmdline parser script
#
# without $2 means this is for real netroot case
# or it is for manually bring up network ie. for kdump scp vmcore
PATH=/usr/sbin:/usr/bin:/sbin:/bin
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
export PS4="ifup.$1.$$ + "
exec >>/run/initramfs/loginit.pipe 2>>/run/initramfs/loginit.pipe
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
# Huh? No $1?
[ -z "$1" ] && exit 1
# $netif reads easier than $1
netif=$1
# enslave this interface to bond?
if [ -e /tmp/bond.info ]; then
. /tmp/bond.info
for slave in $bondslaves ; do
if [ "$netif" = "$slave" ] ; then
netif=$bondname
fi
done
fi
# bridge this interface?
if [ -e /tmp/bridge.info ]; then
. /tmp/bridge.info
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
fi
# bail immediately if the interface is already up
# or we don't need the network
[ -f "/tmp/net.$netif.up" ] && exit 0
[ -f "/tmp/root.info" ] || exit 0
. /tmp/root.info
# disable manual ifup while netroot is set for simplifying our logic
# in netroot case we prefer netroot to bringup $netif automaticlly
[ -n "$2" ] && [ -z "$netroot" ] && manualup="$2"
[ -z "$netroot" ] && [ -z "$manualup" ] && exit 0
[ -n "$manualup" ] && >/tmp/net.$netif.manualup
# Run dhclient
do_dhcp() {
@@ -50,7 +95,11 @@ do_ipv6auto() {
echo online > /sys/class/net/$netif/uevent
initqueue --onetime --name netroot-$netif netroot $netif
if [ -n "$manualup" ]; then
/sbin/netroot $netif -m
else
initqueue --onetime --name netroot-$netif netroot $netif
fi
}
# Handle static ip configuration
@@ -77,47 +126,12 @@ do_static() {
fi >> /tmp/net.$netif.resolv.conf
echo online > /sys/class/net/$netif/uevent
initqueue --onetime --name netroot-$netif netroot $netif
}
export PS4="ifup.$1.$$ + "
exec >>/run/initramfs/loginit.pipe 2>>/run/initramfs/loginit.pipe
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
# Huh? No $1?
[ -z "$1" ] && exit 1
# $netif reads easier than $1
netif=$1
# enslave this interface to bond?
if [ -e /tmp/bond.info ]; then
. /tmp/bond.info
for slave in $bondslaves ; do
if [ "$netif" = "$slave" ] ; then
netif=$bondname
fi
done
fi
# bridge this interface?
if [ -e /tmp/bridge.info ]; then
. /tmp/bridge.info
if [ "$netif" = "$ethname" ]; then
if [ "$netif" = "$bondname" ] && [ -n "$DO_BOND_SETUP" ] ; then
: # We need to really setup bond (recursive call)
else
netif="$bridgename"
fi
if [ -n "$manualup" ]; then
/sbin/netroot $netif -m
else
initqueue --onetime --name netroot-$netif netroot $netif
fi
fi
# bail immediately if the interface is already up
# or we don't need the network
[ -f "/tmp/net.$netif.up" ] && exit 0
[ -f "/tmp/root.info" ] || exit 0
. /tmp/root.info
[ -z "$netroot" ] && exit 0
}
# loopback is always handled the same way
if [ "$netif" = "lo" ] ; then
@@ -228,5 +242,4 @@ for p in $(getargs ip=); do
esac
break
done
exit 0

View File

@@ -36,6 +36,7 @@ installkernel() {
case "$_fname" in
*.ko) _fcont="$(< $_fname)" ;;
*.ko.gz) _fcont="$(gzip -dc $_fname)" ;;
*.ko.xz) _fcont="$(xz -dc $_fname)" ;;
esac
[[ $_fcont =~ $_net_drivers
&& ! $_fcont =~ iw_handler_get_spy ]] \
@@ -57,7 +58,8 @@ installkernel() {
[[ $debug ]] && set -x
}
find_kernel_modules_by_path drivers/net | net_module_filter | instmods
{ find_kernel_modules_by_path drivers/net; find_kernel_modules_by_path drivers/s390/net; } \
| net_module_filter | instmods
instmods ecb arc4
# bridge modules
@@ -71,9 +73,10 @@ install() {
local _arch _i _dir
dracut_install ip arping tr dhclient
dracut_install -o brctl ifenslave
inst "$moddir/ifup" "/sbin/ifup"
inst "$moddir/netroot" "/sbin/netroot"
inst "$moddir/dhclient-script" "/sbin/dhclient-script"
inst "$moddir/ifup.sh" "/sbin/ifup"
inst "$moddir/netroot.sh" "/sbin/netroot"
inst "$moddir/dhclient-script.sh" "/sbin/dhclient-script"
inst "$moddir/net-lib.sh" "/lib/net-lib.sh"
inst_simple "$moddir/dhclient.conf" "/etc/dhclient.conf"
inst_hook pre-udev 50 "$moddir/ifname-genrules.sh"
inst_hook pre-udev 60 "$moddir/net-genrules.sh"

View File

@@ -14,7 +14,7 @@ fix_bootif() {
}
# Don't continue if we don't need network
[ -z "$netroot" ] && return;
[ -z "$netroot" ] && ! getargbool 0 rd.neednet && return;
# Write udev rules
{
@@ -35,17 +35,29 @@ fix_bootif() {
BOOTIF=$(getarg 'BOOTIF=')
if [ -n "$BOOTIF" ] ; then
BOOTIF=$(fix_bootif "$BOOTIF")
printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="/sbin/ifup $env{INTERFACE}"\n' "$BOOTIF"
if [ -n "$netroot" ]; then
printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", OPTIONS+="event_timeout=360", RUN+="/sbin/ifup $env{INTERFACE}"\n' "$BOOTIF"
else
printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", OPTIONS+="event_timeout=360", RUN+="/sbin/ifup $env{INTERFACE} -m"\n' "$BOOTIF"
fi
# If we have to handle multiple interfaces, handle only them.
elif [ -n "$IFACES" ] ; then
for iface in $IFACES ; do
printf 'SUBSYSTEM=="net", ENV{INTERFACE}=="%s", RUN+="/sbin/ifup $env{INTERFACE}"\n' "$iface"
if [ -n "$netroot" ]; then
printf 'SUBSYSTEM=="net", ENV{INTERFACE}=="%s", OPTIONS+="event_timeout=360", RUN+="/sbin/ifup $env{INTERFACE}"\n' "$iface"
else
printf 'SUBSYSTEM=="net", ENV{INTERFACE}=="%s", OPTIONS+="event_timeout=360", RUN+="/sbin/ifup $env{INTERFACE} -m"\n' "$iface"
fi
done
# Default: We don't know the interface to use, handle all
else
printf 'SUBSYSTEM=="net", RUN+="/sbin/ifup $env{INTERFACE}"\n'
if [ -n "$netroot" ]; then
printf 'SUBSYSTEM=="net", OPTIONS+="event_timeout=360", RUN+="/sbin/ifup $env{INTERFACE}"\n'
else
printf 'SUBSYSTEM=="net", OPTIONS+="event_timeout=360", RUN+="/sbin/ifup $env{INTERFACE} -m"\n'
fi
fi
} > /etc/udev/rules.d/60-net.rules

View File

@@ -0,0 +1,33 @@
#!/bin/sh
get_ip() {
local iface="$1" ip=""
ip=$(ip -o -f inet addr show $iface)
ip=${ip%%/*}
ip=${ip##* }
}
iface_for_remote_addr() {
set -- $(ip -o route get to $1)
echo $5
}
iface_for_mac() {
local interface="" mac="$(echo $1 | tr '[:upper:]' '[:lower:]')"
for interface in /sys/class/net/*; do
if [ $(cat $interface/address) = "$mac" ]; then
echo ${interface##*/}
fi
done
}
iface_has_link() {
local interface="$1" flags=""
[ -n "$interface" ] || return 2
interface="/sys/class/net/$interface"
[ -d "$interface" ] || return 2
flags=$(cat $interface/flags)
echo $(($flags|0x41)) > $interface/flags # 0x41: IFF_UP|IFF_RUNNING
[ "$(cat $interface/carrier)" = 1 ] || return 1
# XXX Do we need to reset the flags here? anaconda never bothered..
}

View File

@@ -3,7 +3,6 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
PATH=/usr/sbin:/usr/bin:/sbin:/bin
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
# Huh? Empty $1?
@@ -12,12 +11,16 @@ type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
# Huh? No interface config?
[ ! -e /tmp/net.$1.up ] && exit 1
# There's no sense in doing something if no (net)root info is available
# [ ! -z $2 ] means this is for manually bringing up network
# instead of real netroot; If It's called without $2, then there's
# no sense in doing something if no (net)root info is available
# or root is already there
[ -e /tmp/root.info ] || exit 1
. /tmp/root.info
[ -d $NEWROOT/proc ] && exit 0
[ -z "$netroot" ] && exit 1
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
@@ -31,43 +34,49 @@ done
netif=$1
[ -e "/tmp/net.bootdev" ] && read netif < /tmp/net.bootdev
# Figure out the handler for root=dhcp by recalling all netroot cmdline
# handlers
if [ "$netroot" = "dhcp" ] || [ "$netroot" = "dhcp6" ] ; then
# Unset root so we can check later
unset root
# Load dhcp options
[ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
# If we have a specific bootdev with no dhcpoptions or empty root-path,
# we die. Otherwise we just warn
if [ -z "$new_root_path" ] ; then
[ -n "$BOOTDEV" ] && die "No dhcp root-path received for '$BOOTDEV'"
warn "No dhcp root-path received for '$BOOTDEV' trying other interfaces if available"
exit 1
fi
# Set netroot to new_root_path, so cmdline parsers don't call
netroot=$new_root_path
# FIXME!
for f in $hookdir/cmdline/90*.sh; do
[ -f "$f" ] && . "$f";
done
else
rootok="1"
if [ -e /tmp/net.$netif.manualup ]; then
rm -f /tmp/net.$netif.manualup
fi
# Check: do we really know how to handle (net)root?
[ -z "$root" ] && die "No or empty root= argument"
[ -z "$rootok" ] && die "Don't know how to handle 'root=$root'"
# Figure out the handler for root=dhcp by recalling all netroot cmdline
# handlers when this is not called from manually network bringing up.
if [ -z "$2" ]; then
if [ "$netroot" = "dhcp" ] || [ "$netroot" = "dhcp6" ] ; then
# Unset root so we can check later
unset root
handler=${netroot%%:*}
handler=${handler%%4}
handler=$(command -v ${handler}root)
if [ -z "$netroot" ] || [ ! -e "$handler" ] ; then
die "No handler for netroot type '$netroot'"
# Load dhcp options
[ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
# If we have a specific bootdev with no dhcpoptions or empty root-path,
# we die. Otherwise we just warn
if [ -z "$new_root_path" ] ; then
[ -n "$BOOTDEV" ] && die "No dhcp root-path received for '$BOOTDEV'"
warn "No dhcp root-path received for '$BOOTDEV' trying other interfaces if available"
exit 1
fi
# Set netroot to new_root_path, so cmdline parsers don't call
netroot=$new_root_path
# FIXME!
for f in $hookdir/cmdline/90*.sh; do
[ -f "$f" ] && . "$f";
done
else
rootok="1"
fi
# Check: do we really know how to handle (net)root?
[ -z "$root" ] && die "No or empty root= argument"
[ -z "$rootok" ] && die "Don't know how to handle 'root=$root'"
handler=${netroot%%:*}
handler=${handler%%4}
handler=$(command -v ${handler}root)
if [ -z "$netroot" ] || [ ! -e "$handler" ] ; then
die "No handler for netroot type '$netroot'"
fi
fi
# We're here, so we can assume that upping interfaces is now ok
@@ -122,8 +131,11 @@ if [ -n "$dest" ] && ! arping -q -f -w 60 -I $netif $dest ; then
dinfo "Resolving $dest via ARP on $netif failed"
fi
# exit in case manually bring up network
[ -n "$2" ] && exit 0
# Source netroot hooks before we start the handler
source_all netroot
source_all $hookdir/netroot
# Run the handler; don't store the root, it may change from device to device
# XXX other variables to export?

View File

@@ -25,7 +25,8 @@ parse_ifname_opts() {
case $# in
7)
ifname_if=$1
ifname_mac=$2:$3:$4:$5:$6:$7
# udev requires MAC addresses to be lower case
ifname_mac=`echo $2:$3:$4:$5:$6:$7 | tr '[:upper:]' '[:lower:]'`
;;
*)
die "Invalid arguments for ifname="

View File

@@ -7,7 +7,7 @@
#
# ip=<interface>:[dhcp|on|any]
#
# ip=<client-IP-number>:<server-id>:<gateway-IP-number>:<netmask>:<client-hostname>:<interface>:[dhcp|on|any|none|off]
# ip=<client-IP-number>:<server-IP-number>:<gateway-IP-number>:<netmask>:<client-hostname>:<interface>:[dhcp|on|any|none|off]
#
# When supplying more than only ip= line, <interface> is mandatory and
# bootdev= must contain the name of the primary interface to use for
@@ -38,12 +38,13 @@ fi
# Count ip= lines to decide whether we need bootdev= or not
if [ -z "$NEEDBOOTDEV" ] ; then
local count=0
count=0
for p in $(getargs ip=); do
count=$(( $count + 1 ))
done
[ $count -gt 1 ] && NEEDBOOTDEV=1
fi
unset count
# If needed, check if bootdev= contains anything usable
if [ -n "$NEEDBOOTDEV" ] ; then

View File

@@ -0,0 +1,24 @@
#!/bin/bash
# module-setup for url-lib
check() {
command -v curl >/dev/null || return 1
return 255
}
depends() {
echo network
return 0
}
install() {
inst "$moddir/url-lib.sh" "/lib/url-lib.sh"
dracut_install curl
mkdir -m 0755 -p "$initdir/etc/ssl/certs"
if ! inst_any -t /etc/ssl/certs/ca-bundle.crt \
/etc/ssl/certs/ca-bundle.crt \
/etc/ssl/certs/ca-certificates.crt; then
dwarn "Couldn't find SSL CA cert bundle; HTTPS won't work."
fi
}

115
modules.d/45url-lib/url-lib.sh Executable file
View File

@@ -0,0 +1,115 @@
#!/bin/sh
# url-lib.sh - functions for handling URLs (file fetching etc.)
#
# Authors:
# Will Woods <wwoods@redhat.com>
type mkuniqdir >/dev/null 2>&1 || . /lib/dracut-lib.sh
# fetch_url URL [OUTFILE]
# fetch the given URL to a locally-visible location.
# if OUTFILE is given, the URL will be fetched to that filename,
# overwriting it if present.
# If the URL is something mountable (e.g. nfs://) and no OUTFILE is given,
# the server will be left mounted until pre-pivot.
# the return values are as follows:
# 0: success
# 253: unknown error (file missing)
# 254: unhandled URL scheme / protocol
# 255: bad arguments / unparseable URLs
# other: fetch command failure (whatever curl/mount/etc return)
fetch_url() {
local url="$1" outloc="$2"
local handler="$(get_url_handler $url)"
[ -n "$handler" ] || return 254
[ -n "$url" ] || return 255
$handler "$url" "$outloc"
}
# get_url_handler URL
# returns the first HANDLERNAME corresponding to the URL's scheme
get_url_handler() {
local scheme="${1%%:*}" item=""
for item in $url_handler_map; do
[ "$scheme" = "${item%%:*}" ] && echo "${item#*:}" && return 0
done
return 1
}
# add_url_handler HANDLERNAME SCHEME [SCHEME...]
# associate the named handler with the named scheme(s).
add_url_handler() {
local handler="$1"; shift
local schemes="$@" scheme=""
set --
for scheme in $schemes; do
set -- "$@" "$scheme:$handler"
done
set -- $@ $url_handler_map # add new items to *front* of list
url_handler_map="$@"
}
### HTTP, HTTPS, FTP #################################################
export CURL_HOME="/run/initramfs/url-lib"
mkdir -p $CURL_HOME
curl_args="--location --retry 3 --fail --show-error"
curl_fetch_url() {
local url="$1" outloc="$2"
if [ -n "$outloc" ]; then
curl $curl_args --output "$outloc" "$url" || return $?
else
local outdir="$(mkuniqdir /tmp curl_fetch_url)"
( cd "$outdir"; curl $curl_args --remote-name "$url" || return $? )
outloc="$outdir/$(ls -A $outdir)"
fi
[ -f "$outloc" ] || return 253
echo "$outloc"
}
add_url_handler curl_fetch_url http https ftp
set_http_header() {
echo "header = \"$1: $2\"" >> $CURL_HOME/.curlrc
}
### NFS ##############################################################
. /lib/nfs-lib.sh
nfs_already_mounted() {
local server="$1" path="$2" localdir="" s="" p=""
cat /proc/mounts | while read src mnt rest; do
splitsep ":" "$src" s p
if [ "$server" = "$s" ]; then
if [ "$path" = "$p" ]; then
echo $mnt
elif str_starts "$path" "$p"; then
echo $mnt/${path#$p/}
fi
fi
done
}
nfs_fetch_url() {
local url="$1" outloc="$2" nfs="" server="" path="" options=""
nfs_to_var "$url" || return 255
local filepath="${path%/*}" filename="${path##*/}" mntdir=""
# skip mount if server:/filepath is already mounted
mntdir=$(nfs_already_mounted $server $path)
if [ -z "$mntdir" ]; then
local mntdir="$(mkuniqdir /run nfs_mnt)"
mount_nfs $nfs:$server:$path${options:+:$options} $mntdir
# lazy unmount during pre-pivot hook
inst_hook --hook pre-pivot --name 99url-lib-umount-nfs umount -l $mntdir
fi
if [ -z "$outloc" ]; then
outloc="$mntdir/$filename"
else
cp -f "$mntdir/$filename" "$outloc" || return $?
fi
[ -f "$outloc" ] || return 253
echo "$outloc"
}
add_url_handler nfs_fetch_url nfs nfs4

View File

@@ -3,6 +3,7 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
[[ "$mount_needs" ]] && return 1
[[ -x /sbin/plymouthd && -x /bin/plymouth && -x /usr/sbin/plymouth-set-default-theme ]]
}
@@ -13,8 +14,23 @@ depends() {
installkernel() {
local _modname
# Include KMS capable drm drivers
for _modname in $(find "$srcmods/kernel/drivers/gpu/drm" "$srcmods/extra" -name '*.ko' 2>/dev/null); do
grep -q drm_crtc_init $_modname && instmods $_modname
for _modname in $(find "$srcmods/kernel/drivers/gpu/drm" "$srcmods/extra" \( -name '*.ko' -o -name '*.ko.gz' -o -name '*.ko.xz' \) 2>/dev/null); do
case $_modname in
*.ko) grep -q drm_crtc_init $_modname ;;
*.ko.gz) zgrep -q drm_crtc_init $_modname ;;
*.ko.xz) xzgrep -q drm_crtc_init $_modname ;;
esac
if test $? -eq 0; then
# if the hardware is present, include module even if it is not currently loaded,
# as we could e.g. be in the installer; nokmsboot boot parameter will disable
# loading of the driver if needed
if [[ $hostonly ]] && modinfo -F alias $_modname | sed -e 's,\?,\.,g' -e 's,\*,\.\*,g' \
| grep -qxf - /sys/bus/pci/devices/*/modalias; then
hostonly='' instmods $_modname
continue
fi
instmods $_modname
fi
done
}
@@ -22,7 +38,7 @@ install() {
if grep -q nash /usr/libexec/plymouth/plymouth-populate-initrd \
|| ! grep -q PLYMOUTH_POPULATE_SOURCE_FUNCTIONS /usr/libexec/plymouth/plymouth-populate-initrd \
|| [ ! -x /usr/libexec/plymouth/plymouth-populate-initrd ]; then
. "$moddir"/plymouth-populate-initrd
. "$moddir"/plymouth-populate-initrd.sh
else
PLYMOUTH_POPULATE_SOURCE_FUNCTIONS="$dracutfunctions" \
/usr/libexec/plymouth/plymouth-populate-initrd -t $initdir

View File

@@ -4,17 +4,21 @@
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
dev="${1:-/dev/root}"
btrfs_check_complete() {
local _rootinfo _dev
_dev="${1:-/dev/root}"
[ -e "$_dev" ] || return 0
_rootinfo=$(udevadm info --query=env "--name=$_dev" 2>/dev/null)
if strstr "$_rootinfo" "ID_FS_TYPE=btrfs"; then
info "Checking, if btrfs device complete"
unset __btrfs_mount
mount -o ro "$_dev" /tmp >/dev/null 2>&1
__btrfs_mount=$?
[ $__btrfs_mount -eq 0 ] && umount "$_dev" >/dev/null 2>&1
return $__btrfs_mount
fi
return 0
}
if [ -e "$dev" ]; then
if strstr "$(udevadm info --query=env \"--name=$dev\")" "ID_FS_TYPE=btrfs"; then
info "Checking, if btrfs device complete"
unset __btrfs_mount
mount -o ro "$dev" /tmp >/dev/null 2>&1
__btrfs_mount=$?
[ $__btrfs_mount -eq 0 ] && umount "$dev" >/dev/null 2>&1
exit $__btrfs_mount
fi
fi
exit 0
btrfs_check_complete $1
exit $?

View File

@@ -11,14 +11,14 @@ check() {
. $dracutfunctions
[[ $debug ]] && set -x
is_btrfs() { get_fs_type /dev/block/$1 | grep -q btrfs; }
if [[ $hostonly ]]; then
_rootdev=$(find_root_block_device)
if [[ $_rootdev ]]; then
is_btrfs "$_rootdev" || return 1
fi
fi
[[ $hostonly ]] || [[ $mount_needs ]] && {
local _found
for fs in ${host_fs_types[@]}; do
strstr "$fs" "\|btrfs" && _found="1"
done
[[ $_found ]] || return 1
unset _found
}
return 0
}
@@ -29,7 +29,7 @@ depends() {
}
installkernel() {
instmods btrfs
instmods btrfs crc32c
}
install() {

View File

@@ -4,7 +4,7 @@
# close everything which is not busy
rm -f /etc/udev/rules.d/70-luks.rules >/dev/null 2>&1
if ! getarg rd.luks.uuid rd_LUKS_UUID && getargbool 1 rd.luks -n rd_NO_LUKS; then
if ! getarg rd.luks.uuid rd_LUKS_UUID >/dev/null 2>&1 && getargbool 1 rd.luks -n rd_NO_LUKS >/dev/null 2>&1; then
while true; do
local do_break="y"
for i in /dev/mapper/luks-*; do

View File

@@ -117,6 +117,7 @@ unset device luksname luksfile
# mark device as asked
>> /tmp/cryptroot-asked-$2
need_shutdown
udevsettle
exit 0

View File

@@ -9,18 +9,25 @@ check() {
. $dracutfunctions
is_crypt() { [[ $(get_fs_type /dev/block/$1) = crypto_LUKS ]]; }
[[ $hostonly ]] && {
_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_crypt "$_rootdev" || return 1
else
# root is not on a block device, use the shotgun approach
blkid | grep -q crypto\?_LUKS || return 1
check_crypt() {
local dev=$1 fs=$2
[[ $fs = "crypto_LUKS" ]] || return 1
ID_FS_UUID=$(udevadm info --query=property --name=$dev \
| while read line; do
[[ ${line#ID_FS_UUID} = $line ]] && continue
eval "$line"
echo $ID_FS_UUID
break
done)
[[ ${ID_FS_UUID} ]] || return 1
if ! [[ $kernel_only ]]; then
echo " rd.luks.uuid=luks-${ID_FS_UUID} " >> "${initdir}/etc/cmdline.d/90crypt.conf"
fi
return 0
}
[[ $hostonly ]] || [[ $mount_needs ]] && {
for_each_host_dev_fs check_crypt || return 1
}
return 0

View File

@@ -40,3 +40,4 @@ else
done
fi
need_shutdown

View File

@@ -11,19 +11,37 @@ check() {
. $dracutfunctions
[[ $debug ]] && set -x
is_dmraid() { get_fs_type /dev/block/$1 |grep -v linux_raid_member | \
grep -q _raid_member; }
check_dmraid() {
local dev=$1 fs=$2 holder DEVPATH DM_NAME
[[ "$fs" = "${fs%%_raid_member}" ]] && return 1
[[ $hostonly ]] && {
_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_dmraid "$_rootdev" || return 1
else
# root is not on a block device, use the shotgun approach
dmraid -r | grep -q ok || return 1
DEVPATH=$(udevadm info --query=property --name=$dev \
| while read line; do
[[ ${line#DEVPATH} = $line ]] && continue
eval "$line"
echo $DEVPATH
break
done)
for holder in /sys/$DEVPATH/holders/*; do
[[ -e $holder ]] || continue
DM_NAME=$(udevadm info --query=property --path=$holder \
| while read line; do
[[ ${line#DM_NAME} = $line ]] && continue
eval "$line"
echo $DM_NAME
break
done)
done
[[ ${DM_NAME} ]] || return 1
if ! [[ $kernel_only ]]; then
echo " rd.dm.uuid=${DM_NAME} " >> "${initdir}/etc/cmdline.d/90dmraid.conf"
fi
return 0
}
[[ $hostonly ]] || [[ $mount_needs ]] && {
for_each_host_dev_fs check_dmraid || return 1
}
return 0

View File

@@ -1,8 +1,9 @@
#!/bin/sh
if [ -b /dev/mapper/live-rw ]; then
if pushd /updates &>/dev/null; then
if [ -d /updates ]; then
echo "Applying updates to live image..."
cd /updates
/bin/cp -a -t $NEWROOT .
popd &>/dev/null
cd -
fi
fi

View File

@@ -200,7 +200,12 @@ if [ -n "$ROOTFLAGS" ]; then
ROOTFLAGS="-o $ROOTFLAGS"
fi
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
need_shutdown
exit 0

View File

@@ -16,7 +16,7 @@ depends() {
}
installkernel() {
instmods squashfs
instmods squashfs loop
}
install() {
@@ -35,7 +35,7 @@ install() {
inst_hook pre-udev 30 "$moddir/dmsquash-live-genrules.sh"
inst_hook pre-udev 30 "$moddir/dmsquash-liveiso-genrules.sh"
inst_hook pre-pivot 20 "$moddir/apply-live-updates.sh"
inst "$moddir/dmsquash-live-root" "/sbin/dmsquash-live-root"
inst "$moddir/dmsquash-live-root.sh" "/sbin/dmsquash-live-root"
# should probably just be generally included
inst_rules 60-cdrom_id.rules
}

View File

@@ -17,6 +17,8 @@ fi
[ "${liveroot%%:*}" = "live" ] || return
modprobe -q loop
case "$liveroot" in
live:LABEL=*|LABEL=*) \
root="${root#live:}"
@@ -41,9 +43,9 @@ case "$liveroot" in
live:/*.[Ii][Mm][Gg]|/*.[Ii][Mm][Gg])
[ -f "${root#live:}" ] && rootok=1 ;;
esac
info "liveroot was $liveroot, is now $root"
info "root was $liveroot, is now $root"
# make sure that init doesn't complain
[ -z "$root" ] && root="live"
wait_for_dev /dev/mapper/live-rw
wait_for_dev /dev/mapper/live-rw

View File

@@ -13,6 +13,7 @@ installkernel() {
while read _f; do case "$_f" in
*.ko) [[ $(< $_f) =~ $_blockfuncs ]] && echo "$_f" ;;
*.ko.gz) [[ $(gzip -dc <$_f) =~ $_blockfuncs ]] && echo "$_f" ;;
*.ko.xz) [[ $(xz -dc <$_f) =~ $_blockfuncs ]] && echo "$_f" ;;
esac
done
}
@@ -30,12 +31,12 @@ installkernel() {
eval "( ( rotor ) ${_side2}>&1 | bmf1 ) ${_merge}>&1"
[[ $debug ]] && set -x
}
hostonly='' instmods sr_mod sd_mod scsi_dh scsi_dh_rdac scsi_dh_emc
hostonly='' instmods sr_mod sd_mod scsi_dh scsi_dh_rdac scsi_dh_emc ata_piix
hostonly='' instmods pcmcia firewire-ohci
hostonly='' instmods usb_storage sdhci sdhci-pci
# install keyboard support
hostonly='' instmods atkbd i8042 usbhid hid-apple hid-sunplus hid-cherry hid-logitech 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
# install unix socket support
hostonly='' instmods unix
instmods "=drivers/pcmcia" =ide "=drivers/usb/storage"
@@ -44,13 +45,14 @@ installkernel() {
# if the required list is not set via the filesystems variable
if ! [[ $hostonly ]]; then
if [[ -z $filesystems ]]; then
instmods '=fs'
# hardcoded list of exceptions
# to save a lot of space
rm -fr ${initdir}/lib/modules/*/kernel/fs/ocfs2
omit_drivers="$omit_drivers|kernel/fs/nfs|kernel/fs/nfsd|kernel/fs/lockd" omit_drivers="${omit_drivers##|}" instmods '=fs'
fi
else
hostonly='' instmods $(get_fs_type "/dev/block/$(find_root_block_device)")
inst_fs() {
[[ $2 ]] || return 1
hostonly='' instmods $2
}
for_each_host_dev_fs inst_fs
fi
else
hostonly='' instmods $drivers
@@ -61,24 +63,26 @@ installkernel() {
# force install of scsi_wait_scan
hostonly='' instmods scsi_wait_scan
}
install() {
local _f
[ -f /etc/modprobe.conf ] && dracut_install /etc/modprobe.conf
for i in $(find /etc/modprobe.d/ -type f -name '*.conf'); do
inst_simple "$i"
done
inst_hook cmdline 01 "$moddir/parse-kernel.sh"
inst_simple "$moddir/insmodpost.sh" /sbin/insmodpost.sh
local f
for _f in modules.builtin.bin modules.builtin; do
[[ $srcmods/$_f ]] && inst_simple "$srcmods/$_f" "/lib/modules/$kernel/$_f" \
&& break
[[ $srcmods/$_f ]] && break
done || {
dfatal "No modules.builtin.bin and modules.builtin found!"
return 1
}
for _f in modules.builtin.bin modules.builtin modules.order; do
[[ $srcmods/$_f ]] && inst_simple "$srcmods/$_f" "/lib/modules/$kernel/$_f"
done
}
install() {
local _f i
[ -f /etc/modprobe.conf ] && dracut_install /etc/modprobe.conf
for i in $(find -L /etc/modprobe.d/ -maxdepth 1 -type f -name '*.conf'); do
inst_simple "$i"
done
inst_hook cmdline 01 "$moddir/parse-kernel.sh"
inst_simple "$moddir/insmodpost.sh" /sbin/insmodpost.sh
}

View File

@@ -1,41 +0,0 @@
#!/bin/bash
# livenetroot - fetch a live image from the network and run it
#
# TODO:
# * HTTPS: arg to use --no-check-certificate with https (boo)
# args for --certificate, --ca-certificate
# * NFS support?
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
[ -f /tmp/root.info ] && . /tmp/root.info
PATH=/usr/sbin:/usr/bin:/sbin:/bin
# args get passed from 40network/netroot
netroot=$2
liveurl=${netroot#livenet:}
if [ ${liveurl##*.} == "iso" ]; then
imgfile="/run/live.iso"
else
imgfile="/run/rootfs.img"
fi
case "$liveurl" in
http://*|https://*|ftp://*)
wget -O $imgfile "$liveurl"
;;
*) die "don't know how to handle URL: $liveurl" ;;
esac
[ $? == 0 ] || die "failed to download live image"
if [ ${imgfile##*.} == "iso" ]; then
root=$(losetup -f)
losetup $root $imgfile
else
root=$imgfile
fi
exec /sbin/dmsquash-live-root $root

View File

@@ -0,0 +1,26 @@
#!/bin/bash
# livenetroot - fetch a live image from the network and run it
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
[ -f /tmp/root.info ] && . /tmp/root.info
. /lib/url-lib.sh
PATH=/usr/sbin:/usr/bin:/sbin:/bin
# args get passed from 40network/netroot
netroot="$2"
liveurl="${netroot#livenet:}"
info "fetching $liveurl"
imgfile=$(fetch_url "$liveurl")
[ $? = 0 ] || die "failed to download live image: error $?"
# TODO: couldn't dmsquash-live-root handle this?
if [ ${imgfile##*.} = "iso" ]; then
root=$(losetup -f)
losetup $root $imgfile
else
root=$imgfile
fi
exec /sbin/dmsquash-live-root $root

View File

@@ -2,27 +2,16 @@
# module-setup.sh for livenet
check() {
# a live, host-only image doesn't really make a lot of sense
[[ $hostonly ]] && return 1
command -v wget >/dev/null || return 1
return 255
}
depends() {
echo network dmsquash-live
echo network url-lib dmsquash-live
return 0
}
install() {
dracut_install wget
mkdir -m 0755 -p "$initdir/etc/ssl/certs"
if ! inst_any -t /etc/ssl/certs/ca-bundle.crt \
/etc/ssl/certs/ca-bundle.crt \
/etc/ssl/certs/ca-certificates.crt; then
dwarn "Couldn't find SSL CA cert bundle; HTTPS won't work."
fi
inst_hook cmdline 29 "$moddir/parse-livenet.sh"
inst "$moddir/livenetroot" "/sbin/livenetroot"
inst "$moddir/livenetroot.sh" "/sbin/livenetroot"
}

View File

@@ -3,17 +3,19 @@
# root=live:[url-to-backing-file]
[ -z "$root" ] && root=$(getarg root=)
. /lib/url-lib.sh
str_starts $root "live:" && liveurl=$root
str_starts $liveurl "live:" || return
str_starts "$root" "live:" && liveurl="$root"
str_starts "$liveurl" "live:" || return
liveurl="${liveurl#live:}"
# setting netroot to "livenet:..." makes "livenetroot" get run after ifup
case "$liveurl" in
http://*|https://*|ftp://*)
netroot="livenet:$liveurl"
root="livenet" # quiet complaints from init
rootok=1 ;;
esac
echo '[ -e /dev/root ]' > $hookdir/initqueue/finished/livenet.sh
if get_url_handler "$liveurl" >/dev/null; then
info "livenet: root image at $liveurl"
netroot="livenet:$liveurl"
root="livenet" # quiet complaints from init
rootok=1
wait_for_dev /dev/root
else
info "livenet: no url handler for $liveurl"
fi

View File

@@ -126,3 +126,5 @@ if [ "$lvmwritten" ]; then
rm -f /etc/lvm/lvm.conf
fi
unset lvmwritten
need_shutdown

View File

@@ -3,25 +3,29 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
local _rootdev
local _rootdev _activated
# No point trying to support lvm if the binaries are missing
type -P lvm >/dev/null || return 1
. $dracutfunctions
[[ $debug ]] && set -x
is_lvm() { [[ $(get_fs_type /dev/block/$1) = LVM2_member ]]; }
[[ $hostonly ]] && {
_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_lvm "$_rootdev" || return 1
else
# root is not on a block device, use the shotgun approach
blkid | grep -q LVM2_member || return 1
check_lvm() {
unset DM_VG_NAME
unset DM_LV_NAME
eval $(udevadm info --query=property --name=$1|egrep '(DM_VG_NAME|DM_LV_NAME)=')
[[ ${DM_VG_NAME} ]] && [[ ${DM_LV_NAME} ]] || return 1
if ! strstr " ${_activated[*]} " " ${DM_VG_NAME}/${DM_LV_NAME} "; then
if ! [[ $kernel_only ]]; then
echo " rd.lvm.lv=${DM_VG_NAME}/${DM_LV_NAME} " >> "${initdir}/etc/cmdline.d/90lvm.conf"
fi
push _activated "${DM_VG_NAME}/${DM_LV_NAME}"
fi
return 0
}
[[ $hostonly ]] || [[ $mount_needs ]] && {
for_each_host_dev_fs check_lvm || return 1
}
return 0

View File

@@ -35,6 +35,6 @@ RUN+="/sbin/initqueue --timeout --name 50-mdraid_start --onetime --unique /sbin/
#
LABEL="md_incremental"
RUN+="/sbin/mdadm -I $env{DEVNAME}"
RUN+="/sbin/mdadm $env{rd_MD_OFFROOT} -I $env{DEVNAME}"
LABEL="md_end"

View File

@@ -4,8 +4,9 @@
_do_md_shutdown() {
local ret
local final=$1
local _offroot=$(strstr "$(mdadm --help-options 2>&1)" offroot && echo --offroot)
info "Disassembling mdraid devices."
mdadm -v --stop --scan
mdadm $_offroot -v --stop --scan
ret=$?
if [ "x$final" != "x" ]; then
info "cat /proc/mdstat"

View File

@@ -4,6 +4,7 @@
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
_offroot=$(strstr "$(mdadm --help-options 2>&1)" offroot && echo --offroot)
containers=""
for md in /dev/md[0-9_]*; do
[ -b "$md" ] || continue
@@ -13,11 +14,11 @@ for md in /dev/md[0-9_]*; do
containers="$containers $md"
continue
fi
mdadm -S "$md" >/dev/null 2>&1
mdadm $_offroot -S "$md" >/dev/null 2>&1 || need_shutdown
done
for md in $containers; do
mdadm -S "$md" >/dev/null 2>&1
mdadm $_offroot -S "$md" >/dev/null 2>&1 || need_shutdown
done
unset containers udevinfo
unset containers udevinfo _offroot

View File

@@ -3,6 +3,7 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
if getargbool 0 rd.md.waitclean; then
_offroot=$(strstr "$(mdadm --help-options 2>&1)" offroot && echo --offroot)
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
containers=""
for md in /dev/md[0-9_]*; do
@@ -14,13 +15,13 @@ if getargbool 0 rd.md.waitclean; then
continue
fi
info "Waiting for $md to become clean"
mdadm -W "$md" >/dev/null 2>&1
mdadm $_offroot -W "$md" >/dev/null 2>&1
done
for md in $containers; do
info "Waiting for $md to become clean"
mdadm -W "$md" >/dev/null 2>&1
mdadm $_offroot -W "$md" >/dev/null 2>&1
done
unset containers udevinfo
unset containers udevinfo _offroot
fi

View File

@@ -7,6 +7,8 @@ _md_force_run() {
local _udevinfo
local _path_s
local _path_d
local _offroot
_offroot=$(strstr "$(mdadm --help-options 2>&1)" offroot && echo --offroot)
# try to force-run anything not running yet
for md in /dev/md[0-9_]*; do
[ -b "$md" ] || continue
@@ -20,7 +22,7 @@ _md_force_run() {
# inactive ?
[ "$(cat "$_path_s")" != "inactive" ] && continue
mdadm -R "$md" 2>&1 | vinfo
mdadm $_offroot -R "$md" 2>&1 | vinfo
# still inactive ?
[ "$(cat "$_path_s")" = "inactive" ] && continue
@@ -29,7 +31,7 @@ _md_force_run() {
[ ! -r "$_path_d" ] && continue
# workaround for mdmon bug
[ "$(cat "$_path_d")" -gt "0" ] && mdmon --takeover "$md"
[ "$(cat "$_path_d")" -gt "0" ] && mdmon $_offroot --takeover "$md"
done
}

View File

@@ -10,18 +10,27 @@ check() {
. $dracutfunctions
[[ $debug ]] && set -x
is_mdraid() { [[ -d "/sys/dev/block/$1/md" ]]; }
check_mdraid() {
local dev=$1 fs=$2 holder DEVPATH MD_UUID
[[ "$fs" = "${fs%%_raid_member}" ]] && return 1
[[ $hostonly ]] && {
_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_mdraid "$_rootdev" || return 1
else
# root is not on a block device, use the shotgun approach
blkid | egrep -q '(linux|isw|ddf)_raid' || return 1
MD_UUID=$(/sbin/mdadm --examine --export $dev \
| while read line; do
[[ ${line#MD_UUID} = $line ]] && continue
eval "$line"
echo $MD_UUID
break
done)
[[ ${MD_UUID} ]] || return 1
if ! [[ $kernel_only ]]; then
echo " rd.md.uuid=${MD_UUID} " >> "${initdir}/etc/cmdline.d/90mdraid.conf"
fi
return 0
}
[[ $hostonly ]] || [[ $mount_needs ]] && {
for_each_host_dev_fs check_mdraid || return 1
}
return 0

View File

@@ -51,3 +51,5 @@ if ! getargbool 1 rd.md.ddf -n rd_NO_MDDDF || getarg noddfmd || getarg nodmraid;
info "no MD RAID for SNIA ddf raids"
udevproperty rd_NO_MDDDF=1
fi
strstr "$(mdadm --help-options 2>&1)" offroot && udevproperty rd_MD_OFFROOT=--offroot

View File

@@ -40,11 +40,12 @@ installkernel() {
while read _f; do case "$_f" in
*.ko) [[ $(< $_f) =~ $_mpfuncs ]] && echo "$_f" ;;
*.ko.gz) [[ $(gzip -dc <$_f) =~ $_mpfuncs ]] && echo "$_f" ;;
*.ko.xz) [[ $(xz -dc <$_f) =~ $_mpfuncs ]] && echo "$_f" ;;
esac
done
}
( find_kernel_modules_by_path drivers/scsi;
( 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
[[ $debug ]] && set -x
}

View File

@@ -5,6 +5,7 @@
if [ -e /etc/multipath.conf ]; then
modprobe dm-multipath
multipathd -B || multipathd
need_shutdown
else
rm /etc/udev/rules.d/??-multipath.rules 2>/dev/null
fi

View File

@@ -46,3 +46,5 @@ elif [ "$netdriver" = "bnx2x" ]; then
else
echo -n "$netif" > /sys/module/fcoe/parameters/create
fi
need_shutdown

View File

@@ -6,7 +6,7 @@ check() {
# FIXME
# If hostonly was requested, fail the check until we have some way of
# knowing we are booting from FCoE
[[ $hostonly ]] && return 1
[[ $hostonly ]] || [[ $mount_needs ]] && return 1
return 0
}
@@ -29,7 +29,7 @@ install() {
mkdir -m 0755 -p "$initdir/var/lib/lldpad"
inst "$moddir/fcoe-up" "/sbin/fcoe-up"
inst "$moddir/fcoe-up.sh" "/sbin/fcoe-up"
inst "$moddir/fcoe-edd.sh" "/sbin/fcoe-edd"
inst "$moddir/fcoe-genrules.sh" "/sbin/fcoe-genrules.sh"
inst_hook cmdline 99 "$moddir/parse-fcoe.sh"

View File

@@ -3,7 +3,7 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
test -f /etc/fstab.sys
test -f /etc/fstab.sys || [[ -n $use_fstab || -n $fstab_lines ]]
}
depends() {
@@ -11,6 +11,6 @@ depends() {
}
install() {
dracut_install /etc/fstab.sys
inst /etc/fstab.sys /etc/fstab
inst_hook pre-pivot 00 "$moddir/mount-sys.sh"
}

View File

@@ -11,7 +11,7 @@ fstab_mount() {
info "Mounting from $1"
while read _dev _mp _fs _opts _dump _pass _rest; do
[ -z "${_dev%%#*}" ] && continue # Skip comment lines
if [ ! -e "$_dev" ]; then
if [[ ! "$_fs" =~ "nfs" ]] && [ ! -e "$_dev" ]; then
warn "Device $_dev doesn't exist, skipping mount."
continue
fi
@@ -20,11 +20,16 @@ fstab_mount() {
fi
_fs=$(det_fs "$_dev" "$_fs")
info "Mounting $_dev"
mount -v -t $_fs -o $_opts $_dev $NEWROOT/$_mp 2>&1 | vinfo
if [[ -d $NEWROOT/$_mp ]]; then
mount -v -t $_fs -o $_opts $_dev $NEWROOT/$_mp 2>&1 | vinfo
else
mkdir -p "$_mp"
mount -v -t $_fs -o $_opts $_dev $_mp 2>&1 | vinfo
fi
done < $1
return 0
}
for r in $NEWROOT /; do
fstab_mount "$r/etc/fstab.sys" && break
for r in $NEWROOT/etc/fstab.sys /etc/fstab; do
fstab_mount $r && break
done

View File

@@ -46,11 +46,17 @@ if getargbool 0 rd.iscsi.firmware -y iscsi_firmware ; then
if [ -n "${root%%block:*}" ]; then
# if root is not specified try to mount the whole iSCSI LUN
printf 'ENV{DEVTYPE}!="partition", SYMLINK=="disk/by-path/*-iscsi-*-*", SYMLINK+="root"\n' >> /etc/udev/rules.d/99-iscsi-root.rules
udevadm control --reload
fi
iscsistart -b
exit 0
fi
unset iscsi_initiator iscsi_target_name iscsi_target_ip iscsi_target_port
unset iscsi_target_group iscsi_protocol iscsirw iscsi_lun
unset iscsi_username iscsi_password
unset iscsi_in_username iscsi_in_password
# override conf settings by command line options
arg=$(getargs rd.iscsi.initiator iscsi_initiator=)
[ -n "$arg" ] && iscsi_initiator=$arg
@@ -200,6 +206,8 @@ else
handle_netroot $iroot
fi
need_shutdown
# now we have a root filesystem somewhere in /dev/sda*
# let the normal block handler handle root=
exit 0

View File

@@ -23,7 +23,7 @@ check() {
[[ -d iscsi_session ]]
)
[[ $hostonly ]] && {
[[ $hostonly ]] || [[ $mount_needs ]] && {
_rootdev=$(find_root_block_device)
if [[ $_rootdev ]]; then
# root lives on a block device, so we can be more precise about
@@ -48,10 +48,11 @@ installkernel() {
while read _f; do case "$_f" in
*.ko) [[ $(< $_f) =~ $_iscsifuncs ]] && echo "$_f" ;;
*.ko.gz) [[ $(gzip -dc <$_f) =~ $_iscsifuncs ]] && echo "$_f" ;;
*.ko.xz) [[ $(xz -dc <$_f) =~ $_iscsifuncs ]] && echo "$_f" ;;
esac
done
}
find_kernel_modules_by_path drivers/scsi \
{ find_kernel_modules_by_path drivers/scsi; find_kernel_modules_by_path drivers/s390/scsi; } \
| iscsi_module_filter | instmods
}
@@ -63,6 +64,6 @@ install() {
inst iscsi-iname
inst_hook cmdline 90 "$moddir/parse-iscsiroot.sh"
inst_hook pre-pivot 90 "$moddir/cleanup-iscsi.sh"
inst "$moddir/iscsiroot" "/sbin/iscsiroot"
inst "$moddir/iscsiroot.sh" "/sbin/iscsiroot"
inst "$moddir/mount-lun.sh" "/bin/mount-lun.sh"
}

View File

@@ -28,9 +28,11 @@
if [ "${root%%:*}" = "iscsi" ] ; then
if [ -n "$netroot" ] ; then
echo "Warning: root takes precedence over netroot. Ignoring netroot"
fi
netroot=$root
# if root is not specified try to mount the whole iSCSI LUN
printf 'ENV{DEVTYPE}!="partition", SYMLINK=="disk/by-path/*-iscsi-*-*", SYMLINK+="root"\n' >> /etc/udev/rules.d/99-iscsi-root.rules
root=/dev/root
fi
# If it's not empty or iscsi we don't continue
@@ -40,7 +42,7 @@ if [ -n "$iscsiroot" ] ; then
[ -z "$netroot" ] && netroot=$root
# @deprecated
echo "Warning: Argument isciroot is deprecated and might be removed in a future"
echo "Warning: Argument iscsiroot is deprecated and might be removed in a future"
echo "release. See 'man dracut.kernel' for more information."
# Accept iscsiroot argument?

View File

@@ -9,7 +9,7 @@ check() {
# if an nbd device is not somewhere in the chain of devices root is
# mounted on, fail the hostonly check.
[[ $hostonly ]] && {
[[ $hostonly ]] || [[ $mount_needs ]] && {
is_nbd() { [[ -b /dev/block/$1 && $1 == 43:* ]] ;}
. $dracutfunctions
@@ -34,6 +34,6 @@ install() {
inst nbd-client
inst_hook cmdline 90 "$moddir/parse-nbdroot.sh"
inst "$moddir/nbdroot" "/sbin/nbdroot"
inst "$moddir/nbdroot.sh" "/sbin/nbdroot"
}

View File

@@ -107,4 +107,5 @@ fi
# NBD doesn't emit uevents when it gets connected, so kick it
echo change > /sys/block/nbd0/uevent
udevadm settle
need_shutdown
exit 0

View File

@@ -24,15 +24,16 @@ netroot_to_var() {
server=$2; port=$3;
}
# Don't continue if root is ok
[ -n "$rootok" ] && return
# This script is sourced, so root should be set. But let's be paranoid
[ -z "$root" ] && root=$(getarg root=)
[ -z "$netroot" ] && netroot=$(getarg netroot=)
# Root takes precedence over netroot
if [ "${root%%:*}" = "nbd" ] ; then
# Don't continue if root is ok
[ -n "$rootok" ] && return
if [ -n "$netroot" ] ; then
warn "root takes precedence over netroot. Ignoring netroot"

View File

@@ -3,13 +3,19 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
# If hostonly was requested, fail the check if we are not actually
# booting from root.
[ $hostonly ] && ! egrep -q '/ nfs[34 ]' /proc/mounts && return 1
# If our prerequisites are not met, fail anyways.
type -P rpcbind >/dev/null || type -P portmap >/dev/null || return 1
type -P rpc.statd mount.nfs mount.nfs4 umount >/dev/null || return 1
[[ $hostonly ]] || [[ $mount_needs ]] && {
for fs in ${host_fs_types[@]}; do
strstr "$fs" "\|nfs" && return 0
strstr "$fs" "\|nfs3" && return 0
strstr "$fs" "\|nfs4" && return 0
done
return 255
}
return 0
}
@@ -34,7 +40,7 @@ install() {
for i in /etc/nsswitch.conf /etc/rpc /etc/protocols /etc/idmapd.conf; do
inst_simple $i
done
dracut_install rpc.idmapd
dracut_install rpc.idmapd
dracut_install sed
for _i in {"$libdir","$usrlibdir"}/libnfsidmap_nsswitch.so* \
@@ -51,20 +57,21 @@ install() {
dracut_install $(for _i in $(ls {/usr,}$libdir/libnss*.so 2>/dev/null); do echo $_i;done | egrep "$_nsslibs")
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 "$moddir/nfsroot" "/sbin/nfsroot"
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"
mkdir -m 0755 -p "$initdir/var/lib/rpcbind"
mkdir -m 0755 -p "$initdir/var/lib/nfs/statd/sm"
# Rather than copy the passwd file in, just set a user for rpcbind
# We'll save the state and restart the daemon from the root anyway
egrep '^root:' "$initdir/etc/passwd" 2>/dev/null || echo 'root:x:0:0::/:/bin/sh' >> "$initdir/etc/passwd"
egrep '^nobody:' /etc/passwd >> "$initdir/etc/passwd"
egrep '^nfsnobody:' /etc/passwd >> "$initdir/etc/passwd"
egrep '^rpc:' /etc/passwd >> "$initdir/etc/passwd"
egrep '^rpcuser:' /etc/passwd >> "$initdir/etc/passwd"
#type -P nologin >/dev/null && dracut_install nologin
egrep '^nobody:' /etc/group >> "$initdir/etc/group"
egrep '^rpc:' /etc/group >> "$initdir/etc/group"
# rpc user needs to be able to write to this directory to save the warmstart

139
modules.d/95nfs/nfs-lib.sh Executable file
View File

@@ -0,0 +1,139 @@
#!/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
. /lib/net-lib.sh
# TODO: make these things not pollute the calling namespace
# nfs_to_var NFSROOT [NETIF]
# use NFSROOT to set $nfs, $server, $path, and $options.
# NFSROOT is something like: nfs[4]:<server>:/<path>[:<options>|,<options>]
# NETIF is used to get information from DHCP options, if needed.
nfs_to_var() {
# Unfortunately, there's multiple styles of nfs "URL" in use, so we need
# extra functions to parse them into $nfs, $server, $path, and $options.
# FIXME: local netif=${2:-$netif}?
case "$1" in
nfs://*) rfc2224_nfs_to_var "$1" ;;
nfs:*:*:/*) anaconda_nfs_to_var "$1" ;;
*) nfsroot_to_var "$1" ;;
esac
# if anything's missing, try to fill it in from DHCP options
if [ -z "$server" ] || [ -z "$path" ]; then nfsroot_from_dhcp $2; fi
# if there's a "%s" in the path, replace it with the hostname/IP
if strstr "$path" "%s"; then
local node=""
read node < /proc/sys/kernel/hostname
[ "$node" = "(none)" ] && node=$(get_ip $2)
path=${path%%%s*}$node${path#*%s} # replace only the first %s
fi
}
# root=nfs:[<server-ip>:]<root-dir>[:<nfs-options>]
# root=nfs4:[<server-ip>:]<root-dir>[:<nfs-options>]
nfsroot_to_var() {
# strip nfs[4]:
local arg="$@:"
nfs="${arg%%:*}"
arg="${arg##$nfs:}"
# check if we have a server
if strstr "$arg" ':/*' ; then
server="${arg%%:/*}"
arg="/${arg##*:/}"
fi
path="${arg%%:*}"
# rest are options
options="${arg##$path}"
# strip leading ":"
options="${options##:}"
# strip ":"
options="${options%%:}"
# Does it really start with '/'?
[ -n "${path%%/*}" ] && path="error";
#Fix kernel legacy style separating path and options with ','
if [ "$path" != "${path#*,}" ] ; then
options=${path#*,}
path=${path%%,*}
fi
}
# RFC2224: nfs://<server>[:<port>]/<path>
rfc2224_nfs_to_var() {
nfs="nfs"
server="${1#nfs://}"
path="/${server#*/}"
server="${server%%/*}"
server="${server%%:}" # anaconda compat (nfs://<server>:/<path>)
local port="${server##*:}"
[ "$port" != "$server" ] && options="port=$port"
}
# Anaconda-style path with options: nfs:<options>:<server>:/<path>
# (without mount options, anaconda is the same as dracut)
anaconda_nfs_to_var() {
nfs="nfs"
options="${1#nfs:}"
server="${options#*:}"
server="${server%:/*}"
options="${options%%:*}"
path="/${1##*:/}"
}
# nfsroot_from_dhcp NETIF
# fill in missing server/path from DHCP options.
nfsroot_from_dhcp() {
local f
for f in /tmp/net.$1.override /tmp/dhclient.$1.dhcpopts; do
[ -f $f ] && . $f
done
[ -n "$new_root_path" ] && nfsroot_to_var "$nfs:$new_root_path"
[ -z "$path" ] && [ "$(getarg root=)" == "/dev/nfs" ] && path=/tftpboot/%s
[ -z "$server" ] && server=$new_dhcp_server_identifier
[ -z "$server" ] && server=$new_dhcp_next_server
[ -z "$server" ] && server=${new_root_path%%:*}
}
# Look through $options, fix "rw"/"ro", move "lock"/"nolock" to $nfslock
munge_nfs_options() {
local f="" flags="" nfsrw="ro" OLDIFS="$IFS"
IFS=,
for f in $options; do
case $f in
ro|rw) nfsrw=$f ;;
lock|nolock) nfslock=$f ;;
*) flags=${flags:+$flags,}$f ;;
esac
done
IFS="$OLDIFS"
# Override rw/ro if set on cmdline
getarg ro >/dev/null && nfsrw=ro
getarg rw >/dev/null && nfsrw=rw
options=$nfsrw${flags:+,$flags}
}
# mount_nfs NFSROOT MNTDIR [NETIF]
mount_nfs() {
local nfsroot="$1" mntdir="$2" netif="$3"
local nfs="" server="" path="" options=""
nfs_to_var $nfsroot $netif
munge_nfs_options
if [ "$nfs" = "nfs4" ]; then
options=$options${nfslock+,$nfslock}
else
# NFSv{2,3} doesn't support using locks as it requires a helper to
# transfer the rpcbind state to the new root
[ "$nfslock" = "lock" ] \
&& warn "Locks unsupported on NFSv{2,3}, using nolock" 1>&2
options=$options,nolock
fi
mount -t $nfs -o$options $server:$path $mntdir
}

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
# Start rpcbind or rpcbind
# FIXME occasionally saw 'rpcbind: fork failed: No such device' -- why?
command -v portmap >/dev/null && [ -z "$(pidof portmap)" ] && portmap
command -v rpcbind >/dev/null && [ -z "$(pidof rpcbind)" ] && rpcbind
[ ! -d /var/lib/nfs/rpc_pipefs/nfs ] && \
mount -t rpc_pipefs rpc_pipefs /var/lib/nfs/rpc_pipefs
# Start rpc.statd as mount won't let us use locks on a NFSv4
# filesystem without talking to it. NFSv4 does locks internally,
# rpc.lockd isn't needed
[ -z "$(pidof rpc.statd)" ] && rpc.statd
[ -z "$(pidof rpc.idmapd)" ] && rpc.idmapd

View File

@@ -1,124 +0,0 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
PATH=/usr/sbin:/usr/bin:/sbin:/bin
# Huh? Empty $1?
[ -z "$1" ] && exit 1
# Huh? Empty $2?
[ -z "$2" ] && exit 1
# Huh? Empty $3?
[ -z "$3" ] && exit 1
# root is in the form root=nfs[4]:[server:]path[:options], either from
# cmdline or dhcp root-path
netif="$1"
root="$2"
NEWROOT="$3"
# Continue if nfs prefix
case "${root%%:*}" in
nfs|nfs4);;
*) return;;
esac
nfsroot_to_var $root
#Load other data that might provide info
[ -f /tmp/net.$netif.override ] && . /tmp/net.$netif.override
[ -f /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
#Empty path means try dhcp root-path, this is ok here since parse-nfsroot.sh
#already takes care of nfs:... formatted root-path
[ -z "$path" ] && nfsroot_to_var $nfs:$new_root_path
#Empty path defaults to "/tftpboot/%s" only in nfsroot.txt legacy mode
[ -z "$path" ] && [ "$(getarg root=)" = "/dev/nfs" ] && path="/tftpboot/%s"
if [ -z "$server" ] ; then
# XXX new_dhcp_next_server is unconfirmed this is an assumption
for var in $srv $new_dhcp_server_identifier $new_dhcp_next_server $new_root_path '' ; do
[ -n "$var" ] && server=$var && break;
done
# XXX This blindly assumes that if new_root_path has to used that
# XXX it really can be used as server
server=${server%%:*}
fi
[ -z "$server" ] && die "Required parameter 'server' is missing"
# Kernel replaces first %s with host name, and falls back to the ip address
# if it isn't set. Only the first %s is substituted.
if [ "${path#*%s}" != "$path" ]; then
ip=$(ip -o -f inet addr show $netif)
ip=${ip%%/*}
ip=${ip##* }
read node < /proc/sys/kernel/hostname
[ "$node" = "(none)" ] && node=$ip
path=${path%%%s*}$node${path#*%s}
fi
# Look through the options and remove rw/locking options
OLDIFS="$IFS"
IFS=,
for f in $options ; do
[ "$f" = "ro" -o "$f" = "rw" ] && nfsrw=$f && continue
[ "$f" = "lock" -o "$f" = "nolock" ] && nfslock=$f && continue
flags=${flags:+$flags,}$f
done
IFS="$OLDIFS"
options=$flags
# Override rw/ro if set on cmdline
getarg ro && nfsrw=ro
getarg rw && nfsrw=rw
# Default to ro if unset
[ -z "$nfsrw" ] && nfsrw=ro
options=${options:+$options,}$nfsrw
# Start rpcbind or rpcbind
# FIXME occasionally saw 'rpcbind: fork failed: No such device' -- why?
command -v portmap >/dev/null && [ -z "$(pidof portmap)" ] && portmap
command -v rpcbind >/dev/null && [ -z "$(pidof rpcbind)" ] && rpcbind
if [ "$nfs" = "nfs4" ]; then
[ ! -d /var/lib/nfs/rpc_pipefs/nfs ] && \
mount -t rpc_pipefs rpc_pipefs /var/lib/nfs/rpc_pipefs
# Start rpc.statd as mount won't let us use locks on a NFSv4
# filesystem without talking to it. NFSv4 does locks internally,
# rpc.lockd isn't needed
[ -z "$(pidof rpc.statd)" ] && rpc.statd
[ -z "$(pidof rpc.idmapd)" ] && rpc.idmapd
# XXX Should we loop here?
mount -t nfs4 -o$options${nfslock+,$nfslock} \
$server:$path $NEWROOT \
&& { [ -e /dev/root ] || >/dev/root ; }
else
# NFSv{2,3} doesn't support using locks as it requires a helper to transfer
# the rpcbind state to the new root
[ "$nfslock" = "lock" ] && \
warn "Locks unsupported on NFSv{2,3}, using nolock" 1>&2
# XXX Should we loop here?
{ mount -t nfs -o$options${options:+,}nolock,nfsvers=3 $server:$path $NEWROOT || \
mount -t nfs -o$options${options:+,}nolock,nfsvers=2 $server:$path $NEWROOT ; } \
&& { [ -e /dev/root ] || >/dev/root ; }
fi
# inject new exit_if_exists
echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm "$job"' > $hookdir/initqueue/nfs.sh
# force udevsettle to break
> $hookdir/initqueue/work

View File

@@ -2,6 +2,8 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
type incol2 >/dev/null 2>&1 || . /lib/dracut-lib.sh
[ -f /tmp/nfs.rpc_pipefs_path ] && rpcpipefspath=`cat /tmp/nfs.rpc_pipefs_path`
[ -z "$rpcpipefspath" ] && rpcpipefspath=var/lib/nfs/rpc_pipefs

26
modules.d/95nfs/nfsroot.sh Executable file
View File

@@ -0,0 +1,26 @@
#!/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
. /lib/nfs-lib.sh
[ "$#" = 3 ] || exit 1
# root is in the form root=nfs[4]:[server:]path[:options], either from
# cmdline or dhcp root-path
netif="$1"
root="$2"
NEWROOT="$3"
nfs_to_var $root $netif
[ -z "$server" ] && die "Required parameter 'server' is missing"
mount_nfs $root $NEWROOT $netif && { [ -e /dev/root ] || >/dev/root ; }
# inject new exit_if_exists
echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm "$job"' > $hookdir/initqueue/nfs.sh
# force udevsettle to break
> $hookdir/initqueue/work
need_shutdown

View File

@@ -35,6 +35,9 @@ if [ -n "$resume" ]; then
printf '[ -e "%s" ] && { ln -s "%s" /dev/resume; rm "$job"; }\n' \
"$resume" "$resume" >> $hookdir/initqueue/settled/resume.sh
printf 'warn "Cancelling resume operation. Device not found."; cancel_wait_for_dev /dev/resume; rm "$job" "%s/initqueue/settled/resume.sh";' \
"$hookdir" >> $hookdir/initqueue/timeout/resume.sh
wait_for_dev "/dev/resume"
elif ! getarg noresume; then

View File

@@ -0,0 +1,62 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
# fixme: assume user is root
check() {
# If our prerequisites are not met, fail.
type -P ssh >/dev/null || return 1
type -P scp >/dev/null || return 1
[[ $mount_needs ]] && return 1
if [[ $sshkey ]]; then
[ ! -f $sshkey ] && {
derror "ssh key: $sshkey is not found!"
return 1
}
[[ ! $cttyhack = yes ]] && {
dinfo "--ctty is not used, you should make sure the machine is a knownhost and copy the sshkey to remote machine!"
}
fi
return 255
}
depends() {
# We depend on network modules being loaded
echo network
}
inst_sshenv()
{
if [ -d /root/.ssh ]; then
inst_dir /root/.ssh
chmod 700 ${initdir}/root/.ssh
fi
# Copy over ssh key and knowhosts if needed
[[ $sshkey ]] && {
inst $sshkey
[[ -f /root/.ssh/known_hosts ]] && inst /root/.ssh/known_hosts
[[ -f /etc/ssh/ssh_known_hosts ]] && inst /etc/ssh/ssh_known_hosts
}
# Copy over root and system-wide ssh configs.
[[ -f /root/.ssh/config ]] && inst /root/.ssh/config
[[ -f /etc/ssh/ssh_config ]] && inst /etc/ssh/ssh_config
return 0
}
install() {
[[ ! $cttyhack = yes && ! $sshkey ]] && {
derror "ssh-client needs option --ctty or --sshkey!"
return 1
}
inst ssh
inst scp
inst_sshenv
}

View File

@@ -6,7 +6,7 @@ install() {
local _terminfodir
# terminfo bits make things work better if you fall into interactive mode
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -d ${_terminfodir} ] && break
[ -f ${_terminfodir}/l/linux ] && break
done
if [ -d ${_terminfodir} ]; then

View File

@@ -3,6 +3,7 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
[[ "$mount_needs" ]] && return 1
type -P biosdevname >/dev/null || return 1
return 0
}

View File

@@ -7,7 +7,7 @@ check() {
}
depends() {
echo masterkey securityfs
echo masterkey securityfs selinux
return 0
}

View File

@@ -34,7 +34,7 @@ install() {
dracut_install $_installs
inst_hook cmdline 90 "$moddir/parse-syslog-opts.sh"
inst_hook pre-udev 61 "$moddir/syslog-genrules.sh"
inst_hook pre-pivot 99 "$moddir/syslog-cleanup.sh"
inst_hook cleanup 99 "$moddir/syslog-cleanup.sh"
inst_simple "$moddir/rsyslogd-start.sh" /sbin/rsyslogd-start
inst_simple "$moddir/rsyslogd-stop.sh" /sbin/rsyslogd-stop
mkdir -m 0755 -p ${initdir}/etc/templates

View File

@@ -3,6 +3,7 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
[[ $mount_needs ]] && return 1
return 0
}

View File

@@ -5,13 +5,52 @@
type info >/dev/null 2>&1 || . /lib/dracut-lib.sh
type fsck_single >/dev/null 2>&1 || . /lib/fs-lib.sh
fsck_usr()
{
local _dev=$1
local _fs=$2
local _fsckoptions
if [ -f "$NEWROOT"/fsckoptions ]; then
_fsckoptions=$(cat "$NEWROOT"/fsckoptions)
fi
if [ -f "$NEWROOT"/forcefsck ] || getargbool 0 forcefsck ; then
_fsckoptions="-f $_fsckoptions"
elif [ -f "$NEWROOT"/.autofsck ]; then
[ -f "$NEWROOT"/etc/sysconfig/autofsck ] && . "$NEWROOT"/etc/sysconfig/autofsck
if [ "$AUTOFSCK_DEF_CHECK" = "yes" ]; then
AUTOFSCK_OPT="$AUTOFSCK_OPT -f"
fi
if [ -n "$AUTOFSCK_SINGLEUSER" ]; then
warn "*** Warning -- the system did not shut down cleanly. "
warn "*** Dropping you to a shell; the system will continue"
warn "*** when you leave the shell."
emergency_shell
fi
_fsckoptions="$AUTOFSCK_OPT $_fsckoptions"
fi
fsck_single "$_dev" "$_fs" "$_fsckoptions"
}
mount_usr()
{
local _dev _mp _fs _opts _rest _usr_found _ret
local _dev _mp _fs _opts _rest _usr_found _ret _freq _passno
# check, if we have to mount the /usr filesystem
while read _dev _mp _fs _opts _rest; do
while read _dev _mp _fs _opts _freq _passno; do
if [ "$_mp" = "/usr" ]; then
echo "$_dev $NEWROOT/$_mp $_fs ${_opts},ro $_rest"
case "$_dev" in
LABEL=*)
_dev="$(echo $_dev | sed 's,/,\\x2f,g')"
_dev="/dev/disk/by-label/${_dev#LABEL=}"
;;
UUID=*)
_dev="${_dev#block:}"
_dev="/dev/disk/by-uuid/${_dev#UUID=}"
;;
esac
echo "$_dev ${NEWROOT}${_mp} $_fs ${_opts} $_freq $_passno"
_usr_found="1"
break
fi
@@ -19,7 +58,11 @@ mount_usr()
if [ "x$_usr_found" != "x" ]; then
# we have to mount /usr
fsck_single "$_dev" "$_fs" "$_opts"
if [ "0" != "${_passno:-0}" ]; then
fsck_usr "$_dev" "$_fs"
else
:
fi
_ret=$?
echo $_ret >/run/initramfs/usr-fsck
if [ $_ret -ne 255 ]; then
@@ -29,4 +72,4 @@ mount_usr()
fi
}
mount_usr
mount_usr

View File

@@ -124,6 +124,7 @@ getargbool() {
if [ -n "$_b" ]; then
[ $_b = "0" ] && return 1
[ $_b = "no" ] && return 1
[ $_b = "off" ] && return 1
fi
return 0
}
@@ -391,6 +392,17 @@ wait_for_if_up() {
return 1
}
wait_for_route_ok() {
local cnt=0
while [ $cnt -lt 200 ]; do
li=$(ip route show)
[ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
sleep 0.1
cnt=$(($cnt+1))
done
return 1
}
# root=nfs:[<server-ip>:]<root-dir>[:<nfs-options>]
# root=nfs4:[<server-ip>:]<root-dir>[:<nfs-options>]
nfsroot_to_var() {
@@ -602,6 +614,92 @@ usable_root() {
return 0
}
inst_hook() {
local _hookname _unique _name _job _exe
while [ $# -gt 0 ]; do
case "$1" in
--hook)
_hookname="/$2";shift;;
--unique)
_unique="yes";;
--name)
_name="$2";shift;;
*)
break;;
esac
shift
done
if [ -z "$_unique" ]; then
_job="${_name}$$"
else
_job="${_name:-$1}"
_job=${_job##*/}
fi
_exe=$1
shift
[ -x "$_exe" ] || _exe=$(command -v $_exe)
if [ -n "$onetime" ]; then
{
echo '[ -e "$_job" ] && rm "$_job"'
echo "$_exe $@"
} > "/tmp/$$-${_job}.sh"
else
echo "$_exe $@" > "/tmp/$$-${_job}.sh"
fi
mv -f "/tmp/$$-${_job}.sh" "$hookdir/${_hookname}/${_job}.sh"
}
# inst_mount_hook <mountpoint> <prio> <name> <script>
#
# Install a mount hook with priority <prio>,
# which executes <script> as soon as <mountpoint> is mounted.
inst_mount_hook() {
local _prio="$2" _jobname="$3" _script="$4"
local _hookname="mount-$(str_replace "$1" '/' '\\x2f')"
[ -d "$hookdir/${_hookname}" ] || mkdir -p "$hookdir/${_hookname}"
inst_hook --hook "$_hookname" --unique --name "${_prio}-${_jobname}" "$_script"
}
# add_mount_point <dev> <mountpoint> <filesystem> <fsopts>
#
# Mount <dev> on <mountpoint> with <filesystem> and <fsopts>
# and call any mount hooks, as soon, as it is mounted
add_mount_point() {
local _dev="$1" _mp="$2" _fs="$3" _fsopts="$4"
local _hookname="mount-$(str_replace "$2" '/' '\\x2f')"
local _devname="dev-$(str_replace "$1" '/' '\\x2f')"
echo "$_dev $_mp $_fs $_fsopts 0 0" >> /etc/fstab
exec 7>/etc/udev/rules.d/99-mount-${_devname}.rules
echo 'SUBSYSTEM!="block", GOTO="mount_end"' >&7
echo 'ACTION!="add|change", GOTO="mount_end"' >&7
if [ -n "$_dev" ]; then
udevmatch "$_dev" >&7 || {
warn "add_mount_point dev=$_dev incorrect!"
continue
}
printf ', ' >&7
fi
{
printf -- 'RUN+="%s --unique --onetime ' $(command -v initqueue)
printf -- '--name mount-%%k '
printf -- '%s %s"\n' "$(command -v mount_hook)" "${_mp}"
} >&7
echo 'LABEL="mount_end"' >&7
exec 7>&-
}
# wait_for_mount <mountpoint>
#
# Installs a initqueue-finished script,
# which will cause the main loop only to exit,
# if <mountpoint> is mounted.
wait_for_mount()
{
local _name
@@ -614,6 +712,11 @@ wait_for_mount()
} >> "$hookdir/emergency/90-${_name}.sh"
}
# wait_for_dev <dev>
#
# Installs a initqueue-finished script,
# which will cause the main loop only to exit,
# if the device <dev> is recognized by the system.
wait_for_dev()
{
local _name
@@ -626,15 +729,27 @@ wait_for_dev()
} >> "$hookdir/emergency/80-${_name}.sh"
}
cancel_wait_for_dev()
{
local _name
_name="$(str_replace "$1" '/' '\\x2f')"
rm -f "$hookdir/initqueue/finished/devexists-${_name}.sh"
rm -f "$hookdir/emergency/80-${_name}.sh"
}
killproc() {
local exe="$(command -v $1)"
local sig=$2
local i
[ -x "$exe" ] || return 1
for i in /proc/[0-9]*; do
[ "$i" = "/proc/1" ] && continue
if [ -e "$i"/exe ] && [ "$i/exe" -ef "$exe" ] ; then
kill $sig ${i##*/}
local _exe="$(command -v $1)"
local _sig=$2
local _i
[ -x "$_exe" ] || return 1
for _i in /proc/[0-9]*; do
[ "$_i" = "/proc/1" ] && continue
if [ -e "$_i"/_exe ] && [ "$_i/_exe" -ef "$_exe" ] ; then
kill $_sig ${_i##*/}
fi
done
}
need_shutdown() {
>/run/initramfs/.need_shutdown
}

View File

@@ -40,6 +40,7 @@ wait_for_loginit()
emergency_shell()
{
local _ctty
set +e
if [ "$1" = "-n" ]; then
_rdshell_name=$2
@@ -57,8 +58,17 @@ emergency_shell()
echo "Dropping to debug shell."
echo
export PS1="$_rdshell_name:\${PWD}# "
[ -e /.profile ] || echo "exec 0<>/dev/console 1<>/dev/console 2<>/dev/console" > /.profile
sh -i -l
[ -e /.profile ] || >/.profile
_ctty=/dev/console
if [ -n "$(command -v setsid)" ]; then
_ctty="$(getarg rd.ctty=)" && _ctty="/dev/${_ctty##*/}"
[ -c "$_ctty" ] || _ctty=/dev/tty1
setsid sh -i -l 0<$_ctty 1>$_ctty 2>&1
elif [ -n "$(command -v openvt)" ] && ! getarg "console=" >/dev/null 2>&1 && getargbool 1 "rd.openvt" ; then
openvt -f -c 1 -w -s -l -- sh
else
sh -i -l 0<$_ctty 1>$_ctty 2>&1
fi
else
warn "Boot has failed. To debug this issue add \"rdshell\" to the kernel command line."
# cause a kernel panic
@@ -102,16 +112,7 @@ if [ "$RD_DEBUG" = "yes" ]; then
fi
if ! ismounted /dev; then
# try to mount devtmpfs
if ! mount -t devtmpfs -o mode=0755,nosuid devtmpfs /dev >/dev/null 2>&1; then
# if it failed fall back to normal tmpfs
mount -t tmpfs -o mode=0755,nosuid tmpfs /dev >/dev/null 2>&1
# Make some basic devices first, let udev handle the rest
mknod -m 0666 /dev/null c 1 3
mknod -m 0666 /dev/ptmx c 5 2
mknod -m 0600 /dev/console c 5 1
mknod -m 0660 /dev/kmsg c 1 11
fi
mount -t devtmpfs -o mode=0755,nosuid devtmpfs /dev >/dev/null
fi
# prepare the /dev directory
@@ -122,17 +123,17 @@ fi
if ! ismounted /dev/pts; then
mkdir -m 0755 /dev/pts
mount -t devpts -o gid=5,mode=620,noexec,nosuid devpts /dev/pts >/dev/null 2>&1
mount -t devpts -o gid=5,mode=620,noexec,nosuid devpts /dev/pts >/dev/null
fi
if ! ismounted /dev/shm; then
mkdir -m 0755 /dev/shm
mount -t tmpfs -o mode=1777,nosuid,nodev tmpfs /dev/shm >/dev/null 2>&1
mount -t tmpfs -o mode=1777,nosuid,nodev 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 2>&1
mount -t tmpfs -o mode=0755,nosuid,nodev tmpfs /newrun >/dev/null
cp -a /run/* /newrun
mount --move /newrun /run
rm -fr /newrun
@@ -200,6 +201,7 @@ udevproperty "hookdir=$hookdir"
getarg 'rd.break=pre-trigger' 'rdbreak=pre-trigger' && emergency_shell -n pre-trigger "Break before pre-trigger"
source_hook pre-trigger
udevadm control --reload >/dev/null 2>&1 || :
# then the rest
udevadm trigger --type=subsystems --action=add >/dev/null 2>&1
udevadm trigger --type=devices --action=add >/dev/null 2>&1
@@ -259,16 +261,16 @@ while :; do
fi
if [ $main_loop -gt $(($RDRETRY/2)) ]; then
for job in $hookdir/initqueue/timeout/*.sh; do
for job in $hookdir/initqueue/timeout/*.sh; do
[ -e "$job" ] || break
job=$job . $job
main_loop=0
done
done
fi
main_loop=$(($main_loop+1))
[ $main_loop -gt $RDRETRY ] \
&& { flock -s 9 ; emergency_shell "No root device \"$root\" found"; } 9>/.console_lock
&& { flock -s 9 ; emergency_shell "Unable to process initqueue"; } 9>/.console_lock
done
unset job
unset queuetriggered
@@ -316,7 +318,7 @@ source_hook pre-pivot
# By the time we get here, the root filesystem should be mounted.
# Try to find init.
for i in "$(getarg real_init=)" "$(getarg init=)" /sbin/init /etc/init /init /bin/sh; do
for i in "$(getarg real_init=)" "$(getarg init=)" $(getargs rd.distroinit=) /sbin/init; do
[ -n "$i" ] || continue
__p=$(readlink -f "${NEWROOT}/${i}")
@@ -421,6 +423,8 @@ wait_for_loginit
getarg rd.break rdbreak && emergency_shell -n switch_root "Break before switch_root"
info "Switching root"
source_hook cleanup
unset PS4
CAPSH=$(command -v capsh)

View File

@@ -16,14 +16,19 @@ install() {
dracut_install mount mknod mkdir modprobe pidof sleep chroot \
sed ls flock cp mv dmesg rm ln rmmod mkfifo umount readlink
dracut_install -o less
[[ $cttyhack = yes ]] && dracut_install -o setsid
if [ ! -e "${initdir}/bin/sh" ]; then
dracut_install bash
(ln -s bash "${initdir}/bin/sh" || :)
fi
#add common users in /etc/passwd, it will be used by nfs/ssh currently
egrep '^root:' "$initdir/etc/passwd" 2>/dev/null || echo 'root:x:0:0::/root:/bin/sh' >> "$initdir/etc/passwd"
egrep '^nobody:' /etc/passwd >> "$initdir/etc/passwd"
# install our scripts and hooks
inst "$moddir/init" "/init"
inst "$moddir/initqueue" "/sbin/initqueue"
inst "$moddir/loginit" "/sbin/loginit"
inst "$moddir/init.sh" "/init"
inst "$moddir/initqueue.sh" "/sbin/initqueue"
inst "$moddir/loginit.sh" "/sbin/loginit"
[ -e "${initdir}/lib" ] || mkdir -m 0755 -p ${initdir}/lib
mkdir -m 0755 -p ${initdir}/lib/dracut
@@ -38,8 +43,15 @@ install() {
dracut_install switch_root || dfatal "Failed to install switch_root"
inst "$moddir/dracut-lib.sh" "/lib/dracut-lib.sh"
inst "$moddir/mount-hook.sh" "/usr/bin/mount-hook"
inst_hook cmdline 10 "$moddir/parse-root-opts.sh"
mkdir -p "${initdir}/var"
[ -x /lib/systemd/systemd-timestamp ] && inst /lib/systemd/systemd-timestamp
if [[ $realinitpath ]]; then
for i in $realinitpath; do
echo "rd.distroinit=$i"
done > "${initdir}/etc/cmdline.d/distroinit.conf"
fi
}

View File

@@ -197,7 +197,7 @@ fsck_single() {
info "Checking $_fs: $_dev"
export FSTAB_FILE
eval "$_drv" "\"$_dev\"" "\"$_fop\""
eval "$_drv"
return $?
}

View File

@@ -10,6 +10,32 @@ depends() {
return 0
}
echo_fs_helper() {
local dev=$1 fs=$2
case "$fs" in
xfs)
echo -n " xfs_db xfs_repair xfs_check "
;;
ext?)
echo -n " e2fsck "
;;
jfs)
echo -n " jfs_fsck "
;;
reiserfs)
echo -n " reiserfsck "
;;
btrfs)
echo -n " btrfsck "
;;
*)
[[ -x fsck.$fs ]] && echo -n " fsck.$fs "
;;
esac
}
install() {
local _helpers
@@ -25,33 +51,8 @@ install() {
e2fsck jfs_fsck reiserfsck btrfsck
"
if [[ $hostonly ]]; then
print_fs_type() { get_fs_type /dev/block/$1; }
_rootdev=$(find_root_block_device)
if [[ $_rootdev ]]; then
_helpers="umount mount "
for fs in $(check_block_and_slaves print_fs_type "$_rootdev"); do
case "$fs" in
xfs)
_helpers+=" xfs_db xfs_repair xfs_check "
;;
ext?)
_helpers+=" e2fsck "
;;
jfs)
_helpers+=" jfs_fsck "
;;
reiserfs)
_helpers+=" reiserfsck "
;;
btrfs)
_helpers+=" btrfsck "
;;
*)
[[ -x fsck.$fs ]] && _helpers+= " fsck.$fs "
;;
esac
done
fi
_helpers="umount mount "
_helpers+=$(for_each_host_dev_fs echo_fs_helper)
fi
else
_helpers="$fscks"

72
modules.d/99img-lib/img-lib.sh Executable file
View File

@@ -0,0 +1,72 @@
#!/bin/sh
# img-lib.sh: utilities for dealing with archives and filesystem images.
#
# TODO: identify/unpack rpm, deb?
# super-simple "file" that only identifies archives.
# works with stdin if $1 is not set.
det_archive() {
local bz="BZh" xz="$(echo -e '\xfd7zXZ')" gz="$(echo -e '\x1f\x8b')"
local headerblock="$(dd ${1:+if=$1} bs=262 count=1 2>/dev/null)"
case "$headerblock" in
$xz*) echo "xz" ;;
$gz*) echo "gzip" ;;
$bz*) echo "bzip2" ;;
07070*) echo "cpio" ;;
*ustar) echo "tar" ;;
esac
}
# determine filesystem type for a filesystem image
det_fs_img() {
local dev=$(losetup --find --show "$1") rv=""
det_fs $dev; rv=$?
losetup -d $dev
return $rv
}
# unpack_archive ARCHIVE OUTDIR
# unpack a (possibly compressed) cpio/tar archive
unpack_archive() {
local img="$1" outdir="$2" archiver="" decompr=""
local ft="$(det_archive $img)"
case "$ft" in
xz|gzip|bzip2) decompr="$decompr -dc" ;;
cpio|tar) decompr="cat";;
*) return 1 ;;
esac
ft="$($decompr $img | det_archive)"
case "$ft" in
cpio) archiver="cpio -iumd" ;;
tar) archiver="tar -xf -" ;;
*) return 2 ;;
esac
mkdir -p $outdir
( cd $outdir; $decompr | $archiver 2>/dev/null ) < $img
}
# unpack_fs FSIMAGE OUTDIR
# unpack a filesystem image
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 . )
umount $mnt
rmdir $mnt
}
# unpack an image file - compressed/uncompressed cpio/tar, filesystem, whatever
# unpack_img IMAGEFILE OUTDIR
unpack_img() {
local img="$1" outdir="$2"
[ -r "$img" ] || { warn "can't read img!"; return 1; }
[ -n "$outdir" ] || { warn "unpack_img: no output dir given"; return 1; }
if [ "$(det_img $img)" ]; then
unpack_archive "$@" || { warn "can't unpack archive file!"; return 1; }
else
unpack_fs "$@" || { warn "can't unpack filesystem image!"; return 1; }
fi
}

Some files were not shown because too many files have changed in this diff Show More