Compare commits

..

389 Commits
024 ... 030

Author SHA1 Message Date
Harald Hoyer
951cedf8cb Revert "systemd: add systemd-fsck-root.service"
This reverts commit 35857f556c.
2013-07-17 15:05:30 +02:00
Harald Hoyer
0baf97618d AUTHORS: update 2013-07-17 14:58:44 +02:00
Harald Hoyer
8642792c3e NEWS: update 2013-07-17 14:58:35 +02:00
Harald Hoyer
5bbfd48475 dracut: do not enable early microcode inclusion by default 2013-07-17 14:36:34 +02:00
Harald Hoyer
c33488feb1 rename sosreport to rdsosreport
Renamed sosreport to rdsosreport to differ from the sosreport tool on
the real root.
2013-07-17 14:31:59 +02:00
Harald Hoyer
18e61d3d41 rename dracut-nohostonly and dracut-norescue rpm subpackages
dracut-nohostonly -> dracut-config-generic
dracut-norescue   -> dracut
                  -> dracut-config-rescue
2013-07-17 13:02:58 +02:00
Harald Hoyer
fbf717086e dmraid: let dmraid setup the partitions 2013-07-17 12:07:19 +02:00
Harald Hoyer
5a6a98f875 do not wait_for_dev for the root device
it's specified on the kernel command line
2013-07-17 12:03:01 +02:00
Harald Hoyer
35857f556c systemd: add systemd-fsck-root.service 2013-07-17 12:00:04 +02:00
Harald Hoyer
a6865e6897 rootfs-block: do not touch root-fsck
in systemd environments, we use systemd in the initramfs
2013-07-17 11:58:55 +02:00
Harald Hoyer
55068924f7 i18n: do not moan about missing kbd directory 2013-07-17 11:58:17 +02:00
Harald Hoyer
16addb86fc base: remove RD_TIMESTAMP 2013-07-17 11:26:55 +02:00
Konrad Rzeszutek Wilk
5f2c30d9bc dracut.sh: Support early microcode loading.
On Wed, Jul 10, 2013 at 10:58:15AM -0400, Konrad Rzeszutek Wilk wrote:
> On Wed, Jul 10, 2013 at 09:37:11AM +0200, Harald Hoyer wrote:
> > On 07/10/2013 02:29 AM, Yu, Fenghua wrote:
> > >> From: Konrad Rzeszutek Wilk [mailto:konrad.wilk@oracle.com]
> > >> Sent: Tuesday, July 09, 2013 12:24 PM
> > >> Implement it per Linux kernel Documentation/x86/early-microcode.txt
> > >> (from v3.11-rc0):
> > [...]
> > > This patch works fine with one microcode blob in binary format. There are situations that the microcode is not delivered in one blob in binary format:
> > >
> > > First, each microcode patch is one file instead all microcode patches are in one big blob. Secondly, old delivered microcode file is in ascii format.
> > >
> > > To handle those formats, additional code needs to convert the formats into one big binary microcode blob. I'm not sure if we should consider the code and if we should put the code in dracut.
> > >
> > > Thanks.
> > >
> > > -Fenghua
> > >
> >
> >
> > $ ls /lib/firmware/amd-ucode
> > microcode_amd.bin  microcode_amd_fam15h.bin  microcode_amd_solaris.bin
>
> Right, so all of those blobs (for AMD) get stuck in AuthenticAMD.bin.
>
> > $ ls /lib/firmware/intel-ucode
> > 06-03-02  06-06-00  06-07-02  06-08-0a  06-0b-04  06-0f-06  06-16-01  06-1c-02
> > 06-25-02  06-2d-07  0f-01-02  0f-02-09  0f-04-03  0f-04-0a
> > 06-05-00  06-06-05  06-07-03  06-09-05  06-0d-06  06-0f-07  06-17-06  06-1c-0a
> > 06-25-05  06-2f-02  0f-02-04  0f-03-02  0f-04-04  0f-06-02
> > 06-05-01  06-06-0a  06-08-01  06-0a-00  06-0e-08  06-0f-0a  06-17-07  06-1d-01
> > 06-26-01  06-3a-09  0f-02-05  0f-03-03  0f-04-07  0f-06-04
> > 06-05-02  06-06-0d  06-08-03  06-0a-01  06-0e-0c  06-0f-0b  06-17-0a  06-1e-04
> > 06-2a-07  0f-00-07  0f-02-06  0f-03-04  0f-04-08  0f-06-05
> > 06-05-03  06-07-01  06-08-06  06-0b-01  06-0f-02  06-0f-0d  06-1a-04  06-1e-05
> > 06-2d-06  0f-00-0a  0f-02-07  0f-04-01  0f-04-09  0f-06-08
>
> And all of those get catted in GenuineIntel.bin.
>
> >
> > Also, for [[ $hostonly ]], we only want to add the current running CPU microcode.
>
> <nods> Will do that. Are you OK with me adding some of this CPU detection logic
> in dracut-functions.sh?

This is still RFC, as I had not done the --no-compress logic (or tested it).
Please see if this is OK:

>From 5f853d2ececd4cadff648e22cb9c9287a01a9783 Mon Sep 17 00:00:00 2001
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Date: Tue, 9 Jul 2013 13:57:01 -0400
Subject: [PATCH] dracut.sh: Support early microcode loading.

Implement it per Linux kernel Documentation/x86/early-microcode.txt
(from v3.11-rc0):

<start>
Early load microcode
====================
By Fenghua Yu <fenghua.yu@intel.com>

Kernel can update microcode in early phase of boot time. Loading microcode early
can fix CPU issues before they are observed during kernel boot time.

Microcode is stored in an initrd file. The microcode is read from the initrd
file and loaded to CPUs during boot time.

The format of the combined initrd image is microcode in cpio format followed by
the initrd image (maybe compressed). Kernel parses the combined initrd image
during boot time. The microcode file in cpio name space is:
on Intel: kernel/x86/microcode/GenuineIntel.bin
on AMD  : kernel/x86/microcode/AuthenticAMD.bin

During BSP boot (before SMP starts), if the kernel finds the microcode file in
the initrd file, it parses the microcode and saves matching microcode in memory.
If matching microcode is found, it will be uploaded in BSP and later on in all
APs.

The cached microcode patch is applied when CPUs resume from a sleep state.

There are two legacy user space interfaces to load microcode, either through
/dev/cpu/microcode or through /sys/devices/system/cpu/microcode/reload file
in sysfs.

In addition to these two legacy methods, the early loading method described
here is the third method with which microcode can be uploaded to a system's
CPUs.

The following example script shows how to generate a new combined initrd file in
/boot/initrd-3.5.0.ucode.img with original microcode microcode.bin and
original initrd image /boot/initrd-3.5.0.img.

mkdir initrd
cd initrd
mkdir -p kernel/x86/microcode
cp ../microcode.bin kernel/x86/microcode/GenuineIntel.bin (or AuthenticAMD.bin)
find . | cpio -o -H newc >../ucode.cpio
cd ..
cat ucode.cpio /boot/initrd-3.5.0.img >/boot/initrd-3.5.0.ucode.img
<end>

That is what we do in the patch. Furthermoere there is also
an off-switch: "no-early-microcode" to disable it.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
[v1: Support --host-only parameter]
2013-07-15 14:06:40 +02:00
Harald Hoyer
c00f8e05a6 dracut.sh: correct dropindirs_sort 2013-07-12 10:35:49 +02:00
Harald Hoyer
85231e1ff3 base/module-setup.sh: do not add devs to initqueue/finished
when need-initqueue is not set in systemd mode
2013-07-12 10:15:10 +02:00
Harald Hoyer
88396c383c base/module-setup.sh: do not include systemd-timestamp
when using systemd in the initramfs
2013-07-12 10:14:15 +02:00
Harald Hoyer
df03141dbc dracut-cmdline.service: remove Before: systemd-vconsole-setup.service 2013-07-12 09:47:24 +02:00
Harald Hoyer
bf9cdc472c systemd/module-setup.sh: create emtpy /etc/machine-id
Even in hostonly mode, if none was found on the system.
2013-07-11 12:15:17 +02:00
Harald Hoyer
02b5c8e3a3 dracut.sh: unset all LC_* and LANG
saves 10% of time :-)
2013-07-05 16:27:34 +02:00
Harald Hoyer
f734347ae7 modules.d/10i18n/module-setup.sh: handle empty vconsole.conf
if /etc/vconsole.conf exists and is empty, then do not install anything.
2013-07-05 15:48:40 +02:00
Harald Hoyer
4aca0017e8 terminfo: only install l/linux v/vt100 and v/vt220 2013-07-05 15:32:58 +02:00
Harald Hoyer
1e057b352a add PARTLABEL and PARTUUID 2013-07-05 15:32:38 +02:00
Harald Hoyer
431b86c8e9 masterkey/module-setup.sh:check() check for $hostonly rather than "-h" 2013-07-04 12:31:31 +02:00
Harald Hoyer
b093aa2dc7 beautified shell code
checked with shellcheck http://www.shellcheck.net/about.html
2013-07-04 12:31:15 +02:00
Harald Hoyer
32bd2fbb4c use "rm --" to guard against filenames beginning with "-" 2013-06-28 10:31:18 +02:00
Harald Hoyer
1d84d6940e TEST-04-FULL-SYSTEMD/test.sh: dlfgjlkdfjgldfj 2013-06-28 10:22:27 +02:00
Harald Hoyer
87ae968810 test/run-qemu: specify the kernel 2013-06-28 10:21:42 +02:00
Harald Hoyer
f13deabd22 systemd/module-setup.sh: add slices.target 2013-06-28 09:58:03 +02:00
Harald Hoyer
0d59a84b53 TEST-04-FULL-SYSTEMD: call xargs with "-r" 2013-06-26 09:16:04 +02:00
Harald Hoyer
68cb510f18 systemd: add system.slice unit 2013-06-26 09:15:34 +02:00
Harald Hoyer
5e60145449 use findmnt with "--source" or "--target"
This avoids hanging on stale NFS mounts, which are not part of the boot
process.

https://bugzilla.redhat.com/show_bug.cgi?id=975401
2013-06-24 12:47:53 +02:00
Harald Hoyer
282e0583b0 udev-rules: add 75-net-description.rules
we need IMPORT{builtin}="net_id" for the persistent network names
2013-06-18 17:54:30 +02:00
WANG Chao
32d115f385 selinux: umount $NEWROOT/dev and its submounts
$NEWROOT/dev and its submounts should be umounted after we use it.
Otherwise it fails other scripts that umount /sysroot only.

Signed-off-by: WANG Chao <chaowang@redhat.com>
2013-06-18 08:56:11 +02:00
Harald Hoyer
416d3d6390 NEWS: update 2013-06-14 15:31:28 +02:00
Baoquan He
8a9a5838f3 90lvm/module-setup.sh: redirect error message of lvs to /dev/null
Signed-off-by: Baoquan He <bhe@redhat.com>
2013-06-13 15:49:20 +02:00
Harald Hoyer
a94cd56d6f test/TEST-50-MULTINIC: fix interface test 2013-06-13 15:15:55 +02:00
Harald Hoyer
b819f519cb network: refix BOOTIF logic 2013-06-13 15:15:19 +02:00
Harald Hoyer
44d832c5ad test/TEST-50-MULTINIC: fixed debug output 2013-06-13 14:44:47 +02:00
Harald Hoyer
4961910fe3 systemd/module-setup.sh: mkdir /etc/systemd 2013-06-13 14:44:13 +02:00
Will Woods
3d0da653f0 net-lib: fix set_ifname()
/sys/class/$name$num isn't ever going to work; /sys/class/net/$name$num
(e.g. /sys/class/net/ibft0) should work right.
2013-06-13 14:07:17 +02:00
Will Woods
4ef0e2d92a net-lib: add configured_ifaces()
configured_ifaces is a function that returns the names of each interface
that the user wanted configured.

Currently, this is accomplished by reading the list from
/tmp/net.ifaces. But if we want to allow the user to specify an
interface by its MAC address or IP or something, we need a function that
will read the cache and convert the MACs etc. to names.

(Obviously this conversion only works once udev starts, so it will warn
you if you try it too early.)
2013-06-13 14:07:17 +02:00
Will Woods
bd0f2c034a net-lib: add find_iface_with_link()
Add a function to look at the system network interfaces and return the
first one it finds with an active link (if any.)
2013-06-13 14:07:17 +02:00
Will Woods
d8a698713e Don't explode when mixing BOOTIF and ip=
Now that we can use a MAC as a device identifier, we can just bring up
the device specified by BOOTIF as a normal interface.

So instead of ignoring everything but BOOTIF, we'll put BOOTIF in the
IFACES list and bring it up as normal, defaulting to DHCP if nothing
else is specified.

We can also handle anaconda-style 'ksdevice=bootif' this way.
2013-06-13 14:07:17 +02:00
Will Woods
57f2579281 net-genrules: accept MAC address for $iface, cleanups
A MAC address is a unique identifier for a particular network interface.

We can use the MAC to generate udev rules to bring up that interface,
like we currently do with BOOTIF.

This patch allows interfaces to be specified as a MAC address, either
in the usual colon-separated form or the PXE-style dash-separated form.

(The latter is more useful on the commandline, since it allows for
arguments like: "ip=77-77-6f-6f-64-73:dhcp")

This is useful since it's common for a user who is booting a new OS for
the first time to know the MAC of the device, but not know what the
kernel name will be.
2013-06-13 14:07:17 +02:00
Will Woods
215ff169db move fix_bootif to net-lib
This might be useful to other parts of dracut; move it to net-lib.sh.
2013-06-13 13:54:16 +02:00
Harald Hoyer
85b458d90d Makefile: source dracut-version.sh and correct dist tarball 2013-06-13 12:55:26 +02:00
Harald Hoyer
268ae2841b Makefile: pipe git describe errors to /dev/null 2013-06-13 12:55:26 +02:00
Harald Hoyer
638cad7c97 add dracut-shutdown.service.8.asc manpage 2013-06-13 12:55:26 +02:00
Harald Hoyer
0fbb79d54f move dracut-shutdown.service to modules.d/98systemd 2013-06-13 11:42:26 +02:00
Harald Hoyer
36c34f4e71 Don't use do syncheck for target all and refine syncheck
instead of "dash -n" we now use "bash --posix -n"
we also check for "[[ " in posix shell files
2013-06-13 11:19:26 +02:00
Harald Hoyer
373efa4427 systemd: make unit files symlinks 2013-06-13 11:08:03 +02:00
Harald Hoyer
cee4599131 systemd/dracut-pre-pivot.service: also execute for cleanup hooks or rd.break 2013-06-13 10:37:45 +02:00
Harald Hoyer
c6011f2add i18n: make the default font configurable
To set the default font for your distribution, add
i18n_default_font="latarcyrheb-sun16"
to your /lib/dracut/dracut.conf.d/01-dist.conf distribution config.
2013-06-13 09:29:17 +02:00
Harald Hoyer
f8b958dc62 network: wait 40 seconds for IPv6 auto configuration
https://bugzilla.redhat.com/show_bug.cgi?id=973719
2013-06-12 17:42:35 +02:00
Harald Hoyer
036712546b NEWS: update 2013-06-12 13:29:39 +02:00
Harald Hoyer
391d605790 rename kernel command line param action_on_fail to rd.action_on_fail 2013-06-12 13:16:33 +02:00
Harald Hoyer
aef0f55791 dmsquash-live/iso-scan: wait until the iso-scan/filename is found
Do not only run once, but wait until all devices are found.
2013-06-12 12:49:03 +02:00
Harald Hoyer
66ed711ccf systemd/dracut-initqueue.service: specify all initqueues 2013-06-07 13:56:16 +02:00
Harald Hoyer
960b1e48e8 TODO: update 2013-06-07 12:39:46 +02:00
WANG Chao
437a56dc6b dracut-initqueue.service: Fix systemd start condition
Scripts in dracut initqueue hooks are placed under
/usr/lib/dracut/hooks/initqueue/*/ directory.

And also start initqueue service when kernel cmdline has
rd.break=initqueue

Signed-off-by: WANG Chao <chaowang@redhat.com>
2013-06-07 12:38:36 +02:00
Harald Hoyer
630aed8b66 udev-rules: add 80-net-name-slot.rules 2013-06-06 15:40:29 +02:00
Harald Hoyer
af6292f0fc cms/cmssetup.sh: untabify 2013-06-06 14:13:36 +02:00
Harald Hoyer
b710520a3d cms/cmssetup.sh: reload udev rules after adding them 2013-06-06 14:13:01 +02:00
Harald Hoyer
66e092bb53 cms/cmssetup.sh: fix LAYER2 ccw.conf setup 2013-06-06 12:32:36 +02:00
Harald Hoyer
fdc1037b19 cms/cmsifup.sh: correctly set MACADDR and MTU for the ip line
https://bugzilla.redhat.com/show_bug.cgi?id=971025
2013-06-06 12:28:34 +02:00
Harald Hoyer
76df206685 cms/cmssetup.sh: do not echo newlines for ccw.conf
https://bugzilla.redhat.com/show_bug.cgi?id=970982
2013-06-06 12:27:19 +02:00
WANG Chao
77364fd6bb base: setup correct system time and time zone in initrd
Currently in initrd, hardware clock is always considered to use UTC time
format and system time zone is also UTC. Thus system time isn't correct
if hw clock is localtime or we're using other time zone in real root.

To fix this, install /etc/adjtime and /etc/localtime to initrd. If not
using systemd, install /usr/sbin/hwclock for dracut init to setup system
time.

[harald: combined the two hostonly if's]

Signed-off-by: WANG Chao <chaowang@redhat.com>
Signed-off-by: Harald Hoyer <harald@redhat.com>
2013-06-06 12:10:50 +02:00
Harald Hoyer
41b0e41a09 Makefile: report syntax check files for V=1 2013-06-06 11:31:07 +02:00
Harald Hoyer
791532b0ce dracut-install: install libs also from one dir above
some HW has different flavors of basic libs

$ ldconfig -p|fgrep libc.so
libc.so.6 (libc6,64bit, hwcap: 0x0000001000000000, OS ABI: Linux 2.6.32) => /lib64/power6/libc.so.6
libc.so.6 (libc6,64bit, hwcap: 0x0000000000000200, OS ABI: Linux 2.6.32) => /lib64/power6x/libc.so.6
libc.so.6 (libc6,64bit, OS ABI: Linux 2.6.32) => /lib64/libc.so.6

because setting LD_HWCAP_MASK=0 does not work, we have to workaround
this.

$ LD_TRACE_LOADED_OBJECTS=1  LD_HWCAP_MASK=0 /lib64/ld64.so.1 /bin/sh | fgrep libc.so
libc.so.6 => /lib64/power6/libc.so.6 (0x000000804e260000)

Now we try to install the same library from one directory above the one
we installed also.
2013-06-06 11:06:55 +02:00
Harald Hoyer
ad45024416 lvm: fixed "thin" recognition 2013-06-06 09:40:26 +02:00
Dennis Gilmore
3ae5ac28af include panel-tfp410 module on arm systems in the initramfs needed for framebuffer on omap systems 2013-06-06 09:38:44 +02:00
Harald Hoyer
fd28794bbc TEST-99-RPM: generate rpms and exclude /boot loader entries 2013-05-31 10:00:07 +02:00
Harald Hoyer
d18fd0235b dmsquash-live/dmsquash-live-root.sh: fixup 32214acb3a 2013-05-31 09:04:55 +02:00
Harald Hoyer
15c5c072f4 dracut-functions.sh:get_persistent_dev() fix case for multipath
/dev/mapper/mpath* is not a persistent device path

https://bugzilla.redhat.com/show_bug.cgi?id=969068
2013-05-31 07:47:01 +02:00
Harald Hoyer
caf207afa7 ifcfg/write-ifcfg.sh: fixed logic
seems like nobody tested this with recent dracut versions.
2013-05-30 14:37:41 +02:00
Harald Hoyer
57937cf480 lvm: add tools for thin provisioning
https://bugzilla.redhat.com/show_bug.cgi?id=921235
2013-05-30 12:02:59 +02:00
Harald Hoyer
feaf30ffaa network: wait for all required interfaces if "rd.neednet=1"
also set bootdev to the first configured interface, if missing

https://bugzilla.redhat.com/show_bug.cgi?id=801829
2013-05-30 11:38:23 +02:00
Harald Hoyer
dcae873414 systemd/emergency.service: do not run for action_on_fail=continue
same as for dracut-emergency.service
2013-05-30 11:14:39 +02:00
Harald Hoyer
32214acb3a dmsquash-live/dmsquash-live-root.sh: add parameter rd.live.squashimg
rd.live.squashimg names the squash image in the rd.live.dir
and defaults to squashfs.img

https://bugzilla.redhat.com/show_bug.cgi?id=789036
https://bugzilla.redhat.com/show_bug.cgi?id=782108
2013-05-30 09:27:54 +02:00
Harald Hoyer
e64bcf5a99 kernel-modules/module-setup.sh: add hid-hyperv and hv-vmbus 2013-05-30 08:38:40 +02:00
Harald Hoyer
62cb52f431 base/dracut-lib.sh: export DRACUT_SYSTEMD and NEWROOT 2013-05-30 08:32:18 +02:00
dyoung@redhat.com
cf8b1b7853 selinux: load_policy script fix
chroot load_policy will use selinuxfs which should be mounted
in $NEWROOT/sys/fs/selinux for Fedora 19, but because there's
no $NEWROOT/sys/fs, so later process will fail.

Fixing this by bind mount /sys to $NEWROOT/sys.

Signed-off-by: Dave Young <dyoung@redhat.com>
2013-05-30 08:28:11 +02:00
Dan Horák
bc97e005fa use system provides udev rule and initialization script 2013-05-30 08:28:10 +02:00
Baoquan He
679fa7ed3c 99fs-lib/fs-lib.sh: Let user specify the action after fail for fsck
The fsck is ignored when replace emergency_shell with action_on_fail,
now add it.

Signed-off-by: Baoquan He <bhe@redhat.com>
2013-05-30 08:28:08 +02:00
Harald Hoyer
4f084f3ab5 fs-lib/module-setup.sh: add xfs_metadump 2013-05-29 17:51:57 +02:00
Harald Hoyer
af2716626a kernel-modules/module-setup.sh: add nvme kernel module
apparently not caught by the block driver regexp

https://bugzilla.redhat.com/show_bug.cgi?id=910734
2013-05-29 14:48:13 +02:00
Harald Hoyer
6625c085ae ifcfg/write-ifcfg.sh:
- fix ONBOOT for slaves
- set TYPE=Bond for bonding

https://bugzilla.redhat.com/show_bug.cgi?id=919001
2013-05-29 14:38:52 +02:00
Harald Hoyer
af2578562c udev-rules/module-setup.sh: optionally install /etc/pcmcia/config.opts
https://bugzilla.redhat.com/show_bug.cgi?id=920076
2013-05-29 14:29:02 +02:00
Harald Hoyer
8099e7b1ba crypt-loop/module-setup.sh: install loop kernel module 2013-05-29 13:31:54 +02:00
Harald Hoyer
0a3e348225 i18n/module-setup.sh: install default font latarcyrheb-sun16 2013-05-29 13:27:03 +02:00
Harald Hoyer
b78e6ac2c3 dracut-emergency.service: do not start for "action_on_fail=continue" 2013-05-29 11:33:25 +02:00
Dennis Schridde
cbfe65c2fe [40network] Provide a hostname fallback function, in case there is no executable of this name 2013-05-29 11:32:57 +02:00
Harald Hoyer
284d62da81 ifcfg/write-ifcfg.sh: proper NAME the interfaces
https://bugzilla.redhat.com/show_bug.cgi?id=965842
2013-05-28 16:56:40 +02:00
Harald Hoyer
c6df70fb48 btrfs: include btrfs-zero-log in the initramfs
https://bugzilla.redhat.com/show_bug.cgi?id=963257
2013-05-28 16:34:56 +02:00
Harald Hoyer
1b8616adee url-lib/url-lib.sh: turn off curl globbing
https://bugzilla.redhat.com/show_bug.cgi?id=907497
2013-05-28 16:16:26 +02:00
Harald Hoyer
639bd4873b dracut.spec: put selinux for kdump crash file contexts 2013-05-28 15:40:45 +02:00
Kamil Rytarowski
e0904b27ff Fix memory leak 2013-05-28 14:36:37 +02:00
Kamil Rytarowski
d9eff33ce2 Always check the return number of asprintf
asprintf prints to an allocated string. When  successful,  the
functions return the number of bytes printed. If memory allocation
wasn't possible, or some other error occurs, the function will return
-1.

Don't check strp as a result of asprintf, it's content may be undefined.

man 3 asprintf
2013-05-28 14:35:54 +02:00
Kamil Rytarowski
8974102f6b Use consistiently termination code macros
Operate in install_all and install_one consequently on EXIT_SUCCESS
and EXIT_FAILURE termination code macros as they are meant to be
returned from these functions.
2013-05-28 14:34:44 +02:00
Kamil Rytarowski
599182b108 Introduce stricter type correctness 2013-05-28 14:34:29 +02:00
Kamil Rytarowski
6a736cc129 Fix parsing command line arguments
Adjust correctly the *optstring argument of getopt_long. Add support
for a missing option -v|--verbose and drop unknown options -D, -I and -L.
2013-05-28 14:33:02 +02:00
Baoquan He
15b93069bb 01fips/module-setup.sh: add libssl.so.10 to make kdump work with fips mode
FIPS can work well in 1st kernel, but failed in kdump kernel. the
libssl.so.10 and related hmac file are needed. Now add it and it
works.

Signed-off-by: Baoquan He <bhe@redhat.com>
2013-05-28 14:26:31 +02:00
Harald Hoyer
19b5c10963 dracut-functions.sh: clarify instmods() error message 2013-05-28 14:25:49 +02:00
Harald Hoyer
bcfbddefe1 don't add volatile swap partitions to host_devs 2013-05-28 13:36:37 +02:00
Harald Hoyer
780cb33741 systemd: set environment vars DRACUT_SYSTEMD, NEWROOT in service file 2013-05-28 12:50:57 +02:00
Adam Williamson
8d7c07f191 don't specify "p" as a separator for dmraid arrays (RHBZ #966162)
As per RHBZ #966162, parted stopped unconditionally using "p" as a
separator for dmraid device names in version 3.1, so other things need
to fall in line with that convention now.
2013-05-27 10:08:53 +02:00
Harald Hoyer
fefd3f66f9 dracut.sh: degrade message about missing tools for stripping
warning -> info

https://bugzilla.redhat.com/show_bug.cgi?id=958519
2013-05-06 14:20:16 +02:00
Colin Guthrie
d57b8833c4 usrmount: Fix miss-detection of btrfs subvolumes.
This causes the root FS options to be incorrectly applied to to /usr
In some cases this can cause boot failure e.g. due to and XFS /usr
not supporting the 'acl' option from the ext4 root FS.

https://bugs.mageia.org/show_bug.cgi?id=9884
2013-05-06 14:06:07 +02:00
Harald Hoyer
9584c6ae90 zfcp: match udev rule against KERNEL=="zfcp"
zfcp_cfdc will go away in the future

	tt
2013-04-30 18:56:15 +02:00
Harald Hoyer
021b2fddff test: use grep option "-F" and install /etc/os-release 2013-04-30 18:54:33 +02:00
WANG Chao
b6f2e05819 _emergency_shell: Show current working directory correctly in shell.
When dropped to emergency shell, for example, use rd.break=pre-pivot,
the PS1 won't correctly show current directory we're in:

pre-pivot:/# cd /sysroot/
pre-pivot:/#
(still shows "/")

Let's take a look at PS1 variable:

(I'm adding prefix/suffix 'x' to make it clear):
pre-pivot:/# echo x${PS1}x
xpre-pivot:/# x
(PS1 isn't dynamic)

Regarding the current dracut code, it should be:

pre-pivot:/# cd /sysroot/etc
pre-pivot:/sysroot/etc#

With this patch:

pre-pivot:/# echo x${PS1}x
xpre-pivot:${PWD}# x
(Now PS1 is dynamic, it will show the directory correctly)

I tested for both normal boot and kdump boot.

Signed-off-by: WANG Chao <chaowang@redhat.com>
2013-04-30 12:13:56 +02:00
Harald Hoyer
3ed08d1e4d dracut-install: make use of _cleanup_* macros 2013-04-29 11:35:23 +02:00
Harald Hoyer
26a077fc7e fips: do not fail immediatly after loading the crypto modules
Fail only if tcrypt insmod failed.
2013-04-29 11:34:26 +02:00
Harald Hoyer
8461734ee4 dracut.sh: do not preunlink for fips mode
just install prelink and the cache files
2013-04-25 21:16:03 +02:00
Harald Hoyer
6f4c2dada4 fixed fips mode
- preserve timestamps
- copy /lib*/hmaccalc files
- run sha512hmac after kernel module loading
- add more fips kernel modules
2013-04-25 19:44:01 +02:00
Harald Hoyer
ab42fe38fd fixup 3be5d63c2f
either test or []
2013-04-19 15:08:16 +02:00
Harald Hoyer
3be5d63c2f shutdown: redirect output to /dev/console only if it exists 2013-04-19 15:00:20 +02:00
Harald Hoyer
b4dc22cab7 dracut-install: error out, if ldd reports no execution permission
This turns off lazy resolving on noexec mounted tmp directories.

https://bugzilla.redhat.com/show_bug.cgi?id=953426
2013-04-18 12:54:55 +02:00
Harald Hoyer
2b125c69cc base/dracut-lib.sh: do not setdebug, if not in initramfs 2013-04-18 12:54:30 +02:00
Harald Hoyer
9268366cad Makefile: remove dracut-version.sh on clean 2013-04-16 13:41:19 +02:00
Harald Hoyer
d0eedc4a5f .gitignore: ignore more files 2013-04-16 13:38:16 +02:00
Harald Hoyer
4460416abc lsinitrd.sh: do not output filename for a single file 2013-04-16 13:36:04 +02:00
Harald Hoyer
884e1cda7c lsinitrd: drop use of "file" 2013-04-16 13:04:21 +02:00
Harald Hoyer
46a885bf9f dracut-bash-completion.sh: file filename completion 2013-04-16 11:32:32 +02:00
Harald Hoyer
7dbca9be86 lsinitrd: add bash completion 2013-04-16 11:32:31 +02:00
Harald Hoyer
7d9bb76ac7 lsinitrd: switch to getopt and add "-f" and "-k" parameter 2013-04-16 11:32:31 +02:00
Harald Hoyer
26ab7b07a6 Makefile: fixup tarball Makefile 2013-04-15 11:53:03 +02:00
Harald Hoyer
14499534ba dmsquash-live: add support for "iso-scan/filename" kernel parameter
now you can write grub entries like

  set isofile="/Fedora-live.iso"
  loopback loop $isofile
  linux loop)/isolinux/vmlinuz iso-scan/filename=$isofile root=live:CDLABEL=Fedora-...
  initrd (loop)/isolinux/initrd0.img
2013-04-15 11:39:32 +02:00
Harald Hoyer
1540df0e79 url-lib/module-setup.sh: install ca-bundle.crt by libcurl.so
https://bugzilla.redhat.com/show_bug.cgi?id=950770

curl seems to look for /etc/pki/tls/certs/ca-bundle.crt

extract the correct path by disecting libcurl.so
2013-04-12 15:27:27 +02:00
Harald Hoyer
5d68c80b16 systemd: include the systemd-random-seed-load.service
The systemd cryptsetup-generator wants systemd-random-seed-load.service
in case /dev/urandom is the device.
2013-04-12 15:27:27 +02:00
Harald Hoyer
5f8cd1a4be Makefile,git2spec.pl: use "git describe" 2013-04-12 15:27:27 +02:00
Harald Hoyer
14201d23e7 AUTHORS: update 2013-04-12 15:27:27 +02:00
Harald Hoyer
a229b17434 plymouth/plymouth-pretrigger.sh: fixup of ca2c6936 2013-04-12 15:25:44 +02:00
Harald Hoyer
ca2c693679 Do not call plymouth with full path 2013-04-11 16:08:26 +02:00
Harald Hoyer
cdcb27a4fe crypt/module-setup.sh: also handle UUID= while filtering crypttab
The crypttab filter for host-only did not handle UUID= entries.
https://bugzilla.redhat.com/show_bug.cgi?id=919752
2013-04-10 10:16:49 +02:00
WANG Chao
0c5ccb35c7 ifup.sh: Add support for bridge over a vlan tagged interface
This patch add support for bridge a vlan tagged interface, like
br0 -> bond0.7 -> bond0 -> eth0

Signed-off-by: WANG Chao <chaowang@redhat.com>
2013-04-09 13:39:32 +02:00
Baoquan He
9d787df196 Let user specify the action after fail
Currently the default action is emergency_shell when failure happened
during system boot. In kdump, this default may not be expected. E.g,
if dump target is not rootfs, it does not matter if mount root failed.
Adding an action which allow dracut always go ahead though failure
happens is needed by kdump.

So here add a function action_on_fail() and cmdline parameter
action_on_fail=<shell | continue>. Use action_to_fail() to replace
emergency_shell which was called after failure. By $(getarg action_on_fail=),
decide to drop into shell, or to leave away the failure and go ahead.

v3->v4:
add handling of selinux policy loaded failure, and change code format to
be consitent

Signed-off-by: Baoquan He <bhe@redhat.com>

[Edited by harald@redhat.com]
2013-04-09 11:14:08 +02:00
Baoquan He
0290e98271 Wait for logical interface to be up
If bootdev is logical interface like bond, bridge or vlan, we need
wait them up.

Signed-off-by: Baoquan He <bhe@redhat.com>
2013-04-09 10:53:08 +02:00
Harald Hoyer
d136ca4eeb network: support multiple bonding interfaces
Currently dracut only support 1 bond, namyly bond0 by default. However multiple
bonds configuration may be needed. For example in kdump, in 1st kernel, more
than one bonds may be configured, and bondX other than bond0 is used as output
interface to remote host which will store dump core. This patch can solve this
problem, to write real bond information to initramfs, 2nd kdump kernel will
use it to create the relevant bondX interface.

Tested-by: Baoquan He <bhe@redhat.com>
Signed-off-by: Baoquan He <bhe@redhat.com>
2013-04-09 10:52:22 +02:00
WANG Chao
a55f910cf6 ifup.sh: Add support for bridge over team and vlan tagged team
Team is the same network stack as bonding. Therefore give ifup the ability to
handle bridge over team and vlan tagged team as bonding too.

Signed-off-by: WANG Chao <chaowang@redhat.com>
2013-04-09 10:52:22 +02:00
Harald Hoyer
96efbc51ac crypt/module-setup.sh: filter /etc/crypttab in host-only mode
only take those /etc/crypttab entries, which we need to boot the system
2013-04-09 10:48:26 +02:00
Harald Hoyer
9d36d4fb1d dracut-functions.sh: make use of findmnt 2013-04-09 10:47:39 +02:00
Harald Hoyer
41bfa5dad1 nfs/module-setup.sh: combine egreps for /etc/passwd and /etc/group 2013-04-05 16:34:36 +02:00
Harald Hoyer
db9fbaf9b8 TEST-99-RPM: ignore rescue images 2013-04-05 11:52:33 +02:00
Harald Hoyer
56fb5c4dbf TESTSUITE: s/i6300esbwdt/i6300esb ib700wdt/g 2013-04-05 11:07:55 +02:00
Harald Hoyer
a8986425a4 TEST-50-MULTINIC: fixup test suite
qemu of the day doesn't like multicast anymore
2013-04-05 11:07:40 +02:00
Harald Hoyer
ea3c4e8273 Add missing options to manpage and --help output
https://bugzilla.redhat.com/show_bug.cgi?id=948510
2013-04-05 09:01:48 +02:00
Harald Hoyer
6db8c5a5fe base/dracut-lib.sh:wait_for_dev()/cancel_wait_for_dev() set systemd timeouts
Set systemd unit timeouts for the devices we wait for. The systemd
default is 90 seconds, which is way too low for complicated setups.
2013-04-05 08:32:17 +02:00
Harald Hoyer
ab9b04f55b crypt/parse-crypt.sh: create udev rule for systemd
Start the systemd-cryptsetup@luks-*.service for the detected crypto_LUKS
device in the initqueue, so we block in the initqueue and wait for the
password entry.
2013-04-04 12:54:59 +02:00
Harald Hoyer
c4b572b5ca base/dracut-lib.sh: add dev_unit_name()
add helper function to convert device path to systemd unit names
2013-04-04 12:52:53 +02:00
Harald Hoyer
cc6f0925df base/init.sh: fix version output 2013-04-02 13:29:24 +02:00
Harald Hoyer
d50cf62d62 dracut.spec: Require systemd >= 199 2013-03-26 17:04:43 +01:00
Harald Hoyer
75369f8ba0 version 027 2013-03-26 16:55:03 +01:00
Harald Hoyer
8e2bcb4b42 dracut.spec: don't BuildRequire bash-completion for rhel 2013-03-26 16:54:34 +01:00
Harald Hoyer
bfac40665b systemd: add new timers.target and paths.target 2013-03-26 16:19:27 +01:00
Harald Hoyer
6c6d805765 use systemd*dir variables everywhere 2013-03-26 16:19:00 +01:00
Harald Hoyer
44f870be42 test: change qemu param -nographic to -display none for -daemonize
qemu does not like -nographic in combination with -daemonize
2013-03-26 16:17:24 +01:00
Harald Hoyer
b37398dc1c x-initrd-rootfs.mount -> x-initrd.mount 2013-03-26 15:38:50 +01:00
Harald Hoyer
1b0a362d83 multipath: install native systemd service 2013-03-25 07:58:45 +01:00
Harald Hoyer
bb425d20a1 systemd: add dracut.bootup(7) reference to service man pages 2013-03-25 07:56:12 +01:00
Harald Hoyer
cbd69dc6ff install dracut-*.service units 2013-03-25 07:56:12 +01:00
Harald Hoyer
cb8def95c4 dracut.sh: export systemdsystemconfdir 2013-03-22 09:09:10 +01:00
Harald Hoyer
78d1d4f86d dracut.sh: turn off hostonly mode, if udev database is not found 2013-03-20 10:25:23 +01:00
Harald Hoyer
5bfa3b363a dracut.sh: turn off host-only mode, if essential system filesystems not mounted 2013-03-20 10:22:41 +01:00
Harald Hoyer
1d4b337543 dracut.spec: use configure 2013-03-20 08:01:29 +01:00
Harald Hoyer
8c67d395d4 dracut.spec: use pkg-config for bashcompletiondir 2013-03-20 07:15:04 +01:00
Harald Hoyer
02566acdd7 dracut.sh: remove temporary cpio output in trap 2013-03-20 07:08:29 +01:00
Harald Hoyer
478aa7dac1 51-dracut-rescue-postinst.sh,51-dracut-rescue.install: use systemd-machine-id-setup
if /etc/machine-id is empty, use systemd-machine-id-setup
2013-03-20 07:08:29 +01:00
Harald Hoyer
967db70090 51-dracut-rescue-postinst.sh: Rename image and grub entry
grub2-mkconfig ordered the rescue entries higher than the normal ones.

https://bugzilla.redhat.com/show_bug.cgi?id=923439
2013-03-20 07:08:29 +01:00
Harald Hoyer
619c1bb334 51-dracut-rescue-postinst.sh: add extra checks 2013-03-19 16:56:56 +01:00
Harald Hoyer
57aa1e9140 TEST-40-NBD/test.sh: kill_server() after test_run() 2013-03-19 14:53:17 +01:00
Harald Hoyer
af2fcbafe8 network/netroot.sh: do not unset root 2013-03-19 14:53:09 +01:00
Harald Hoyer
7b6bdc3f94 nbd/nbdroot.sh: fix root != blockdev case 2013-03-19 12:26:06 +01:00
Harald Hoyer
db43f56d94 fs-lib/fs-lib.sh:write_fs_tab() start initrd-root-fs.target 2013-03-19 12:26:06 +01:00
Harald Hoyer
a1ebd77179 add dracut.bootup.7 man page 2013-03-19 12:26:06 +01:00
Harald Hoyer
e26d76dca1 systemd: add more ordering 2013-03-19 12:22:33 +01:00
Harald Hoyer
d59732004d drm/module-setup.sh: redirect grep to /dev/null
on some architectures, no pci devices exist
2013-03-18 14:17:19 +01:00
Harald Hoyer
a3a8f58d73 Makefile: use -D_FILE_OFFSET_BITS=64 to build dracut-install 2013-03-18 10:58:25 +01:00
Harald Hoyer
c9e5b75308 kernel-modules/module-setup.sh: don't fail hard on a missing module 2013-03-18 09:29:08 +01:00
Harald Hoyer
fd191a7b41 kernel-modules/module-setup.sh: install all host filesystem drivers
https://bugzilla.redhat.com/show_bug.cgi?id=922565
2013-03-18 08:43:23 +01:00
Harald Hoyer
e42c7a980c sosreport: mkdir /run/initramfs, if it does not exist yet 2013-03-16 10:34:20 +01:00
Harald Hoyer
85804a9197 dmsquash-live: force load squashfs kernel module
https://bugzilla.redhat.com/show_bug.cgi?id=922248
2013-03-16 10:31:37 +01:00
Harald Hoyer
ee2321c91e dracut.conf.5.asc: remove duplicated install_items 2013-03-15 16:54:38 +01:00
Harald Hoyer
11fbde4454 TEST-16-DMSQUASH: use current releasever 2013-03-15 14:41:11 +01:00
Harald Hoyer
fb05f9876a dracut-bash-completion.sh: add --kver kernel version completion 2013-03-15 10:42:18 +01:00
Harald Hoyer
7e9bfdde14 sosreport.sh: use -o short-monotonic for the journal output 2013-03-15 10:41:41 +01:00
Harald Hoyer
7e9fc37db8 dracut.spec: bump systemd version requirement 2013-03-15 07:11:17 +01:00
Harald Hoyer
bb278147cf fixed testsuite 2013-03-15 07:10:20 +01:00
Will Woods
81b676a675 fix typo in dracut.conf.5.asc
It's /etc/dracut.conf.d, not /etc/dracut/conf.d
2013-03-15 07:10:20 +01:00
Harald Hoyer
6b46e7baa0 systemd: do not use "systemd --version" until fixed 2013-03-15 07:10:20 +01:00
Harald Hoyer
85c85f07e2 systemd: switch to new initrd.target
(normal startup)
                                    :
                                    :
                                    v
                              basic.target
                                    |
             ______________________/|
            /                       |
            |                  sysroot.mount
            |                       |
            |                       v
            |             initrd-root-fs.target
            |                       |
            |                       v
            |            initrd-parse-etc.service
(custom initrd services)            |
            |                       v
            |            (sysroot-usr.mount and
            |             various mounts marked
            |               with fstab option
            |                x-initrd.mount)
            |                       |
            |                       v
            |                initrd-fs.target
            |                       |
            \______________________ |
                                   \|
                                    v
                               initrd.target
                                    |
                                    v
                          initrd-cleanup.service
                               isolates to
                         initrd-switch-root.target
                                    |
                                    v
             ______________________/|
            /                       |
            |        initrd-udevadm-cleanup-db.service
            |                       |
(custom initrd services)            |
            |                       |
            \______________________ |
                                   \|
                                    v
                        initrd-switch-root.target
                                    |
                                    v
                        initrd-switch-root.service
                                    |
                                    v
                               switch-root
2013-03-15 07:10:20 +01:00
Harald Hoyer
c853dc72e9 udev-rules/module-setup.sh: do not install /run/* 2013-03-14 18:30:35 +01:00
Harald Hoyer
18d0c9b858 nfs/nfsroot.sh: only cat /etc/fstab, if existant 2013-03-14 18:30:35 +01:00
Harald Hoyer
0a5fd0dcec iscsi/iscsiroot.sh: do not mount manually in systemd mode 2013-03-14 18:30:35 +01:00
Harald Hoyer
e0e99c59a5 ifcfg/write-ifcfg.sh: fixed typo 2013-03-14 18:30:35 +01:00
Harald Hoyer
d46394ad33 dracut.spec: fix requirements 2013-03-14 18:30:35 +01:00
Harald Hoyer
87dc81a1f6 dracut-install: handle more ldd errors 2013-03-14 18:30:35 +01:00
Harald Hoyer
ce92ca0527 51-dracut-rescue-postinst.sh: fixed new-kernel-pkg call 2013-03-14 18:30:35 +01:00
Harald Hoyer
c390590fac TODO: remove completed items 2013-03-14 18:30:35 +01:00
Radek Vykydal
fd8e4aef90 Write BOOTPROTO=ibft for ip=ibft to ifcfg files 2013-03-14 10:54:28 +01:00
Radek Vykydal
c5a742a3bf Don't write DHCPV6C=yes for each dhcp (ipv4) configuration.
Caused probably by commit 32ec0a762d
2013-03-14 10:54:28 +01:00
Harald Hoyer
fc4e10a859 shutdown/shutdown.sh: mount --move all basic mounts out of /oldroot
After mount moving /dev away, apps like plymouth can do reexec with fd
passing of devices, which they want to keep open until the very end.
2013-03-13 17:45:37 +01:00
Harald Hoyer
83bb0893ed dracut.sh: Add --noimageifnotneeded parameter
Do not create an image in host-only mode, if no kernel driver is needed
and no $initdir/etc/cmdline/*.conf is generated.
2013-03-13 14:49:20 +01:00
Harald Hoyer
8fdcc1a9b1 kernel-modules: move usb-storage out of fixed drivers 2013-03-13 14:46:39 +01:00
Harald Hoyer
a23b368c92 systemd: remove upstream renamed old service files 2013-03-13 14:45:55 +01:00
dyoung@redhat.com
bbfff3e58b Add memdebug at different points in 99base/init.sh
Previously I added several trace point to the begin of several
init hooks of systemd, old init script also need this debug info.

Doing same here as what's added in the systemd service scripts:
At cmdline hooks adding trace of "1+:mem 1+:iomem 3+:slab"
For other hooks adding trace of "1:shortmem 2+:mem 3+:slab"

Signed-off-by: Dave Young <dyoung@redhat.com>
2013-03-13 13:12:57 +01:00
dyoung@redhat.com
9c322b2f3b Improve documentation of rd.memdebug
Explain more about rd.memdebug verbose level in dracut.cmdline.7.asc.

Signed-off-by: Dave Young <dyoung@redhat.com>
2013-03-13 13:12:57 +01:00
dyoung@redhat.com
dff9a66c44 print memdebug to stderr
memory usage tracing outputs are debug info, so it should be moved to
stderr instead of stdout.

Signed-off-by: Dave Young <dyoung@redhat.com>
2013-03-13 13:12:57 +01:00
Harald Hoyer
449b0e0707 dracut-initramfs-restore.sh: also look for image in boot loader spec dir 2013-03-13 13:09:13 +01:00
Harald Hoyer
4a5a9c6d89 dracut.spec: fix requirements 2013-03-13 13:01:33 +01:00
Harald Hoyer
917f3e4d25 add dracut-bash-completion.sh 2013-03-13 13:01:33 +01:00
Harald Hoyer
7d848c55a6 dracut.sh: add --regenerate-all 2013-03-13 13:01:33 +01:00
Harald Hoyer
7d17d6c976 plymouth: do not install hooks in systemd mode 2013-03-13 13:01:20 +01:00
Harald Hoyer
b8060ef781 systemd: add sysctl.d and sysctl.conf 2013-03-13 11:37:05 +01:00
Harald Hoyer
727543c1e6 systemd: add modules-load.d modules to the initramfs 2013-03-13 11:37:05 +01:00
Harald Hoyer
c85cda9e2f systemd: local-fs.target is now root-fs.target and initrd-fs.target
Also rename dracut.target to initrd.target

see also systemd commit 700e07f
http://cgit.freedesktop.org/systemd/systemd/commit/?id=700e07f
2013-03-13 09:34:47 +01:00
Harald Hoyer
c0c6c74d99 51-dracut-rescue.install: create directory, if it does not exist 2013-03-13 09:32:14 +01:00
Harald Hoyer
d26bd6ca55 lsinitrd.sh: simplify check for boot loader spec dirs 2013-03-13 09:32:14 +01:00
Harald Hoyer
e22eb857be dracut.spec: add nohostonly and norescue subpackages
we need rpm subpackages, to be able to pull them in the installation
transaction for the initial %posttrans initramfs image creation.
2013-03-12 13:52:57 +01:00
Harald Hoyer
2fa6fd3aaa add 51-dracut-rescue-postinst.sh
also fixup 51-dracut-rescue.install to read in dracut conf
2013-03-11 18:58:32 +01:00
Harald Hoyer
dd5875499e dracut.sh: add swap partitions to host-only setup 2013-03-11 18:58:32 +01:00
Harald Hoyer
d351541ee6 make host_fs_types a hashmap
This requires bash >= 4, but hash maps are so much more comfortable
2013-03-11 18:58:32 +01:00
Harald Hoyer
d928724c3c lsinitrd.sh: removed trailing "}" 2013-03-11 15:46:37 +01:00
Harald Hoyer
727e68d0b5 lsinitrd.sh: fix for default initrd not found, but image given 2013-03-11 15:13:02 +01:00
Harald Hoyer
8d28614e4f 51-dracut-rescue.install: do not unset installonly on remove 2013-03-11 15:12:49 +01:00
Harald Hoyer
fba5fbbdad dracut.spec: add rescue module 2013-03-09 15:32:32 +01:00
Harald Hoyer
d008b6b89f dracut.sh: move cleanup trap, just after mktemp 2013-03-09 15:31:09 +01:00
Harald Hoyer
aede120c92 add rescue dracut module 2013-03-09 15:17:26 +01:00
Harald Hoyer
cc2303001e dracut.sh: add new default path to initramfs according to bootloader spec
see kernel-install(8) and
http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec
2013-03-09 15:17:26 +01:00
Harald Hoyer
54e7d7c32d dracut.sh: remove (default) marker in --help 2013-03-09 15:17:26 +01:00
Harald Hoyer
bcd352dfa1 fedora.conf.example: make hostonly default for fedora 2013-03-09 15:17:26 +01:00
Harald Hoyer
d837ac3984 add /lib/kernel/install.d/51-dracut-rescue.install
Upon installation of a kernel, check if a rescue image is already
available and if not, create a non-hostonly generic initramfs image with
the rescue module added.
2013-03-09 15:16:31 +01:00
Harald Hoyer
900e15da34 systemd/module-setup.sh: call systemd in private dir for version 2013-03-08 11:50:03 +01:00
Harald Hoyer
19d69051a3 NEWS: dracut-026 2013-03-08 07:07:48 +01:00
Harald Hoyer
31737a05e1 systemd: add version check in install() 2013-03-08 07:07:01 +01:00
Harald Hoyer
1161f03777 fips: add lzo module 2013-03-08 07:05:55 +01:00
Harald Hoyer
cf24ac8c19 crypt, dmraid, mdraid: use for_each_host_dev_and_slaves_all()
To catch _all_ UUIDs and not only the first one, use
for_each_host_dev_and_slaves_all
2013-03-07 16:00:00 +01:00
Harald Hoyer
af3ef92a6b dmsquash-live: add iso9660 kernel module 2013-03-07 15:49:24 +01:00
Harald Hoyer
c46cda8260 split 95udev-rules/59-persistent-storage.rules to md and dm modules 2013-03-07 15:01:47 +01:00
Harald Hoyer
34bd2be23f dracut-functions.sh: fix inst_rule_programs()
Logic for the $env{.*} check was reversed and env was missing.

Thanks Colin Guthrie!
2013-03-07 15:01:47 +01:00
Harald Hoyer
c3dd68fcf1 iscsi: run iscsiroot even if no network configured
Also inject finished hooks for every iscsiroot netroot
2013-03-07 14:17:49 +01:00
Harald Hoyer
3e35441f18 kernel-modules: better match for arm architecure 2013-03-07 14:17:33 +01:00
Harald Hoyer
dde2db3da9 lsinitrd: use /boot/<machine-id>/<kernel-version>/initrd as the default image
if /boot/<machine-id> exists; then
use /boot/<machine-id>/<kernel-version>/initrd as the default image;
else fallback to /boot/initramfs-<kernel-version>.img
2013-03-07 13:03:24 +01:00
Harald Hoyer
cbc21754e5 kernel-modules: move some kernel modules out of unconditional install 2013-03-07 12:10:53 +01:00
Harald Hoyer
eb2dc8c34b systemd: add missing dracut-mount.service dracut-pre-mount.service 2013-03-07 11:47:00 +01:00
Harald Hoyer
c4e098a514 document /usr/lib/dracut/dracut.conf.d 2013-03-07 11:44:44 +01:00
Harald Hoyer
72875215a3 dracut.conf: move default settings to distro example 2013-03-07 11:44:16 +01:00
Harald Hoyer
335bc217b3 dracut.sh: rename source_dirs_prio() to dropindirs_sort() 2013-03-07 11:43:52 +01:00
Harald Hoyer
510aecdbd8 systemd: add missing dracut-mount.sh dracut-pre-mount.sh dracut.target 2013-03-07 10:35:06 +01:00
Harald Hoyer
9dd9d81fc6 add 50-dracut.install 2013-03-07 10:08:35 +01:00
Harald Hoyer
a5b48ce798 add systemd-bootchart module 2013-03-07 09:56:30 +01:00
Harald Hoyer
59afbd8e73 add missing systemd service man pages 2013-03-07 09:42:00 +01:00
Harald Hoyer
348baca3e4 dracut.conf.d/fedora.conf.example: turn off rd.auto
realinitpath is not needed anymore for systemd >= 198
2013-03-06 17:29:12 +01:00
Harald Hoyer
83691c413f testsuite fixup 2013-03-06 17:29:12 +01:00
Harald Hoyer
ca36b9b8f8 base: save host_devs which we need bring up and process them with wait_for_dev 2013-03-06 17:29:12 +01:00
Harald Hoyer
a9c7dc74c4 base: in systemd mode parse-root-opts.sh is in the services 2013-03-06 17:29:12 +01:00
Harald Hoyer
ce862de624 base/dracut-lib.sh: reset /etc/profile 2013-03-06 17:29:12 +01:00
Harald Hoyer
500861cd05 base/init.sh: reset main loop counter, if work is in initqueue 2013-03-06 17:29:12 +01:00
Harald Hoyer
44d26d9209 base/dracut-lib.sh: extend wait_for_dev() for systemd 2013-03-06 17:29:12 +01:00
Harald Hoyer
35270e34d0 rootfs-block/parse-block.sh: wait_for_dev 2013-03-06 17:29:12 +01:00
Harald Hoyer
fe654ff0aa usrmount: in systemd mode, functionality is in systemd 2013-03-06 17:29:12 +01:00
Harald Hoyer
5e1e1ec060 iscsi, nbd: call write_fs_tab() and write /etc/fstab 2013-03-06 17:29:12 +01:00
Harald Hoyer
2673ff1932 rootfs-block: in systemd mode, functionality is in the dracut services 2013-03-06 17:29:11 +01:00
Harald Hoyer
e8f7ea6794 resume: generate rules already in parse-resume.sh 2013-03-06 17:29:11 +01:00
Harald Hoyer
3899211bfc resume: in systemd mode move functionality in the dracut services 2013-03-06 17:29:11 +01:00
Harald Hoyer
6e0c1c448d nfs/nfsroot.sh: trigger nfs mount with cat'ing /etc/fstab
otherwise the whole nfs communication can take too long for the
systemd-fstab-generator
2013-03-06 17:29:11 +01:00
Harald Hoyer
6ae68b4674 kernel-modules: handle rd.driver.* in systemd mode in dracut-pre-udev 2013-03-06 17:29:11 +01:00
Harald Hoyer
41eba87b32 dracut_need_initqueue 2013-03-06 17:29:11 +01:00
Harald Hoyer
a1084c02fd fs-lib/fs-lib.sh: add write_fs_tab() 2013-03-06 17:29:11 +01:00
Harald Hoyer
5ac8420abc crypt/parse-crypt.sh: don't generate luks rules in systemd mode 2013-03-06 17:29:11 +01:00
Harald Hoyer
24d009507f btrfs: no need for btrfs_timeout in systemd mode 2013-03-06 17:29:11 +01:00
Harald Hoyer
e9020221a7 crypt: do not cleanup in systemd mode 2013-03-06 17:29:11 +01:00
Harald Hoyer
b59e9e5724 network/netroot.sh: remove the dhcp finished hook, if we have a handler 2013-03-06 17:22:09 +01:00
Harald Hoyer
b5859d6359 i18n: no manual setup needed if systemd is in the game 2013-03-06 17:22:09 +01:00
Harald Hoyer
dbfaae0e34 systemd: changes for new initrd services
Requires systemd >= 198
2013-03-06 17:21:47 +01:00
Harald Hoyer
8d85429a44 dracut-functions.sh: add dracut_need_initqueue() dracut_module_included()
for all rules files, which reference initqueue also call
dracut_need_initqueue()
2013-03-06 16:04:03 +01:00
Harald Hoyer
3e4ab73cd4 test: make testsuite work with systemd 2013-03-02 13:27:08 +01:00
Harald Hoyer
4e32b2e916 test: removed unused cryptroot-ask.sh scripts 2013-03-02 13:22:29 +01:00
Harald Hoyer
356333b331 test: add finished-false.sh for create-root.sh initqueue job 2013-03-02 13:20:59 +01:00
Harald Hoyer
f62f3a2191 reset initqueue loop counter only if new uevents exist 2013-03-02 13:19:20 +01:00
Harald Hoyer
389333396a resume: move resume hook from mount to pre-mount 2013-03-02 13:11:38 +01:00
Harald Hoyer
cfb7410cd0 mdraid/mdraid_start.sh: remove mdmon workaround 2013-03-02 13:10:57 +01:00
Harald Hoyer
f672b1c399 btrfs/btrfs_timeout.sh: do not "exit 0" 2013-03-02 13:10:04 +01:00
Harald Hoyer
f12f694355 btrfs: Use upstream 64-btrfs.rules 2013-02-22 11:14:04 +01:00
Lars R. Damerow
9a9c6e1256 dracut: write initramfs to temp file then move into place
We've been finding cases where multiple instances of dracut can be launched
simultaneously, resulting in a corrupted initramfs file. This patch makes
dracut write the initramfs to a new file, then move it into place atomically.
2013-02-22 11:05:29 +01:00
Harald Hoyer
9c65c125a9 systemd: change path of switch-root.conf
we do not have to clean it up for /etc/switch-root.conf
2013-02-21 12:18:21 +01:00
Harald Hoyer
7d4d3f8da6 lvm/module-setup.sh: use for_each_host_dev_and_slaves_all
Use for_each_host_dev_and_slaves_all to get all lvm setups for the
host-only case.

Thanks to Olivier Thauvin
2013-02-21 12:13:56 +01:00
Harald Hoyer
569ffe77bf systemd: add systemd-modules-load.service and hook dirs 2013-02-21 12:13:09 +01:00
Harald Hoyer
a42b2b8133 introduce /usr/lib/dracut/dracut.conf.d/ drop-in directory
/usr/lib/dracut/dracut.conf.d/*.conf can be overwritten by the same
filenames in /etc/dracut.conf.d.

Packages should use /usr/lib/dracut/dracut.conf.d rather than
/etc/dracut.conf.d. /etc/dracut.conf.d belongs to the system
administrator.
2013-02-19 17:46:24 +01:00
Harald Hoyer
31ba4de21d url-lib/url-lib.sh: remove bashism
remove the forgotten bashism "+="
2013-02-19 16:13:49 +01:00
Stefan Reimer
a005c47763 base/init.sh: create /run/log
If the systemd module is not used /run/log is not created which results
in dangeling softlink from /var/log which causes stuff to fail.
2013-02-18 12:05:23 +01:00
Harald Hoyer
5db6ca5a4b dracut: enable initramfs building without kernel modules 2013-02-18 12:03:02 +01:00
Harald Hoyer
1a6fdf2417 btrfs: use "btrfs device ready" 2013-02-18 11:58:11 +01:00
Harald Hoyer
27a2c3a406 systemd: services got renamed 2013-02-14 12:32:12 +01:00
Harald Hoyer
b347edfa23 dracut-emergency.service: wants systemd-vconsole-setup.service 2013-02-14 12:32:04 +01:00
Colin Guthrie
3ed09d970e resume: Ensure we remove the timout job when we find the resume device 2013-02-13 17:46:24 +01:00
Thomas Backlund
a28e2aeefe kernel-modules: Add ehci support for kernel 3.8+
Kernel 3.8 split ehci-hcd into ehci-hcd, ehci-pci and ehci-platform,
so adapt the list to cope with this change.
2013-02-13 17:42:32 +01:00
Wim Muskee
c6a71c7b8a make nbd port check more robust
The following change makes the check for the nbd port or named export
more robust.
I wasn't sure whether to include sed in the dracut_install() of
module-setup.sh since net already does that (and nbd depends on that).
2013-02-11 15:44:11 +01:00
Harald Hoyer
6ecb9a2d68 url-lib/url-lib.sh: add proxy support for curl 2013-02-11 13:56:04 +01:00
Harald Hoyer
918a6874df url-lib/url-lib.sh: remove bashisms 2013-02-11 13:55:44 +01:00
Harald Hoyer
2663232a01 systemd/dracut-initqueue.sh: call udevadm settle directly 2013-02-11 11:49:19 +01:00
Harald Hoyer
cebab07e68 systemd/dracut-initqueue: run after cryptsetup.target 2013-02-11 11:49:19 +01:00
Harald Hoyer
a04f3077cd systemd/dracut-pre-pivot.sh: remove /dev/root symlink after shell 2013-02-11 11:49:19 +01:00
Harald Hoyer
04b873598b systemd: set udev debug/info via config file and report obsolete options 2013-02-11 11:49:19 +01:00
Harald Hoyer
22137f9cac systemd/dracut-pre-trigger.sh: enable rd.break=pre-trigger debug shell 2013-02-11 11:49:19 +01:00
Harald Hoyer
54665349ec systemd/dracut-cmdline.sh: create /run/log subdir 2013-02-11 11:49:19 +01:00
Harald Hoyer
f251a89772 systemd/dracut-pre-trigger.service: load service on demand 2013-02-11 11:49:19 +01:00
Harald Hoyer
fbdfa57746 systemd/dracut-pre-udev.service: load service on demand 2013-02-11 11:49:19 +01:00
Harald Hoyer
6b095274fb systemd: trigger systemd-vconsole-setup.service only on demand 2013-02-11 11:49:19 +01:00
Harald Hoyer
11174408e8 systemd/dracut-initqueue.sh: replace $UDEV_QUEUE_EMPTY
for systemd-udevd the version of udevd is high enough
2013-02-11 11:49:19 +01:00
Harald Hoyer
c2117747fd virtfs: add virtio_pci kernel module 2013-02-11 11:49:19 +01:00
Harald Hoyer
4f6e293308 udev-rules: modify udev rules on initramfs creation time 2013-02-11 11:49:19 +01:00
Harald Hoyer
d9076cac19 btrfs/btrfs_finished.sh: use btrfs device ready for probing 2013-02-08 16:52:38 +01:00
Harald Hoyer
ff52ca1b57 btrfs/80-btrfs.rules: remove modprobe of btrfs module
this should be automatically modprobed by the kernel on demand
2013-02-08 16:52:38 +01:00
Harald Hoyer
8a3c4957fc drm/module-setup.sh: make drm module only install on dependency 2013-02-08 16:52:38 +01:00
Harald Hoyer
3f54a83ca8 dracut.sh: make /var/log a symlink to /run/log 2013-02-08 16:52:38 +01:00
Harald Hoyer
7fa3b9e376 url-lib/url-lib.sh: turn off curl globbing
https://bugzilla.redhat.com/show_bug.cgi?id=907497
2013-02-08 16:52:38 +01:00
Harald Hoyer
39135af155 network/ifup.sh: echo in get_vid() instead of using the return value
The return value is module 256, so VLAN ids > 255 could not be returned.
2013-02-08 16:52:38 +01:00
Dan Horák
02640e8e65 set peer for point-to-point connections
network/net-lib.sh: only set net vars, if they have a value
2013-02-08 16:52:30 +01:00
Frederick Grose
579f385384 Provide devices to enable booting with rd.live.overlay.readonly=1 2013-02-06 13:52:30 +01:00
Kevin Yung
56d60c4b2d network/ifup.sh: enable bridged vlan interfaces
To use vlan for net boot, you need to specify vlan and ip kernel options
for the boot interface. For example,

 vlan=eth1.1:eth1 bootdev=eth1.1
 ip=1.2.3.4:1.2.3.4::255.255.255.0:my-hostname:eth1:none

To use bridge for net boot, you need to specify bridge and ip kernel
option for the boot interface. For example

 bridge=br1:eth1 bootdev=br1
 ip=1.2.3.4:1.2.3.4::255.255.255.0:my-hostname:eth1:none

In my environment, I needs to boot machines from network within
a vlan or on a bridged network.	I found curent dracut release
if-up.sh script in 40network module bypass ip setting for both
bridge and vlan interface.
2013-02-06 13:52:30 +01:00
Dan Horák
62fd2b3644 fix CTC example in rd.znet
The CTC interface uses 2 channels.
2013-02-06 13:52:30 +01:00
Colin Guthrie
cd9072d342 Mount /proc before including dracut-lib.sh.
When dracut-lib.sh is sourced it checks the command line (when not using systemd)
as part of the check_quiet() call.

Therefore mount /proc earlier in init.

Avoids the error:

init: 77: /lib/dracut-lib.sh: /proc/cmdline: No such file or directory
2013-02-06 13:52:30 +01:00
Harald Hoyer
19bab59c48 dracut.sh: reverting return value change
reverting _get_fs_type() return values of patch
c8d685c9d3
2013-02-05 16:45:42 +01:00
Harald Hoyer
d8b627b9dc shutdown: call "losetup -D" on shutdown 2013-02-05 11:04:02 +01:00
Harald Hoyer
6320d072a1 mdmon: renamed mdmon-offroot@.service to mdmon@.service 2013-02-05 10:58:06 +01:00
Harald Hoyer
7abeb49878 TODO: updated 2013-02-05 10:58:05 +01:00
Harald Hoyer
14fcfbec3e network/net-genrules.sh: remove some bashisms 2013-01-30 17:22:25 +01:00
Joe Lawrence
fa9f15e3be Support out-of-tree and updated drivers in initramfs creation
The find_kernel_modules_by_path function shouldn't filter out modules not
located underneath the /lib/modules/ver/kernel directory as out-of-tree
drivers may reside in /lib/modules/ver/extra and updated drivers in
/lib/modules/ver/updates.

Signed-off-by: Joe Lawrence <joe.lawrence@stratus.com>
2013-01-25 13:07:59 +01:00
Harald Hoyer
ae4758ce0d rootfs-block/mount-root.sh: fixup for 8b6bf0ef5
not only fix the warning message, but the real mount arguments, too
2013-01-23 16:24:33 +01:00
Harald Hoyer
66f01450a8 NEWS: update for version 025 2013-01-23 16:12:18 +01:00
Harald Hoyer
e5786ed1b7 version 025 2013-01-23 15:38:48 +01:00
Harald Hoyer
b47517140b dracut.spec: add drm module 2013-01-23 15:38:48 +01:00
Colin Guthrie
3de6001e1e Include crc32c module for xfs.
Just like btrfs, xfs now requires CRC module that cannot be resolved via
normal module resolving.

Move this hack into fs-lib and remove it from btrfs module.

https://bugs.mageia.org/show_bug.cgi?id=8676
2013-01-23 15:24:27 +01:00
Harald Hoyer
c8d685c9d3 dracut-functions.sh: cope with optional field #7 in mountinfo
also handle fstab entries with LABEL=, UUID= and PARTUUID=
2013-01-23 15:24:27 +01:00
Harald Hoyer
d6d3173916 network/dhclient-script.sh: also touch "/tmp/setup_net_<mac>.ok" 2013-01-23 15:24:27 +01:00
Harald Hoyer
8b6bf0ef57 romount fix 2013-01-23 15:24:27 +01:00
Dave Young
7bd8f23303 Add memory usage trace to diffrent hook points
Hi, Here is an update of this patch, fixed the local variable issue.
2013-01-23 15:24:27 +01:00
dyoung@redhat.com
a08ea34aba add function getargnum
For cmdline argument with numeric value, add a new function getargnum
It will get proper value with default value as $1, min value as $2,
max value as $3, and param name as $4. valid result will be echo to stdout.
for nul or value not valid it will just echo the default value.
Note: The values should be >=0

[v1->v2]: add arg <minval>
[v2->v3]: do not use bash string match =~

Signed-off-by: Dave Young <dyoung@redhat.com>
2013-01-23 15:24:27 +01:00
Dave Young
6cb77ea91f use linkup in dhclient-script.sh
linkup is a wrapper function for waiting interface ready and up.
change to use linkup as what we do in ifup script.

Signed-off-by: Dave Young <dyoung@redhat.com>
2013-01-23 15:24:27 +01:00
Colin Guthrie
c586b033a7 Extend 52f1b041 to allow devices to be specified in config files as well as cmdline.
This also changes the command line switch to be --add-device and the
config directive is set to add_device. This was chosen as device= in the
config file seems too generic and not quite as consistent with other
directives (i.e. drivers/add_drivers)

The --device command line is still supported but it should be considered
deprecated in favour of --add-device.
2013-01-23 15:24:27 +01:00
Jiri Pirko
a9f634f815 fix teamd exec in case config does not include devname
In case that configuration file did not include name of team device,
teamd would not start. Fix this by adding "-t" parameter.

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-01-23 15:24:27 +01:00
Harald Hoyer
551c2dd71f shutdown: kill all processes and report remaining ones 2013-01-22 15:31:45 +01:00
Harald Hoyer
ffc4f173b6 mdraid: add mdmon-offroot@.service and takeover mdmon in shutdown 2013-01-22 15:31:41 +01:00
Harald Hoyer
ebd1d65a1b shutdown: source pre-shutdown hook and force quit plymouth before umount 2013-01-22 15:31:22 +01:00
Harald Hoyer
5b68300899 dracut-lib.sh: force hide plymouth in shutdown emergency shell 2013-01-22 15:31:19 +01:00
Harald Hoyer
2b6dd6a1fc dracut-functions.sh: add pre-shutdown hook 2013-01-22 15:31:16 +01:00
Harald Hoyer
1d22c670b0 dracut.asc: document shutdown procedure 2013-01-18 10:13:14 +01:00
Harald Hoyer
0ae480dcbf dracut.asc: s/rd.ip/ip/g 2013-01-07 18:00:06 +01:00
Harald Hoyer
256cba18c3 dracut-functions.sh: fixed inst_rules search path 2013-01-03 09:29:05 +01:00
Harald Hoyer
e6fcec9173 usrmount/mount-usr.sh: filter "subvol=" from root rflags
https://bugzilla.redhat.com/show_bug.cgi?id=890577
2013-01-02 14:06:44 +01:00
Harald Hoyer
1db3d2615d kernel-modules: create /etc/modprobe.d if it does not yet exist
https://bugzilla.redhat.com/show_bug.cgi?id=873220
2013-01-02 13:57:40 +01:00
Harald Hoyer
5204d1d36d dmsquash-live: fixed checkisomd5 service call 2013-01-02 13:56:27 +01:00
dyoung@redhat.com
3fa59d171d Wait for interface up at the early stage
In case long delay of network driver initqueue will exit before net dev is
ready. We have no chance to setup it then.
For dhcp, when we finish the setup there will be a setup_net_<dev>.ok. Doing
same for static ip case. Also add a check to initqueue when we generate udev
rules to ensure it's early enough.

[v1->v2]: only wait for bootdev or it's possible to cause boot fail for
waiting for non-bootdev. For example bond0->eth0, set bond0 as bootdev and
dhcp, we only need to wait bond0 setup ok.

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-12-14 09:09:00 +01:00
dyoung@redhat.com
d7264a3cc0 Get ifaces for udev rule use
In case BOOTIF is not set and IFACES are not set in bonding/vlan/bridge code,
net-genrule.sh will fall to bring up all net interfaces.

Here add a failsafe option to read IFACES from /tmp/net.ifaces

[v1->v2]: move IFACES reading from net.ifaces after bonding/vlan/bridge info
code chunks.
[v2->v3]: [ -n "$IFACES" ] should be  [ -z "$IFACES" ]

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-12-14 09:08:59 +01:00
dyoung@redhat.com
9078167927 Wait for link ready before use the interface
Some network driver will take long time to initialize. We have an example
in a HP machine which take about one minute for this. The callback such as
"ip link set <dev> up" will fail, afterwards setup for network will also
fail.

Fix this by add a new function wait_for_if_link, wait the link ready before
use it.

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-12-14 09:08:59 +01:00
dyoung@redhat.com
3bd7fba7af Change to use linkup function in network scripts
Update ifup.sh and fcoe-up.sh, use linkup function instead of directly
call ip command.

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-12-14 09:08:59 +01:00
dyoung@redhat.com
b455451f49 Add function linkup
set link up usually include two steps, ip link set <dev> up and
wait_for_if_up <dev>. Now do these two steps in one function linkup.
Later patch will add other code into it.

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-12-14 09:08:59 +01:00
dyoung@redhat.com
efa5eb424d Move wait for if functions to net lib
net-lib.sh are created for net related functions, move the wait_for_if* to
net-lib.sh naturally.

Signed-off-by: Dave Young <dyoung@redhat.com>
2012-12-14 09:08:59 +01:00
Cong Wang
3baa150bd4 dracut: add team device support
V2: merge patch 2/2
    fix active-backup mode by adding slaves one by one
    sync with the latest teamd
    improve the comments
    wait for team ports to come up
    install /etc/libnl/classid too

This patch adds the initial support for team device [1].
A new cmdline team= is introduced for it.

Note, currently we don't support stacked devices
on/under team, it is tricky and can be added on request.

1. http://www.libteam.org/

Cc: Harald Hoyer <harald@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Cong Wang <amwang@redhat.com>
2012-12-14 09:06:51 +01:00
Harald Hoyer
43cc4d84bc change for "udevadm control": s/--reload-rules/--reload/g 2012-12-14 09:04:56 +01:00
Harald Hoyer
6b84015e67 iscsi/iscsiroot.sh: reload rules after adding 99-iscsi-root.rules 2012-12-14 09:04:56 +01:00
Harald Hoyer
60bbb8fcc9 cms/cms-write-ifcfg.sh: also fill in /etc/hostname 2012-12-14 09:04:56 +01:00
Harald Hoyer
16c84f2873 udev-rules/udev-rules-prepare.sh: get UDEVVERSION, if unset 2012-12-14 09:04:56 +01:00
Amadeusz Żołnowski
579238a3ac Fallback to external blkid and path_id in udev rules for <udev-176.
Starting with commit 24a38bc1cb dracut
uses udev builtins but still depends on >=udev-166 in dracut.spec.  This
patch makes dracut work with older udev again.

All credits go to Alexander Tsoy <alexander@tsoy.me>; see

  https://bugs.gentoo.org/show_bug.cgi?id=437700
2012-12-14 09:04:56 +01:00
Harald Hoyer
2b5cd3dbf8 nfs/nfsroot-cleanup.sh: mount --bind instead of --move 2012-12-14 09:04:55 +01:00
Harald Hoyer
3d8a164d0e dracut.spec: add iputils and iproute requirement for dracut-network 2012-12-14 09:04:55 +01:00
Nicolas Chauvet
00ae54f00a Fix rd.blacklist.driver when no /etc/modprobe.d exists
This bug was reported as http://bugzilla.redhat.com/873220#c2

As the /etc/modprobe.d isn't created in the boot process
nor bundled within the initramfs, the initramfsblacklist.conf
cannot be created.

Instead, the /usr/lib/modprobe.d directory is available and using it
will restore the blacklist behavior.
2012-12-14 09:04:55 +01:00
Will Woods
488d55c546 add 'swapoff' to initramfs to fix shutdown/reboot
systemd shutdown/reboot won't work unless 'swapoff' is available.
2012-12-14 09:04:55 +01:00
Will Woods
9d6165f235 drop NEWROOT from module-setup.sh
This was almost certainly copy-pasted from mount-root.sh, but it's not
valid here - dracut doesn't use NEWROOT outside of the initramfs.
2012-12-14 09:04:55 +01:00
Dave Young
2258f00e91 split plymouth module
Kdump module will need the drm and kms kernel modules so user can see the
emergency shell at least.

Fix this by split 50plymouth module to 50drm and 50plymouth. Moving the
installkernel part to 50drm so user can use drm directly without adding
extra plymouth utils.

Signed-off-by: Dave Young <dyoung@redhat.com>
Tested-by: Chao Wang <chaowang@redhat.com>
2012-12-14 09:04:55 +01:00
Harald Hoyer
2bac2d6d76 systemd/dracut-cmdline.service: run before systemd-vconsole-setup
cmdline does generate vconsole.conf, which is needed by vconsole-setup
2012-12-14 09:04:55 +01:00
Harald Hoyer
b6b895bab5 systemd/service-to-run.sh: silence "cp" errors 2012-12-14 09:04:55 +01:00
Harald Hoyer
fdeae2a3ac crypt/crypt-run-generator.sh: do not timeout for LUKS passwords with systemd 2012-12-14 09:04:55 +01:00
Harald Hoyer
040f388331 dmsquash-live: add systemd checkisomd5 service 2012-12-14 09:04:55 +01:00
Harald Hoyer
7990578443 network: fixed MAC address assignment 2012-11-26 13:49:38 +01:00
Harald Hoyer
528ae4f46c systemd/module-setup.sh: turn off RateLimit for the journal 2012-11-26 13:49:19 +01:00
Harald Hoyer
0fb7b847c5 cms/cmssetup.sh: sync udev rules names with network/net-genrules.sh
https://bugzilla.redhat.com/show_bug.cgi?id=825199
2012-11-22 12:32:19 +01:00
Harald Hoyer
a67a6f957d nfs/nfs-start-rpc.sh: prevent mount error, if sunrpc kernel module is not in the initramfs
https://bugzilla.redhat.com/show_bug.cgi?id=870632
2012-11-22 12:29:43 +01:00
Harald Hoyer
965edeb63b i18n/parse-i18n.sh: fix locale.conf caused by 4dbc1d1bb3
https://bugzilla.redhat.com/show_bug.cgi?id=870632
2012-11-22 11:59:10 +01:00
Harald Hoyer
329bbd797f crypt/crypt-run-generator.sh: fixup last commit 065fc56ab2 2012-11-21 16:36:37 +01:00
Robert Buchholz
065fc56ab2 Make short uuid specification for allow-discards work
1) strstr " $discarduuids " did not remove the optional
'luks-' prefix from the argument as the documentation says.

2) The lookup seems backwards. $luksdev ($luks in the other code copy)
is the full uuid and thus one should check whether the user-supplied
argument (short form) is contained therein, not the other way around.

Before this commit, the only way to trigger allow-discards was to
specify the full uuid without the 'luks-' prefix.
2012-11-21 16:01:45 +01:00
Harald Hoyer
64d144aece Add sosreport script and generate /run/initramfs/sosreport.txt 2012-11-21 14:17:43 +01:00
Harald Hoyer
2d9b156e9e dracut.sh: do not strip signed kernel modules
https://bugzilla.redhat.com/show_bug.cgi?id=873796
2012-11-21 14:07:32 +01:00
Harald Hoyer
2b9be6f707 [nfs|cifs]root.sh: make "/dev/root" a symlink, so it gets cleaned up later on 2012-11-19 17:03:55 +01:00
Harald Hoyer
b26897fb60 dracut.sh: only 'warn' not 'error', if we don't strip 2012-10-19 11:20:30 +02:00
WANG Chao
8bf25df640 40network/ifup.sh: do_static() and do_ipv6auto return 0 if no errors.
Commit a0be1ed removes some lines from do_static() and do_ipv6auto().

When $hostname is empty, do_static() and do_ipv6auto() will return 1
and fails to run setup_net at the last of ifup.sh

Signed-off-by: WANG Chao <chaowang@redhat.com>
2012-10-19 11:10:52 +02:00
Harald Hoyer
e743cfdd4b dracut.conf.d/fedora.conf.example: s/kernelcmdline/kernel_cmdline 2012-10-19 11:10:03 +02:00
Harald Hoyer
636e5cd2d5 dracut.sh: only save $kernel_cmdline, if set 2012-10-19 11:09:38 +02:00
239 changed files with 5310 additions and 2240 deletions

4
.gitignore vendored
View File

@@ -13,3 +13,7 @@ test*.img
/.project /.project
/dracut-version.sh /dracut-version.sh
/install/dracut-install /install/dracut-install
/*.rpm
/*.[0-9]
/modules.d/98systemd/*.service.8
/*.sign

View File

@@ -1,12 +1,15 @@
Philippe Seewer <philippe.seewer@bfh.ch> <philippe.seewer-omB+W0Dpw2o@public.gmane.org> Philippe Seewer <philippe.seewer@bfh.ch> <philippe.seewer-omB+W0Dpw2o@public.gmane.org>
Seewer Philippe <philippe.seewer@bfh.ch> <philippe.seewer@bfh.ch> Seewer Philippe <philippe.seewer@bfh.ch> <philippe.seewer@bfh.ch>
Philippe Seewer <philippe.seewer@bfh.ch> <philippe.seewer@bfh.ch> Philippe Seewer <philippe.seewer@bfh.ch> <philippe.seewer@bfh.ch>
Victor Lowther <victor.lowther@gmail.com> <victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Victor Lowther <victor.lowther@gmail.com> <victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Harald Hoyer <harald@redhat.com> <harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> Harald Hoyer <harald@redhat.com> <harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Harald Hoyer <harald@redhat.com> <harald@eeepc.(none)> Harald Hoyer <harald@redhat.com> <harald@eeepc.(none)>
Mike Snitzer <snitzer@redhat.com> <msnitzer@redhat.com> Mike Snitzer <snitzer@redhat.com> <msnitzer@redhat.com>
Amerigo Wang <amwang@redhat.com> <xiyou.wangcong@gmail.com> Amerigo Wang <amwang@redhat.com> <xiyou.wangcong@gmail.com>
Andrey Borzenkov <arvidjaar@gmail.com> <arvidjaar@mail.ru> Andrey Borzenkov <arvidjaar@gmail.com> <arvidjaar@mail.ru>
Dan Horák <dhorak@redhat.com> <dan@danny.cz> Dan Horák <dhorak@redhat.com> <dan@danny.cz>
John Reiser <jreiser@bitwagon.com> <jreiser@BitWagon.com> John Reiser <jreiser@bitwagon.com> <jreiser@BitWagon.com>
Luca Berra <bluca@vodka.it> <bluca@comedia.it> Luca Berra <bluca@vodka.it> <bluca@comedia.it>
Dave Young <dyoung@redhat.com> dyoung@redhat.com
Frederick Grose <fgrose@sugarlabs.org> <fgrose@gmail.com>
Frederic Crozat <fcrozat@suse.com> <fcrozat@mandriva.com>

33
50-dracut.install Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
if [[ -f /etc/kernel/cmdline ]]; then
readarray -t BOOT_OPTIONS < /etc/kernel/cmdline
fi
if ! [[ "${BOOT_OPTIONS[@]}" ]]; then
readarray -t BOOT_OPTIONS < /proc/cmdline
fi
unset noimageifnotneeded
for ((i=0; i < "${#BOOT_OPTIONS[@]}"; i++)); do
if [[ ${BOOT_OPTIONS[$i]} == root\=PARTUUID\=* ]]; then
noimageifnotneeded="yes"
break
fi
done
ret=0
case "$1" in
add)
dracut ${noimageifnotneeded+--noimageifnotneeded} "$3"/initrd "$2"
ret=$?
;;
remove)
rm -f -- "$3"/initrd
ret=$?
;;
esac
exit $ret

70
51-dracut-rescue-postinst.sh Executable file
View File

@@ -0,0 +1,70 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
export LANG=C
KERNEL_VERSION="$1"
KERNEL_IMAGE="$2"
[[ -f /etc/os-release ]] && . /etc/os-release
if [[ ! -f /etc/machine-id ]] || [[ ! -s /etc/machine-id ]]; then
systemd-machine-id-setup
fi
[[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
[[ $MACHINE_ID ]] || exit 1
[[ -f $KERNEL_IMAGE ]] || exit 1
INITRDFILE="/boot/initramfs-0-rescue-${MACHINE_ID}.img"
NEW_KERNEL_IMAGE="${KERNEL_IMAGE%/*}/vmlinuz-0-rescue-${MACHINE_ID}"
[[ -f $INITRDFILE ]] && [[ -f $NEW_KERNEL_IMAGE ]] && exit 0
dropindirs_sort()
{
suffix=$1; shift
args=("$@")
files=$(
while (( $# > 0 )); do
for i in ${1}/*${suffix}; do
[[ -f $i ]] && echo ${i##*/}
done
shift
done | sort -Vu
)
for f in $files; do
for d in "${args[@]}"; do
if [[ -f "$d/$f" ]]; then
echo "$d/$f"
continue 2
fi
done
done
}
# source our config dir
for f in $(dropindirs_sort ".conf" "/etc/dracut.conf.d" "/usr/lib/dracut/dracut.conf.d"); do
[[ -e $f ]] && . "$f"
done
[[ $dracut_rescue_image != "yes" ]] && exit 0
if [[ ! -f $INITRDFILE ]]; then
dracut --no-hostonly -a "rescue" "$INITRDFILE" "$KERNEL_VERSION"
((ret+=$?))
fi
if [[ ! -f $NEW_KERNEL_IMAGE ]]; then
cp "$KERNEL_IMAGE" "$NEW_KERNEL_IMAGE"
((ret+=$?))
fi
new-kernel-pkg --install "$KERNEL_VERSION" --kernel-image "$NEW_KERNEL_IMAGE" --initrdfile "$INITRDFILE" --banner "$NAME $VERSION_ID Rescue $MACHINE_ID"
((ret+=$?))
exit $ret

101
51-dracut-rescue.install Executable file
View File

@@ -0,0 +1,101 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
export LANG=C
COMMAND="$1"
KERNEL_VERSION="$2"
dropindirs_sort()
{
suffix=$1; shift
args=("$@")
files=$(
while (( $# > 0 )); do
for i in ${1}/*${suffix}; do
[[ -f $i ]] && echo ${i##*/}
done
shift
done | sort -Vu
)
for f in $files; do
for d in "${args[@]}"; do
if [[ -f "$d/$f" ]]; then
echo "$d/$f"
continue 2
fi
done
done
}
[[ -f /etc/os-release ]] && . /etc/os-release
if [[ ! -f /etc/machine-id ]] || [[ ! -s /etc/machine-id ]]; then
systemd-machine-id-setup
fi
[[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
if [[ -f /etc/kernel/cmdline ]]; then
readarray -t BOOT_OPTIONS < /etc/kernel/cmdline
fi
if ! [[ "${BOOT_OPTIONS[@]}" ]]; then
readarray -t BOOT_OPTIONS < /proc/cmdline
fi
if ! [[ $BOOT_OPTIONS ]]; then
exit 1
fi
LOADER_ENTRY="/boot/loader/entries/${MACHINE_ID}-0-rescue.conf"
BOOT_DIR="/${MACHINE_ID}/0-rescue"
BOOT_DIR_ABS="/boot${BOOT_DIR}"
ret=0
case "$COMMAND" in
add)
for i in "/boot/loader/entries/${MACHINE_ID}-0-rescue.conf"; do
[[ -f $i ]] && exit 0
done
# source our config dir
for f in $(dropindirs_sort ".conf" "/etc/dracut.conf.d" "/usr/lib/dracut/dracut.conf.d"); do
[[ -e $f ]] && . "$f"
done
[[ $dracut_rescue_image != "yes" ]] && exit 0
[[ -d "$BOOT_DIR_ABS" ]] || mkdir -p "$BOOT_DIR_ABS"
if ! cp "$KERNEL_IMAGE" "$BOOT_DIR_ABS"/linux; then
echo "Can't copy '$KERNEL_IMAGE to '$BOOT_DIR_ABS/linux'!" >&2
fi
dracut --no-hostonly -a "rescue" "$BOOT_DIR_ABS"/initrd "$2"
((ret+=$?))
{
echo "title $PRETTY_NAME - Rescue Image"
echo "version $KERNEL_VERSION"
echo "machine-id $MACHINE_ID"
echo "options ${BOOT_OPTIONS[@]} rd.auto=1"
echo "linux $BOOT_DIR/linux"
echo "initrd $BOOT_DIR/initrd"
} > $LOADER_ENTRY
((ret+=$?))
;;
remove)
exit 0
;;
*)
usage
ret=1;;
esac
((ret+=$?))
exit $ret

36
AUTHORS
View File

@@ -1,14 +1,14 @@
Harald Hoyer <harald@redhat.com> Harald Hoyer <harald@redhat.com>
Victor Lowther <victor.lowther@gmail.com> Victor Lowther <victor.lowther@gmail.com>
Amadeusz Żołnowski <aidecoe@aidecoe.name> Amadeusz Żołnowski <aidecoe@aidecoe.name>
Will Woods <wwoods@redhat.com>
Philippe Seewer <philippe.seewer@bfh.ch> Philippe Seewer <philippe.seewer@bfh.ch>
Warren Togami <wtogami@redhat.com> Warren Togami <wtogami@redhat.com>
Will Woods <wwoods@redhat.com>
Jeremy Katz <katzj@redhat.com> Jeremy Katz <katzj@redhat.com>
David Dillow <dave@thedillows.org> David Dillow <dave@thedillows.org>
Dave Young <dyoung@redhat.com>
Michal Soltys <soltys@ziu.info> Michal Soltys <soltys@ziu.info>
Amerigo Wang <amwang@redhat.com> Amerigo Wang <amwang@redhat.com>
Dave Young <dyoung@redhat.com>
Colin Guthrie <colin@mageia.org> Colin Guthrie <colin@mageia.org>
Andrey Borzenkov <arvidjaar@gmail.com> Andrey Borzenkov <arvidjaar@gmail.com>
Andreas Thienemann <andreas@bawue.net> Andreas Thienemann <andreas@bawue.net>
@@ -17,53 +17,64 @@ Peter Jones <pjones@redhat.com>
John Reiser <jreiser@bitwagon.com> John Reiser <jreiser@bitwagon.com>
Luca Berra <bluca@vodka.it> Luca Berra <bluca@vodka.it>
Daniel Drake <dsd@laptop.org> Daniel Drake <dsd@laptop.org>
Dan Horák <dhorak@redhat.com>
WANG Chao <chaowang@redhat.com>
Leho Kraav <leho@kraav.com> Leho Kraav <leho@kraav.com>
Baoquan He <bhe@redhat.com>
Brian C. Lane <bcl@redhat.com> Brian C. Lane <bcl@redhat.com>
Kamil Rytarowski <n54@gmx.com>
Marc Grimme <grimme@atix.de> Marc Grimme <grimme@atix.de>
Chao Wang <chaowang@redhat.com> Chao Wang <chaowang@redhat.com>
Dan Horák <dhorak@redhat.com> Frederic Crozat <fcrozat@suse.com>
Jesse Keating <jkeating@redhat.com> Jesse Keating <jkeating@redhat.com>
Milan Broz <mbroz@redhat.com> Milan Broz <mbroz@redhat.com>
Roberto Sassu <roberto.sassu@polito.it> Roberto Sassu <roberto.sassu@polito.it>
dyoung@redhat.com <dyoung@redhat.com>
Anton Blanchard <anton@samba.org> Anton Blanchard <anton@samba.org>
Bill Nottingham <notting@redhat.com> Bill Nottingham <notting@redhat.com>
David Cantrell <dcantrell@redhat.com> David Cantrell <dcantrell@redhat.com>
Frederic Crozat <fcrozat@suse.com> Dennis Gilmore <dennis@ausil.us>
Jon Ander Hernandez <jonan.h@gmail.com> Jon Ander Hernandez <jonan.h@gmail.com>
Juan RP <xtraeme@gmail.com> Juan RP <xtraeme@gmail.com>
Lance Albertson <lance@osuosl.org> Lance Albertson <lance@osuosl.org>
Marian Ganisin <mganisin@redhat.com> Marian Ganisin <mganisin@redhat.com>
Michael Ploujnikov <plouj@somanetworks.com> Michael Ploujnikov <plouj@somanetworks.com>
Peter Rajnoha <prajnoha@redhat.com> Peter Rajnoha <prajnoha@redhat.com>
Radek Vykydal <rvykydal@redhat.com>
Wim Muskee <wimmuskee@gmail.com>
Alan Jenkins <alan-jenkins@tuffmail.co.uk> Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Alan Pevec <apevec@redhat.com> Alan Pevec <apevec@redhat.com>
Colin Walters <walters@verbum.org> Colin Walters <walters@verbum.org>
Dennis Gilmore <dennis@ausil.us> Frederick Grose <fgrose@sugarlabs.org>
Ian Dall <ian@beware.dropbear.id.au> Ian Dall <ian@beware.dropbear.id.au>
James Buren <ryuo@frugalware.org> James Buren <ryuo@frugalware.org>
Joey Boggs <jboggs@redhat.com> Joey Boggs <jboggs@redhat.com>
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Mike Snitzer <snitzer@redhat.com> Mike Snitzer <snitzer@redhat.com>
Przemysław Rudy <prudy1@o2.pl> Przemysław Rudy <prudy1@o2.pl>
Stefan Reimer <it@startux.de>
Thomas Lange <lange@informatik.uni-koeln.de> Thomas Lange <lange@informatik.uni-koeln.de>
Vivek Goyal <vgoyal@redhat.com> Vivek Goyal <vgoyal@redhat.com>
Vladislav Bogdanov <bubble@hoster-ok.com> Vladislav Bogdanov <bubble@hoster-ok.com>
Wim Muskee <wimmuskee@gmail.com> Adam Williamson <awilliam@redhat.com>
Alexander Todorov <atodorov@redhat.com> Alexander Todorov <atodorov@redhat.com>
Andy Lutomirski <luto@mit.edu> Andy Lutomirski <luto@mit.edu>
Anssi Hannula <anssi@mageia.org> Anssi Hannula <anssi@mageia.org>
Canek Peláez Valdés <caneko@gmail.com> Canek Peláez Valdés <caneko@gmail.com>
Chris Leech <cleech@redhat.com> Chris Leech <cleech@redhat.com>
Christian Heinz <christian.ch.heinz@gmail.com> Christian Heinz <christian.ch.heinz@gmail.com>
Cong Wang <amwang@redhat.com>
Dave Jones <davej@redhat.com> Dave Jones <davej@redhat.com>
Dave Young <dave@redhat.com>
Dennis Schridde <devurandom@gmx.net>
Duane Griffin <duaneg@dghda.com> Duane Griffin <duaneg@dghda.com>
Frederic Crozat <fcrozat@mandriva.com>
Frederick Grose <fgrose@gmail.com>
Glen Gray <slaine@slaine.org> Glen Gray <slaine@slaine.org>
Hermann Gausterer <git-dracut-2012@mrq1.org> Hermann Gausterer <git-dracut-2012@mrq1.org>
James Laska <jlaska@redhat.com> James Laska <jlaska@redhat.com>
Jan Stodola <jstodola@redhat.com> Jan Stodola <jstodola@redhat.com>
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Jiri Pirko <jiri@resnulli.us>
Joe Lawrence <Joe.Lawrence@stratus.com>
Kevin Yung <Kevin.Yung@myob.com>
Lars R. Damerow <lars@pixar.com>
Lennert Buytenhek <buytenh@wantstofly.org> Lennert Buytenhek <buytenh@wantstofly.org>
Lubomir Rintel <lkundrak@v3.sk> Lubomir Rintel <lkundrak@v3.sk>
Matt <smoothsailing72@hotmail.com> Matt <smoothsailing72@hotmail.com>
@@ -71,17 +82,18 @@ Matt Smith <shadowfax@gmx.com>
Michal Schmidt <mschmidt@redhat.com> Michal Schmidt <mschmidt@redhat.com>
Mike Gorse <mgorse@suse.com> Mike Gorse <mgorse@suse.com>
Munehiro Matsuda <haro@kgt.co.jp> Munehiro Matsuda <haro@kgt.co.jp>
Nicolas Chauvet <kwizart@gmail.com>
Nikoli <nikoli@lavabit.com> Nikoli <nikoli@lavabit.com>
Olivier Blin <dev@blino.org> Olivier Blin <dev@blino.org>
Paolo Bonzini <pbonzini@redhat.com> Paolo Bonzini <pbonzini@redhat.com>
Peter Robinson <pbrobinson@fedoraproject.org> Peter Robinson <pbrobinson@fedoraproject.org>
Pádraig Brady <P@draigBrady.com> Pádraig Brady <P@draigBrady.com>
Quentin Armitage <quentin@armitage.org.uk> Quentin Armitage <quentin@armitage.org.uk>
Radek Vykydal <rvykydal@redhat.com> Robert Buchholz <rbu@goodpoint.de>
Sergey Fionov <fionov@gmail.com> Sergey Fionov <fionov@gmail.com>
Srinivasa T N <seenutn@linux.vnet.ibm.com> Srinivasa T N <seenutn@linux.vnet.ibm.com>
Stefan Reimer <it@startux.de>
Thilo Bangert <thilo.bangert@gmx.net> Thilo Bangert <thilo.bangert@gmx.net>
Thomas Backlund <tmb@mageia.org>
Tomasz Torcz <tomek@pipebreaker.pl> Tomasz Torcz <tomek@pipebreaker.pl>
Vadim Kuznetsov <vadimk@gentoo.org> Vadim Kuznetsov <vadimk@gentoo.org>
Ville Skyttä <ville.skytta@iki.fi> Ville Skyttä <ville.skytta@iki.fi>

View File

@@ -1,5 +1,7 @@
VERSION=024 -include dracut-version.sh
GITVERSION=$(shell [ -d .git ] && git rev-list --abbrev-commit -n 1 HEAD |cut -b 1-8)
VERSION = $(shell [ -d .git ] && git describe --abbrev=0 --tags 2>/dev/null || echo $(DRACUT_VERSION))
GITVERSION = $(shell [ -d .git ] && { v=$$(git describe --tags 2>/dev/null); [ $${v\#*-} != $$v ] && echo -$${v\#*-}; } )
-include Makefile.inc -include Makefile.inc
@@ -11,31 +13,34 @@ sysconfdir ?= ${prefix}/etc
bindir ?= ${prefix}/bin bindir ?= ${prefix}/bin
mandir ?= ${prefix}/share/man mandir ?= ${prefix}/share/man
CFLAGS ?= -O2 -g -Wall CFLAGS ?= -O2 -g -Wall
CFLAGS += -std=gnu99 CFLAGS += -std=gnu99 -D_FILE_OFFSET_BITS=64
bashcompletiondir ?= ${datadir}/bash-completion/completions
man1pages = lsinitrd.1 man1pages = lsinitrd.1
man5pages = dracut.conf.5 man5pages = dracut.conf.5
man7pages = dracut.cmdline.7 man7pages = dracut.cmdline.7 \
dracut.bootup.7
man8pages = dracut.8 \ man8pages = dracut.8 \
dracut-catimages.8 \ dracut-catimages.8 \
mkinitrd.8 \ mkinitrd.8 \
modules.d/98systemd/dracut-cmdline.service.8 \ modules.d/98systemd/dracut-cmdline.service.8 \
modules.d/98systemd/dracut-initqueue.service.8 \ modules.d/98systemd/dracut-initqueue.service.8 \
modules.d/98systemd/dracut-mount.service.8 \
modules.d/98systemd/dracut-shutdown.service.8 \
modules.d/98systemd/dracut-pre-mount.service.8 \
modules.d/98systemd/dracut-pre-pivot.service.8 \ modules.d/98systemd/dracut-pre-pivot.service.8 \
modules.d/98systemd/dracut-pre-trigger.service.8 \ modules.d/98systemd/dracut-pre-trigger.service.8 \
modules.d/98systemd/dracut-pre-udev.service.8 \ modules.d/98systemd/dracut-pre-udev.service.8
modules.d/98systemd/initrd-switch-root.service.8 \
modules.d/98systemd/udevadm-cleanup-db.service.8
manpages = $(man1pages) $(man5pages) $(man7pages) $(man8pages) manpages = $(man1pages) $(man5pages) $(man7pages) $(man8pages)
.PHONY: install clean archive rpm testimage test all check AUTHORS doc .PHONY: install clean archive rpm testimage test all check AUTHORS doc dracut-version.sh
all: syncheck dracut-version.sh dracut-install all: dracut-version.sh dracut-install
DRACUT_INSTALL_OBJECTS = \ DRACUT_INSTALL_OBJECTS = \
install/dracut-install.o \ install/dracut-install.o \
@@ -77,7 +82,7 @@ dracut.html: dracut.asc $(manpages)
--stringparam html.stylesheet \ --stringparam html.stylesheet \
http://docs.fedoraproject.org/en-US/Common_Content/css/default.css \ http://docs.fedoraproject.org/en-US/Common_Content/css/default.css \
http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl dracut.xml http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl dracut.xml
rm dracut.xml rm -f -- dracut.xml
install: dracut-version.sh install: dracut-version.sh
mkdir -p $(DESTDIR)$(pkglibdir) mkdir -p $(DESTDIR)$(pkglibdir)
@@ -91,6 +96,7 @@ install: dracut-version.sh
install -m 0755 lsinitrd.sh $(DESTDIR)$(bindir)/lsinitrd install -m 0755 lsinitrd.sh $(DESTDIR)$(bindir)/lsinitrd
install -m 0644 dracut.conf $(DESTDIR)$(sysconfdir)/dracut.conf install -m 0644 dracut.conf $(DESTDIR)$(sysconfdir)/dracut.conf
mkdir -p $(DESTDIR)$(sysconfdir)/dracut.conf.d mkdir -p $(DESTDIR)$(sysconfdir)/dracut.conf.d
mkdir -p $(DESTDIR)$(pkglibdir)/dracut.conf.d
install -m 0755 dracut-functions.sh $(DESTDIR)$(pkglibdir)/dracut-functions.sh install -m 0755 dracut-functions.sh $(DESTDIR)$(pkglibdir)/dracut-functions.sh
install -m 0755 dracut-version.sh $(DESTDIR)$(pkglibdir)/dracut-version.sh install -m 0755 dracut-version.sh $(DESTDIR)$(pkglibdir)/dracut-version.sh
ln -fs dracut-functions.sh $(DESTDIR)$(pkglibdir)/dracut-functions ln -fs dracut-functions.sh $(DESTDIR)$(pkglibdir)/dracut-functions
@@ -106,17 +112,37 @@ ifneq ($(enable_documentation),no)
endif endif
if [ -n "$(systemdsystemunitdir)" ]; then \ if [ -n "$(systemdsystemunitdir)" ]; then \
mkdir -p $(DESTDIR)$(systemdsystemunitdir); \ mkdir -p $(DESTDIR)$(systemdsystemunitdir); \
install -m 0644 dracut-shutdown.service $(DESTDIR)$(systemdsystemunitdir); \ ln -srf $(DESTDIR)$(pkglibdir)/modules.d/98systemd/dracut-shutdown.service $(DESTDIR)$(systemdsystemunitdir)/dracut-shutdown.service; \
mkdir -p $(DESTDIR)$(systemdsystemunitdir)/shutdown.target.wants; \ mkdir -p $(DESTDIR)$(systemdsystemunitdir)/shutdown.target.wants; \
ln -s ../dracut-shutdown.service \ ln -s ../dracut-shutdown.service \
$(DESTDIR)$(systemdsystemunitdir)/shutdown.target.wants/dracut-shutdown.service; \ $(DESTDIR)$(systemdsystemunitdir)/shutdown.target.wants/dracut-shutdown.service; \
mkdir -p $(DESTDIR)$(systemdsystemunitdir)/initrd.target.wants; \
for i in \
dracut-cmdline.service \
dracut-initqueue.service \
dracut-mount.service \
dracut-pre-mount.service \
dracut-pre-pivot.service \
dracut-pre-trigger.service \
dracut-pre-udev.service \
; do \
ln -srf $(DESTDIR)$(pkglibdir)/modules.d/98systemd/$$i $(DESTDIR)$(systemdsystemunitdir); \
ln -s ../$$i \
$(DESTDIR)$(systemdsystemunitdir)/initrd.target.wants/$$i; \
done \
fi fi
if [ -f install/dracut-install ]; then \ if [ -f install/dracut-install ]; then \
install -m 0755 install/dracut-install $(DESTDIR)$(pkglibdir)/dracut-install; \ install -m 0755 install/dracut-install $(DESTDIR)$(pkglibdir)/dracut-install; \
fi fi
mkdir -p $(DESTDIR)${prefix}/lib/kernel/install.d
install -m 0755 50-dracut.install $(DESTDIR)${prefix}/lib/kernel/install.d/50-dracut.install
install -m 0755 51-dracut-rescue.install $(DESTDIR)${prefix}/lib/kernel/install.d/51-dracut-rescue.install
mkdir -p $(DESTDIR)${bashcompletiondir}
install -m 0644 dracut-bash-completion.sh $(DESTDIR)${bashcompletiondir}/dracut
install -m 0644 lsinitrd-bash-completion.sh $(DESTDIR)${bashcompletiondir}/lsinitrd
dracut-version.sh: dracut-version.sh:
@echo "DRACUT_VERSION=$(VERSION)-$(GITVERSION)" > dracut-version.sh @echo "DRACUT_VERSION=$(VERSION)$(GITVERSION)" > dracut-version.sh
clean: clean:
$(RM) *~ $(RM) *~
@@ -125,22 +151,22 @@ clean:
$(RM) $(manpages:%=%.xml) dracut.xml $(RM) $(manpages:%=%.xml) dracut.xml
$(RM) test-*.img $(RM) test-*.img
$(RM) dracut-*.rpm dracut-*.tar.bz2 $(RM) dracut-*.rpm dracut-*.tar.bz2
$(RM) dracut-version.sh
$(RM) dracut-install install/dracut-install $(DRACUT_INSTALL_OBJECTS) $(RM) dracut-install install/dracut-install $(DRACUT_INSTALL_OBJECTS)
$(RM) $(manpages) dracut.html $(RM) $(manpages) dracut.html
$(MAKE) -C test clean $(MAKE) -C test clean
archive: dracut-$(VERSION)-$(GITVERSION).tar.bz2
dist: dracut-$(VERSION).tar.bz2 dist: dracut-$(VERSION).tar.bz2
dracut-$(VERSION).tar.bz2: doc dracut-$(VERSION).tar.bz2: doc
@echo "DRACUT_VERSION=$(VERSION)" > dracut-version.sh
git archive --format=tar $(VERSION) --prefix=dracut-$(VERSION)/ > dracut-$(VERSION).tar git archive --format=tar $(VERSION) --prefix=dracut-$(VERSION)/ > dracut-$(VERSION).tar
mkdir -p dracut-$(VERSION) mkdir -p dracut-$(VERSION)
cp $(manpages) dracut.html dracut-$(VERSION) for i in $(manpages) dracut.html dracut-version.sh; do [ "$${i%/*}" != "$$i" ] && mkdir -p "dracut-$(VERSION)/$${i%/*}"; cp "$$i" "dracut-$(VERSION)/$$i"; done
tar -rf dracut-$(VERSION).tar dracut-$(VERSION)/*.[0-9] dracut-$(VERSION)/dracut.html tar --owner=root --group=root -rf dracut-$(VERSION).tar $$(find dracut-$(VERSION) -type f)
rm -fr dracut-$(VERSION).tar.bz2 dracut-$(VERSION) rm -fr -- dracut-$(VERSION).tar.bz2 dracut-$(VERSION)
bzip2 -9 dracut-$(VERSION).tar bzip2 -9 dracut-$(VERSION).tar
rm -f dracut-$(VERSION).tar rm -f -- dracut-$(VERSION).tar
rpm: dracut-$(VERSION).tar.bz2 rpm: dracut-$(VERSION).tar.bz2
rpmbuild=$$(mktemp -d -t rpmbuild-dracut.XXXXXX); src=$$(pwd); \ rpmbuild=$$(mktemp -d -t rpmbuild-dracut.XXXXXX); src=$$(pwd); \
@@ -149,21 +175,21 @@ rpm: dracut-$(VERSION).tar.bz2
(cd "$$rpmbuild"; rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" \ (cd "$$rpmbuild"; rpmbuild --define "_topdir $$PWD" --define "_sourcedir $$PWD" \
--define "_specdir $$PWD" --define "_srcrpmdir $$PWD" \ --define "_specdir $$PWD" --define "_srcrpmdir $$PWD" \
--define "_rpmdir $$PWD" -ba dracut.spec; ) && \ --define "_rpmdir $$PWD" -ba dracut.spec; ) && \
( mv "$$rpmbuild"/$$(arch)/*.rpm .; mv "$$rpmbuild"/*.src.rpm .;rm -fr "$$rpmbuild"; ls *.rpm ) ( mv "$$rpmbuild"/$$(arch)/*.rpm .; mv "$$rpmbuild"/*.src.rpm .;rm -fr -- "$$rpmbuild"; ls *.rpm )
syncheck: syncheck:
@ret=0;for i in dracut-initramfs-restore.sh dracut-logger.sh \ @ret=0;for i in dracut-initramfs-restore.sh modules.d/*/*.sh; do \
modules.d/99base/init.sh modules.d/*/*.sh; do \
[ "$${i##*/}" = "module-setup.sh" ] && continue; \ [ "$${i##*/}" = "module-setup.sh" ] && continue; \
read line < "$$i"; [ "$${line#*bash*}" != "$$line" ] && continue; \ read line < "$$i"; [ "$${line#*bash*}" != "$$line" ] && continue; \
dash -n "$$i" ; ret=$$(($$ret+$$?)); \ [ $$V ] && echo "posix syntax check: $$i"; bash --posix -n "$$i" ; ret=$$(($$ret+$$?)); \
[ $$V ] && echo "checking for [[: $$i"; if grep -Fq '[[ ' "$$i" ; then ret=$$(($$ret+1)); echo "$$i contains [["; fi \
done;exit $$ret done;exit $$ret
@ret=0;for i in *.sh mkinitrd-dracut.sh modules.d/*/*.sh \ @ret=0;for i in *.sh mkinitrd-dracut.sh modules.d/*/*.sh \
modules.d/*/module-setup.sh; do \ modules.d/*/module-setup.sh; do \
bash -n "$$i" ; ret=$$(($$ret+$$?)); \ [ $$V ] && echo "bash syntax check: $$i"; bash -n "$$i" ; ret=$$(($$ret+$$?)); \
done;exit $$ret done;exit $$ret
check: all syncheck check: all syncheck rpm
@[ "$$EUID" == "0" ] || { echo "'check' must be run as root! Please use 'sudo'."; exit 1; } @[ "$$EUID" == "0" ] || { echo "'check' must be run as root! Please use 'sudo'."; exit 1; }
@$(MAKE) -C test check @$(MAKE) -C test check

132
NEWS
View File

@@ -1,3 +1,135 @@
dracut-030
==========
- support new persistent network interface names
- fix findmnt calls, prevents hang on stale NFS mounts
- add systemd.slice and slice.target units
- major shell cleanup
- support root=PARTLABEL= and root=PARTUUID=
- terminfo: only install l/linux v/vt100 and v/vt220
- unset all LC_* and LANG, 10% faster
- fixed dependency loop for dracut-cmdline.service
- do not wait_for_dev for the root devices
- do not wait_for_dev for devices, if dracut-initqueue is not needed
- support early microcode loading with --early-microcode
- dmraid, let dmraid setup its own partitions
- sosreport renamed to rdsosreport
dracut-029
==========
- wait for IPv6 autoconfiguration
- i18n: make the default font configurable
To set the default font for your distribution, add
i18n_default_font="latarcyrheb-sun16"
to your /lib/dracut/dracut.conf.d/01-dist.conf distribution config.
- proper handle "rd.break" in systemd mode before switch-root
- systemd: make unit files symlinks
- build without dash requirement
- add dracut-shutdown.service.8 manpage
- handle MACs for "ip="
"ip=77-77-6f-6f-64-73:dhcp"
- don't explode when mixing BOOTIF and ip=
- 90lvm/module-setup.sh: redirect error message of lvs to /dev/null
Contributions from:
Harald Hoyer
Will Woods
Baoquan He
dracut-028
==========
- full integration of crypto devs in systemd logic
- support for bridge over team and vlan tagged team
- support multiple bonding interfaces
- new kernel command line param "rd.action_on_fail"
to control the emergency action
- support for bridge over a vlan tagged interface
- support for "iso-scan/filename" kernel parameter
- lsinitrd got some love and does not use "file" anymore
- fixed issue with noexec mounted tmp dirs
- FIPS mode fixed
- dracut_install got some love
- fixed some /usr mounting problems
- ifcfg dracut module got some love and fixes
- default installed font is now latarcyrheb-sun16
- new parameters rd.live.dir and rd.live.squashimg
- lvm: add tools for thin provisioning
- also install non-hwcap libs
- setup correct system time and time zone in initrd
- s390: fixed cms setup
- add systemd-udevd persistent network interface naming
Contributions from:
Harald Hoyer
Kamil Rytarowski
WANG Chao
Baoquan He
Adam Williamson
Colin Guthrie
Dan Horák
Dave Young
Dennis Gilmore
Dennis Schridde
dracut-027
==========
- dracut now has bash-completion
- require bash version 4
- systemd module now requires systemd >= 199
- dracut makes use of native systemd initrd units
- added hooks for new-kernel-pkg and kernel-install
- hostonly is now default for fedora
- comply with the BootLoaderSpec paths
http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec
- added rescue module
- host_fs_types is now a hashmap
- new dracut argument "--regenerate-all"
- new dracut argument "--noimageifnotneeded"
- new man page dracut.bootup
- install all host filesystem drivers
- use -D_FILE_OFFSET_BITS=64 to build dracut-install
dracut-026
==========
- introduce /usr/lib/dracut/dracut.conf.d/ drop-in directory
/usr/lib/dracut/dracut.conf.d/*.conf can be overwritten by the same
filenames in /etc/dracut.conf.d.
Packages should use /usr/lib/dracut/dracut.conf.d rather than
/etc/dracut.conf.d for drop-in configuration files.
/etc/dracut.conf and /etc/dracut.conf.d belong to the system administrator.
- uses systemd-198 native initrd units
- totally rely on the fstab-generator in systemd mode for block devices
- dracut systemd now uses dracut.target rather than basic.target
- dracut systemd services optimize themselves away
- fixed hostonly parameter generation
- turn off curl globbing (fixes IPv6)
- modify the udev rules on install and not runtime time
- enable initramfs building without kernel modules (fixed regression)
- in the initqueue/timeout,
reset the main loop counter, as we see new udev events or initqueue/work
- fixed udev rule installation
dracut-025
==========
- do not strip signed kernel modules
- add sosreport script and generate /run/initramfs/sosreport.txt
- make short uuid specification for allow-discards work
- turn off RateLimit for the systemd journal
- fixed MAC address assignment
- add systemd checkisomd5 service
- splitout drm kernel modules from plymouth module
- add 'swapoff' to initramfs to fix shutdown/reboot
- add team device support
- add pre-shutdown hook
- kill all processes in shutdown and report remaining ones
- "--device" changed to "--add-device" and "add_device=" added for conf files
- add memory usage trace to different hook points
- cope with optional field #7 in /proc/self/mountinfo
- lots of small bugfixes
dracut-024 dracut-024
========== ==========
- new dracut option "--device" - new dracut option "--device"

8
TODO
View File

@@ -7,7 +7,6 @@ Items are ordered in priority.
INITRAMFS TODO INITRAMFS TODO
- use info and warn prefix - use info and warn prefix
- add sosreport
- generate systemd unit dracut-initramfs-restore in /run/systemd dynamically - generate systemd unit dracut-initramfs-restore in /run/systemd dynamically
- put "root=" parsing hooks in separate hook dir - put "root=" parsing hooks in separate hook dir
- call "root=" parsing hooks after getting new rootpath from dhcp - call "root=" parsing hooks after getting new rootpath from dhcp
@@ -20,18 +19,19 @@ INITRAMFS TODO
- disable write-ifcfg https://bugzilla.redhat.com/show_bug.cgi?id=840784 - disable write-ifcfg https://bugzilla.redhat.com/show_bug.cgi?id=840784
- check for /var to be mounted in convertfs https://bugzilla.redhat.com/show_bug.cgi?id=848172 - check for /var to be mounted in convertfs https://bugzilla.redhat.com/show_bug.cgi?id=848172
- probably fix "--include" https://bugzilla.redhat.com/show_bug.cgi?id=849338 - probably fix "--include" https://bugzilla.redhat.com/show_bug.cgi?id=849338
- iscsi livecd boot
GENERATOR TODO GENERATOR TODO
- remove wait for swap devs, if no "resume=" is given on the kernel command line
- add presets (predefined set of modules)
- add interpreter/plugin-scripts to be sourced at the beginning or end (can use dracut-functions) - add interpreter/plugin-scripts to be sourced at the beginning or end (can use dracut-functions)
- provide "installkernel" and "new-kernel-pkg"
- add mechanism for module specific command line options - add mechanism for module specific command line options
- pkg-config integration, to make it easy for other packages to use us. - pkg-config integration, to make it easy for other packages to use us.
- add recovery image creator (mkrecovery)
- default module specification could use some work - default module specification could use some work
- udev rule copying, as mentioned above, is a bit too hard-coded - udev rule copying, as mentioned above, is a bit too hard-coded
- dracut-install parse LD_SHOW_AUXV="" AT_PLATFORM for lib install
CODE TODO CODE TODO
- document more functions - document more functions

31
configure vendored
View File

@@ -25,6 +25,7 @@ read_arg() {
# return 1 to indicate they should do it instead. # return 1 to indicate they should do it instead.
return 1 return 1
fi fi
return 0
} }
while (($# > 0)); do while (($# > 0)); do
@@ -36,18 +37,42 @@ while (($# > 0)); do
--sbindir) read_arg sbindir "$@" || shift;; --sbindir) read_arg sbindir "$@" || shift;;
--mandir) read_arg mandir "$@" || shift;; --mandir) read_arg mandir "$@" || shift;;
--disable-documentation) enable_documentation=no;; --disable-documentation) enable_documentation=no;;
--program-prefix) read_arg programprefix "$@" || shift;;
--exec-prefix) read_arg execprefix "$@" || shift;;
--bindir) read_arg bindir "$@" || shift;;
--includedir) read_arg includedir "$@" || shift;;
--libexecdir) read_arg libexecdir "$@" || shift;;
--localstatedir) read_arg localstatedir "$@" || shift;;
--sharedstatedir) read_arg sharedstatedir "$@" || shift;;
--infodir) read_arg infodir "$@" || shift;;
--systemdsystemunitdir) read_arg systemdsystemunitdir "$@" || shift;;
--bashcompletiondir) read_arg bashcompletiondir "$@" || shift;;
*) echo "Ignoring unknown option '$1'";; *) echo "Ignoring unknown option '$1'";;
esac esac
shift shift
done done
cat > Makefile.inc.tmp <<EOF cat > Makefile.inc.$$ <<EOF
prefix ?= ${prefix} prefix ?= ${prefix}
libdir ?= ${libdir:-${prefix}/lib} libdir ?= ${libdir:-${prefix}/lib}
datadir ?= ${datadir:-${prefix}/share} datadir ?= ${datadir:-${prefix}/share}
sysconfdir ?= ${sysconfdir:-${prefix}/etc} sysconfdir ?= ${sysconfdir:-${prefix}/etc}
sbindir ?= ${sbindir:-${prefix}/sbin} sbindir ?= ${sbindir:-${prefix}/sbin}
mandir ?= ${mandir:-${prefix}/share/man} mandir ?= ${mandir:-${prefix}/share/man}
enable_documentation ?= ${enable_documentation} enable_documentation ?= ${enable_documentation:-yes}
bindir ?= ${bindir:-${prefix}/bin}
EOF EOF
mv Makefile.inc.tmp Makefile.inc
{
[[ $programprefix ]] && echo "programprefix ?= ${programprefix}"
[[ $execprefix ]] && echo "execprefix ?= ${execprefix}"
[[ $includedir ]] && echo "includedir ?= ${includedir}"
[[ $libexecdir ]] && echo "libexecdir ?= ${libexecdir}"
[[ $localstatedir ]] && echo "localstatedir ?= ${localstatedir}"
[[ $sharedstatedir ]] && echo "sharedstatedir ?= ${sharedstatedir}"
[[ $infodir ]] && echo "infodir ?= ${infodir}"
[[ $systemdsystemunitdir ]] && echo "systemdsystemunitdir ?= ${systemdsystemunitdir}"
[[ $bashcompletiondir ]] && echo "bashcompletiondir ?= ${bashcompletiondir}"
} >> Makefile.inc.$$
mv Makefile.inc.$$ Makefile.inc

76
dracut-bash-completion.sh Normal file
View File

@@ -0,0 +1,76 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
#
# Copyright 2013 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
__contains_word () {
local word=$1; shift
for w in $*; do [[ $w = $word ]] && return 0; done
return 1
}
_dracut() {
local field_vals= cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
local -A OPTS=(
[STANDALONE]='-f -v -q -l -H -h -M -N
--ro-mnt --force --kernel-only --no-kernel --strip --nostrip
--hardlink --nohardlink --noprefix --mdadmconf --nomdadmconf
--lvmconf --nolvmconf --debug --profile --verbose --quiet
--local --hostonly --no-hostonly --fstab --help --bzip2 --lzma
--xz --no-compress --gzip --list-modules --show-modules --keep
--printsize --regenerate-all --noimageifnotneeded --early-microcode
--no-early-microcode'
[ARG]='-a -m -o -d -I -k -c -L --kver --add --force-add --add-drivers
--omit-drivers --modules --omit --drivers --filesystems --install
--fwdir --libdirs --fscks --add-fstab --mount --device --nofscks
--kmoddir --conf --confdir --tmpdir --stdlog --compress --prefix
--kernel-cmdline --sshkey'
)
if __contains_word "$prev" ${OPTS[ARG]}; then
case $prev in
--kmoddir|-k|--fwdir|--confdir|--tmpdir)
comps=$(compgen -d -- "$cur")
compopt -o filenames
;;
-c|--conf|--sshkey|--add-fstab|--add-device|-I|--install)
comps=$(compgen -f -- "$cur")
compopt -o filenames
;;
-a|-m|-o|--add|--modules|--omit)
comps=$(dracut --list-modules 2>/dev/null)
;;
--kver)
comps=$(cd /lib/modules; echo [0-9]*)
;;
*)
return 0
;;
esac
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
return 0
fi
if [[ $cur = -* ]]; then
COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
return 0
fi
}
complete -F _dracut dracut

View File

@@ -118,11 +118,11 @@ fi
images+=($@) images+=($@)
dinfo "Using base image $baseimage" dinfo "Using base image $baseimage"
cat "$baseimage" > "$outfile" cat -- "$baseimage" > "$outfile"
for i in "${images[@]}"; do for i in "${images[@]}"; do
dinfo "Appending $i" dinfo "Appending $i"
cat "$i" >> "$outfile" cat -- "$i" >> "$outfile"
done done
dinfo "Created $outfile" dinfo "Created $outfile"

View File

@@ -39,13 +39,13 @@ strstr() { [[ $1 = *$2* ]]; }
# search in the usual places to find the binary. # search in the usual places to find the binary.
find_binary() { find_binary() {
if [[ -z ${1##/*} ]]; then if [[ -z ${1##/*} ]]; then
if [[ -x $1 ]] || { strstr "$1" ".so" && ldd $1 &>/dev/null; }; then if [[ -x $1 ]] || { [[ "$1" == *.so* ]] && ldd "$1" &>/dev/null; }; then
echo $1 printf "%s\n" "$1"
return 0 return 0
fi fi
fi fi
type -P ${1##*/} type -P "${1##*/}"
} }
if ! [[ $dracutbasedir ]]; then if ! [[ $dracutbasedir ]]; then
@@ -65,7 +65,7 @@ fi
# Detect lib paths # Detect lib paths
if ! [[ $libdirs ]] ; then if ! [[ $libdirs ]] ; then
if strstr "$(ldd /bin/sh)" "/lib64/" &>/dev/null \ if [[ "$(ldd /bin/sh)" == */lib64/* ]] &>/dev/null \
&& [[ -d /lib64 ]]; then && [[ -d /lib64 ]]; then
libdirs+=" /lib64" libdirs+=" /lib64"
[[ -d /usr/lib64 ]] && libdirs+=" /usr/lib64" [[ -d /usr/lib64 ]] && libdirs+=" /usr/lib64"
@@ -83,7 +83,7 @@ fi
srcmods="/lib/modules/$kernel/" srcmods="/lib/modules/$kernel/"
[[ $drivers_dir ]] && { [[ $drivers_dir ]] && {
if vercmp $(modprobe --version | cut -d' ' -f3) lt 3.7; then if vercmp "$(modprobe --version | cut -d' ' -f3)" lt 3.7; then
dfatal 'To use --kmoddir option module-init-tools >= 3.7 is required.' dfatal 'To use --kmoddir option module-init-tools >= 3.7 is required.'
exit 1 exit 1
fi fi
@@ -106,20 +106,30 @@ fi
hookdirs="cmdline pre-udev pre-trigger netroot " hookdirs="cmdline pre-udev pre-trigger netroot "
hookdirs+="initqueue initqueue/settled initqueue/online initqueue/finished initqueue/timeout " hookdirs+="initqueue initqueue/settled initqueue/online initqueue/finished initqueue/timeout "
hookdirs+="pre-mount pre-pivot cleanup mount " hookdirs+="pre-mount pre-pivot cleanup mount "
hookdirs+="emergency shutdown-emergency shutdown " hookdirs+="emergency shutdown-emergency pre-shutdown shutdown "
export hookdirs export hookdirs
} }
dracut_need_initqueue() {
>"$initdir/lib/dracut/need-initqueue"
}
dracut_module_included() {
[[ "$mods_to_load $modules_loaded" == *$@* ]]
}
# Create all subdirectories for given path without creating the last element. # Create all subdirectories for given path without creating the last element.
# $1 = path # $1 = path
mksubdirs() { [[ -e ${1%/*} ]] || mkdir -m 0755 -p ${1%/*}; } mksubdirs() {
[[ -e ${1%/*} ]] || mkdir -m 0755 -p -- "${1%/*}"
}
# Version comparision function. Assumes Linux style version scheme. # Version comparision function. Assumes Linux style version scheme.
# $1 = version a # $1 = version a
# $2 = comparision op (gt, ge, eq, le, lt, ne) # $2 = comparision op (gt, ge, eq, le, lt, ne)
# $3 = version b # $3 = version b
vercmp() { vercmp() {
local _n1=(${1//./ }) _op=$2 _n2=(${3//./ }) _i _res local _n1=${1//./ } _op=$2 _n2=${3//./ } _i _res
for ((_i=0; ; _i++)) for ((_i=0; ; _i++))
do do
@@ -144,7 +154,7 @@ vercmp() {
# is_func <command> # is_func <command>
# Check whether $1 is a function. # Check whether $1 is a function.
is_func() { is_func() {
[[ $(type -t $1) = "function" ]] [[ "$(type -t "$1")" = "function" ]]
} }
# Function prints global variables in format name=value line by line. # Function prints global variables in format name=value line by line.
@@ -152,10 +162,10 @@ is_func() {
print_vars() { print_vars() {
local _var _value local _var _value
for _var in $@ for _var in "$@"
do do
_value=$(eval echo \$$_var) eval printf -v _value "%s" "\$$_var"
[[ ${_value} ]] && echo "${_var}=\"${_value}\"" [[ ${_value} ]] && printf '%s="%s"\n' "$_var" "$_value"
done done
} }
@@ -196,7 +206,7 @@ convert_abs_rel() {
__abssize=${#__absolute[@]} __abssize=${#__absolute[@]}
__cursize=${#__current[@]} __cursize=${#__current[@]}
while [[ ${__absolute[__level]} == ${__current[__level]} ]] while [[ "${__absolute[__level]}" == "${__current[__level]}" ]]
do do
(( __level++ )) (( __level++ ))
if (( __level > __abssize || __level > __cursize )) if (( __level > __abssize || __level > __cursize ))
@@ -226,7 +236,7 @@ convert_abs_rel() {
echo "$__newpath" echo "$__newpath"
} }
if strstr "$(ln --help)" "--relative"; then if [[ "$(ln --help)" == *--relative* ]]; then
ln_r() { ln_r() {
ln -sfnr "${initdir}/$1" "${initdir}/$2" ln -sfnr "${initdir}/$1" "${initdir}/$2"
} }
@@ -235,7 +245,7 @@ else
local _source=$1 local _source=$1
local _dest=$2 local _dest=$2
[[ -d "${_dest%/*}" ]] && _dest=$(readlink -f "${_dest%/*}")/${_dest##*/} [[ -d "${_dest%/*}" ]] && _dest=$(readlink -f "${_dest%/*}")/${_dest##*/}
ln -sfn $(convert_abs_rel "${_dest}" "${_source}") "${initdir}/${_dest}" ln -sfn -- "$(convert_abs_rel "${_dest}" "${_source}")" "${initdir}/${_dest}"
} }
fi fi
@@ -246,44 +256,54 @@ get_persistent_dev() {
[ -z "$_dev" ] && return [ -z "$_dev" ] && return
for i in /dev/mapper/* /dev/disk/by-uuid/* /dev/disk/by-id/*; do for i in /dev/mapper/* /dev/disk/by-uuid/* /dev/disk/by-id/*; do
[[ $i == /dev/mapper/mpath* ]] && continue
_tmp=$(udevadm info --query=name --name="$i" 2>/dev/null) _tmp=$(udevadm info --query=name --name="$i" 2>/dev/null)
if [ "$_tmp" = "$_dev" ]; then if [ "$_tmp" = "$_dev" ]; then
echo $i printf -- "%s" "$i"
return return
fi fi
done done
} }
# get_fs_env <device> # get_fs_env <device>
# Get and set the ID_FS_TYPE and ID_FS_UUID variable from udev for a device. # Get and set the ID_FS_TYPE variable from udev for a device.
# Example: # Example:
# $ get_fs_env /dev/sda2; echo $ID_FS_TYPE; echo $ID_FS_UUID # $ get_fs_env /dev/sda2; echo $ID_FS_TYPE
# ext4 # ext4
# 551a39aa-4ae9-4e70-a262-ef665cadb574
get_fs_env() { get_fs_env() {
local evalstr local evalstr
local found local found
[[ $1 ]] || return [[ $1 ]] || return
unset ID_FS_TYPE unset ID_FS_TYPE
unset ID_FS_UUID if ID_FS_TYPE=$(udevadm info --query=env --name="$1" \
if evalstr=$(udevadm info --query=env --name=$1 \
| { while read line; do | { while read line; do
strstr "$line" "DEVPATH" && found=1; [[ "$line" == DEVPATH\=* ]] && found=1;
strstr "$line" "ID_FS_TYPE=" && { echo $line; exit 0;} if [[ "$line" == ID_FS_TYPE\=* ]]; then
printf "%s" "${line#ID_FS_TYPE=}";
exit 0;
fi
done; [[ $found ]] && exit 0; exit 1; }) ; then done; [[ $found ]] && exit 0; exit 1; }) ; then
eval $evalstr if [[ $ID_FS_TYPE ]]; then
[[ $ID_FS_TYPE ]] && return 0 printf "%s" "$ID_FS_TYPE"
return 0
fi
return 1 return 1
fi fi
# Fallback, if we don't have udev information # Fallback, if we don't have udev information
if find_binary blkid >/dev/null; then if find_binary blkid >/dev/null; then
eval $(blkid -o udev $1 \ ID_FS_TYPE=$(blkid -u filesystem -o export -- "$1" \
| while read line; do | while read line; do
strstr "$line" "ID_FS_TYPE=" && echo $line; if [[ "$line" == TYPE\=* ]]; then
printf "%s" "${line#TYPE=}";
exit 0;
fi
done) done)
[[ $ID_FS_TYPE ]] && return 0 if [[ $ID_FS_TYPE ]]; then
printf "%s" "$ID_FS_TYPE"
return 0
fi
fi fi
return 1 return 1
} }
@@ -294,10 +314,9 @@ get_fs_env() {
# $ get_maj_min /dev/sda2 # $ get_maj_min /dev/sda2
# 8:2 # 8:2
get_maj_min() { get_maj_min() {
local _dev local _maj _min
_dev=$(stat -L -c '$((0x%t)):$((0x%T))' "$1" 2>/dev/null) read _maj _min < <(stat -L -c '%t %T' "$1" 2>/dev/null)
_dev=$(eval "echo $_dev") printf "%s" "$((0x$_maj)):$((0x$_min))"
echo $_dev
} }
# find_block_device <mountpoint> # find_block_device <mountpoint>
@@ -311,63 +330,49 @@ get_maj_min() {
# $ find_block_device /usr # $ find_block_device /usr
# 8:4 # 8:4
find_block_device() { find_block_device() {
local _x _mpt _majmin _dev _fs _maj _min local _majmin _dev _majmin _find_mpt
_find_mpt="$1"
if [[ $use_fstab != yes ]]; then if [[ $use_fstab != yes ]]; then
while read _x _x _majmin _x _mpt _x _x _fs _dev _x; do [[ -d $_find_mpt/. ]]
[[ $_mpt = $1 ]] || continue while read _majmin _dev; do
[[ $_fs = nfs ]] && { echo $_dev; return 0;} if [[ -b $_dev ]]; then
[[ $_fs = nfs3 ]] && { echo $_dev; return 0;} if ! [[ $_majmin ]] || [[ $_majmin == 0:* ]]; then
[[ $_fs = nfs4 ]] && { echo $_dev; return 0;} read _majmin < <(get_maj_min $_dev)
[[ $_fs = btrfs ]] && { fi
get_maj_min $_dev if [[ $_majmin ]]; then
return 0; echo $_majmin
} else
if [[ ${_majmin#0:} = $_majmin ]]; then echo $_dev
echo $_majmin fi
return 0 # we have a winner! return 0
fi fi
done < /proc/self/mountinfo if [[ $_dev = *:* ]]; then
echo $_dev
return 0
fi
done < <(findmnt -e -v -n -o 'MAJ:MIN,SOURCE' --target "$_find_mpt")
fi fi
# fall back to /etc/fstab # fall back to /etc/fstab
while read _dev _mpt _fs _x; do
[ "${_dev%%#*}" != "$_dev" ] && continue
if [[ $_mpt = $1 ]]; then while read _majmin _dev; do
[[ $_fs = nfs ]] && { echo $_dev; return 0;} if ! [[ $_dev ]]; then
[[ $_fs = nfs3 ]] && { echo $_dev; return 0;} _dev="$_majmin"
[[ $_fs = nfs4 ]] && { echo $_dev; return 0;} unset _majmin
[[ $_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.
get_maj_min "$_dev" && return 0
fi fi
done < /etc/fstab if [[ -b $_dev ]]; then
[[ $_majmin ]] || read _majmin < <(get_maj_min $_dev)
return 1 if [[ $_majmin ]]; then
} echo $_majmin
else
# find_dev_fstype <device> echo $_dev
# Echo the filesystem type for a given device. fi
# /proc/self/mountinfo is taken as the primary source of information return 0
# and /etc/fstab is used as a fallback. fi
# No newline is appended! if [[ $_dev = *:* ]]; then
# Example: echo $_dev
# $ find_dev_fstype /dev/sda2;echo return 0
# ext4 fi
find_dev_fstype() { done < <(findmnt -e --fstab -v -n -o 'MAJ:MIN,SOURCE' --target "$_find_mpt")
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 return 1
} }
@@ -381,48 +386,85 @@ find_dev_fstype() {
# $ find_mp_fstype /;echo # $ find_mp_fstype /;echo
# ext4 # ext4
find_mp_fstype() { find_mp_fstype() {
local _x _mpt _majmin _dev _fs _maj _min local _fs
while read _x _x _majmin _x _mpt _x _x _fs _dev _x; do
[[ $_mpt = $1 ]] || continue
echo -n $_fs;
return 0;
done < /proc/self/mountinfo
# fall back to /etc/fstab if [[ $use_fstab != yes ]]; then
while read _dev _mpt _fs _x; do while read _fs; do
[[ $_mpt = $1 ]] || continue [[ $_fs ]] || continue
echo -n $_fs; [[ $_fs = "autofs" ]] && continue
return 0; echo -n $_fs
done < /etc/fstab return 0
done < <(findmnt -e -v -n -o 'FSTYPE' --target "$1")
fi
while read _fs; do
[[ $_fs ]] || continue
[[ $_fs = "autofs" ]] && continue
echo -n $_fs
return 0
done < <(findmnt --fstab -e -v -n -o 'FSTYPE' --target "$1")
return 1 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 _find_dev _fs
_find_dev="$1"
[[ "$_find_dev" = /dev* ]] || _find_dev="/dev/block/$_find_dev"
if [[ $use_fstab != yes ]]; then
while read _fs; do
[[ $_fs ]] || continue
[[ $_fs = "autofs" ]] && continue
echo -n $_fs
return 0
done < <(findmnt -e -v -n -o 'FSTYPE' --source "$_find_dev")
fi
while read _fs; do
[[ $_fs ]] || continue
[[ $_fs = "autofs" ]] && continue
echo -n $_fs
return 0
done < <(findmnt --fstab -e -v -n -o 'FSTYPE' --source "$_find_dev")
return 1
}
# finds the major:minor of the block device backing the root filesystem. # finds the major:minor of the block device backing the root filesystem.
find_root_block_device() { find_block_device /; } find_root_block_device() { find_block_device /; }
# for_each_host_dev_fs <func> # for_each_host_dev_fs <func>
# Execute "<func> <dev> <filesystem>" for every "<dev>|<fs>" pair found # Execute "<func> <dev> <filesystem>" for every "<dev> <fs>" pair found
# in ${host_fs_types[@]} # in ${host_fs_types[@]}
for_each_host_dev_fs() for_each_host_dev_fs()
{ {
local _func="$1" local _func="$1"
local _dev local _dev
local _fs
local _ret=1 local _ret=1
for f in ${host_fs_types[@]}; do
OLDIFS="$IFS" [[ "${!host_fs_types[@]}" ]] || return 0
IFS="|"
set -- $f for _dev in "${!host_fs_types[@]}"; do
IFS="$OLDIFS" $_func "$_dev" "${host_fs_types[$_dev]}" && _ret=0
_dev="$1"
[[ -b "$_dev" ]] || continue
_fs="$2"
$_func $_dev $_fs && _ret=0
done done
return $_ret return $_ret
} }
host_fs_all()
{
echo "${host_fs_types[@]}"
}
# Walk all the slave relationships for a given block device. # Walk all the slave relationships for a given block device.
# Stop when our helper function returns success # Stop when our helper function returns success
# $1 = function to call on every found block device # $1 = function to call on every found block device
@@ -468,6 +510,9 @@ for_each_host_dev_and_slaves_all()
local _func="$1" local _func="$1"
local _dev local _dev
local _ret=1 local _ret=1
[[ "${host_devs[@]}" ]] || return 0
for _dev in ${host_devs[@]}; do for _dev in ${host_devs[@]}; do
[[ -b "$_dev" ]] || continue [[ -b "$_dev" ]] || continue
if check_block_and_slaves_all $_func $(get_maj_min $_dev); then if check_block_and_slaves_all $_func $(get_maj_min $_dev); then
@@ -481,6 +526,9 @@ for_each_host_dev_and_slaves()
{ {
local _func="$1" local _func="$1"
local _dev local _dev
[[ "${host_devs[@]}" ]] || return 0
for _dev in ${host_devs[@]}; do for _dev in ${host_devs[@]}; do
[[ -b "$_dev" ]] || continue [[ -b "$_dev" ]] || continue
check_block_and_slaves $_func $(get_maj_min $_dev) && return 0 check_block_and_slaves $_func $(get_maj_min $_dev) && return 0
@@ -623,7 +671,7 @@ else
# We never overwrite the target if it exists. # We never overwrite the target if it exists.
inst_simple() { inst_simple() {
[[ -f "$1" ]] || return 1 [[ -f "$1" ]] || return 1
strstr "$1" "/" || return 1 [[ "$1" == */* ]] || return 1
local _src=$1 _target="${2:-$1}" local _src=$1 _target="${2:-$1}"
[[ -L $_src ]] && { inst_symlink $_src $_target; return $?; } [[ -L $_src ]] && { inst_symlink $_src $_target; return $?; }
@@ -652,7 +700,7 @@ else
# same as above, but specialized for symlinks # same as above, but specialized for symlinks
inst_symlink() { inst_symlink() {
local _src=$1 _target=${2:-$1} _realsrc local _src=$1 _target=${2:-$1} _realsrc
strstr "$1" "/" || return 1 [[ "$1" == */* ]] || return 1
[[ -L $1 ]] || return 1 [[ -L $1 ]] || return 1
[[ -L $initdir/$_target ]] && return 0 [[ -L $initdir/$_target ]] && return 0
_realsrc=$(readlink -f "$_src") _realsrc=$(readlink -f "$_src")
@@ -673,7 +721,7 @@ else
# is referenced. # is referenced.
inst_library() { inst_library() {
local _src="$1" _dest=${2:-$1} _lib _reallib _symlink local _src="$1" _dest=${2:-$1} _lib _reallib _symlink
strstr "$1" "/" || return 1 [[ "$1" == */* ]] || return 1
[[ -e $initdir/$_dest ]] && return 0 [[ -e $initdir/$_dest ]] && return 0
if [[ -L $_src ]]; then if [[ -L $_src ]]; then
if [[ $DRACUT_FIPS_MODE ]]; then if [[ $DRACUT_FIPS_MODE ]]; then
@@ -725,7 +773,7 @@ else
continue continue
fi fi
if [[ $_line =~ not\ found ]]; then if [[ $_line == *not\ found* ]]; then
dfatal "Missing a shared library required by $_bin." dfatal "Missing a shared library required by $_bin."
dfatal "Run \"ldd $_bin\" to find out what it is." dfatal "Run \"ldd $_bin\" to find out what it is."
dfatal "$_line" dfatal "$_line"
@@ -811,7 +859,7 @@ rev_lib_symlinks() {
local fn="$1" orig="$(readlink -f "$1")" links='' local fn="$1" orig="$(readlink -f "$1")" links=''
[[ ${fn} =~ .*\.so\..* ]] || return 1 [[ ${fn} == *.so.* ]] || return 1
until [[ ${fn##*.} == so ]]; do until [[ ${fn##*.} == so ]]; do
fn="${fn%.*}" fn="${fn%.*}"
@@ -830,7 +878,7 @@ inst_rule_programs() {
_bin="" _bin=""
if [ -x ${udevdir}/$_prog ]; then if [ -x ${udevdir}/$_prog ]; then
_bin=${udevdir}/$_prog _bin=${udevdir}/$_prog
elif [[ "${_prog/\$\{/}" != "$_prog" ]]; then elif [[ "${_prog/\$env\{/}" == "$_prog" ]]; then
_bin=$(find_binary "$_prog") || { _bin=$(find_binary "$_prog") || {
dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found" dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found"
continue; continue;
@@ -845,7 +893,7 @@ inst_rule_programs() {
_bin="" _bin=""
if [ -x ${udevdir}/$_prog ]; then if [ -x ${udevdir}/$_prog ]; then
_bin=${udevdir}/$_prog _bin=${udevdir}/$_prog
elif [[ "${_prog/\$\{/}" != "$_prog" ]]; then elif [[ "${_prog/\$env\{/}" == "$_prog" ]] && [[ "${_prog}" != "/sbin/initqueue" ]]; then
_bin=$(find_binary "$_prog") || { _bin=$(find_binary "$_prog") || {
dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found" dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found"
continue; continue;
@@ -860,7 +908,7 @@ inst_rule_programs() {
_bin="" _bin=""
if [ -x ${udevdir}/$_prog ]; then if [ -x ${udevdir}/$_prog ]; then
_bin=${udevdir}/$_prog _bin=${udevdir}/$_prog
elif [[ "${_prog/\$\{/}" != "$_prog" ]]; then elif [[ "${_prog/\$env\{/}" == "$_prog" ]]; then
_bin=$(find_binary "$_prog") || { _bin=$(find_binary "$_prog") || {
dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found" dinfo "Skipping program $_prog using in udev rule ${1##*/} as it cannot be found"
continue; continue;
@@ -892,6 +940,12 @@ inst_rule_group_owner() {
fi fi
} }
inst_rule_initqueue() {
if grep -q -F initqueue "$1"; then
dracut_need_initqueue
fi
}
# udev rules always get installed in the same place, so # udev rules always get installed in the same place, so
# create a function to install them to make life simpler. # create a function to install them to make life simpler.
inst_rules() { inst_rules() {
@@ -900,12 +954,13 @@ inst_rules() {
inst_dir "${udevdir}/rules.d" inst_dir "${udevdir}/rules.d"
inst_dir "$_target" inst_dir "$_target"
for _rule in "$@"; do for _rule in "$@"; do
if [ "${rule#/}" = "$rule" ]; then if [ "${_rule#/}" = "$_rule" ]; then
for r in ${udevdir}/rules.d /etc/udev/rules.d; do for r in ${udevdir}/rules.d /etc/udev/rules.d; do
if [[ -f $r/$_rule ]]; then if [[ -f $r/$_rule ]]; then
_found="$r/$_rule" _found="$r/$_rule"
inst_rule_programs "$_found" inst_rule_programs "$_found"
inst_rule_group_owner "$_found" inst_rule_group_owner "$_found"
inst_rule_initqueue "$_found"
inst_simple "$_found" inst_simple "$_found"
fi fi
done done
@@ -915,6 +970,7 @@ inst_rules() {
_found="${r}$_rule" _found="${r}$_rule"
inst_rule_programs "$_found" inst_rule_programs "$_found"
inst_rule_group_owner "$_found" inst_rule_group_owner "$_found"
inst_rule_initqueue "$_found"
inst_simple "$_found" "$_target/${_found##*/}" inst_simple "$_found" "$_target/${_found##*/}"
fi fi
done done
@@ -922,6 +978,33 @@ inst_rules() {
done done
} }
prepare_udev_rules() {
[ -z "$UDEVVERSION" ] && export UDEVVERSION=$(udevadm --version)
for f in "$@"; do
f="${initdir}/etc/udev/rules.d/$f"
[ -e "$f" ] || continue
while read line; do
if [ "${line%%IMPORT PATH_ID}" != "$line" ]; then
if [ $UDEVVERSION -ge 174 ]; then
printf '%sIMPORT{builtin}="path_id"\n' "${line%%IMPORT PATH_ID}"
else
printf '%sIMPORT{program}="path_id %%p"\n' "${line%%IMPORT PATH_ID}"
fi
elif [ "${line%%IMPORT BLKID}" != "$line" ]; then
if [ $UDEVVERSION -ge 176 ]; then
printf '%sIMPORT{builtin}="blkid"\n' "${line%%IMPORT BLKID}"
else
printf '%sIMPORT{program}="/sbin/blkid -o udev -p $tempnode"\n' "${line%%IMPORT BLKID}"
fi
else
echo "$line"
fi
done < "${f}" > "${f}.new"
mv "${f}.new" "$f"
done
}
# install function specialized for hooks # install function specialized for hooks
# $1 = type of hook, $2 = hook priority (lower runs first), $3 = hook # $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. # All hooks should be POSIX/SuS compliant, they will be sourced by init.
@@ -930,7 +1013,7 @@ inst_hook() {
dfatal "Cannot install a hook ($3) that does not exist." dfatal "Cannot install a hook ($3) that does not exist."
dfatal "Aborting initrd creation." dfatal "Aborting initrd creation."
exit 1 exit 1
elif ! strstr "$hookdirs" "$1"; then elif ! [[ "$hookdirs" == *$1* ]]; then
dfatal "No such hook type $1. Aborting initrd creation." dfatal "No such hook type $1. Aborting initrd creation."
exit 1 exit 1
fi fi
@@ -1048,6 +1131,7 @@ module_check() {
_ret=$? _ret=$?
else else
unset check depends install installkernel unset check depends install installkernel
check() { true; }
. $_moddir/module-setup.sh . $_moddir/module-setup.sh
is_func check || return 0 is_func check || return 0
[ $_forced -ne 0 ] && unset hostonly [ $_forced -ne 0 ] && unset hostonly
@@ -1075,8 +1159,8 @@ module_check_mount() {
_ret=$? _ret=$?
else else
unset check depends install installkernel unset check depends install installkernel
check() { false; }
. $_moddir/module-setup.sh . $_moddir/module-setup.sh
is_func check || return 1
check 0 check 0
_ret=$? _ret=$?
unset check depends install installkernel unset check depends install installkernel
@@ -1099,8 +1183,8 @@ module_depends() {
return $? return $?
else else
unset check depends install installkernel unset check depends install installkernel
depends() { true; }
. $_moddir/module-setup.sh . $_moddir/module-setup.sh
is_func depends || return 0
depends depends
_ret=$? _ret=$?
unset check depends install installkernel unset check depends install installkernel
@@ -1120,8 +1204,8 @@ module_install() {
return $? return $?
else else
unset check depends install installkernel unset check depends install installkernel
install() { true; }
. $_moddir/module-setup.sh . $_moddir/module-setup.sh
is_func install || return 0
install install
_ret=$? _ret=$?
unset check depends install installkernel unset check depends install installkernel
@@ -1141,8 +1225,8 @@ module_installkernel() {
return $? return $?
else else
unset check depends install installkernel unset check depends install installkernel
. $_moddir/module-setup.sh installkernel() { true; }
is_func installkernel || return 0 . $_moddir/module-setup.sh
installkernel installkernel
_ret=$? _ret=$?
unset check depends install installkernel unset check depends install installkernel
@@ -1162,20 +1246,20 @@ check_mount() {
[ "${#host_fs_types[*]}" -le 0 ] && return 1 [ "${#host_fs_types[*]}" -le 0 ] && return 1
# If we are already scheduled to be loaded, no need to check again. # If we are already scheduled to be loaded, no need to check again.
strstr " $mods_to_load " " $_mod " && return 0 [[ " $mods_to_load " == *\ $_mod\ * ]] && return 0
strstr " $mods_checked_as_dep " " $_mod " && return 1 [[ " $mods_checked_as_dep " == *\ $_mod\ * ]] && return 1
# This should never happen, but... # This should never happen, but...
[[ -d $_moddir ]] || return 1 [[ -d $_moddir ]] || return 1
[[ $2 ]] || mods_checked_as_dep+=" $_mod " [[ $2 ]] || mods_checked_as_dep+=" $_mod "
if strstr " $omit_dracutmodules " " $_mod "; then if [[ " $omit_dracutmodules " == *\ $_mod\ * ]]; then
dinfo "dracut module '$_mod' will not be installed, because it's in the list to be omitted!" dinfo "dracut module '$_mod' will not be installed, because it's in the list to be omitted!"
return 1 return 1
fi fi
if strstr " $dracutmodules $add_dracutmodules $force_add_dracutmodules" " $_mod "; then if [[ " $dracutmodules $add_dracutmodules $force_add_dracutmodules" == *\ $_mod\ * ]]; then
module_check_mount $_mod; ret=$? module_check_mount $_mod; ret=$?
# explicit module, so also accept ret=255 # explicit module, so also accept ret=255
@@ -1194,9 +1278,9 @@ check_mount() {
for _moddep in $(module_depends $_mod); do for _moddep in $(module_depends $_mod); do
# handle deps as if they were manually added # handle deps as if they were manually added
strstr " $add_dracutmodules " " $_moddep " || \ [[ " $add_dracutmodules " == *\ $_moddep\ * ]] || \
add_dracutmodules+=" $_moddep " add_dracutmodules+=" $_moddep "
strstr " $force_add_dracutmodules " " $_moddep " || \ [[ " $force_add_dracutmodules " == *\ $_moddep\ * ]] || \
force_add_dracutmodules+=" $_moddep " force_add_dracutmodules+=" $_moddep "
# if a module we depend on fail, fail also # if a module we depend on fail, fail also
if ! check_module $_moddep; then if ! check_module $_moddep; then
@@ -1205,7 +1289,7 @@ check_mount() {
fi fi
done done
strstr " $mods_to_load " " $_mod " || \ [[ " $mods_to_load " == *\ $_mod\ * ]] || \
mods_to_load+=" $_mod " mods_to_load+=" $_mod "
return 0 return 0
@@ -1221,21 +1305,21 @@ check_module() {
local _ret local _ret
local _moddep local _moddep
# If we are already scheduled to be loaded, no need to check again. # If we are already scheduled to be loaded, no need to check again.
strstr " $mods_to_load " " $_mod " && return 0 [[ " $mods_to_load " == *\ $_mod\ * ]] && return 0
strstr " $mods_checked_as_dep " " $_mod " && return 1 [[ " $mods_checked_as_dep " == *\ $_mod\ * ]] && return 1
# This should never happen, but... # This should never happen, but...
[[ -d $_moddir ]] || return 1 [[ -d $_moddir ]] || return 1
[[ $2 ]] || mods_checked_as_dep+=" $_mod " [[ $2 ]] || mods_checked_as_dep+=" $_mod "
if strstr " $omit_dracutmodules " " $_mod "; then if [[ " $omit_dracutmodules " == *\ $_mod\ * ]]; then
dinfo "dracut module '$_mod' will not be installed, because it's in the list to be omitted!" dinfo "dracut module '$_mod' will not be installed, because it's in the list to be omitted!"
return 1 return 1
fi fi
if strstr " $dracutmodules $add_dracutmodules $force_add_dracutmodules" " $_mod "; then if [[ " $dracutmodules $add_dracutmodules $force_add_dracutmodules" == *\ $_mod\ * ]]; then
if strstr " $force_add_dracutmodules" " $_mod"; then if [[ " $force_add_dracutmodules " == *\ $_mod\ * ]]; then
module_check $_mod 1; ret=$? module_check $_mod 1; ret=$?
else else
module_check $_mod 0; ret=$? module_check $_mod 0; ret=$?
@@ -1255,9 +1339,9 @@ check_module() {
for _moddep in $(module_depends $_mod); do for _moddep in $(module_depends $_mod); do
# handle deps as if they were manually added # handle deps as if they were manually added
strstr " $add_dracutmodules " " $_moddep " || \ [[ " $add_dracutmodules " == *\ $_moddep\ * ]] || \
add_dracutmodules+=" $_moddep " add_dracutmodules+=" $_moddep "
strstr " $force_add_dracutmodules " " $_moddep " || \ [[ " $force_add_dracutmodules " == *\ $_moddep\ * ]] || \
force_add_dracutmodules+=" $_moddep " force_add_dracutmodules+=" $_moddep "
# if a module we depend on fail, fail also # if a module we depend on fail, fail also
if ! check_module $_moddep; then if ! check_module $_moddep; then
@@ -1266,7 +1350,7 @@ check_module() {
fi fi
done done
strstr " $mods_to_load " " $_mod " || \ [[ " $mods_to_load " == *\ $_mod\ * ]] || \
mods_to_load+=" $_mod " mods_to_load+=" $_mod "
return 0 return 0
@@ -1289,8 +1373,8 @@ for_each_module_dir() {
_modcheck="$add_dracutmodules $force_add_dracutmodules" _modcheck="$add_dracutmodules $force_add_dracutmodules"
[[ $dracutmodules != all ]] && _modcheck="$m $dracutmodules" [[ $dracutmodules != all ]] && _modcheck="$m $dracutmodules"
for _mod in $_modcheck; do for _mod in $_modcheck; do
strstr "$mods_to_load" "$_mod" && continue [[ " $mods_to_load " == *\ $_mod\ * ]] && continue
strstr "$omit_dracutmodules" "$_mod" && continue [[ " $omit_dracutmodules " == *\ $_mod\ * ]] && continue
derror "dracut module '$_mod' cannot be found or installed." derror "dracut module '$_mod' cannot be found or installed."
done done
} }
@@ -1435,18 +1519,20 @@ dracut_kernel_post() {
exit 1 exit 1
fi fi
[[ $DRACUT_KERNEL_LAZY_HASHDIR ]] && rm -fr "$DRACUT_KERNEL_LAZY_HASHDIR" [[ $DRACUT_KERNEL_LAZY_HASHDIR ]] && rm -fr -- "$DRACUT_KERNEL_LAZY_HASHDIR"
} }
module_is_host_only() ( module_is_host_only() { (
local _mod=$1 local _mod=$1
_mod=${_mod##*/} _mod=${_mod##*/}
_mod=${_mod%.ko} _mod=${_mod%.ko}
[[ "$add_drivers" =~ " ${_mod} " ]] && return 0 [[ " $add_drivers " == *\ ${_mod}\ * ]] && return 0
# check if module is loaded # check if module is loaded
[[ -d $(echo /sys/module/${_mod//-/_}|{ read a b; echo $a; }) ]] && return 0 for i in /sys/module/${_mod//-/_}; do
[[ -d $i ]] && return 0
done
# check if module is loadable on the current kernel # check if module is loadable on the current kernel
# this covers the case, where a new module is introduced # this covers the case, where a new module is introduced
@@ -1455,19 +1541,23 @@ module_is_host_only() (
modinfo -F filename "$_mod" &>/dev/null || return 0 modinfo -F filename "$_mod" &>/dev/null || return 0
return 1 return 1
) )
}
find_kernel_modules_by_path () ( find_kernel_modules_by_path () {
local _OLDIFS local _OLDIFS
_OLDIFS=$IFS
IFS=: [[ -f "$srcmods/modules.dep" ]] || return 0
while read a rest; do
[[ $a = kernel*/$1/* ]] || continue _OLDIFS=$IFS
echo $srcmods/$a IFS=:
done < $srcmods/modules.dep while read a rest; do
IFS=$_OLDIFS [[ $a = */$1/* ]] || continue
printf "%s\n" "$srcmods/$a"
done < "$srcmods/modules.dep"
IFS=$_OLDIFS
return 0 return 0
) }
find_kernel_modules () { find_kernel_modules () {
find_kernel_modules_by_path drivers find_kernel_modules_by_path drivers
@@ -1551,7 +1641,7 @@ instmods() {
while read _mod; do while read _mod; do
inst1mod "${_mod%.ko*}" || { inst1mod "${_mod%.ko*}" || {
if [[ "$_check" == "yes" ]]; then if [[ "$_check" == "yes" ]]; then
[[ "$_silent" == "no" ]] && dfatal "Failed to install $_mod" [[ "$_silent" == "no" ]] && dfatal "Failed to install module $_mod"
return 1 return 1
fi fi
} }
@@ -1560,7 +1650,7 @@ instmods() {
while (($# > 0)); do # filenames as arguments while (($# > 0)); do # filenames as arguments
inst1mod ${1%.ko*} || { inst1mod ${1%.ko*} || {
if [[ "$_check" == "yes" ]]; then if [[ "$_check" == "yes" ]]; then
[[ "$_silent" == "no" ]] && dfatal "Failed to install $1" [[ "$_silent" == "no" ]] && dfatal "Failed to install module $1"
return 1 return 1
fi fi
} }
@@ -1577,3 +1667,36 @@ instmods() {
_ret=$? _ret=$?
return $_ret return $_ret
} }
# get_cpu_vendor
# Only two values are returned: AMD or Intel
get_cpu_vendor ()
{
if grep -qE AMD /proc/cpuinfo; then
printf "AMD"
fi
if grep -qE Intel /proc/cpuinfo; then
printf "Intel"
fi
}
# get_host_ucode
# Get the hosts' ucode file based on the /proc/cpuinfo
get_ucode_file ()
{
local family=`grep -E "cpu family" /proc/cpuinfo | head -1 | sed s/.*:\ //`
local model=`grep -E "model" /proc/cpuinfo |grep -v name | head -1 | sed s/.*:\ //`
local stepping=`grep -E "stepping" /proc/cpuinfo | head -1 | sed s/.*:\ //`
if [[ "$(get_cpu_vendor)" == "AMD" ]]; then
# If family greater or equal than 0x15
if [[ $family -ge 21 ]]; then
printf "microcode_amd_fam15h.bin"
else
printf "microcode_amd.bin"
fi
fi
if [[ "$(get_cpu_vendor)" == "Intel" ]]; then
# The /proc/cpuinfo are in decimal.
printf "%02x-%02x-%02x" ${family} ${model} ${stepping}
fi
}

View File

@@ -1,18 +1,29 @@
#!/bin/sh #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh # ex: ts=8 sw=4 sts=4 et filetype=sh
set -e set -e
KERNEL_VERSION="$(uname -r)"
[[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
if [[ $MACHINE_ID ]] && [[ -d /boot/${MACHINE_ID} || -L /boot/${MACHINE_ID} ]] ; then
IMG="/boot/${MACHINE_ID}/${KERNEL_VERSION}/initrd"
fi
[[ -f $IMG ]] || IMG="/boot/initramfs-${KERNEL_VERSION}.img"
cd /run/initramfs cd /run/initramfs
IMG="/boot/initramfs-$(uname -r).img"
[ -f .need_shutdown -a -f "$IMG" ] || exit 1 [ -f .need_shutdown -a -f "$IMG" ] || exit 1
if zcat "$IMG" | cpio -id >/dev/null 2>&1; then if zcat "$IMG" | cpio -id --quiet >/dev/null; then
rm .need_shutdown rm -f -- .need_shutdown
elif xzcat "$IMG" | cpio -id >/dev/null 2>&1; then elif xzcat "$IMG" | cpio -id --quiet >/dev/null; then
rm .need_shutdown rm -f -- .need_shutdown
else else
# something failed, so we clean up # something failed, so we clean up
rm -f /run/initramfs/shutdown echo "Unpacking of $IMG to /run/initramfs failed" >&2
rm -f -- /run/initramfs/shutdown
exit 1 exit 1
fi fi

View File

@@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 et filetype=sh # ex: ts=8 sw=4 et filetype=sh
# #

View File

@@ -30,6 +30,13 @@ early userspace.
For a complete list of kernel command line options see *dracut.cmdline*(7). For a complete list of kernel command line options see *dracut.cmdline*(7).
If you are dropped to an emergency shell, while booting your initramfs,
the file _/run/initramfs/rdsosreport.txt_ is created, which can be safed to a
(to be mounted by hand) partition (usually /boot) or a USB stick.
Additional debugging info can be produced by adding **rd.debug** to the kernel command line.
_/run/initramfs/rdsosreport.txt_ contains all logs and the output of some tools.
It should be attached to any report about dracut problems.
EXAMPLE EXAMPLE
------- -------
@@ -68,12 +75,12 @@ version is:
---- ----
If you want to create lighter, smaller initramfs images, you may want to specify If you want to create lighter, smaller initramfs images, you may want to specify
the --host-only or -H option. Using this option, the resulting image will the --hostonly or -H option. Using this option, the resulting image will
contain only those dracut modules, kernel modules and filesystems, which are contain only those dracut modules, kernel modules and filesystems, which are
needed to boot this specific machine. This has the drawback, that you can't put needed to boot this specific machine. This has the drawback, that you can't put
the disk on another controller or machine, and that you can't switch to another the disk on another controller or machine, and that you can't switch to another
root filesystem, without recreating the initramfs image. The usage of the root filesystem, without recreating the initramfs image. The usage of the
--host-only option is only for experts and you will have to keep the broken --hostonly option is only for experts and you will have to keep the broken
pieces. At least keep a copy of a general purpose image (and corresponding pieces. At least keep a copy of a general purpose image (and corresponding
kernel) as a fallback to rescue your system. kernel) as a fallback to rescue your system.
@@ -325,8 +332,11 @@ provide a valid _/etc/fstab_.
Mount _<device>_ on _<mountpoint>_ with _<filesystem type>_ and _<filesystem Mount _<device>_ on _<mountpoint>_ with _<filesystem type>_ and _<filesystem
options>_ in the initramfs options>_ in the initramfs
**--device** _<device>_ :: **--add-device** _<device>_ ::
Bring up _<device>_ in initramfs, _<device>_ should be the device name Bring up _<device>_ in initramfs, _<device>_ should be the device name.
This can be useful in hostonly mode for resume support when your swap is on
LVM or an encrypted partition.
[NB --device can be used for compatibility with earlier releases]
**-i, --include** _<SOURCE>_ _<TARGET>_:: **-i, --include** _<SOURCE>_ _<TARGET>_::
include the files in the SOURCE directory into the include the files in the SOURCE directory into the
@@ -366,7 +376,7 @@ will not be able to boot. Equivalent to "--compress=bzip2"
[WARNING] [WARNING]
==== ====
Make sure your kernel has lzma decompression support compiled in, otherwise you Make sure your kernel has lzma decompression support compiled in, otherwise you
will not be able to boot. Equivalent to "--compress=lzma -9" will not be able to boot. Equivalent to "lzma --compress=lzma -9"
==== ====
**--xz**:: **--xz**::
@@ -375,8 +385,7 @@ will not be able to boot. Equivalent to "--compress=lzma -9"
[WARNING] [WARNING]
==== ====
Make sure your kernel has xz decompression support compiled in, otherwise you Make sure your kernel has xz decompression support compiled in, otherwise you
will not be able to boot. Equivalent to "--compress=xz --check=crc32 will not be able to boot. Equivalent to "lzma --compress=xz --check=crc32 --lzma2=dict=1MiB"
--lzma2=dict=1MiB"
==== ====
**--compress** _<compressor>_:: **--compress** _<compressor>_::
@@ -399,6 +408,31 @@ will not be able to boot. Equivalent to "--compress=xz --check=crc32
**--keep**:: **--keep**::
Keep the initramfs temporary directory for debugging purposes. Keep the initramfs temporary directory for debugging purposes.
**--printsize**::
Print out the module install size
**--profile**:
Output profile information of the build process
**--ro-mnt**:
Mount / and /usr read-only by default.
**-L, --stdlog** _<level>_::
[0-6] Specify logging level (to standard error)
----
0 - suppress any messages
1 - only fatal errors
2 - all errors
3 - warnings
4 - info
5 - debug info (here starts lots of output)
6 - trace info (and even more)
----
**--regenerate-all**::
Regenerate all initramfs images at the default location with the kernel versions found on the system.
Additional parameters are passed through.
FILES FILES
----- -----
_/var/log/dracut.log_:: _/var/log/dracut.log_::
@@ -414,6 +448,9 @@ _/etc/dracut.conf_::
_/etc/dracut.conf.d/*.conf_:: _/etc/dracut.conf.d/*.conf_::
see dracut.conf5 see dracut.conf5
_/usr/lib/dracut/dracut.conf.d/*.conf_::
see dracut.conf5
Configuration in the initramfs Configuration in the initramfs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_/etc/conf.d/_:: _/etc/conf.d/_::

View File

@@ -79,7 +79,7 @@ udev pulls in modules matching the computer's detected hardware.
initialized and a user-space helper started to paint animations onto the display initialized and a user-space helper started to paint animations onto the display
in lockstep with the boot process. in lockstep with the boot process.
* If the root file system is on NFS, dracut does then: * If the root file system is on NFS, dracut does then:
** Bring up the primary network interface. ** Bring up the primary network interface.
** Invoke a DHCP client, with which it can obtain a DHCP lease. ** Invoke a DHCP client, with which it can obtain a DHCP lease.
** Extract the name of the NFS share and the address of the NFS server from the ** Extract the name of the NFS share and the address of the NFS server from the
@@ -120,6 +120,29 @@ final cleanup tasks. On an initramfs, the initial root file system cannot be
rotated away. Instead, it is simply emptied and the final root file system rotated away. Instead, it is simply emptied and the final root file system
mounted over the top. mounted over the top.
If the systemd module is used in the initramfs, the ordering of the services
started looks like <<dracutbootup7>>.
== Dracut on shutdown
On a systemd driven system, the dracut initramfs is also used for the shutdown procedure.
The following steps are executed during a shutdown:
* systemd switches to the shutdown.target
* systemd starts /lib/systemd/system/shutdown.target.wants/dracut-shutdown.service
* dracut-shutdown.service executes /usr/lib/dracut/dracut-initramfs-restore
which unpacks the initramfs to /run/initramfs
* systemd finishes shutdown.target
* systemd kills all processes
* systemd tries to unmount everything and mounts the remaining read-only
* systemd checks, if there is a /run/initramfs/shutdown executable
* if yes, it does a pivot_root to /run/initramfs and executes ./shutdown.
The old root is then mounted on /oldroot. /usr/lib/dracut/modules.d/99shutdown/shutdown.sh is the shutdown executable.
* shutdown will try to umount every /oldroot mount and calls the various shutdown hooks from the dracut modules
This ensures, that all devices are disassembled and unmounted cleanly.
= User Manual = User Manual
== Creating an initramfs Image == Creating an initramfs Image
@@ -391,7 +414,7 @@ How to setup your PXE/TFTP server can be found in the
http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/[Red http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/[Red
Hat Enterprise Linux Storage Administration Guide]. Hat Enterprise Linux Storage Administration Guide].
If you specify rd.ip=auto on the kernel command line, then dracut asks a dhcp If you specify ip=auto on the kernel command line, then dracut asks a dhcp
server about the ip adress for the machine. The dhcp server can also serve an server about the ip adress for the machine. The dhcp server can also serve an
additional root-path, which will set the root device for dracut. With this additional root-path, which will set the root device for dracut. With this
mechanism, you have static configuration on your client machine and a mechanism, you have static configuration on your client machine and a
@@ -466,6 +489,7 @@ dracut shell commands are printed as they are executed
---- ----
# journalctl -ab # journalctl -ab
---- ----
. With dracut >= 025 the file /run/initramfs/rdsosreport.txt is generated, which contains all the logs and the output of all significant tools, which are mentioned later.
If you want to save that output, simply mount /boot by hand or insert an USB stick and mount that. If you want to save that output, simply mount /boot by hand or insert an USB stick and mount that.
Then you can store the output for later inspection. Then you can store the output for later inspection.
@@ -510,19 +534,19 @@ all files in _/etc/dracut.conf.d/*.conf_
As well as the information from <<all-bug-reports>> include the following As well as the information from <<all-bug-reports>> include the following
information: information:
* Include physical volume information by running the command: * Include physical volume information by running the command:
+ +
---- ----
# lvm pvdisplay # lvm pvdisplay
---- ----
+ +
* Include volume group information by running the command: * Include volume group information by running the command:
+ +
---- ----
# lvm vgdisplay # lvm vgdisplay
---- ----
+ +
* Include logical volume information by running the command: * Include logical volume information by running the command:
+ +
---- ----
# lvm lvdisplay # lvm lvdisplay
@@ -533,7 +557,7 @@ information:
As well as the information from <<all-bug-reports>>, include the following As well as the information from <<all-bug-reports>>, include the following
information: information:
* If using software RAID disk partitions, please include the output of * If using software RAID disk partitions, please include the output of
+ +
---- ----
# cat /proc/mdstat # cat /proc/mdstat
@@ -638,7 +662,7 @@ title Fedora (2.6.29.5-191.fc11.x86_64)
No root device found No root device found
Dropping to debug shell. Dropping to debug shell.
# #
---- ----
+ +
. Use this shell prompt to gather the information requested above (see <<all-bug-reports>>). . Use this shell prompt to gather the information requested above (see <<all-bug-reports>>).
@@ -658,7 +682,7 @@ The exact method for locating and preparing will vary. However, to continue with
a successful boot, the objective is to locate your root volume and create a a successful boot, the objective is to locate your root volume and create a
symlink _/dev/root_ which points to the file system. For example, the following symlink _/dev/root_ which points to the file system. For example, the following
example demonstrates accessing and booting a root volume that is an encrypted example demonstrates accessing and booting a root volume that is an encrypted
LVM Logical volume. LVM Logical volume.
. Inspect your partitions using parted . Inspect your partitions using parted
+ +
@@ -674,7 +698,7 @@ Number Start End Size Type File system Flags
---- ----
+ +
. You recall that your root volume was a LVM logical volume. Scan and activate . You recall that your root volume was a LVM logical volume. Scan and activate
any logical volumes. any logical volumes.
+ +
---- ----
# lvm vgscan # lvm vgscan
@@ -700,7 +724,7 @@ Installation Guide, you unlock your encrypted root volume.
# UUID=$(cryptsetup luksUUID /dev/mapper/linux-root) # UUID=$(cryptsetup luksUUID /dev/mapper/linux-root)
# cryptsetup luksOpen /dev/mapper/linux-root luks-$UUID # cryptsetup luksOpen /dev/mapper/linux-root luks-$UUID
Enter passphrase for /dev/mapper/linux-root: Enter passphrase for /dev/mapper/linux-root:
Key slot 0 unlocked. Key slot 0 unlocked.
---- ----
+ +
. Next, make a symbolic link to the unlocked root volume . Next, make a symbolic link to the unlocked root volume
@@ -759,7 +783,7 @@ processes, and switches to the real root device for further booting. dracut
modules can insert custom script at various points, to control the boot process. modules can insert custom script at various points, to control the boot process.
These hooks are plain directories containing shell scripts ending with ".sh", These hooks are plain directories containing shell scripts ending with ".sh",
which are sourced by init. which are sourced by init.
Common used functions are in _dracut-lib.sh_, which can be sourced by any script. Common used functions are in _dracut-lib.sh_, which can be sourced by any script.
@@ -808,7 +832,7 @@ udevadm.
=== Trigger Udev === Trigger Udev
udev is triggered by calling udevadm trigger, which sends add events for all udev is triggered by calling udevadm trigger, which sends add events for all
devices and subsystems. devices and subsystems.
@@ -888,7 +912,6 @@ still running from the initramfs should not have any open file descriptors left.
== Network Infrastructure == Network Infrastructure
FIXME FIXME
@@ -1007,13 +1030,11 @@ instmods
=== Creation Functions === Creation Functions
FIXME FIXME
=== Initramfs Functions === Initramfs Functions
FIXME FIXME
@@ -1021,6 +1042,9 @@ FIXME
FIXME FIXME
:leveloffset: 1
[[dracutbootup7]]
include::dracut.bootup.7.asc[]
:leveloffset: 1 :leveloffset: 1
[[dracut8]] [[dracut8]]

122
dracut.bootup.7.asc Normal file
View File

@@ -0,0 +1,122 @@
DRACUT.BOOTUP(7)
================
:doctype: manpage
:man source: dracut
:man manual: dracut
NAME
----
dracut.bootup - boot ordering in the initramfs
DESCRIPTION
-----------
This flow chart illustrates the ordering of the services, if systemd is used in the dracut initramfs.
----
systemd-journal.socket
|
v
dracut-cmdline.service
|
v
dracut-pre-udev.service
|
v
systemd-udevd.service
|
v
local-fs-pre.target dracut-pre-trigger.service
| |
v v
(various mounts) (various swap systemd-udev-trigger.service
| devices...) | (various low-level (various low-level
| | | services: seed, API VFS mounts:
v v v tmpfiles, random mqueue, configfs,
local-fs.target swap.target dracut-initqueue.service sysctl, ...) debugfs, ...)
| | | | |
\_______________|____________________ | ___________________|____________________/
\|/
v
sysinit.target
|
_________________/|\___________________
/ | \
| | |
v | v
(various | rescue.service
sockets...) | |
| | v
v | rescue.target
sockets.target |
| |
\_________________ | emergency.service
\| |
v v
basic.target emergency.target
|
______________________/|
/ |
| v
| dracut-pre-mount.service
| |
| v
| sysroot.mount
| |
| v
| initrd-root-fs.target
(custom initrd services) |
| v
| dracut-mount.service
| |
| v
| initrd-parse-etc.service
| |
| v
| (sysroot-usr.mount and
| various mounts marked
| with fstab option
| x-initrd.mount)
| |
| v
| initrd-fs.target
\______________________ |
\|
v
initrd.target
|
v
dracut-pre-pivot.service
|
v
initrd-cleanup.service
isolates to
initrd-switch-root.target
|
v
______________________/|
/ |
| initrd-udevadm-cleanup-db.service
| |
(custom initrd services) |
| |
\______________________ |
\|
v
initrd-switch-root.target
|
v
initrd-switch-root.service
|
v
switch-root
----
AUTHOR
------
Harald Hoyer
SEE ALSO
--------
*dracut*(8) *bootup*(7)

View File

@@ -121,9 +121,19 @@ Misc
specify the controlling terminal for the console. specify the controlling terminal for the console.
This is useful, if you have multiple "console=" arguments. This is useful, if you have multiple "console=" arguments.
**rd.action_on_fail=**_{shell|continue}_::
Specify the action after failure. By default it's emergency_shell.
'continue' means: ignore the current failure and go ahead.
[[dracutkerneldebug]] [[dracutkerneldebug]]
Debug Debug
~~~~~ ~~~~~
If you are dropped to an emergency shell, the file _/run/initramfs/rdsosreport.txt_ is created,
which can be safed to a (to be mounted by hand) partition (usually /boot) or a USB stick.
Additional debugging info can be produced by adding **rd.debug** to the kernel command line.
_/run/initramfs/rdsosreport.txt_ contains all logs and the output of some tools.
It should be attached to any report about dracut problems.
**rd.info**:: **rd.info**::
print informational output though "quiet" is set print informational output though "quiet" is set
@@ -131,8 +141,19 @@ Debug
allow dropping to a shell, if root mounting fails allow dropping to a shell, if root mounting fails
**rd.debug**:: **rd.debug**::
set -x for the dracut shell and logs to dmesg, console and set -x for the dracut shell.
_/run/initramfs/init.log_ If systemd is active in the initramfs, all output is logged to the systemd journal,
which you can inspect with "journalctl -ab".
If systemd is not active, the logs are written to dmesg and _/run/initramfs/init.log_.
If "quiet" is set, it also logs to the console.
**rd.memdebug=[0-3]**::
Print memory usage info at various points, set the verbose level from 0 to 3
Higher level means more debugging output:
0 - no output
1 - partial /proc/meminfo
2 - /proc/meminfo
3 - /proc/meminfo + /proc/slabinfo
**rd.break**:: **rd.break**::
drop to a shell at the end drop to a shell at the end
@@ -411,6 +432,10 @@ interface name. Better name it "bootnet" or "bluesocket".
then its values should be separated by semicolon. then its values should be separated by semicolon.
Bond without parameters assumes bond=bond0:eth0,eth1:mode=balance-rr Bond without parameters assumes bond=bond0:eth0,eth1:mode=balance-rr
**team =_<teammaster>_:_<teamslaves>_**::
Setup team device <teammaster> on top of <teamslaves>.
<teamslaves> is a comma-separated list of physical (ethernet) interfaces.
**bridge=_<bridgename>_:_<ethnames>_**:: **bridge=_<bridgename>_:_<ethnames>_**::
Setup bridge <bridgename> with <ethnames>. <ethnames> is a comma-separated Setup bridge <bridgename> with <ethnames>. <ethnames> is a comma-separated
list of physical (ethernet) interfaces. Bridge without parameters assumes bridge=br0:eth0 list of physical (ethernet) interfaces. Bridge without parameters assumes bridge=br0:eth0
@@ -583,7 +608,7 @@ ZNET
+ +
---- ----
rd.znet=qeth,0.0.0600,0.0.0601,0.0.0602,layer2=1,portname=foo rd.znet=qeth,0.0.0600,0.0.0601,0.0.0602,layer2=1,portname=foo
rd.znet=ctc,0.0.0600,0.0.0601,0.0.0602,protocol=bar rd.znet=ctc,0.0.0600,0.0.0601,protocol=bar
---- ----
Plymouth Boot Splash Plymouth Boot Splash

View File

@@ -1,11 +1,11 @@
# PUT YOUR CONFIG HERE OR IN separate files named *.conf # PUT YOUR CONFIG HERE OR IN separate files named *.conf
# in /etc/dracut.conf.d # in /etc/dracut.conf.d
# /etc/dracut.conf.d/*.conf will override the settings in here # SEE man dracut.conf(5)
# Sample dracut config file # Sample dracut config file
logfile=/var/log/dracut.log #logfile=/var/log/dracut.log
fileloglvl=6 #fileloglvl=6
# Exact list of dracut modules to use. Modules not listed here are not going # Exact list of dracut modules to use. Modules not listed here are not going
# to be included. If you only want to add some optional modules use # to be included. If you only want to add some optional modules use
@@ -29,10 +29,10 @@ fileloglvl=6
# #
# install local /etc/mdadm.conf # install local /etc/mdadm.conf
mdadmconf="yes" #mdadmconf="no"
# install local /etc/lvm/lvm.conf # install local /etc/lvm/lvm.conf
lvmconf="yes" #lvmconf="no"
# A list of fsck tools to install. If it's not specified, module's hardcoded # A list of fsck tools to install. If it's not specified, module's hardcoded
# default is used, currently: "umount mount /sbin/fsck* xfs_db xfs_check # default is used, currently: "umount mount /sbin/fsck* xfs_db xfs_check

View File

@@ -10,17 +10,24 @@ dracut.conf - configuration file(s) for dracut
SYNOPSIS SYNOPSIS
-------- --------
_/etc/dracut.conf_ _/etc/dracut.conf.d/*.conf_ _/etc/dracut.conf_ _/etc/dracut.conf.d/*.conf_ _/usr/lib/dracut/dracut.conf.d/*.conf_
Description Description
----------- -----------
_dracut.conf_ is loaded during the initialisation phase of dracut. Command line _dracut.conf_ is loaded during the initialisation phase of dracut. Command line
parameter will overwrite any values set here. _dracut.conf.d/*.conf_ files are parameter will overwrite any values set here.
read in alphanumerical order and will overwrite parameters set in
_*.conf_ files are read from /usr/lib/dracut/dracut.conf.d and /etc/dracut.conf.d.
Files with the same name in /etc/dracut.conf.d will replace files in /usr/lib/dracut/dracut.conf.d.
The files are then read in alphanumerical order and will overwrite parameters set in
_/etc/dracut.conf_. Each line specifies an attribute and a value. A '#' _/etc/dracut.conf_. Each line specifies an attribute and a value. A '#'
indicates the beginning of a comment; following characters, up to the end of the indicates the beginning of a comment; following characters, up to the end of the
line are not interpreted. line are not interpreted.
dracut command line options will overwrite any values set here.
Configuration files must have the extension .conf; other extensions are ignored.
*dracutmodules+=*" __<dracut modules>__ ":: *dracutmodules+=*" __<dracut modules>__ "::
Specify a space-separated list of dracut modules to call when building the Specify a space-separated list of dracut modules to call when building the
initramfs. Modules are located in _/usr/lib/dracut/modules.d_. initramfs. Modules are located in _/usr/lib/dracut/modules.d_.
@@ -44,10 +51,6 @@ line are not interpreted.
Specify a space-separated list of kernel modules not to add to the Specify a space-separated list of kernel modules not to add to the
initramfs. The kernel modules have to be specified without the ".ko" suffix. initramfs. The kernel modules have to be specified without the ".ko" suffix.
*install_items+=*" __<kernel modules>__ "::
Specify a space-separated list of files, which are added to the initramfs
image.
*filesystems+=*" __<filesystem names>__ ":: *filesystems+=*" __<filesystem names>__ "::
Specify a space-separated list of kernel filesystem modules to exclusively Specify a space-separated list of kernel filesystem modules to exclusively
include in the generic initramfs. include in the generic initramfs.
@@ -82,6 +85,11 @@ If chrooted to another root other than the real root device, use --fstab and pro
*add_fstab+=*" __<filename>__ ":: *add_fstab+=*" __<filename>__ "::
Add entries of __<filename>__ to the initramfs /etc/fstab. Add entries of __<filename>__ to the initramfs /etc/fstab.
*add_device+=*" __<device>__ "::
Bring up _<device>_ in initramfs, _<device>_ should be the device name.
This can be useful in hostonly mode for resume support when your swap is on
LVM an encrypted partition.
*mdadmconf=*"__{yes|no}__":: *mdadmconf=*"__{yes|no}__"::
Include local _/etc/mdadm.conf_ (default=yes) Include local _/etc/mdadm.conf_ (default=yes)
@@ -122,13 +130,13 @@ If chrooted to another root other than the real root device, use --fstab and pro
Path to log file. Path to log file.
*show_modules=*"__{yes|no}__":: *show_modules=*"__{yes|no}__"::
Print included module's name to standard output during build. Print the name of the included modules to standard output during build.
Files Files
----- -----
_/etc/dracut.conf_:: _/etc/dracut.conf_::
Old configuration file. You better use your own file in Old configuration file. You better use your own file in
_/etc/dracut/conf.d/_. _/etc/dracut.conf.d/_.
_/etc/dracut.conf.d/_:: _/etc/dracut.conf.d/_::
Any _/etc/dracut.conf.d/*.conf_ file can overwrite the values in Any _/etc/dracut.conf.d/*.conf_ file can overwrite the values in

View File

@@ -2,13 +2,16 @@
# i18n # i18n
i18n_vars="/etc/sysconfig/keyboard:KEYTABLE-KEYMAP /etc/sysconfig/i18n:SYSFONT-FONT,FONTACM-FONT_MAP,FONT_UNIMAP" i18n_vars="/etc/sysconfig/keyboard:KEYTABLE-KEYMAP /etc/sysconfig/i18n:SYSFONT-FONT,FONTACM-FONT_MAP,FONT_UNIMAP"
omit_drivers+=" .*/fs/ocfs/.* i2o_scsi" i18n_default_font="latarcyrheb-sun16"
omit_drivers+=' .*/fs/ocfs/.* i2o_scsi'
stdloglvl=3 stdloglvl=3
logfile=/var/log/dracut.log
fileloglvl=6
install_items+=" vi /etc/virc ps grep cat rm " install_items+=" vi /etc/virc ps grep cat rm "
prefix="/" prefix="/"
systemdutildir=/usr/lib/systemd systemdutildir=/usr/lib/systemd
systemdsystemunitdir=/usr/lib/systemd/system systemdsystemunitdir=/usr/lib/systemd/system
systemdsystemconfdir=/etc/systemd/system
udevdir=/usr/lib/udev udevdir=/usr/lib/udev
add_dracutmodules+=" systemd " add_dracutmodules+=" systemd "
realinitpath="/usr/lib/systemd/systemd" hostonly="yes"
kernelcmdline+=" rd.auto=1 "

450
dracut.sh
View File

@@ -7,7 +7,7 @@
# of the various mkinitrd implementations out there # of the various mkinitrd implementations out there
# #
# Copyright 2005-2010 Red Hat, Inc. All rights reserved. # Copyright 2005-2013 Red Hat, Inc. All rights reserved.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@@ -69,33 +69,37 @@ Creates initial ramdisk images for preloading modules
--kver [VERSION] Set kernel version to [VERSION]. --kver [VERSION] Set kernel version to [VERSION].
-f, --force Overwrite existing initramfs file. -f, --force Overwrite existing initramfs file.
-a, --add [LIST] Add a space-separated list of dracut modules.
-m, --modules [LIST] Specify a space-separated list of dracut modules to -m, --modules [LIST] Specify a space-separated list of dracut modules to
call when building the initramfs. Modules are located call when building the initramfs. Modules are located
in /usr/lib/dracut/modules.d. in /usr/lib/dracut/modules.d.
-o, --omit [LIST] Omit a space-separated list of dracut modules. -o, --omit [LIST] Omit a space-separated list of dracut modules.
-a, --add [LIST] Add a space-separated list of dracut modules. --force-add [LIST] Force to add a space-separated list of dracut modules
to the default set of modules, when -H is specified.
-d, --drivers [LIST] Specify a space-separated list of kernel modules to -d, --drivers [LIST] Specify a space-separated list of kernel modules to
exclusively include in the initramfs. 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. modules to add to the initramfs.
--omit-drivers [LIST] Specify a space-separated list of kernel --omit-drivers [LIST] Specify a space-separated list of kernel
modules not to add to the initramfs. modules not to add to the initramfs.
--filesystems [LIST] Specify a space-separated list of kernel filesystem --filesystems [LIST] Specify a space-separated list of kernel filesystem
modules to exclusively include in the generic modules to exclusively include in the generic
initramfs. initramfs.
-k, --kmoddir [DIR] Specify the directory, where to look for kernel -k, --kmoddir [DIR] Specify the directory, where to look for kernel
modules modules
--fwdir [DIR] Specify additional directories, where to look for --fwdir [DIR] Specify additional directories, where to look for
firmwares, separated by : firmwares, separated by :
--kernel-only Only install kernel drivers and firmware files --kernel-only Only install kernel drivers and firmware files
--no-kernel Do not install kernel drivers and firmware files --no-kernel Do not install kernel drivers and firmware files
--early-microcode Combine early microcode with ramdisk
--no-early-microcode Do not combine early microcode with ramdisk
--kernel-cmdline [PARAMETERS] Specify default kernel command line parameters --kernel-cmdline [PARAMETERS] Specify default kernel command line parameters
--strip Strip binaries in the initramfs (default) --strip Strip binaries in the initramfs
--nostrip Do not strip binaries in the initramfs --nostrip Do not strip binaries in the initramfs
--hardlink Hardlink files in the initramfs (default) --hardlink Hardlink files in the initramfs
--nohardlink Do not hardlink files in the initramfs --nohardlink Do not hardlink files in the initramfs
--prefix [DIR] Prefix initramfs files with [DIR] --prefix [DIR] Prefix initramfs files with [DIR]
--noprefix Do not prefix initramfs files (default) --noprefix Do not prefix initramfs files
--mdadmconf Include local /etc/mdadm.conf --mdadmconf Include local /etc/mdadm.conf
--nomdadmconf Do not include local /etc/mdadm.conf --nomdadmconf Do not include local /etc/mdadm.conf
--lvmconf Include local /etc/lvm/lvm.conf --lvmconf Include local /etc/lvm/lvm.conf
@@ -111,11 +115,11 @@ Creates initial ramdisk images for preloading modules
1 - only fatal errors 1 - only fatal errors
2 - all errors 2 - all errors
3 - warnings 3 - warnings
4 - info (default) 4 - info
5 - debug info (here starts lots of output) 5 - debug info (here starts lots of output)
6 - trace info (and even more) 6 - trace info (and even more)
-v, --verbose Increase verbosity level (default is info(4)) -v, --verbose Increase verbosity level
-q, --quiet Decrease verbosity level (default is info(4)) -q, --quiet Decrease verbosity level
-c, --conf [FILE] Specify configuration file to use. -c, --conf [FILE] Specify configuration file to use.
Default: /etc/dracut.conf Default: /etc/dracut.conf
--confdir [DIR] Specify configuration directory to use *.conf files --confdir [DIR] Specify configuration directory to use *.conf files
@@ -134,7 +138,7 @@ Creates initial ramdisk images for preloading modules
--mount "[DEV] [MP] [FSTYPE] [FSOPTS]" --mount "[DEV] [MP] [FSTYPE] [FSOPTS]"
Mount device [DEV] on mountpoint [MP] with filesystem Mount device [DEV] on mountpoint [MP] with filesystem
[FSTYPE] and options [FSOPTS] in the initramfs [FSTYPE] and options [FSOPTS] in the initramfs
--device "[DEV]" Bring up [DEV] in initramfs --add-device "[DEV]" Bring up [DEV] in initramfs
-i, --include [SOURCE] [TARGET] -i, --include [SOURCE] [TARGET]
Include the files in the SOURCE directory into the Include the files in the SOURCE directory into the
Target directory in the final initramfs. Target directory in the final initramfs.
@@ -211,7 +215,7 @@ pop() {
if [[ "$__resultvar" ]]; then if [[ "$__resultvar" ]]; then
eval $__resultvar="'$_value'" eval $__resultvar="'$_value'"
else else
echo "$_value" printf "%s" "$_value"
fi fi
eval unset ${__stack}'[${#'${__stack}'[@]}-1]' eval unset ${__stack}'[${#'${__stack}'[@]}-1]'
return 0 return 0
@@ -235,6 +239,32 @@ read_arg() {
fi fi
} }
dropindirs_sort()
{
local suffix=$1; shift
local -a files
local f d
readarray -t files < <(
for d in "$@"; do
for i in "$d/"*"$suffix"; do
if [[ -e "$i" ]]; then
printf "%s\n" "${i##*/}"
fi
done
done | sort -Vu
)
for f in "${files[@]}"; do
for d in "$@"; do
if [[ -e "$d/$f" ]]; then
printf "%s\n" "$d/$f"
continue 2
fi
done
done
}
verbosity_mod_l=0 verbosity_mod_l=0
unset kernel unset kernel
unset outfile unset outfile
@@ -293,7 +323,9 @@ TEMP=$(unset POSIXLY_CORRECT; getopt \
--long quiet \ --long quiet \
--long local \ --long local \
--long hostonly \ --long hostonly \
--long host-only \
--long no-hostonly \ --long no-hostonly \
--long no-host-only \
--long fstab \ --long fstab \
--long help \ --long help \
--long bzip2 \ --long bzip2 \
@@ -305,6 +337,8 @@ TEMP=$(unset POSIXLY_CORRECT; getopt \
--long show-modules \ --long show-modules \
--long keep \ --long keep \
--long printsize \ --long printsize \
--long regenerate-all \
--long noimageifnotneeded \
-- "$@") -- "$@")
if (( $? != 0 )); then if (( $? != 0 )); then
@@ -331,7 +365,8 @@ while :; do
--fscks) push fscks_l "$2"; shift;; --fscks) push fscks_l "$2"; shift;;
--add-fstab) push add_fstab_l "$2"; shift;; --add-fstab) push add_fstab_l "$2"; shift;;
--mount) push fstab_lines "$2"; shift;; --mount) push fstab_lines "$2"; shift;;
--device) push host_devs "$2"; shift;; --add-device|--device)
push add_device_l "$2"; shift;;
--kernel-cmdline) push kernel_cmdline_l "$2"; shift;; --kernel-cmdline) push kernel_cmdline_l "$2"; shift;;
--nofscks) nofscks_l="yes";; --nofscks) nofscks_l="yes";;
--ro-mnt) ro_mnt_l="yes";; --ro-mnt) ro_mnt_l="yes";;
@@ -345,6 +380,8 @@ while :; do
-f|--force) force=yes;; -f|--force) force=yes;;
--kernel-only) kernel_only="yes"; no_kernel="no";; --kernel-only) kernel_only="yes"; no_kernel="no";;
--no-kernel) kernel_only="no"; no_kernel="yes";; --no-kernel) kernel_only="no"; no_kernel="yes";;
--early-microcode) early_microcode="yes";;
--no-early-microcode) early_microcode="no";;
--strip) do_strip_l="yes";; --strip) do_strip_l="yes";;
--nostrip) do_strip_l="no";; --nostrip) do_strip_l="no";;
--hardlink) do_hardlink_l="yes";; --hardlink) do_hardlink_l="yes";;
@@ -361,11 +398,13 @@ while :; do
-q|--quiet) ((verbosity_mod_l--));; -q|--quiet) ((verbosity_mod_l--));;
-l|--local) -l|--local)
allowlocal="yes" allowlocal="yes"
[[ -f "$(readlink -f ${0%/*})/dracut-functions.sh" ]] \ [[ -f "$(readlink -f "${0%/*}")/dracut-functions.sh" ]] \
&& dracutbasedir="$(readlink -f ${0%/*})" && dracutbasedir="$(readlink -f "${0%/*}")"
;; ;;
-H|--hostonly) hostonly_l="yes" ;; -H|--hostonly|--host-only)
-N|--no-hostonly) hostonly_l="no" ;; hostonly_l="yes" ;;
-N|--no-hostonly|--no-host-only)
hostonly_l="no" ;;
--fstab) use_fstab_l="yes" ;; --fstab) use_fstab_l="yes" ;;
-h|--help) long_usage; exit 1 ;; -h|--help) long_usage; exit 1 ;;
-i|--include) push include_src "$2" -i|--include) push include_src "$2"
@@ -381,6 +420,8 @@ while :; do
;; ;;
--keep) keep="yes";; --keep) keep="yes";;
--printsize) printsize="yes";; --printsize) printsize="yes";;
--regenerate-all) regenerate_all="yes";;
--noimageifnotneeded) noimageifnotneeded="yes";;
--) shift; break;; --) shift; break;;
@@ -412,12 +453,45 @@ while (($# > 0)); do
shift shift
done done
if [[ $regenerate_all == "yes" ]]; then
ret=0
if [[ $kernel ]]; then
printf -- "--regenerate-all cannot be called with a kernel version\n" >&2
exit 1
fi
if [[ $outfile ]]; then
printf -- "--regenerate-all cannot be called with a image file\n" >&2
exit 1
fi
((len=${#dracut_args[@]}))
for ((i=0; i < len; i++)); do
[[ ${dracut_args[$i]} == "--regenerate-all" ]] && \
unset dracut_args[$i]
done
cd /lib/modules
for i in *; do
[[ -f $i/modules.builtin ]] || continue
dracut --kver="$i" "${dracut_args[@]}"
((ret+=$?))
done
exit $ret
fi
if ! [[ $kernel ]]; then if ! [[ $kernel ]]; then
kernel=$(uname -r) kernel=$(uname -r)
fi fi
if ! [[ $outfile ]]; then if ! [[ $outfile ]]; then
outfile="/boot/initramfs-$kernel.img" [[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
if [[ $MACHINE_ID ]] && ( [[ -d /boot/${MACHINE_ID} ]] || [[ -L /boot/${MACHINE_ID} ]] ); then
outfile="/boot/${MACHINE_ID}/$kernel/initrd"
else
outfile="/boot/initramfs-$kernel.img"
fi
fi fi
for i in /usr/sbin /sbin /usr/bin /bin; do for i in /usr/sbin /sbin /usr/bin /bin; do
@@ -430,6 +504,10 @@ for i in /usr/sbin /sbin /usr/bin /bin; do
fi fi
done done
export PATH="${NPATH#:}" export PATH="${NPATH#:}"
unset LC_MESSAGES
unset LC_CTYPE
export LC_ALL=C
export LANG=C
unset NPATH unset NPATH
unset LD_LIBRARY_PATH unset LD_LIBRARY_PATH
unset GREP_OPTIONS unset GREP_OPTIONS
@@ -451,24 +529,28 @@ export DRACUT_LOG_LEVEL=warning
# if we were not passed a config file, try the default one # if we were not passed a config file, try the default one
if [[ ! -f $conffile ]]; then if [[ ! -f $conffile ]]; then
[[ $allowlocal ]] && conffile="$dracutbasedir/dracut.conf" || \ if [[ $allowlocal ]]; then
conffile="$dracutbasedir/dracut.conf"
else
conffile="/etc/dracut.conf" conffile="/etc/dracut.conf"
fi
fi fi
if [[ ! -d $confdir ]]; then if [[ ! -d $confdir ]]; then
[[ $allowlocal ]] && confdir="$dracutbasedir/dracut.conf.d" || \ if [[ $allowlocal ]]; then
confdir="$dracutbasedir/dracut.conf.d"
else
confdir="/etc/dracut.conf.d" confdir="/etc/dracut.conf.d"
fi
fi fi
# source our config file # source our config file
[[ -f $conffile ]] && . "$conffile" [[ -f $conffile ]] && . "$conffile"
# source our config dir # source our config dir
if [[ $confdir && -d $confdir ]]; then for f in $(dropindirs_sort ".conf" "$confdir" "$dracutbasedir/dracut.conf.d"); do
for f in "$confdir"/*.conf; do [[ -e $f ]] && . "$f"
[[ -e $f ]] && . "$f" done
done
fi
# these optins add to the stuff in the config file # these optins add to the stuff in the config file
if (( ${#add_dracutmodules_l[@]} )); then if (( ${#add_dracutmodules_l[@]} )); then
@@ -577,8 +659,7 @@ case $compress in
bzip2) compress="bzip2 -9";; bzip2) compress="bzip2 -9";;
lzma) compress="lzma -9";; lzma) compress="lzma -9";;
xz) compress="xz --check=crc32 --lzma2=dict=1MiB";; xz) compress="xz --check=crc32 --lzma2=dict=1MiB";;
gzip) command -v pigz > /dev/null 2>&1 && compress="pigz -9" || \ gzip) compress="gzip -9"; command -v pigz > /dev/null 2>&1 && compress="pigz -9";;
compress="gzip -9";;
esac esac
if [[ $_no_compress_l = "cat" ]]; then if [[ $_no_compress_l = "cat" ]]; then
compress="cat" compress="cat"
@@ -588,21 +669,33 @@ fi
[[ $hostonly != "-h" ]] && unset hostonly [[ $hostonly != "-h" ]] && unset hostonly
readonly TMPDIR="$tmpdir" readonly TMPDIR="$tmpdir"
readonly initdir=$(mktemp --tmpdir="$TMPDIR/" -d -t initramfs.XXXXXX) readonly initdir="$(mktemp --tmpdir="$TMPDIR/" -d -t initramfs.XXXXXX)"
[ -d "$initdir" ] || { [ -d "$initdir" ] || {
echo "dracut: mktemp --tmpdir=\"$TMPDIR/\" -d -t initramfs.XXXXXX failed." >&2 printf "%s\n" "dracut: mktemp --tmpdir=\"$TMPDIR/\" -d -t initramfs.XXXXXX failed." >&2
exit 1 exit 1
} }
if [[ $early_microcode = yes ]]; then
readonly microcode_dir="$(mktemp --tmpdir="$TMPDIR/" -d -t early_microcode.XXXXXX)"
[ -d "$microcode_dir" ] || {
printf "%s\n" "dracut: mktemp --tmpdir=\"$TMPDIR/\" -d -t early_microcode.XXXXXX failed." >&2
exit 1
}
fi
# clean up after ourselves no matter how we die.
trap 'ret=$?;[[ $outfile ]] && [[ -f $outfile.$$ ]] && rm -f -- "$outfile.$$";[[ $keep ]] && echo "Not removing $initdir." >&2 || { [[ $initdir ]] && rm -rf -- "$initdir"; [[ $microcode_dir ]] && rm -Rf -- "$microcode_dir"; exit $ret; };' EXIT
# clean up after ourselves no matter how we die.
trap 'exit 1;' SIGINT
export DRACUT_KERNEL_LAZY="1" export DRACUT_KERNEL_LAZY="1"
export DRACUT_RESOLVE_LAZY="1" export DRACUT_RESOLVE_LAZY="1"
if [[ -f $dracutbasedir/dracut-functions.sh ]]; then if [[ -f $dracutbasedir/dracut-functions.sh ]]; then
. $dracutbasedir/dracut-functions.sh . $dracutbasedir/dracut-functions.sh
else else
echo "dracut: Cannot find $dracutbasedir/dracut-functions.sh." >&2 printf "%s\n" "dracut: Cannot find $dracutbasedir/dracut-functions.sh." >&2
echo "dracut: Are you running from a git checkout?" >&2 printf "%s\n" "dracut: Are you running from a git checkout?" >&2
echo "dracut: Try passing -l as an argument to $0" >&2 printf "%s\n" "dracut: Try passing -l as an argument to $0" >&2
exit 1 exit 1
fi fi
@@ -611,16 +704,15 @@ if ! $DRACUT_INSTALL ${initdir+-D "$initdir"} -R "$initdir/bin/sh" &>/dev/null;
unset DRACUT_RESOLVE_LAZY unset DRACUT_RESOLVE_LAZY
export DRACUT_RESOLVE_DEPS=1 export DRACUT_RESOLVE_DEPS=1
fi fi
rm -fr ${initdir}/* rm -fr -- ${initdir}/*
if [[ -f $dracutbasedir/dracut-version.sh ]]; then if [[ -f $dracutbasedir/dracut-version.sh ]]; then
. $dracutbasedir/dracut-version.sh . $dracutbasedir/dracut-version.sh
fi fi
# Verify bash version, current minimum is 3.1 # Verify bash version, current minimum is 3.1
if (( ${BASH_VERSINFO[0]} < 3 || if (( BASH_VERSINFO[0] < 4 )); then
( ${BASH_VERSINFO[0]} == 3 && ${BASH_VERSINFO[1]} < 1 ) )); then dfatal 'You need at least Bash 4 to use dracut, sorry.'
dfatal 'You need at least Bash 3.1 to use dracut, sorry.'
exit 1 exit 1
fi fi
@@ -657,7 +749,7 @@ fi
omit_drivers_corrected="" omit_drivers_corrected=""
for d in $omit_drivers; do for d in $omit_drivers; do
strstr " $drivers $add_drivers " " $d " && continue [[ " $drivers $add_drivers " == *\ $d\ * ]] && continue
omit_drivers_corrected+="$d|" omit_drivers_corrected+="$d|"
done done
omit_drivers="${omit_drivers_corrected%|}" omit_drivers="${omit_drivers_corrected%|}"
@@ -665,7 +757,7 @@ unset omit_drivers_corrected
# prepare args for logging # prepare args for logging
for ((i=0; i < ${#dracut_args[@]}; i++)); do for ((i=0; i < ${#dracut_args[@]}; i++)); do
strstr "${dracut_args[$i]}" " " && \ [[ "${dracut_args[$i]}" == *\ * ]] && \
dracut_args[$i]="\"${dracut_args[$i]}\"" dracut_args[$i]="\"${dracut_args[$i]}\""
#" keep vim happy #" keep vim happy
done done
@@ -676,7 +768,7 @@ ddebug "Executing: $0 ${dracut_args[@]}"
[[ -d $mod ]] || continue; [[ -d $mod ]] || continue;
[[ -e $mod/install || -e $mod/installkernel || \ [[ -e $mod/install || -e $mod/installkernel || \
-e $mod/module-setup.sh ]] || continue -e $mod/module-setup.sh ]] || continue
echo ${mod##*/??} printf "%s\n" "${mod##*/??}"
done done
exit 0 exit 0
} }
@@ -688,10 +780,11 @@ esac
abs_outfile=$(readlink -f "$outfile") && outfile="$abs_outfile" abs_outfile=$(readlink -f "$outfile") && outfile="$abs_outfile"
[[ -f $srcmods/modules.dep ]] || { if [[ -d $srcmods ]]; then
dfatal "$srcmods/modules.dep is missing. Did you run depmod?" [[ -f $srcmods/modules.dep ]] || {
exit 1 dwarn "$srcmods/modules.dep is missing. Did you run depmod?"
} }
fi
if [[ -f $outfile && ! $force ]]; then if [[ -f $outfile && ! $force ]]; then
dfatal "Will not override existing initramfs ($outfile) without --force" dfatal "Will not override existing initramfs ($outfile) without --force"
@@ -702,7 +795,7 @@ outdir=${outfile%/*}
[[ $outdir ]] || outdir="/" [[ $outdir ]] || outdir="/"
if [[ ! -d "$outdir" ]]; then if [[ ! -d "$outdir" ]]; then
dfatal "Can't write $outfile: Directory $outdir does not exist." dfatal "Can't write to $outdir: Directory $outdir does not exist or is not accessible."
exit 1 exit 1
elif [[ ! -w "$outdir" ]]; then elif [[ ! -w "$outdir" ]]; then
dfatal "No permission to write to $outdir." dfatal "No permission to write to $outdir."
@@ -712,33 +805,54 @@ elif [[ -f "$outfile" && ! -w "$outfile" ]]; then
exit 1 exit 1
fi fi
# clean up after ourselves no matter how we die.
trap 'ret=$?;[[ $keep ]] && echo "Not removing $initdir." >&2 || rm -rf "$initdir";exit $ret;' EXIT
# clean up after ourselves no matter how we die.
trap 'exit 1;' SIGINT
# Need to be able to have non-root users read stuff (rpcbind etc) # Need to be able to have non-root users read stuff (rpcbind etc)
chmod 755 "$initdir" chmod 755 "$initdir"
if [[ $hostonly ]]; then
for i in /sys /proc /run /dev; do
if ! findmnt --target "$i" &>/dev/null; then
dwarning "Turning off host-only mode: '$i' is not mounted!"
unset hostonly
fi
done
if ! [[ -d /run/udev/data ]]; then
dwarning "Turning off host-only mode: udev database not found!"
unset hostonly
fi
fi
declare -A host_fs_types
for line in "${fstab_lines[@]}"; do for line in "${fstab_lines[@]}"; do
set -- $line set -- $line
#dev mp fs fsopts #dev mp fs fsopts
push host_devs "$1" push host_devs "$1"
push host_fs_types "$1|$3" host_fs_types["$1"]="$3"
done done
for f in $add_fstab; do for f in $add_fstab; do
[ -e $f ] || continue [[ -e $f ]] || continue
while read dev rest; do while read dev rest; do
push host_devs $dev push host_devs "$dev"
done < $f done < "$f"
done done
for dev in $add_device; do
push host_devs "$dev"
done
if (( ${#add_device_l[@]} )); then
while pop add_device_l val; do
add_device+=" $val "
push host_devs "$val"
done
fi
if [[ $hostonly ]]; then if [[ $hostonly ]]; then
# in hostonly mode, determine all devices, which have to be accessed # in hostonly mode, determine all devices, which have to be accessed
# and examine them for filesystem types # and examine them for filesystem types
push host_mp \ for mp in \
"/" \ "/" \
"/etc" \ "/etc" \
"/usr" \ "/usr" \
@@ -746,43 +860,69 @@ if [[ $hostonly ]]; then
"/usr/sbin" \ "/usr/sbin" \
"/usr/lib" \ "/usr/lib" \
"/usr/lib64" \ "/usr/lib64" \
"/boot" "/boot";
do
for mp in "${host_mp[@]}"; do
mountpoint "$mp" >/dev/null 2>&1 || continue mountpoint "$mp" >/dev/null 2>&1 || continue
push host_devs $(readlink -f "/dev/block/$(find_block_device "$mp")") _dev="$(readlink -f "/dev/block/$(find_block_device "$mp")")"
[[ "$_mp" == "/" ]] && root_dev="$_dev"
push host_devs "$_dev"
done done
while read dev type rest; do
[[ -b $dev ]] || continue
[[ "$type" == "partition" ]] || continue
while read _d _m _t _o _r; do
[[ "$_d" == \#* ]] && continue
[[ $_d ]] || continue
[[ $_t != "swap" ]] || [[ $_m != "swap" ]] && continue
[[ "$_o" == *noauto* ]] && continue
[[ "$_d" == UUID\=* ]] && _d="/dev/disk/by-uuid/${_d#UUID=}"
[[ "$_d" == LABEL\=* ]] && _d="/dev/disk/by-label/$_d#LABEL=}"
[[ "$_d" -ef "$dev" ]] || continue
while read _mapper _a _p _o; do
[[ $_mapper = \#* ]] && continue
[[ "$_d" -ef /dev/mapper/"$_mapper" ]] || continue
[[ "$_o" ]] || _o="$_p"
# skip mkswap swap
[[ $_o == *swap* ]] && continue 2
done < /etc/crypttab
push host_devs "$(readlink -f "$dev")"
break
done < /etc/fstab
done < /proc/swaps
fi fi
_get_fs_type() ( _get_fs_type() { (
[[ $1 ]] || return [[ $1 ]] || return
if [[ -b $1 ]] && get_fs_env $1; then if [[ -b /dev/block/$1 ]] && ID_FS_TYPE=$(get_fs_env "/dev/block/$1"); then
echo "$(readlink -f $1)|$ID_FS_TYPE" printf "%s\n" "$(readlink -f "/dev/block/$1")" "$ID_FS_TYPE"
return 1 return 1
fi fi
if [[ -b /dev/block/$1 ]] && get_fs_env /dev/block/$1; then if [[ -b $1 ]] && ID_FS_TYPE=$(get_fs_env "$1"); then
echo "$(readlink -f /dev/block/$1)|$ID_FS_TYPE" printf "%s\n" "$(readlink -f "$1")" "$ID_FS_TYPE"
return 1 return 1
fi fi
if fstype=$(find_dev_fstype $1); then if fstype=$(find_dev_fstype "$1"); then
echo "$1|$fstype" printf "%s\n" "$1" "$fstype"
return 1 return 1
fi fi
return 1 return 1
) ) }
for dev in "${host_devs[@]}"; do for dev in "${host_devs[@]}"; do
unset fs_type while read key; do
for fstype in $(_get_fs_type $dev) \ read val
$(check_block_and_slaves _get_fs_type $(get_maj_min $dev)); do host_fs_types["$key"]="$val"
if ! strstr " ${host_fs_types[*]} " " $fstype ";then done < <(
push host_fs_types "$fstype" _get_fs_type "$dev"
fi check_block_and_slaves_all _get_fs_type "$(get_maj_min "$dev")"
done )
done done
[[ -d $udevdir ]] \ [[ -d $udevdir ]] \
|| udevdir=$(pkg-config udev --variable=udevdir 2>/dev/null) || udevdir="$(pkg-config udev --variable=udevdir 2>/dev/null)"
if ! [[ -d "$udevdir" ]]; then if ! [[ -d "$udevdir" ]]; then
[[ -d /lib/udev ]] && udevdir=/lib/udev [[ -d /lib/udev ]] && udevdir=/lib/udev
[[ -d /usr/lib/udev ]] && udevdir=/usr/lib/udev [[ -d /usr/lib/udev ]] && udevdir=/usr/lib/udev
@@ -790,23 +930,30 @@ fi
[[ -d $systemdutildir ]] \ [[ -d $systemdutildir ]] \
|| systemdutildir=$(pkg-config systemd --variable=systemdutildir 2>/dev/null) || systemdutildir=$(pkg-config systemd --variable=systemdutildir 2>/dev/null)
[[ -d $systemdsystemunitdir ]] \
|| systemdsystemunitdir=$(pkg-config systemd --variable=systemdsystemunitdir 2>/dev/null)
if ! [[ -d "$systemdutildir" ]]; then if ! [[ -d "$systemdutildir" ]]; then
[[ -d /lib/systemd ]] && systemdutildir=/lib/systemd [[ -d /lib/systemd ]] && systemdutildir=/lib/systemd
[[ -d /usr/lib/systemd ]] && systemdutildir=/usr/lib/systemd [[ -d /usr/lib/systemd ]] && systemdutildir=/usr/lib/systemd
fi fi
[[ -d $systemdsystemunitdir ]] \
|| systemdsystemunitdir=$(pkg-config systemd --variable=systemdsystemunitdir 2>/dev/null)
[[ -d "$systemdsystemunitdir" ]] || systemdsystemunitdir=${systemdutildir}/system [[ -d "$systemdsystemunitdir" ]] || systemdsystemunitdir=${systemdutildir}/system
[[ -d $systemdsystemconfdir ]] \
|| systemdsystemconfdir=$(pkg-config systemd --variable=systemdsystemconfdir 2>/dev/null)
[[ -d "$systemdsystemconfdir" ]] || systemdsystemconfdir=/etc/systemd/system
export initdir dracutbasedir dracutmodules \ export initdir dracutbasedir dracutmodules \
fw_dir drivers_dir debug no_kernel kernel_only \ fw_dir drivers_dir debug no_kernel kernel_only \
omit_drivers mdadmconf lvmconf \ omit_drivers mdadmconf lvmconf root_dev \
use_fstab fstab_lines libdirs fscks nofscks ro_mnt \ use_fstab fstab_lines libdirs fscks nofscks ro_mnt \
stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \ stdloglvl sysloglvl fileloglvl kmsgloglvl logfile \
debug host_fs_types host_devs sshkey add_fstab \ debug host_fs_types host_devs sshkey add_fstab \
DRACUT_VERSION udevdir systemdutildir systemdsystemunitdir \ DRACUT_VERSION udevdir prefix filesystems drivers \
prefix filesystems drivers systemdutildir systemdsystemunitdir systemdsystemconfdir
# Create some directory structure first # Create some directory structure first
[[ $prefix ]] && mkdir -m 0755 -p "${initdir}${prefix}" [[ $prefix ]] && mkdir -m 0755 -p "${initdir}${prefix}"
@@ -816,13 +963,13 @@ export initdir dracutbasedir dracutmodules \
if [[ $prefix ]]; then if [[ $prefix ]]; then
for d in bin etc lib sbin tmp usr var $libdirs; do for d in bin etc lib sbin tmp usr var $libdirs; do
strstr "$d" "/" && continue [[ "$d" == */* ]] && continue
ln -sfn "${prefix#/}/${d#/}" "$initdir/$d" ln -sfn "${prefix#/}/${d#/}" "$initdir/$d"
done done
fi fi
if [[ $kernel_only != yes ]]; then if [[ $kernel_only != yes ]]; then
for d in usr/bin usr/sbin bin etc lib sbin tmp usr var var/log $libdirs; do for d in usr/bin usr/sbin bin etc lib sbin tmp usr var $libdirs; do
[[ -e "${initdir}${prefix}/$d" ]] && continue [[ -e "${initdir}${prefix}/$d" ]] && continue
if [ -L "/$d" ]; then if [ -L "/$d" ]; then
inst_symlink "/$d" "${prefix}/$d" inst_symlink "/$d" "${prefix}/$d"
@@ -841,6 +988,7 @@ if [[ $kernel_only != yes ]]; then
ln -sfn ../run "$initdir/var/run" ln -sfn ../run "$initdir/var/run"
ln -sfn ../run/lock "$initdir/var/lock" ln -sfn ../run/lock "$initdir/var/lock"
ln -sfn ../run/log "$initdir/var/log"
else else
for d in lib "$libdir"; do for d in lib "$libdir"; do
[[ -e "${initdir}${prefix}/$d" ]] && continue [[ -e "${initdir}${prefix}/$d" ]] && continue
@@ -870,25 +1018,28 @@ mods_to_load=""
for_each_module_dir check_module for_each_module_dir check_module
for_each_module_dir check_mount for_each_module_dir check_mount
strstr "$mods_to_load" "fips" && export DRACUT_FIPS_MODE=1 [[ "$mods_to_load " == *01fips\ * ]] && export DRACUT_FIPS_MODE=1
_isize=0 #initramfs size _isize=0 #initramfs size
modules_loaded=" " modules_loaded=" "
# source our modules. # source our modules.
for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
_d_mod=${moddir##*/}; _d_mod=${_d_mod#[0-9][0-9]} _d_mod=${moddir##*/}; _d_mod=${_d_mod#[0-9][0-9]}
if strstr "$mods_to_load" " $_d_mod "; then if [[ "$mods_to_load" == *\ $_d_mod\ * ]]; then
[[ $show_modules = yes ]] && echo "$_d_mod" || \ if [[ $show_modules = yes ]]; then
printf "%s\n" "$_d_mod"
else
dinfo "*** Including module: $_d_mod ***" dinfo "*** Including module: $_d_mod ***"
if [[ $kernel_only = yes ]]; then fi
module_installkernel $_d_mod || { if [[ $kernel_only == yes ]]; then
module_installkernel "$_d_mod" || {
dfatal "installkernel failed in module $_d_mod" dfatal "installkernel failed in module $_d_mod"
exit 1 exit 1
} }
else else
module_install $_d_mod module_install "$_d_mod"
if [[ $no_kernel != yes ]]; then if [[ $no_kernel != yes ]]; then
module_installkernel $_d_mod || { module_installkernel "$_d_mod" || {
dfatal "installkernel failed in module $_d_mod" dfatal "installkernel failed in module $_d_mod"
exit 1 exit 1
} }
@@ -900,8 +1051,8 @@ for moddir in "$dracutbasedir/modules.d"/[0-9][0-9]*; do
#print the module install size #print the module install size
if [ -n "$printsize" ]; then if [ -n "$printsize" ]; then
_isize_new=$(du -sk ${initdir}|cut -f1) _isize_new=$(du -sk ${initdir}|cut -f1)
_isize_delta=$(($_isize_new - $_isize)) _isize_delta=$((_isize_new - _isize))
echo "$_d_mod install size: ${_isize_delta}k" printf "%s\n" "$_d_mod install size: ${_isize_delta}k"
_isize=$_isize_new _isize=$_isize_new
fi fi
fi fi
@@ -910,7 +1061,7 @@ unset moddir
for i in $modules_loaded; do for i in $modules_loaded; do
mkdir -p $initdir/lib/dracut mkdir -p $initdir/lib/dracut
echo "$i" >> $initdir/lib/dracut/modules.txt printf "%s\n" "$i" >> $initdir/lib/dracut/modules.txt
done done
dinfo "*** Including modules done ***" dinfo "*** Including modules done ***"
@@ -932,27 +1083,46 @@ if [[ $no_kernel != yes ]]; then
dinfo "*** Installing kernel module dependencies and firmware ***" dinfo "*** Installing kernel module dependencies and firmware ***"
dracut_kernel_post dracut_kernel_post
dinfo "*** Installing kernel module dependencies and firmware done ***" dinfo "*** Installing kernel module dependencies and firmware done ***"
if [[ $noimageifnotneeded == yes ]] && [[ $hostonly ]]; then
if [[ ! -f "$initdir/lib/dracut/need-initqueue" ]] && \
[[ -f ${initdir}/lib/modules/$kernel/modules.dep && ! -s ${initdir}/lib/modules/$kernel/modules.dep ]]; then
for i in ${initdir}/etc/cmdline.d/*.conf; do
# We need no initramfs image and do not generate one.
[[ $i == "${initdir}/etc/cmdline.d/*.conf" ]] && exit 0
done
fi
fi
fi fi
if [[ $kernel_only != yes ]]; then if [[ $kernel_only != yes ]]; then
(( ${#install_items[@]} > 0 )) && dracut_install ${install_items[@]} (( ${#install_items[@]} > 0 )) && dracut_install ${install_items[@]}
echo "$kernel_cmdline" >> "${initdir}/etc/cmdline.d/01-default.conf" [[ $kernel_cmdline ]] && printf "%s\n" "$kernel_cmdline" >> "${initdir}/etc/cmdline.d/01-default.conf"
while pop fstab_lines line; do while pop fstab_lines line; do
echo "$line 0 0" >> "${initdir}/etc/fstab" printf "%s\n" "$line 0 0" >> "${initdir}/etc/fstab"
done done
for f in $add_fstab; do for f in $add_fstab; do
cat $f >> "${initdir}/etc/fstab" cat "$f" >> "${initdir}/etc/fstab"
done done
if [ -d ${initdir}/$systemdutildir ]; then
mkdir -p ${initdir}/etc/conf.d
{
printf "%s\n" "systemdutildir=\"$systemdutildir\""
printf "%s\n" "systemdsystemunitdir=\"$systemdsystemunitdir\""
printf "%s\n" "systemdsystemconfdir=\"$systemdsystemconfdir\""
} > ${initdir}/etc/conf.d/systemd.conf
fi
if [[ $DRACUT_RESOLVE_LAZY ]] && [[ $DRACUT_INSTALL ]]; then if [[ $DRACUT_RESOLVE_LAZY ]] && [[ $DRACUT_INSTALL ]]; then
dinfo "*** Resolving executable dependencies ***" dinfo "*** Resolving executable dependencies ***"
find "$initdir" -type f \ find "$initdir" -type f \
'(' -perm -0100 -or -perm -0010 -or -perm -0001 ')' \ '(' -perm -0100 -or -perm -0010 -or -perm -0001 ')' \
-not -path '*.ko' -print0 \ -not -path '*.ko' -print0 \
| xargs -r -0 $DRACUT_INSTALL ${initdir+-D "$initdir"} -R ${DRACUT_FIPS_MODE+-H} | xargs -r -0 $DRACUT_INSTALL ${initdir+-D "$initdir"} -R ${DRACUT_FIPS_MODE+-H} --
dinfo "*** Resolving executable dependencies done***" dinfo "*** Resolving executable dependencies done***"
fi fi
fi fi
@@ -997,26 +1167,22 @@ if [[ $kernel_only != yes ]]; then
fi fi
fi fi
if (($maxloglvl >= 5)); then if (( maxloglvl >= 5 )); then
ddebug "Listing sizes of included files:" ddebug "Listing sizes of included files:"
du -c "$initdir" | sort -n | ddebug du -c "$initdir" | sort -n | ddebug
fi fi
PRELINK_BIN=$(command -v prelink) PRELINK_BIN="$(command -v prelink)"
if [[ $UID = 0 ]] && [[ $PRELINK_BIN ]]; then if [[ $UID = 0 ]] && [[ $PRELINK_BIN ]]; then
if [[ $DRACUT_FIPS_MODE ]]; then if [[ $DRACUT_FIPS_MODE ]]; then
dinfo "*** Pre-unlinking files ***" dinfo "*** Installing prelink files ***"
dracut_install -o prelink /etc/prelink.conf /etc/prelink.conf.d/*.conf /etc/prelink.cache dracut_install -o prelink /etc/prelink.conf /etc/prelink.conf.d/*.conf /etc/prelink.cache
chroot "$initdir" $PRELINK_BIN -u -a
rm -f "$initdir"/$PRELINK_BIN
rm -fr "$initdir"/etc/prelink.*
dinfo "*** Pre-unlinking files done ***"
else else
dinfo "*** Pre-linking files ***" dinfo "*** Pre-linking files ***"
dracut_install -o prelink /etc/prelink.conf /etc/prelink.conf.d/*.conf dracut_install -o prelink /etc/prelink.conf /etc/prelink.conf.d/*.conf
chroot "$initdir" $PRELINK_BIN -a chroot "$initdir" "$PRELINK_BIN" -a
rm -f "$initdir"/$PRELINK_BIN rm -f -- "$initdir/$PRELINK_BIN"
rm -fr "$initdir"/etc/prelink.* rm -fr -- "$initdir"/etc/prelink.*
dinfo "*** Pre-linking files done ***" dinfo "*** Pre-linking files done ***"
fi fi
fi fi
@@ -1031,7 +1197,7 @@ fi
if [[ $do_strip = yes ]] ; then if [[ $do_strip = yes ]] ; then
for p in strip xargs find; do for p in strip xargs find; do
if ! type -P $p >/dev/null; then if ! type -P $p >/dev/null; then
derror "Could not find '$p'. You should run $0 with '--nostrip'." dinfo "Could not find '$p'. Not stripping the initramfs."
do_strip=no do_strip=no
fi fi
done done
@@ -1041,31 +1207,69 @@ if [[ $do_strip = yes ]] ; then
dinfo "*** Stripping files ***" dinfo "*** Stripping files ***"
if [[ $DRACUT_FIPS_MODE ]]; then if [[ $DRACUT_FIPS_MODE ]]; then
find "$initdir" -type f \ find "$initdir" -type f \
'(' -perm -0100 -or -perm -0010 -or -perm -0001 \ -executable -not -path '*/lib/modules/*.ko' -print0 \
-or -path '*/lib/modules/*.ko' ')' -print0 \
| while read -r -d $'\0' f; do | while read -r -d $'\0' f; do
if ! [[ -e "${f%/*}/.${f##*/}.hmac" ]] \ if ! [[ -e "${f%/*}/.${f##*/}.hmac" ]] \
&& ! [[ -e "/lib/hmaccalc/${f##*/}.hmac" ]] \
&& ! [[ -e "/lib64/hmaccalc/${f##*/}.hmac" ]] \
&& ! [[ -e "/lib/fipscheck/${f##*/}.hmac" ]] \ && ! [[ -e "/lib/fipscheck/${f##*/}.hmac" ]] \
&& ! [[ -e "/lib64/fipscheck/${f##*/}.hmac" ]]; then && ! [[ -e "/lib64/fipscheck/${f##*/}.hmac" ]]; then
echo -n "$f"; echo -n -e "\000" printf "%s\000" "$f";
fi fi
done |xargs -r -0 strip -g 2>/dev/null done | xargs -r -0 strip -g 2>/dev/null
else else
find "$initdir" -type f \ find "$initdir" -type f \
'(' -perm -0100 -or -perm -0010 -or -perm -0001 \ -executable -not -path '*/lib/modules/*.ko' -print0 \
-or -path '*/lib/modules/*.ko' ')' -print0 \
| xargs -r -0 strip -g 2>/dev/null | xargs -r -0 strip -g 2>/dev/null
fi fi
# strip kernel modules, but do not touch signed modules
find "$initdir" -type f -path '*/lib/modules/*.ko' -print0 \
| while read -r -d $'\0' f; do
SIG=$(tail -c 28 "$f")
[[ $SIG == '~Module signature appended~' ]] || { printf "%s\000" "$f"; }
done | xargs -r -0 strip -g
dinfo "*** Stripping files done ***" dinfo "*** Stripping files done ***"
fi fi
if [[ $early_microcode = yes ]]; then
rm -f "$outfile" dinfo "*** Generating early-microcode cpio image ***"
ucode_dir=(amd-ucode intel-ucode)
ucode_dest=(AuthenticAMD.bin GenuineIntel.bin)
_dest_dir="$microcode_dir/d/kernel/x86/microcode"
_dest_idx="0 1"
mkdir -p $_dest_dir
if [[ $hostonly ]]; then
[[ $(get_cpu_vendor) == "AMD" ]] && _dest_idx="0"
[[ $(get_cpu_vendor) == "Intel" ]] && _dest_idx="1"
fi
for idx in $_dest_idx; do
_fw=${ucode_dir[$idx]}
for _fwdir in $fw_dir; do
if [[ -d $_fwdir && -d $_fwdir/$_fw ]]; then
_src="*"
dinfo "*** Constructing ${ucode_dest[$idx]} ****"
if [[ $hostonly ]]; then
_src=$(get_ucode_file)
fi
cat $_fwdir/$_fw/$_src > $_dest_dir/${ucode_dest[$idx]}
fi
done
done
(cd "$microcode_dir/d"; find . | cpio -o -H newc --quiet >../ucode.cpio)
fi
rm -f -- "$outfile"
dinfo "*** Creating image file ***" dinfo "*** Creating image file ***"
if [[ $early_microcode = yes ]]; then
# The microcode blob is _before_ the initramfs blob, not after
mv $microcode_dir/ucode.cpio $outfile.$$
fi
if ! ( umask 077; cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet| \ if ! ( umask 077; cd "$initdir"; find . |cpio -R 0:0 -H newc -o --quiet| \
$compress > "$outfile"; ); then $compress >> "$outfile.$$"; ); then
dfatal "dracut: creation of $outfile failed" dfatal "dracut: creation of $outfile.$$ failed"
exit 1 exit 1
fi fi
mv -- "$outfile.$$" "$outfile"
dinfo "*** Creating image file done ***" dinfo "*** Creating image file done ***"
dinfo "Wrote $outfile:" dinfo "Wrote $outfile:"

View File

@@ -30,11 +30,17 @@ URL: https://dracut.wiki.kernel.org/
# http://git.kernel.org/?p=boot/dracut/dracut.git;a=snapshot;h=%{version};sf=tgz # http://git.kernel.org/?p=boot/dracut/dracut.git;a=snapshot;h=%{version};sf=tgz
Source0: http://www.kernel.org/pub/linux/utils/boot/dracut/dracut-%{version}.tar.bz2 Source0: http://www.kernel.org/pub/linux/utils/boot/dracut/dracut-%{version}.tar.bz2
BuildRequires: dash bash git BuildRequires: bash git
%if 0%{?fedora} || 0%{?rhel} %if 0%{?fedora} || 0%{?rhel}
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: pkgconfig
%endif %endif
%if 0%{?fedora}
BuildRequires: bash-completion
BuildRequires: pkgconfig
%endif
%if 0%{?suse_version} %if 0%{?suse_version}
BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif %endif
@@ -70,7 +76,11 @@ Provides: mkinitrd = 2.6.1
Obsoletes: dracut-kernel < 005 Obsoletes: dracut-kernel < 005
Provides: dracut-kernel = %{version}-%{release} Provides: dracut-kernel = %{version}-%{release}
Requires: bash Obsoletes: dracut <= 029
Obsoletes: dracut-norescue
Provides: dracut-horescue
Requires: bash >= 4
Requires: coreutils Requires: coreutils
Requires: cpio Requires: cpio
Requires: filesystem >= 2.1.0 Requires: filesystem >= 2.1.0
@@ -78,16 +88,16 @@ Requires: findutils
Requires: grep Requires: grep
Requires: hardlink Requires: hardlink
Requires: gzip xz Requires: gzip xz
Requires: module-init-tools >= 3.7-9 Requires: kmod
Requires: sed Requires: sed
Requires: file
Requires: kpartx Requires: kpartx
Requires: udev > 166
Requires: kbd kbd-misc
%if 0%{?fedora} || 0%{?rhel} > 6 %if 0%{?fedora} || 0%{?rhel} > 6
Requires: util-linux >= 2.21 Requires: util-linux >= 2.21
Conflicts: systemd < 187 Requires: systemd >= 199
Conflicts: grubby < 8.23
%else %else
Requires: udev > 166
Requires: util-linux-ng >= 2.21 Requires: util-linux-ng >= 2.21
%endif %endif
@@ -96,6 +106,8 @@ Conflicts: initscripts < 8.63-1
Conflicts: plymouth < 0.8.0-0.2009.29.09.19.1 Conflicts: plymouth < 0.8.0-0.2009.29.09.19.1
%endif %endif
Conflicts: mdadm < 3.2.6-14
%description %description
dracut contains tools to create a bootable initramfs for 2.6 Linux kernels. dracut contains tools to create a bootable initramfs for 2.6 Linux kernels.
Unlike existing implementations, dracut does hard-code as little as possible Unlike existing implementations, dracut does hard-code as little as possible
@@ -106,6 +118,8 @@ NFS, iSCSI, NBD, FCoE with the dracut-network package.
%package network %package network
Summary: dracut modules to build a dracut initramfs with network support Summary: dracut modules to build a dracut initramfs with network support
Requires: %{name} = %{version}-%{release} Requires: %{name} = %{version}-%{release}
Requires: iputils
Requires: iproute
Obsoletes: dracut-generic < 008 Obsoletes: dracut-generic < 008
Provides: dracut-generic = %{version}-%{release} Provides: dracut-generic = %{version}-%{release}
@@ -128,7 +142,7 @@ Requires: nss-softokn-freebl
%description fips %description fips
This package requires everything which is needed to build an This package requires everything which is needed to build an
all purpose initramfs with dracut, which does an integrity check. initramfs with dracut, which does an integrity check.
%endif %endif
%package fips-aesni %package fips-aesni
@@ -137,8 +151,7 @@ Requires: %{name}-fips = %{version}-%{release}
%description fips-aesni %description fips-aesni
This package requires everything which is needed to build an This package requires everything which is needed to build an
all purpose initramfs with dracut, which does an integrity check initramfs with dracut, which does an integrity check and adds the aesni-intel kernel module.
and adds the aesni-intel kernel module.
%package caps %package caps
Summary: dracut modules to build a dracut initramfs which drops capabilities Summary: dracut modules to build a dracut initramfs which drops capabilities
@@ -147,7 +160,26 @@ Requires: libcap
%description caps %description caps
This package requires everything which is needed to build an This package requires everything which is needed to build an
all purpose initramfs with dracut, which drops capabilities. initramfs with dracut, which drops capabilities.
%package config-generic
Summary: dracut configuration to turn off hostonly image generation
Requires: %{name} = %{version}-%{release}
Obsoletes: dracut-nohostonly
Provides: dracut-nohostonly
%description config-generic
This package provides the configuration to turn off the host specific initramfs
generation with dracut and generates a generic image by default.
%package config-rescue
Summary: dracut configuration to turn on rescue image generation
Requires: %{name} = %{version}-%{release}
Obsoletes: dracut <= 029
%description config-rescue
This package provides the configuration to turn on the rescue initramfs
generation with dracut.
%package tools %package tools
Summary: dracut tools to build the local initramfs Summary: dracut tools to build the local initramfs
@@ -171,39 +203,41 @@ git am -p1 %{patches}
%endif %endif
%build %build
make all %configure --systemdsystemunitdir=%{_unitdir} --bashcompletiondir=$(pkg-config --variable=completionsdir bash-completion) --libdir=%{_prefix}/lib
make %{?_smp_mflags}
%install %install
%if 0%{?fedora} || 0%{?rhel} %if 0%{?fedora} || 0%{?rhel}
rm -rf $RPM_BUILD_ROOT rm -rf -- $RPM_BUILD_ROOT
%endif %endif
make install DESTDIR=$RPM_BUILD_ROOT \ make %{?_smp_mflags} install \
libdir=%{_prefix}/lib \ DESTDIR=$RPM_BUILD_ROOT \
bindir=%{_bindir} \ libdir=%{_prefix}/lib
%if %{defined _unitdir}
systemdsystemunitdir=%{_unitdir} \
%endif
sysconfdir=/etc mandir=%{_mandir}
echo "DRACUT_VERSION=%{version}-%{release}" > $RPM_BUILD_ROOT/%{dracutlibdir}/dracut-version.sh echo "DRACUT_VERSION=%{version}-%{release}" > $RPM_BUILD_ROOT/%{dracutlibdir}/dracut-version.sh
%if 0%{?fedora} == 0 && 0%{?rhel} == 0 && 0%{?suse_version} == 0 %if 0%{?fedora} == 0 && 0%{?rhel} == 0 && 0%{?suse_version} == 0
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/01fips rm -fr -- $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/01fips
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/02fips-aesni rm -fr -- $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/02fips-aesni
%endif
%if %{defined _unitdir}
# for systemd, better use systemd-bootchart
rm -fr -- $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/00bootchart
%endif %endif
# we do not support dash in the initramfs # we do not support dash in the initramfs
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/00dash rm -fr -- $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/00dash
# remove gentoo specific modules # remove gentoo specific modules
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/50gensplash rm -fr -- $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/50gensplash
%if %{defined _unitdir} %if %{defined _unitdir}
# with systemd IMA and selinux modules do not make sense # with systemd IMA and selinux modules do not make sense
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/96securityfs rm -fr -- $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/96securityfs
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/97masterkey rm -fr -- $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/97masterkey
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/98integrity rm -fr -- $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/98integrity
rm -fr $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/98selinux
%endif %endif
mkdir -p $RPM_BUILD_ROOT/boot/dracut mkdir -p $RPM_BUILD_ROOT/boot/dracut
@@ -213,28 +247,37 @@ touch $RPM_BUILD_ROOT%{_localstatedir}/log/dracut.log
mkdir -p $RPM_BUILD_ROOT%{_sharedstatedir}/initramfs mkdir -p $RPM_BUILD_ROOT%{_sharedstatedir}/initramfs
%if 0%{?fedora} || 0%{?rhel} || 0%{?suse_version} %if 0%{?fedora} || 0%{?rhel} || 0%{?suse_version}
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/fedora.conf.example $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/01-dist.conf
install -m 0644 dracut.conf.d/fips.conf.example $RPM_BUILD_ROOT/etc/dracut.conf.d/40-fips.conf install -m 0644 dracut.conf.d/fips.conf.example $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/40-fips.conf
%endif %endif
%if 0%{?suse_version} %if 0%{?suse_version}
install -m 0644 dracut.conf.d/suse.conf.example $RPM_BUILD_ROOT/etc/dracut.conf.d/01-dist.conf install -m 0644 dracut.conf.d/suse.conf.example $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/01-dist.conf
%endif %endif
%if 0%{?fedora} <= 12 && 0%{?rhel} < 6 && 0%{?suse_version} <= 9999 %if 0%{?fedora} <= 12 && 0%{?rhel} < 6 && 0%{?suse_version} <= 9999
rm $RPM_BUILD_ROOT%{_bindir}/mkinitrd rm -f -- $RPM_BUILD_ROOT%{_bindir}/mkinitrd
rm $RPM_BUILD_ROOT%{_bindir}/lsinitrd rm -f -- $RPM_BUILD_ROOT%{_bindir}/lsinitrd
%endif %endif
mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d %if 0%{?fedora} || 0%{?rhel} > 6
install -m 0644 dracut.logrotate $RPM_BUILD_ROOT/etc/logrotate.d/dracut_log # FIXME: remove after F19
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/kernel/postinst.d
install -m 0755 51-dracut-rescue-postinst.sh $RPM_BUILD_ROOT%{_sysconfdir}/kernel/postinst.d/51-dracut-rescue-postinst.sh
echo 'hostonly="no"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/02-generic-image.conf
echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/02-rescue.conf
%endif
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d
install -m 0644 dracut.logrotate $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/dracut_log
# create compat symlink # create compat symlink
mkdir -p $RPM_BUILD_ROOT/sbin mkdir -p $RPM_BUILD_ROOT/sbin
ln -s /usr/bin/dracut $RPM_BUILD_ROOT/sbin/dracut ln -s /usr/bin/dracut $RPM_BUILD_ROOT/sbin/dracut
%clean %clean
rm -rf $RPM_BUILD_ROOT rm -rf -- $RPM_BUILD_ROOT
%files %files
%defattr(-,root,root,0755) %defattr(-,root,root,0755)
@@ -242,6 +285,8 @@ rm -rf $RPM_BUILD_ROOT
%{_bindir}/dracut %{_bindir}/dracut
# compat symlink # compat symlink
/sbin/dracut /sbin/dracut
%{_datadir}/bash-completion/completions/dracut
%{_datadir}/bash-completion/completions/lsinitrd
%if 0%{?fedora} > 12 || 0%{?rhel} >= 6 || 0%{?suse_version} > 9999 %if 0%{?fedora} > 12 || 0%{?rhel} >= 6 || 0%{?suse_version} > 9999
%{_bindir}/mkinitrd %{_bindir}/mkinitrd
%{_bindir}/lsinitrd %{_bindir}/lsinitrd
@@ -254,11 +299,12 @@ rm -rf $RPM_BUILD_ROOT
%{dracutlibdir}/dracut-logger.sh %{dracutlibdir}/dracut-logger.sh
%{dracutlibdir}/dracut-initramfs-restore %{dracutlibdir}/dracut-initramfs-restore
%{dracutlibdir}/dracut-install %{dracutlibdir}/dracut-install
%config(noreplace) /etc/dracut.conf %config(noreplace) %{_sysconfdir}/dracut.conf
%if 0%{?fedora} || 0%{?suse_version} || 0%{?rhel} %if 0%{?fedora} || 0%{?suse_version} || 0%{?rhel}
%config /etc/dracut.conf.d/01-dist.conf %{dracutlibdir}/dracut.conf.d/01-dist.conf
%endif %endif
%dir /etc/dracut.conf.d %dir %{_sysconfdir}/dracut.conf.d
%dir %{dracutlibdir}/dracut.conf.d
%{_mandir}/man8/dracut.8* %{_mandir}/man8/dracut.8*
%{_mandir}/man8/*service.8* %{_mandir}/man8/*service.8*
%if 0%{?fedora} > 12 || 0%{?rhel} >= 6 || 0%{?suse_version} > 9999 %if 0%{?fedora} > 12 || 0%{?rhel} >= 6 || 0%{?suse_version} > 9999
@@ -267,13 +313,20 @@ rm -rf $RPM_BUILD_ROOT
%endif %endif
%{_mandir}/man7/dracut.kernel.7* %{_mandir}/man7/dracut.kernel.7*
%{_mandir}/man7/dracut.cmdline.7* %{_mandir}/man7/dracut.cmdline.7*
%{_mandir}/man7/dracut.bootup.7*
%{_mandir}/man5/dracut.conf.5* %{_mandir}/man5/dracut.conf.5*
%if %{defined _unitdir}
%{dracutlibdir}/modules.d/00systemd-bootchart
%else
%{dracutlibdir}/modules.d/00bootchart %{dracutlibdir}/modules.d/00bootchart
%endif
%{dracutlibdir}/modules.d/03rescue
%{dracutlibdir}/modules.d/04watchdog %{dracutlibdir}/modules.d/04watchdog
%{dracutlibdir}/modules.d/05busybox %{dracutlibdir}/modules.d/05busybox
%{dracutlibdir}/modules.d/10i18n %{dracutlibdir}/modules.d/10i18n
%{dracutlibdir}/modules.d/30convertfs %{dracutlibdir}/modules.d/30convertfs
%{dracutlibdir}/modules.d/45url-lib %{dracutlibdir}/modules.d/45url-lib
%{dracutlibdir}/modules.d/50drm
%{dracutlibdir}/modules.d/50plymouth %{dracutlibdir}/modules.d/50plymouth
%{dracutlibdir}/modules.d/80cms %{dracutlibdir}/modules.d/80cms
%{dracutlibdir}/modules.d/90btrfs %{dracutlibdir}/modules.d/90btrfs
@@ -301,12 +354,12 @@ rm -rf $RPM_BUILD_ROOT
%if %{undefined _unitdir} %if %{undefined _unitdir}
%{dracutlibdir}/modules.d/96securityfs %{dracutlibdir}/modules.d/96securityfs
%{dracutlibdir}/modules.d/97masterkey %{dracutlibdir}/modules.d/97masterkey
%{dracutlibdir}/modules.d/98selinux
%{dracutlibdir}/modules.d/98integrity %{dracutlibdir}/modules.d/98integrity
%endif %endif
%{dracutlibdir}/modules.d/97biosdevname %{dracutlibdir}/modules.d/97biosdevname
%{dracutlibdir}/modules.d/98ecryptfs %{dracutlibdir}/modules.d/98ecryptfs
%{dracutlibdir}/modules.d/98pollcdrom %{dracutlibdir}/modules.d/98pollcdrom
%{dracutlibdir}/modules.d/98selinux
%{dracutlibdir}/modules.d/98syslog %{dracutlibdir}/modules.d/98syslog
%{dracutlibdir}/modules.d/98systemd %{dracutlibdir}/modules.d/98systemd
%{dracutlibdir}/modules.d/98usrmount %{dracutlibdir}/modules.d/98usrmount
@@ -314,12 +367,30 @@ rm -rf $RPM_BUILD_ROOT
%{dracutlibdir}/modules.d/99fs-lib %{dracutlibdir}/modules.d/99fs-lib
%{dracutlibdir}/modules.d/99img-lib %{dracutlibdir}/modules.d/99img-lib
%{dracutlibdir}/modules.d/99shutdown %{dracutlibdir}/modules.d/99shutdown
%config(noreplace) /etc/logrotate.d/dracut_log %config(noreplace) %{_sysconfdir}/logrotate.d/dracut_log
%attr(0644,root,root) %ghost %config(missingok,noreplace) %{_localstatedir}/log/dracut.log %attr(0644,root,root) %ghost %config(missingok,noreplace) %{_localstatedir}/log/dracut.log
%dir %{_sharedstatedir}/initramfs %dir %{_sharedstatedir}/initramfs
%if %{defined _unitdir} %if %{defined _unitdir}
%{_unitdir}/dracut-shutdown.service %{_unitdir}/dracut-shutdown.service
%{_unitdir}/shutdown.target.wants/dracut-shutdown.service %{_unitdir}/shutdown.target.wants/dracut-shutdown.service
%{_unitdir}/dracut-cmdline.service
%{_unitdir}/dracut-initqueue.service
%{_unitdir}/dracut-mount.service
%{_unitdir}/dracut-pre-mount.service
%{_unitdir}/dracut-pre-pivot.service
%{_unitdir}/dracut-pre-trigger.service
%{_unitdir}/dracut-pre-udev.service
%{_unitdir}/initrd.target.wants/dracut-cmdline.service
%{_unitdir}/initrd.target.wants/dracut-initqueue.service
%{_unitdir}/initrd.target.wants/dracut-mount.service
%{_unitdir}/initrd.target.wants/dracut-pre-mount.service
%{_unitdir}/initrd.target.wants/dracut-pre-pivot.service
%{_unitdir}/initrd.target.wants/dracut-pre-trigger.service
%{_unitdir}/initrd.target.wants/dracut-pre-udev.service
%endif
%if 0%{?fedora} || 0%{?rhel} > 6
%{_prefix}/lib/kernel/install.d/50-dracut.install
%endif %endif
%files network %files network
@@ -340,7 +411,7 @@ rm -rf $RPM_BUILD_ROOT
%files fips %files fips
%defattr(-,root,root,0755) %defattr(-,root,root,0755)
%{dracutlibdir}/modules.d/01fips %{dracutlibdir}/modules.d/01fips
%config(noreplace) /etc/dracut.conf.d/40-fips.conf %{dracutlibdir}/dracut.conf.d/40-fips.conf
%endif %endif
%files fips-aesni %files fips-aesni
@@ -360,4 +431,16 @@ rm -rf $RPM_BUILD_ROOT
%dir /var/lib/dracut %dir /var/lib/dracut
%dir /var/lib/dracut/overlay %dir /var/lib/dracut/overlay
%files config-generic
%defattr(-,root,root,0755)
%{dracutlibdir}/dracut.conf.d/02-generic-image.conf
%files config-rescue
%defattr(-,root,root,0755)
%{dracutlibdir}/dracut.conf.d/02-rescue.conf
%if 0%{?fedora} || 0%{?rhel} > 6
%{_prefix}/lib/kernel/install.d/51-dracut-rescue.install
%{_sysconfdir}/kernel/postinst.d/51-dracut-rescue-postinst.sh
%endif
%changelog %changelog

View File

@@ -1,21 +1,5 @@
#!/usr/bin/perl #!/usr/bin/perl
sub last_tag {
open( GIT, 'git log --pretty=format:%H |');
LINE: while( <GIT> ) {
open( GIT2, "git tag --contains $_ |");
while( <GIT2> ) {
chomp;
last LINE if /..*/;
}
close GIT2;
}
$tag=$_;
close GIT2;
close GIT; # be done
return $tag;
};
sub create_patches { sub create_patches {
my $tag=shift; my $tag=shift;
my $pdir=shift; my $pdir=shift;
@@ -31,7 +15,8 @@ my $datestr = strftime "%Y%m%d", gmtime;
my $tag=shift; my $tag=shift;
my $pdir=shift; my $pdir=shift;
$tag=&last_tag if not defined $tag; $tag=`git describe --abbrev=0 --tags` if not defined $tag;
chomp($tag);
my @patches=&create_patches($tag, $pdir); my @patches=&create_patches($tag, $pdir);
my $num=$#patches + 2; my $num=$#patches + 2;
$tag=~s/[^0-9]+?([0-9]+)/$1/; $tag=~s/[^0-9]+?([0-9]+)/$1/;

View File

@@ -62,6 +62,10 @@ static int dracut_install(const char *src, const char *dst, bool isdir, bool res
static size_t dir_len(char const *file) static size_t dir_len(char const *file)
{ {
size_t length; size_t length;
if(!file)
return 0;
/* Strip the basename and any redundant slashes before it. */ /* Strip the basename and any redundant slashes before it. */
for (length = strlen(file)-1; 0 < length; length--) for (length = strlen(file)-1; 0 < length; length--)
if (file[length] == '/' && file[length-1] != '/') if (file[length] == '/' && file[length-1] != '/')
@@ -73,20 +77,23 @@ static char *convert_abs_rel(const char *from, const char *target)
{ {
/* we use the 4*MAXPATHLEN, which should not overrun */ /* we use the 4*MAXPATHLEN, which should not overrun */
char relative_from[MAXPATHLEN * 4]; char relative_from[MAXPATHLEN * 4];
char *realtarget = NULL; _cleanup_free_ char *realtarget = NULL;
char *p, *q; _cleanup_free_ char *target_dir_p = NULL, *realpath_p = NULL;
const char *realfrom = from; const char *realfrom = from;
int level = 0, fromlevel = 0, targetlevel = 0; size_t level = 0, fromlevel = 0, targetlevel = 0;
int l, i, rl; int l;
int dirlen; size_t i, rl, dirlen;
int ret;
p = strdup(target); target_dir_p = strdup(target);
dirlen = dir_len(p); if (!target_dir_p)
p[dirlen] = '\0'; return strdup(from);
q = realpath(p, NULL);
if (q == NULL) { dirlen = dir_len(target_dir_p);
free(p); target_dir_p[dirlen] = '\0';
realpath_p = realpath(target_dir_p, NULL);
if (realpath_p == NULL) {
log_warning("convert_abs_rel(): target '%s' directory has no realpath.", target); log_warning("convert_abs_rel(): target '%s' directory has no realpath.", target);
return strdup(from); return strdup(from);
} }
@@ -95,11 +102,13 @@ static char *convert_abs_rel(const char *from, const char *target)
* character - need to skip all leading /'s */ * character - need to skip all leading /'s */
rl = strlen(target); rl = strlen(target);
for (i = dirlen+1; i < rl; ++i) for (i = dirlen+1; i < rl; ++i)
if (p[i] != '/') if (target_dir_p[i] != '/')
break; break;
asprintf(&realtarget, "%s/%s", q, &p[i]); ret = asprintf(&realtarget, "%s/%s", realpath_p, &target_dir_p[i]);
free(p); if (ret < 0) {
free(q); log_error("Out of memory!");
exit(EXIT_FAILURE);
}
/* now calculate the relative path from <from> to <target> and /* now calculate the relative path from <from> to <target> and
store it in <relative_from> store it in <relative_from>
@@ -122,8 +131,6 @@ static char *convert_abs_rel(const char *from, const char *target)
if (realtarget[i] == '/') if (realtarget[i] == '/')
level++; level++;
free(realtarget);
/* add "../" to the relative_from path, until the common pathname is /* add "../" to the relative_from path, until the common pathname is
reached */ reached */
for (i = level; i < targetlevel; i++) { for (i = level; i < targetlevel; i++) {
@@ -155,18 +162,16 @@ static char *convert_abs_rel(const char *from, const char *target)
static int ln_r(const char *src, const char *dst) static int ln_r(const char *src, const char *dst)
{ {
int ret; int ret;
const char *points_to = convert_abs_rel(src, dst); _cleanup_free_ const char *points_to = convert_abs_rel(src, dst);
log_info("ln -s '%s' '%s'", points_to, dst); log_info("ln -s '%s' '%s'", points_to, dst);
ret = symlink(points_to, dst); ret = symlink(points_to, dst);
if (ret != 0) { if (ret != 0) {
log_error("ERROR: ln -s '%s' '%s': %m", points_to, dst); log_error("ERROR: ln -s '%s' '%s': %m", points_to, dst);
free((char *)points_to);
return 1; return 1;
} }
free((char *)points_to);
return 0; return 0;
} }
@@ -186,11 +191,11 @@ static bool use_clone = true;
static int cp(const char *src, const char *dst) static int cp(const char *src, const char *dst)
{ {
int pid; int pid;
int ret; int ret = 0;
if (use_clone) { if (use_clone) {
struct stat sb; struct stat sb;
int dest_desc, source_desc; _cleanup_close_ int dest_desc = -1, source_desc = -1;
if (lstat(src, &sb) != 0) if (lstat(src, &sb) != 0)
goto normal_copy; goto normal_copy;
@@ -207,20 +212,24 @@ static int cp(const char *src, const char *dst)
(sb.st_mode) & (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)); (sb.st_mode) & (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO));
if (dest_desc < 0) { if (dest_desc < 0) {
close(source_desc);
goto normal_copy; goto normal_copy;
} }
ret = clone_file(dest_desc, source_desc); ret = clone_file(dest_desc, source_desc);
close(source_desc);
if (ret == 0) { if (ret == 0) {
struct timeval tv[2];
if (fchown(dest_desc, sb.st_uid, sb.st_gid) != 0) if (fchown(dest_desc, sb.st_uid, sb.st_gid) != 0)
fchown(dest_desc, -1, sb.st_gid); fchown(dest_desc, (__uid_t)-1, sb.st_gid);
close(dest_desc); tv[0].tv_sec = sb.st_atime;
tv[0].tv_usec = 0;
tv[1].tv_sec = sb.st_mtime;
tv[1].tv_usec = 0;
futimes(dest_desc, tv);
return ret; return ret;
} }
close(dest_desc); close(dest_desc);
dest_desc = -1;
/* clone did not work, remove the file */ /* clone did not work, remove the file */
unlink(dst); unlink(dst);
/* do not try clone again */ /* do not try clone again */
@@ -230,16 +239,83 @@ static int cp(const char *src, const char *dst)
normal_copy: normal_copy:
pid = fork(); pid = fork();
if (pid == 0) { if (pid == 0) {
execlp("cp", "cp", "--reflink=auto", "--sparse=auto", "--preserve=mode", "-fL", src, dst, NULL); execlp("cp", "cp", "--reflink=auto", "--sparse=auto", "--preserve=mode,timestamps", "-fL", src, dst, NULL);
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);
} }
while (waitpid(pid, &ret, 0) < 0) { while (waitpid(pid, &ret, 0) < 0) {
if (errno != EINTR) { if (errno != EINTR) {
ret = -1; ret = -1;
log_error("Failed: cp --reflink=auto --sparse=auto --preserve=mode,timestamps -fL %s %s", src, dst);
break; break;
} }
} }
log_debug("cp ret = %d", ret);
return ret;
}
static int library_install(const char *src, const char *lib)
{
_cleanup_free_ char *p = NULL;
_cleanup_free_ char *pdir = NULL, *ppdir = NULL, *clib = NULL;
char *q;
int r, ret = 0;
p = strdup(lib);
r = dracut_install(p, p, false, false, true);
if (r != 0)
log_error("ERROR: failed to install '%s' for '%s'", p, src);
else
log_debug("Lib install: '%s'", p);
ret += r;
/* also install lib.so for lib.so.* files */
q = strstr(p, ".so.");
if (q) {
q[3] = '\0';
/* ignore errors for base lib symlink */
if (dracut_install(p, p, false, false, true) == 0)
log_debug("Lib install: '%s'", p);
}
/* Also try to install the same library from one directory above.
This fixes the case, where only the HWCAP lib would be installed
# ldconfig -p|fgrep libc.so
libc.so.6 (libc6,64bit, hwcap: 0x0000001000000000, OS ABI: Linux 2.6.32) => /lib64/power6/libc.so.6
libc.so.6 (libc6,64bit, hwcap: 0x0000000000000200, OS ABI: Linux 2.6.32) => /lib64/power6x/libc.so.6
libc.so.6 (libc6,64bit, OS ABI: Linux 2.6.32) => /lib64/libc.so.6
*/
free(p);
p = strdup(lib);
pdir = dirname(p);
if (!pdir)
return ret;
pdir = strdup(pdir);
ppdir = dirname(pdir);
if (!ppdir)
return ret;
ppdir = strdup(ppdir);
strcpy(p, lib);
clib = strjoin(ppdir, "/", basename(p), NULL);
if (dracut_install(clib, clib, false, false, true) == 0)
log_debug("Lib install: '%s'", clib);
/* also install lib.so for lib.so.* files */
q = strstr(clib, ".so.");
if (q) {
q[3] = '\0';
/* ignore errors for base lib symlink */
if (dracut_install(clib, clib, false, false, true) == 0)
log_debug("Lib install: '%s'", p);
}
return ret; return ret;
} }
@@ -248,17 +324,19 @@ static int resolve_deps(const char *src)
{ {
int ret = 0; int ret = 0;
char *buf = malloc(LINE_MAX); _cleanup_free_ char *buf = malloc(LINE_MAX);
size_t linesize = LINE_MAX; size_t linesize = LINE_MAX;
FILE *fptr; _cleanup_pclose_ FILE *fptr = NULL;
char *cmd; _cleanup_free_ char *cmd = NULL;
if (strstr(src, ".so") == 0) { if (strstr(src, ".so") == 0) {
int fd; _cleanup_close_ int fd = -1;
fd = open(src, O_RDONLY | O_CLOEXEC); fd = open(src, O_RDONLY | O_CLOEXEC);
if (fd < 0)
return -errno;
read(fd, buf, LINE_MAX); read(fd, buf, LINE_MAX);
buf[LINE_MAX - 1] = '\0'; buf[LINE_MAX - 1] = '\0';
close(fd);
if (buf[0] == '#' && buf[1] == '!') { if (buf[0] == '#' && buf[1] == '!') {
/* we have a shebang */ /* we have a shebang */
char *p, *q; char *p, *q;
@@ -274,7 +352,14 @@ static int resolve_deps(const char *src)
} }
/* run ldd */ /* run ldd */
asprintf(&cmd, "ldd %s 2>&1", src); ret = asprintf(&cmd, "ldd %s 2>&1", src);
if (ret < 0) {
log_error("Out of memory!");
exit(EXIT_FAILURE);
}
ret = 0;
fptr = popen(cmd, "r"); fptr = popen(cmd, "r");
while (!feof(fptr)) { while (!feof(fptr)) {
@@ -285,6 +370,12 @@ static int resolve_deps(const char *src)
log_debug("ldd: '%s'", buf); log_debug("ldd: '%s'", buf);
if (strstr(buf, "you do not have execution permission")) {
log_error("%s", buf);
ret+=1;
break;
}
if (strstr(buf, "not a dynamic executable")) if (strstr(buf, "not a dynamic executable"))
break; break;
@@ -294,31 +385,21 @@ static int resolve_deps(const char *src)
if (strstr(buf, "not regular file")) if (strstr(buf, "not regular file"))
break; break;
p = strstr(buf, "/"); if (strstr(buf, "cannot read header"))
break;
if (strstr(buf, destrootdir))
break;
p = strchr(buf, '/');
if (p) { if (p) {
int r;
for (q = p; *q && *q != ' ' && *q != '\n'; q++) ; for (q = p; *q && *q != ' ' && *q != '\n'; q++) ;
*q = '\0'; *q = '\0';
r = dracut_install(p, p, false, false, true);
if (r != 0)
log_error("ERROR: failed to install '%s' for '%s'", p, src);
else
log_debug("Lib install: '%s'", p);
ret += r;
/* also install lib.so for lib.so.* files */ ret += library_install(src, p);
q = strstr(p, ".so.");
if (q) {
q += 3;
*q = '\0';
/* ignore errors for base lib symlink */
if (dracut_install(p, p, false, false, true) == 0)
log_debug("Lib install: '%s'", p);
}
} }
} }
pclose(fptr);
return ret; return ret;
} }
@@ -326,10 +407,15 @@ static int resolve_deps(const char *src)
/* Install ".<filename>.hmac" file for FIPS self-checks */ /* Install ".<filename>.hmac" file for FIPS self-checks */
static int hmac_install(const char *src, const char *dst, const char *hmacpath) static int hmac_install(const char *src, const char *dst, const char *hmacpath)
{ {
char *srcpath = strdup(src); _cleanup_free_ char *srcpath = strdup(src);
char *dstpath = strdup(dst); _cleanup_free_ char *dstpath = strdup(dst);
char *srchmacname = NULL; _cleanup_free_ char *srchmacname = NULL;
char *dsthmacname = NULL; _cleanup_free_ char *dsthmacname = NULL;
int ret;
if (!(srcpath && dstpath))
return -ENOMEM;
size_t dlen = dir_len(src); size_t dlen = dir_len(src);
if (endswith(src, ".hmac")) if (endswith(src, ".hmac"))
@@ -338,35 +424,51 @@ static int hmac_install(const char *src, const char *dst, const char *hmacpath)
if (!hmacpath) { if (!hmacpath) {
hmac_install(src, dst, "/lib/fipscheck"); hmac_install(src, dst, "/lib/fipscheck");
hmac_install(src, dst, "/lib64/fipscheck"); hmac_install(src, dst, "/lib64/fipscheck");
hmac_install(src, dst, "/lib/hmaccalc");
hmac_install(src, dst, "/lib64/hmaccalc");
} }
srcpath[dlen] = '\0'; srcpath[dlen] = '\0';
dstpath[dir_len(dst)] = '\0'; dstpath[dir_len(dst)] = '\0';
if (hmacpath) { if (hmacpath) {
asprintf(&srchmacname, "%s/%s.hmac", hmacpath, &src[dlen + 1]); ret = asprintf(&srchmacname, "%s/%s.hmac", hmacpath, &src[dlen + 1]);
asprintf(&dsthmacname, "%s/%s.hmac", hmacpath, &src[dlen + 1]); if (ret < 0) {
log_error("Out of memory!");
exit(EXIT_FAILURE);
}
ret = asprintf(&dsthmacname, "%s/%s.hmac", hmacpath, &src[dlen + 1]);
if (ret < 0) {
log_error("Out of memory!");
exit(EXIT_FAILURE);
}
} else { } else {
asprintf(&srchmacname, "%s/.%s.hmac", srcpath, &src[dlen + 1]); ret = asprintf(&srchmacname, "%s/.%s.hmac", srcpath, &src[dlen + 1]);
asprintf(&dsthmacname, "%s/.%s.hmac", dstpath, &src[dlen + 1]); if (ret < 0) {
log_error("Out of memory!");
exit(EXIT_FAILURE);
}
ret = asprintf(&dsthmacname, "%s/.%s.hmac", dstpath, &src[dlen + 1]);
if (ret < 0) {
log_error("Out of memory!");
exit(EXIT_FAILURE);
}
} }
log_debug("hmac cp '%s' '%s')", srchmacname, dsthmacname); log_debug("hmac cp '%s' '%s')", srchmacname, dsthmacname);
dracut_install(srchmacname, dsthmacname, false, false, true); dracut_install(srchmacname, dsthmacname, false, false, true);
free(dsthmacname);
free(srchmacname);
free(srcpath);
free(dstpath);
return 0; return 0;
} }
static int dracut_install(const char *src, const char *dst, bool isdir, bool resolvedeps, bool hashdst) static int dracut_install(const char *src, const char *dst, bool isdir, bool resolvedeps, bool hashdst)
{ {
struct stat sb, db; struct stat sb, db;
char *dname = NULL; _cleanup_free_ char *fulldstpath = NULL;
char *fulldstpath = NULL; _cleanup_free_ char *fulldstdir = NULL;
char *fulldstdir = NULL;
int ret; int ret;
bool src_exists = true; bool src_exists = true;
char *i, *existing; char *i = NULL;
char *existing;
log_debug("dracut_install('%s', '%s')", src, dst); log_debug("dracut_install('%s', '%s')", src, dst);
@@ -399,9 +501,16 @@ static int dracut_install(const char *src, const char *dst, bool isdir, bool res
} }
i = strdup(dst); i = strdup(dst);
if (!i)
return -ENOMEM;
hashmap_put(items, i, i); hashmap_put(items, i, i);
asprintf(&fulldstpath, "%s%s", destrootdir, dst); ret = asprintf(&fulldstpath, "%s%s", destrootdir, dst);
if (ret < 0) {
log_error("Out of memory!");
exit(EXIT_FAILURE);
}
ret = stat(fulldstpath, &sb); ret = stat(fulldstpath, &sb);
@@ -417,7 +526,6 @@ static int dracut_install(const char *src, const char *dst, bool isdir, bool res
} else } else
log_debug("'%s' already exists", fulldstpath); log_debug("'%s' already exists", fulldstpath);
free(fulldstpath);
/* dst does already exist */ /* dst does already exist */
return ret; return ret;
} }
@@ -429,6 +537,8 @@ static int dracut_install(const char *src, const char *dst, bool isdir, bool res
ret = stat(fulldstdir, &db); ret = stat(fulldstdir, &db);
if (ret < 0) { if (ret < 0) {
_cleanup_free_ char *dname = NULL;
if (errno != ENOENT) { if (errno != ENOENT) {
log_error("ERROR: stat '%s': %m", fulldstdir); log_error("ERROR: stat '%s': %m", fulldstdir);
return 1; return 1;
@@ -436,35 +546,34 @@ static int dracut_install(const char *src, const char *dst, bool isdir, bool res
/* create destination directory */ /* create destination directory */
log_debug("dest dir '%s' does not exist", fulldstdir); log_debug("dest dir '%s' does not exist", fulldstdir);
dname = strdup(dst); dname = strdup(dst);
if (!dname)
return 1;
dname[dir_len(dname)] = '\0'; dname[dir_len(dname)] = '\0';
ret = dracut_install(dname, dname, true, false, true); ret = dracut_install(dname, dname, true, false, true);
free(dname);
if (ret != 0) { if (ret != 0) {
log_error("ERROR: failed to create directory '%s'", fulldstdir); log_error("ERROR: failed to create directory '%s'", fulldstdir);
free(fulldstdir);
return 1; return 1;
} }
} }
free(fulldstdir);
if (isdir && !src_exists) { if (isdir && !src_exists) {
log_info("mkdir '%s'", fulldstpath); log_info("mkdir '%s'", fulldstpath);
return mkdir(fulldstpath, 0755); ret = mkdir(fulldstpath, 0755);
return ret;
} }
/* ready to install src */ /* ready to install src */
if (S_ISDIR(sb.st_mode)) { if (S_ISDIR(sb.st_mode)) {
log_info("mkdir '%s'", fulldstpath); log_info("mkdir '%s'", fulldstpath);
return mkdir(fulldstpath, sb.st_mode | S_IWUSR); ret = mkdir(fulldstpath, sb.st_mode | S_IWUSR);
return ret;
} }
if (S_ISLNK(sb.st_mode)) { if (S_ISLNK(sb.st_mode)) {
char *abspath; _cleanup_free_ char *abspath = NULL;
char *absdestpath = NULL;
abspath = realpath(src, NULL); abspath = realpath(src, NULL);
@@ -482,15 +591,17 @@ static int dracut_install(const char *src, const char *dst, bool isdir, bool res
} }
if (lstat(fulldstpath, &sb) != 0) { if (lstat(fulldstpath, &sb) != 0) {
_cleanup_free_ char *absdestpath = NULL;
asprintf(&absdestpath, "%s%s", destrootdir, abspath); ret = asprintf(&absdestpath, "%s%s", destrootdir, abspath);
if (ret < 0) {
log_error("Out of memory!");
exit(EXIT_FAILURE);
}
ln_r(absdestpath, fulldstpath); ln_r(absdestpath, fulldstpath);
free(absdestpath);
} }
free(abspath);
if (arg_hmac) { if (arg_hmac) {
/* copy .hmac files also */ /* copy .hmac files also */
hmac_install(src, dst, NULL); hmac_install(src, dst, NULL);
@@ -508,8 +619,12 @@ static int dracut_install(const char *src, const char *dst, bool isdir, bool res
} }
} }
log_debug("dracut_install ret = %d", ret);
log_info("cp '%s' '%s'", src, fulldstpath); log_info("cp '%s' '%s'", src, fulldstpath);
ret += cp(src, fulldstpath); ret += cp(src, fulldstpath);
log_debug("dracut_install ret = %d", ret);
return ret; return ret;
} }
@@ -520,49 +635,49 @@ static void item_free(char *i)
} }
static void usage(int status) static void usage(int status)
{ {
/* */ /* */
printf("\ printf("Usage: %s -D DESTROOTDIR [OPTION]... -a SOURCE...\n"
Usage: %s -D DESTROOTDIR [OPTION]... -a SOURCE...\n\ "or: %s -D DESTROOTDIR [OPTION]... SOURCE DEST\n"
or: %s -D DESTROOTDIR [OPTION]... SOURCE DEST\n\ "\n"
\n\ "Install SOURCE to DEST in DESTROOTDIR with all needed dependencies.\n"
Install SOURCE to DEST in DESTROOTDIR with all needed dependencies.\n\ "\n"
\n\ " -D --destrootdir Install all files to DESTROOTDIR as the root\n"
-D --destrootdir Install all files to DESTROOTDIR as the root\n\ " -a --all Install all SOURCE arguments to DESTROOTDIR\n"
-a --all Install all SOURCE arguments to DESTROOTDIR\n\ " -o --optional If SOURCE does not exist, do not fail\n"
-o --optional If SOURCE does not exist, do not fail\n\ " -d --dir SOURCE is a directory\n"
-d --dir SOURCE is a directory\n\ " -l --ldd Also install shebang executables and libraries\n"
-l --ldd Also install shebang executables and libraries\n\ " -R --resolvelazy Only install shebang executables and libraries\n"
-R --resolvelazy Only install shebang executables and libraries for all SOURCE files\n\ " for all SOURCE files\n"
-H --fips Also install all '.SOURCE.hmac' files\n\ " -H --fips Also install all '.SOURCE.hmac' files\n"
-v --verbose Show more output\n\ " -v --verbose Show more output\n"
--debug Show debug output\n\ " --debug Show debug output\n"
--version Show package version\n\ " --version Show package version\n"
-h --help Show this help\n\ " -h --help Show this help\n"
\n\ "\n"
Example:\n\ "Example:\n"
# mkdir -p /var/tmp/test-root\n\ "# mkdir -p /var/tmp/test-root\n"
# %s -D /var/tmp/test-root --ldd -a sh tr\n\ "# %s -D /var/tmp/test-root --ldd -a sh tr\n"
# tree /var/tmp/test-root\n\ "# tree /var/tmp/test-root\n"
/var/tmp/test-root\n\ "/var/tmp/test-root\n"
|-- lib64 -> usr/lib64\n\ "|-- lib64 -> usr/lib64\n"
`-- usr\n\ "`-- usr\n"
|-- bin\n\ " |-- bin\n"
| |-- bash\n\ " | |-- bash\n"
| |-- sh -> bash\n\ " | |-- sh -> bash\n"
| `-- tr\n\ " | `-- tr\n"
`-- lib64\n\ " `-- lib64\n"
|-- ld-2.15.90.so\n\ " |-- ld-2.15.90.so\n"
|-- ld-linux-x86-64.so.2 -> ld-2.15.90.so\n\ " |-- ld-linux-x86-64.so.2 -> ld-2.15.90.so\n"
|-- libc-2.15.90.so\n\ " |-- libc-2.15.90.so\n"
|-- libc.so\n\ " |-- libc.so\n"
|-- libc.so.6 -> libc-2.15.90.so\n\ " |-- libc.so.6 -> libc-2.15.90.so\n"
|-- libdl-2.15.90.so\n\ " |-- libdl-2.15.90.so\n"
|-- libdl.so -> libdl-2.15.90.so\n\ " |-- libdl.so -> libdl-2.15.90.so\n"
|-- libdl.so.2 -> libdl-2.15.90.so\n\ " |-- libdl.so.2 -> libdl-2.15.90.so\n"
|-- libtinfo.so.5 -> libtinfo.so.5.9\n\ " |-- libtinfo.so.5 -> libtinfo.so.5.9\n"
`-- libtinfo.so.5.9\n\ " `-- libtinfo.so.5.9\n"
", program_invocation_short_name, program_invocation_short_name, program_invocation_short_name); , program_invocation_short_name, program_invocation_short_name, program_invocation_short_name);
exit(status); exit(status);
} }
@@ -575,7 +690,7 @@ static int parse_argv(int argc, char *argv[])
ARG_DEBUG ARG_DEBUG
}; };
static const struct option const options[] = { static struct option const options[] = {
{"help", no_argument, NULL, 'h'}, {"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, ARG_VERSION}, {"version", no_argument, NULL, ARG_VERSION},
{"dir", no_argument, NULL, 'd'}, {"dir", no_argument, NULL, 'd'},
@@ -590,7 +705,7 @@ static int parse_argv(int argc, char *argv[])
{NULL, 0, NULL, 0} {NULL, 0, NULL, 0}
}; };
while ((c = getopt_long(argc, argv, "adhloD:DHILR", options, NULL)) != -1) { while ((c = getopt_long(argc, argv, "adhloD:HR", options, NULL)) != -1) {
switch (c) { switch (c) {
case ARG_VERSION: case ARG_VERSION:
puts(PROGRAM_VERSION_STRING); puts(PROGRAM_VERSION_STRING);
@@ -641,7 +756,7 @@ static int parse_argv(int argc, char *argv[])
static int resolve_lazy(int argc, char **argv) static int resolve_lazy(int argc, char **argv)
{ {
int i; int i;
int destrootdirlen = strlen(destrootdir); size_t destrootdirlen = strlen(destrootdir);
int ret = 0; int ret = 0;
char *item; char *item;
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
@@ -671,10 +786,12 @@ static int resolve_lazy(int argc, char **argv)
static char *find_binary(const char *src) static char *find_binary(const char *src)
{ {
char *path; _cleanup_free_ char *path = NULL;
char *p, *q; char *p, *q;
bool end = false; bool end = false;
char *newsrc = NULL; char *newsrc = NULL;
int ret;
path = getenv("PATH"); path = getenv("PATH");
if (path == NULL) { if (path == NULL) {
@@ -683,6 +800,12 @@ static char *find_binary(const char *src)
} }
path = strdup(path); path = strdup(path);
p = path; p = path;
if (path == NULL) {
log_error("Out of memory!");
exit(EXIT_FAILURE);
}
log_debug("PATH=%s", path); log_debug("PATH=%s", path);
do { do {
@@ -695,7 +818,12 @@ static char *find_binary(const char *src)
else else
*q = '\0'; *q = '\0';
asprintf(&newsrc, "%s/%s", p, src); ret = asprintf(&newsrc, "%s/%s", p, src);
if (ret < 0) {
log_error("Out of memory!");
exit(EXIT_FAILURE);
}
p = q + 1; p = q + 1;
if (stat(newsrc, &sb) != 0) { if (stat(newsrc, &sb) != 0) {
@@ -709,15 +837,15 @@ static char *find_binary(const char *src)
} while (!end); } while (!end);
free(path);
if (newsrc) if (newsrc)
log_debug("find_binary(%s) == %s", src, newsrc); log_debug("find_binary(%s) == %s", src, newsrc);
return newsrc; return newsrc;
} }
static int install_one(const char *src, const char *dst) static int install_one(const char *src, const char *dst)
{ {
int r = 0; int r = EXIT_SUCCESS;
int ret; int ret;
if (strchr(src, '/') == NULL) { if (strchr(src, '/') == NULL) {
@@ -746,29 +874,27 @@ static int install_one(const char *src, const char *dst)
static int install_all(int argc, char **argv) static int install_all(int argc, char **argv)
{ {
int r = 0; int r = EXIT_SUCCESS;
int i; int i;
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
int ret; int ret;
log_debug("Handle '%s'", argv[i]); log_debug("Handle '%s'", argv[i]);
if (strchr(argv[i], '/') == NULL) { if (strchr(argv[i], '/') == NULL) {
char *newsrc = find_binary(argv[i]); _cleanup_free_ char *newsrc = find_binary(argv[i]);
if (newsrc) { if (newsrc) {
log_debug("dracut_install '%s'", newsrc); log_debug("dracut_install '%s'", newsrc);
ret = dracut_install(newsrc, newsrc, arg_createdir, arg_resolvedeps, true); ret = dracut_install(newsrc, newsrc, arg_createdir, arg_resolvedeps, true);
if (ret == 0) { if (ret == 0) {
log_debug("dracut_install '%s' OK", newsrc); log_debug("dracut_install '%s' OK", newsrc);
} }
free(newsrc);
} else { } else {
ret = -1; ret = -1;
} }
} else { } else {
char *dest = strdup(argv[i]); _cleanup_free_ char *dest = strdup(argv[i]);
ret = dracut_install(argv[i], dest, arg_createdir, arg_resolvedeps, true); ret = dracut_install(argv[i], dest, arg_createdir, arg_resolvedeps, true);
free(dest);
} }
if ((ret != 0) && (!arg_optional)) { if ((ret != 0) && (!arg_optional)) {

View File

@@ -1,7 +1,6 @@
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
#ifndef foomacrohfoo #pragma once
#define foomacrohfoo
/*** /***
This file is part of systemd. This file is part of systemd.
@@ -45,16 +44,38 @@
#define _hidden_ __attribute__ ((visibility("hidden"))) #define _hidden_ __attribute__ ((visibility("hidden")))
#define _weakref_(x) __attribute__((weakref(#x))) #define _weakref_(x) __attribute__((weakref(#x)))
#define _introspect_(x) __attribute__((section("introspect." x))) #define _introspect_(x) __attribute__((section("introspect." x)))
#define _alignas_(x) __attribute__((aligned(__alignof(x))))
#define _cleanup_(x) __attribute__((cleanup(x)))
/* automake test harness */
#define EXIT_TEST_SKIP 77
#define XSTRINGIFY(x) #x #define XSTRINGIFY(x) #x
#define STRINGIFY(x) XSTRINGIFY(x) #define STRINGIFY(x) XSTRINGIFY(x)
/* Rounds up */ /* Rounds up */
#define ALIGN(l) ALIGN_TO((l), sizeof(void*))
#define ALIGN4(l) (((l) + 3) & ~3)
#define ALIGN8(l) (((l) + 7) & ~7)
#if __SIZEOF_POINTER__ == 8
#define ALIGN(l) ALIGN8(l)
#elif __SIZEOF_POINTER__ == 4
#define ALIGN(l) ALIGN4(l)
#else
#error "Wut? Pointers are neither 4 nor 8 bytes long?"
#endif
#define ALIGN_PTR(p) ((void*) ALIGN((unsigned long) p))
#define ALIGN4_PTR(p) ((void*) ALIGN4((unsigned long) p))
#define ALIGN8_PTR(p) ((void*) ALIGN8((unsigned long) p))
static inline size_t ALIGN_TO(size_t l, size_t ali) { static inline size_t ALIGN_TO(size_t l, size_t ali) {
return ((l + ali - 1) & ~(ali - 1)); return ((l + ali - 1) & ~(ali - 1));
} }
#define ALIGN_TO_PTR(p, ali) ((void*) ALIGN_TO((unsigned long) p))
#define ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0])) #define ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0]))
/* /*
@@ -64,34 +85,35 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) {
* @member: the name of the member within the struct. * @member: the name of the member within the struct.
* *
*/ */
#define container_of(ptr, type, member) ({ \ #define container_of(ptr, type, member) \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \ __extension__ ({ \
(type *)( (char *)__mptr - offsetof(type,member) );}) const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) ); \
#ifndef MAX
#define MAX(a,b) \
__extension__ ({ \
typeof(a) _a = (a); \
typeof(b) _b = (b); \
_a > _b ? _a : _b; \
}) })
#endif
#define MAX3(a,b,c) \ #undef MAX
MAX(MAX(a,b),c) #define MAX(a,b) \
__extension__ ({ \
typeof(a) _a = (a); \
typeof(b) _b = (b); \
_a > _b ? _a : _b; \
})
#ifndef MIN #define MAX3(x,y,z) \
__extension__ ({ \
typeof(x) _c = MAX(x,y); \
MAX(_c, z); \
})
#undef MIN
#define MIN(a,b) \ #define MIN(a,b) \
__extension__ ({ \ __extension__ ({ \
typeof(a) _a = (a); \ typeof(a) _a = (a); \
typeof(b) _b = (b); \ typeof(b) _b = (b); \
_a < _b ? _a : _b; \ _a < _b ? _a : _b; \
}) })
#endif
#define MIN3(a,b,c) \
MIN(MIN(a,b),c)
#ifndef CLAMP
#define CLAMP(x, low, high) \ #define CLAMP(x, low, high) \
__extension__ ({ \ __extension__ ({ \
typeof(x) _x = (x); \ typeof(x) _x = (x); \
@@ -99,6 +121,7 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) {
typeof(high) _high = (high); \ typeof(high) _high = (high); \
((_x > _high) ? _high : ((_x < _low) ? _low : _x)); \ ((_x > _high) ? _high : ((_x < _low) ? _low : _x)); \
}) })
#endif
#define assert_se(expr) \ #define assert_se(expr) \
do { \ do { \
@@ -119,14 +142,21 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) {
log_assert_failed_unreachable(t, __FILE__, __LINE__, __PRETTY_FUNCTION__); \ log_assert_failed_unreachable(t, __FILE__, __LINE__, __PRETTY_FUNCTION__); \
} while (false) } while (false)
#define assert_cc(expr) \ #if defined(static_assert)
do { \ #define assert_cc(expr) \
switch (0) { \ do { \
case 0: \ static_assert(expr, #expr); \
case !!(expr): \
; \
} \
} while (false) } while (false)
#else
#define assert_cc(expr) \
do { \
switch (0) { \
case 0: \
case !!(expr): \
; \
} \
} while (false)
#endif
#define PTR_TO_UINT(p) ((unsigned int) ((uintptr_t) (p))) #define PTR_TO_UINT(p) ((unsigned int) ((uintptr_t) (p)))
#define UINT_TO_PTR(u) ((void*) ((uintptr_t) (u))) #define UINT_TO_PTR(u) ((void*) ((uintptr_t) (u)))
@@ -149,6 +179,8 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) {
#define memzero(x,l) (memset((x), 0, (l))) #define memzero(x,l) (memset((x), 0, (l)))
#define zero(x) (memzero(&(x), sizeof(x))) #define zero(x) (memzero(&(x), sizeof(x)))
#define CHAR_TO_STR(x) ((char[2]) { x, 0 })
#define char_array_0(x) x[sizeof(x)-1] = 0; #define char_array_0(x) x[sizeof(x)-1] = 0;
#define IOVEC_SET_STRING(i, s) \ #define IOVEC_SET_STRING(i, s) \
@@ -187,6 +219,66 @@ static inline size_t IOVEC_INCREMENT(struct iovec *i, unsigned n, size_t k) {
return k; return k;
} }
#include "log.h" #define VA_FORMAT_ADVANCE(format, ap) \
do { \
int _argtypes[128]; \
size_t _i, _k; \
_k = parse_printf_format((format), ELEMENTSOF(_argtypes), _argtypes); \
assert(_k < ELEMENTSOF(_argtypes)); \
for (_i = 0; _i < _k; _i++) { \
if (_argtypes[_i] & PA_FLAG_PTR) { \
(void) va_arg(ap, void*); \
continue; \
} \
\
switch (_argtypes[_i]) { \
case PA_INT: \
case PA_INT|PA_FLAG_SHORT: \
case PA_CHAR: \
(void) va_arg(ap, int); \
break; \
case PA_INT|PA_FLAG_LONG: \
(void) va_arg(ap, long int); \
break; \
case PA_INT|PA_FLAG_LONG_LONG: \
(void) va_arg(ap, long long int); \
break; \
case PA_WCHAR: \
(void) va_arg(ap, wchar_t); \
break; \
case PA_WSTRING: \
case PA_STRING: \
case PA_POINTER: \
(void) va_arg(ap, void*); \
break; \
case PA_FLOAT: \
case PA_DOUBLE: \
(void) va_arg(ap, double); \
break; \
case PA_DOUBLE|PA_FLAG_LONG_DOUBLE: \
(void) va_arg(ap, long double); \
break; \
default: \
assert_not_reached("Unknown format string argument."); \
} \
} \
} while(false)
#endif /* Because statfs.t_type can be int on some architecures, we have to cast
* the const magic to the type, otherwise the compiler warns about
* signed/unsigned comparison, because the magic can be 32 bit unsigned.
*/
#define F_TYPE_CMP(a, b) (a == (typeof(a)) b)
/* Returns the number of chars needed to format variables of the
* specified type as a decimal string. Adds in extra space for a
* negative '-' prefix. */
#define DECIMAL_STR_MAX(type) \
(1+(sizeof(type) <= 1 ? 3 : \
sizeof(type) <= 2 ? 5 : \
sizeof(type) <= 4 ? 10 : \
sizeof(type) <= 8 ? 20 : sizeof(int[-2*(sizeof(type) > 8)])))
#include "log.h"

View File

@@ -185,3 +185,95 @@ static const char *const log_level_table[] = {
}; };
DEFINE_STRING_TABLE_LOOKUP(log_level, int); DEFINE_STRING_TABLE_LOOKUP(log_level, int);
char *strnappend(const char *s, const char *suffix, size_t b) {
size_t a;
char *r;
if (!s && !suffix)
return strdup("");
if (!s)
return strndup(suffix, b);
if (!suffix)
return strdup(s);
assert(s);
assert(suffix);
a = strlen(s);
if (b > ((size_t) -1) - a)
return NULL;
r = new(char, a+b+1);
if (!r)
return NULL;
memcpy(r, s, a);
memcpy(r+a, suffix, b);
r[a+b] = 0;
return r;
}
char *strappend(const char *s, const char *suffix) {
return strnappend(s, suffix, suffix ? strlen(suffix) : 0);
}
char *strjoin(const char *x, ...) {
va_list ap;
size_t l;
char *r, *p;
va_start(ap, x);
if (x) {
l = strlen(x);
for (;;) {
const char *t;
size_t n;
t = va_arg(ap, const char *);
if (!t)
break;
n = strlen(t);
if (n > ((size_t) -1) - l) {
va_end(ap);
return NULL;
}
l += n;
}
} else
l = 0;
va_end(ap);
r = new(char, l+1);
if (!r)
return NULL;
if (x) {
p = stpcpy(r, x);
va_start(ap, x);
for (;;) {
const char *t;
t = va_arg(ap, const char *);
if (!t)
break;
p = stpcpy(p, t);
}
va_end(ap);
} else
r[0] = 0;
return r;
}

View File

@@ -507,6 +507,42 @@ void* memdup(const void *p, size_t l);
int is_kernel_thread(pid_t pid); int is_kernel_thread(pid_t pid);
static inline void freep(void *p) {
free(*(void**) p);
}
static inline void fclosep(FILE **f) {
if (*f)
fclose(*f);
}
static inline void pclosep(FILE **f) {
if (*f)
pclose(*f);
}
static inline void closep(int *fd) {
if (*fd >= 0)
close_nointr_nofail(*fd);
}
static inline void closedirp(DIR **d) {
if (*d)
closedir(*d);
}
static inline void umaskp(mode_t *u) {
umask(*u);
}
#define _cleanup_free_ _cleanup_(freep)
#define _cleanup_fclose_ _cleanup_(fclosep)
#define _cleanup_pclose_ _cleanup_(pclosep)
#define _cleanup_close_ _cleanup_(closep)
#define _cleanup_closedir_ _cleanup_(closedirp)
#define _cleanup_umask_ _cleanup_(umaskp)
#define _cleanup_globfree_ _cleanup_(globfree)
int fd_inc_sndbuf(int fd, size_t n); int fd_inc_sndbuf(int fd, size_t n);
int fd_inc_rcvbuf(int fd, size_t n); int fd_inc_rcvbuf(int fd, size_t n);
@@ -524,4 +560,6 @@ bool in_initrd(void);
void warn_melody(void); void warn_melody(void);
char *strjoin(const char *x, ...) _sentinel_;
#endif #endif

View File

@@ -0,0 +1,63 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
#
# Copyright 2013 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
__contains_word () {
local word=$1; shift
for w in $*; do [[ $w = $word ]] && return 0; done
return 1
}
_lsinitrd() {
local field_vals= cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
local -A OPTS=(
[STANDALONE]='-s --size -h --help'
[ARG]='-f --file -k --kver'
)
if __contains_word "$prev" ${OPTS[ARG]}; then
case $prev in
--file|-f)
comps=$(compgen -f -- "$cur")
compopt -o filenames
;;
--kver|-k)
comps=$(cd /lib/modules; echo [0-9]*)
;;
*)
return 0
;;
esac
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
return 0
fi
if [[ $cur = -* ]]; then
COMPREPLY=( $(compgen -W '${OPTS[*]}' -- "$cur") )
return 0
fi
comps=$(compgen -f -- "$cur")
compopt -o filenames
COMPREPLY=( $(compgen -W '$comps' -- "$cur") )
return 0
}
complete -F _lsinitrd lsinitrd

View File

@@ -10,12 +10,15 @@ lsinitrd - tool to show the contents of an initramfs image
SYNOPSIS SYNOPSIS
-------- --------
*lsinit* ['OPTION...'] [<image>] *lsinitrd* ['OPTION...'] [<image> [<filename> [<filename> [...] ]]]
*lsinitrd* ['OPTION...'] -k <kernel-version>
DESCRIPTION DESCRIPTION
----------- -----------
lsinitrd shows the contents of an initramfs image. if <image> is omitted, then lsinitrd shows the contents of an initramfs image. if <image> is omitted, then
lsinitrd uses the default image /boot/initramfs-<kernel version>.img. lsinitrd uses the default image _/boot/<machine-id>/<kernel-version>/initrd_ or
_/boot/initramfs-<kernel-version>.img_.
OPTIONS OPTIONS
------- -------
@@ -25,6 +28,12 @@ OPTIONS
**-s, --size**:: **-s, --size**::
sort the contents of the initramfs by size. sort the contents of the initramfs by size.
**-f, --file** _<filename>_::
print the contents of <filename>.
**-k, --kver** _<kernel version>_::
inspect the initramfs of <kernel version>.
AVAILABILITY AVAILABILITY
------------ ------------
The lsinitrd command is part of the dracut package and is available from The lsinitrd command is part of the dracut package and is available from

View File

@@ -21,55 +21,132 @@
usage() usage()
{ {
echo "Usage: $(${0##*/}) [-s] [<initramfs file> [<filename>]]" {
echo "Usage: ${0##*/} [options] [<initramfs file> [<filename> [<filename> [...] ]]]"
echo "Usage: ${0##*/} [options] -k <kernel version>"
echo
echo "-h, --help print a help message and exit."
echo "-s, --size sort the contents of the initramfs by size."
echo "-f, --file <filename> print the contents of <filename>."
echo "-k, --kver <kernel version> inspect the initramfs of <kernel version>."
echo
} >&2
} }
[[ $# -le 2 ]] || { usage ; exit 1 ; }
sorted=0 sorted=0
while getopts "s" opt; do declare -A filenames
case $opt in
s) sorted=1;; unset POSIXLY_CORRECT
h) usage; exit 0;; TEMP=$(getopt \
\?) usage; exit 1;; -o "shf:k:" \
--long kver: \
--long file: \
--long help \
--long size \
-- "$@")
if (( $? != 0 )); then
usage
exit 1
fi
eval set -- "$TEMP"
while (($# > 0)); do
case $1 in
-k|--kver) KERNEL_VERSION="$2"; shift;;
-f|--file) filenames[${2#/}]=1; shift;;
-s|--size) sorted=1;;
-h|--help) usage; exit 0;;
--) shift;break;;
*) usage; exit 1;;
esac esac
shift
done done
shift $((OPTIND-1))
image="${1:-/boot/initramfs-$(uname -r).img}" [[ $KERNEL_VERSION ]] || KERNEL_VERSION="$(uname -r)"
[[ -f "$image" ]] || { echo "$image does not exist" ; exit 1 ; }
CAT=zcat if [[ $1 ]]; then
FILE_T=$(file --dereference "$image") image="$1"
if ! [[ -f "$image" ]]; then
if echo "test"|xz|xz -dc --single-stream >/dev/null 2>&1; then {
XZ_SINGLE_STREAM="--single-stream" echo "$image does not exist"
fi echo
} >&2
if [[ "$FILE_T" =~ :\ gzip\ compressed\ data ]]; then usage
CAT=zcat exit 1
elif [[ "$FILE_T" =~ :\ xz\ compressed\ data ]]; then fi
CAT="xzcat $XZ_SINGLE_STREAM"
elif [[ "$FILE_T" =~ :\ XZ\ compressed\ data ]]; then
CAT="xzcat $XZ_SINGLE_STREAM"
elif [[ "$FILE_T" =~ :\ LZMA ]]; then
CAT="xzcat $XZ_SINGLE_STREAM"
elif [[ "$FILE_T" =~ :\ data ]]; then
CAT="xzcat $XZ_SINGLE_STREAM"
fi
if [[ $# -eq 2 ]]; then
$CAT $image | cpio --extract --verbose --quiet --to-stdout ${2#/} 2>/dev/null
exit $?
fi
echo "$image: $(du -h $image | while read a b; do echo $a;done)"
echo "========================================================================"
$CAT "$image" | cpio --extract --verbose --quiet --to-stdout '*lib/dracut/dracut-*' 2>/dev/null
echo "========================================================================"
if [ "$sorted" -eq 1 ]; then
$CAT "$image" | cpio --extract --verbose --quiet --list | sort -n -k5
else else
$CAT "$image" | cpio --extract --verbose --quiet --list | sort -k9 [[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
if [[ -d /boot/loader/entries || -L /boot/loader/entries ]] \
&& [[ $MACHINE_ID ]] \
&& [[ -d /boot/${MACHINE_ID} || -L /boot/${MACHINE_ID} ]] ; then
image="/boot/${MACHINE_ID}/${KERNEL_VERSION}/initrd"
else
image="/boot/initramfs-${KERNEL_VERSION}.img"
fi
fi fi
echo "========================================================================"
shift
while (($# > 0)); do
filenames[${1#/}]=1;
shift
done
if ! [[ -f "$image" ]]; then
{
echo "No <initramfs file> specified and the default image '$image' cannot be accessed!"
echo
} >&2
usage
exit 1
fi
read -N 6 bin < "$image"
case $bin in
$'\x1f\x8b'*)
CAT="zcat";;
BZh*)
CAT="bzcat";;
070701)
CAT="cat";;
*)
CAT="xzcat";
if echo "test"|xz|xzcat --single-stream >/dev/null 2>&1; then
CAT="xzcat --single-stream"
fi
;;
esac
ret=0
if (( ${#filenames[@]} > 0 )); then
(( ${#filenames[@]} == 1 )) && nofileinfo=1
for f in ${!filenames[@]}; do
[[ $nofileinfo ]] || echo "initramfs:/$f"
[[ $nofileinfo ]] || echo "========================================================================"
$CAT -- $image | cpio --extract --verbose --quiet --to-stdout $f 2>/dev/null
((ret+=$?))
[[ $nofileinfo ]] || echo "========================================================================"
[[ $nofileinfo ]] || echo
done
else
echo "Image: $image: $(du -h $image | while read a b; do echo $a;done)"
echo "========================================================================"
version=$($CAT -- "$image" | cpio --extract --verbose --quiet --to-stdout -- '*lib/dracut/dracut-*' 2>/dev/null)
((ret+=$?))
echo "$version with dracut modules:"
$CAT -- "$image" | cpio --extract --verbose --quiet --to-stdout -- 'usr/lib/dracut/modules.txt' 2>/dev/null
((ret+=$?))
echo "========================================================================"
if [ "$sorted" -eq 1 ]; then
$CAT -- "$image" | cpio --extract --verbose --quiet --list | sort -n -k5
else
$CAT -- "$image" | cpio --extract --verbose --quiet --list | sort -k9
fi
((ret+=$?))
echo "========================================================================"
fi
exit $ret

View File

@@ -0,0 +1,18 @@
#!/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
[ -x $systemdutildir/systemd-bootchart ] || return 1
return 255
}
depends() {
return 0
}
install() {
inst_symlink /init /sbin/init
dracut_install $systemdutildir/systemd-bootchart
}

View File

@@ -3,7 +3,7 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh # ex: ts=8 sw=4 sts=4 et filetype=sh
if ! fipsmode=$(getarg fips) || [ $fipsmode = "0" ]; then if ! fipsmode=$(getarg fips) || [ $fipsmode = "0" ]; then
rm -f /etc/modprobe.d/fips.conf >/dev/null 2>&1 rm -f -- /etc/modprobe.d/fips.conf >/dev/null 2>&1
elif getarg boot= >/dev/null; then elif getarg boot= >/dev/null; then
. /sbin/fips.sh . /sbin/fips.sh
if mount_boot; then if mount_boot; then

View File

@@ -3,7 +3,7 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh # ex: ts=8 sw=4 sts=4 et filetype=sh
if ! fipsmode=$(getarg fips) || [ $fipsmode = "0" ]; then if ! fipsmode=$(getarg fips) || [ $fipsmode = "0" ]; then
rm -f /etc/modprobe.d/fips.conf >/dev/null 2>&1 rm -f -- /etc/modprobe.d/fips.conf >/dev/null 2>&1
elif ! [ -f /tmp/fipsdone ]; then elif ! [ -f /tmp/fipsdone ]; then
. /sbin/fips.sh . /sbin/fips.sh
mount_boot mount_boot

View File

@@ -15,6 +15,12 @@ mount_boot()
UUID=*) UUID=*)
boot="/dev/disk/by-uuid/${boot#UUID=}" boot="/dev/disk/by-uuid/${boot#UUID=}"
;; ;;
PARTUUID=*)
boot="/dev/disk/by-partuuid/${boot#PARTUUID=}"
;;
PARTLABEL=*)
boot="/dev/disk/by-partlabel/${boot#PARTLABEL=}"
;;
/dev/*) /dev/*)
;; ;;
*) *)
@@ -44,14 +50,13 @@ mount_boot()
info "Mounting $boot as /boot" info "Mounting $boot as /boot"
mount -oro "$boot" /boot || return 1 mount -oro "$boot" /boot || return 1
elif [ -d "$NEWROOT/boot" ]; then elif [ -d "$NEWROOT/boot" ]; then
rm -fr /boot rm -fr -- /boot
ln -sf "$NEWROOT/boot" /boot ln -sf "$NEWROOT/boot" /boot
fi fi
} }
do_fips() do_fips()
{ {
info "Checking integrity of kernel"
KERNEL=$(uname -r) KERNEL=$(uname -r)
if ! [ -e "/boot/.vmlinuz-${KERNEL}.hmac" ]; then if ! [ -e "/boot/.vmlinuz-${KERNEL}.hmac" ]; then
@@ -59,19 +64,21 @@ do_fips()
return 1 return 1
fi fi
sha512hmac -c "/boot/.vmlinuz-${KERNEL}.hmac" || return 1
FIPSMODULES=$(cat /etc/fipsmodules) FIPSMODULES=$(cat /etc/fipsmodules)
info "Loading and integrity checking all crypto modules" info "Loading and integrity checking all crypto modules"
for module in $FIPSMODULES; do for module in $FIPSMODULES; do
if [ "$module" != "tcrypt" ]; then if [ "$module" != "tcrypt" ]; then
modprobe ${module} || return 1 modprobe ${module}
fi fi
done done
info "Self testing crypto algorithms" info "Self testing crypto algorithms"
modprobe tcrypt || return 1 modprobe tcrypt || return 1
rmmod tcrypt rmmod tcrypt
info "Checking integrity of kernel"
sha512hmac -c "/boot/.vmlinuz-${KERNEL}.hmac" || return 1
info "All initrd crypto checks done" info "All initrd crypto checks done"
> /tmp/fipsdone > /tmp/fipsdone

View File

@@ -12,9 +12,11 @@ depends() {
installkernel() { installkernel() {
local _fipsmodules _mod local _fipsmodules _mod
_fipsmodules="aead aes_generic xts aes-x86_64 ansi_cprng cbc ccm chainiv ctr gcm ghash_generic" _fipsmodules="aead aes_generic aes-x86_64 ansi_cprng arc4 blowfish camellia cast6 cbc ccm "
_fipsmodules+=" des deflate ecb eseqiv hmac seqiv sha256 sha256_generic sha512 sha512_generic" _fipsmodules+="chainiv crc32c cryptomgr crypto_null ctr cts deflate des des3_ede dm-crypt dm-mod "
_fipsmodules+=" cryptomgr crypto_null tcrypt dm-mod dm-crypt" _fipsmodules+="ecb eseqiv fcrypt gcm ghash_generic hmac khazad lzo md4 md5 michael_mic rmd128 "
_fipsmodules+="rmd160 rmd256 rmd320 rot13 salsa20 seed seqiv serpent sha1 sha224 sha256 sha256_generic "
_fipsmodules+="sha384 sha512 sha512_generic tcrypt tea tnepres twofish wp256 wp384 wp512 xeta xtea xts zlib"
mkdir -m 0755 -p "${initdir}/etc/modprobe.d" mkdir -m 0755 -p "${initdir}/etc/modprobe.d"
@@ -36,7 +38,7 @@ install() {
inst_libdir_file libsoftokn3.so libsoftokn3.so \ inst_libdir_file libsoftokn3.so libsoftokn3.so \
libsoftokn3.chk libfreebl3.so libfreebl3.chk \ libsoftokn3.chk libfreebl3.so libfreebl3.chk \
libssl.so 'hmaccalc/sha512hmac.hmac' libssl.so 'hmaccalc/sha512hmac.hmac' libssl.so.10
dracut_install -o prelink dracut_install -o prelink
} }

View File

@@ -0,0 +1,19 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
# do not add this module by default
return 255
}
depends() {
return 0
}
install() {
dracut_install -o ps grep more cat rm strace free showmount \
ping netstat rpcinfo vi scp ping6 ssh \
fsck fsck.ext2 fsck.ext4 fsck.ext3 fsck.ext4dev fsck.vfat e2fsck
}

View File

@@ -4,8 +4,8 @@
[ -n "$DRACUT_SYSTEMD" ] && exit 0 [ -n "$DRACUT_SYSTEMD" ] && exit 0
if [ -x /lib/systemd/systemd-vconsole-setup ]; then if [ -x $systemdutildir/systemd-vconsole-setup ]; then
/lib/systemd/systemd-vconsole-setup "$@" $systemdutildir/systemd-vconsole-setup "$@"
fi fi
[ -e /etc/vconsole.conf ] && . /etc/vconsole.conf [ -e /etc/vconsole.conf ] && . /etc/vconsole.conf

View File

@@ -12,9 +12,18 @@ depends() {
} }
install() { install() {
[ -x /lib/systemd/systemd-vconsole-setup ] && dracut_install /lib/systemd/systemd-vconsole-setup if dracut_module_included "systemd"; then
[[ -f /etc/vconsole.conf ]] || return 0
unset FONT
unset KEYMAP
. /etc/vconsole.conf
# if vconsole.conf has no settings, do not include anything
[[ $FONT ]] || [[ $KEYMAP ]] || return 0
fi
dracut_install -o $systemdutildir/systemd-vconsole-setup
KBDSUBDIRS=consolefonts,consoletrans,keymaps,unimaps KBDSUBDIRS=consolefonts,consoletrans,keymaps,unimaps
DEFAULT_FONT=LatArCyrHeb-16 DEFAULT_FONT="${i18n_default_font:-LatArCyrHeb-16}"
I18N_CONF="/etc/locale.conf" I18N_CONF="/etc/locale.conf"
VCONFIG_CONF="/etc/vconsole.conf" VCONFIG_CONF="/etc/vconsole.conf"
@@ -86,9 +95,11 @@ install() {
install_base() { install_base() {
dracut_install setfont loadkeys kbd_mode stty dracut_install setfont loadkeys kbd_mode stty
inst ${moddir}/console_init.sh /lib/udev/console_init if ! dracut_module_included "systemd"; then
inst_rules ${moddir}/10-console.rules inst ${moddir}/console_init.sh /lib/udev/console_init
inst_hook cmdline 20 "${moddir}/parse-i18n.sh" inst_rules ${moddir}/10-console.rules
inst_hook cmdline 20 "${moddir}/parse-i18n.sh"
fi
} }
install_all_kbd() { install_all_kbd() {
@@ -100,7 +111,7 @@ install() {
done done
# remove unnecessary files # remove unnecessary files
rm -f "${initdir}${kbddir}/consoletrans/utflist" rm -f -- "${initdir}${kbddir}/consoletrans/utflist"
find "${initdir}${kbddir}/" -name README\* -delete find "${initdir}${kbddir}/" -name README\* -delete
find "${initdir}${kbddir}/" -name '*.gz' -print -quit \ find "${initdir}${kbddir}/" -name '*.gz' -print -quit \
| while read line; do | while read line; do
@@ -210,12 +221,6 @@ install() {
kbddir='' kbddir=''
done done
[[ ${kbddir} ]] || {
derror "Directories ${KBDSUBDIRS//,/, } not found. Please" \
"inform us about the issue including your OS name and version."
return 1
}
[[ -f $I18N_CONF && -f $VCONFIG_CONF ]] || \ [[ -f $I18N_CONF && -f $VCONFIG_CONF ]] || \
[[ ! ${hostonly} || ${i18n_vars} ]] || { [[ ! ${hostonly} || ${i18n_vars} ]] || {
derror 'i18n_vars not set! Please set up i18n_vars in ' \ derror 'i18n_vars not set! Please set up i18n_vars in ' \

View File

@@ -26,8 +26,8 @@ inst_key_val '' /etc/vconsole.conf vconsole.font.unimap FONT_UNIMAP -d UNIMAP
inst_key_val 1 /etc/vconsole.conf vconsole.font.unicode UNICODE vconsole.unicode inst_key_val 1 /etc/vconsole.conf vconsole.font.unicode UNICODE vconsole.unicode
inst_key_val '' /etc/vconsole.conf vconsole.keymap.ext EXT_KEYMAP inst_key_val '' /etc/vconsole.conf vconsole.keymap.ext EXT_KEYMAP
inst_key_val '' /etc/locale.conf LANG locale.LANG inst_key_val '' /etc/locale.conf locale.LANG LANG
inst_key_val '' /etc/locale.conf LC_ALL locale.LC_ALL inst_key_val '' /etc/locale.conf locale.LC_ALL LC_ALL
if [ -f /etc/locale.conf ]; then if [ -f /etc/locale.conf ]; then
. /etc/locale.conf . /etc/locale.conf
@@ -36,7 +36,7 @@ if [ -f /etc/locale.conf ]; then
fi fi
if [ -n "$DRACUT_SYSTEMD" ]; then if [ -n "$DRACUT_SYSTEMD" ]; then
rm -f /etc/udev/rules.d/10-console.rules rm -f -- /etc/udev/rules.d/10-console.rules
rm -f /lib/udev/rules.d/10-console.rules rm -f -- /lib/udev/rules.d/10-console.rules
rm -f /lib/udev/console_init rm -f -- /lib/udev/console_init
fi fi

View File

@@ -56,22 +56,22 @@ if ! needconvert; then
fi fi
testfile="$ROOT/.usrmovecheck$$" testfile="$ROOT/.usrmovecheck$$"
rm -f "$testfile" rm -f -- "$testfile"
> "$testfile" > "$testfile"
if [[ ! -e "$testfile" ]]; then if [[ ! -e "$testfile" ]]; then
echo "Cannot write to $ROOT/" echo "Cannot write to $ROOT/"
exit 1 exit 1
fi fi
rm -f "$testfile" rm -f -- "$testfile"
testfile="$ROOT/usr/.usrmovecheck$$" testfile="$ROOT/usr/.usrmovecheck$$"
rm -f "$testfile" rm -f -- "$testfile"
> "$testfile" > "$testfile"
if [[ ! -e "$testfile" ]]; then if [[ ! -e "$testfile" ]]; then
echo "Cannot write to $ROOT/usr/" echo "Cannot write to $ROOT/usr/"
exit 1 exit 1
fi fi
rm -f "$testfile" rm -f -- "$testfile"
find_mount() { find_mount() {
local dev mnt etc wanted_dev local dev mnt etc wanted_dev
@@ -108,11 +108,11 @@ cleanup() {
for dir in "$ROOT/bin" "$ROOT/sbin" "$ROOT/lib" "$ROOT/lib64" \ for dir in "$ROOT/bin" "$ROOT/sbin" "$ROOT/lib" "$ROOT/lib64" \
"$ROOT/usr/bin" "$ROOT/usr/sbin" "$ROOT/usr/lib" \ "$ROOT/usr/bin" "$ROOT/usr/sbin" "$ROOT/usr/lib" \
"$ROOT/usr/lib64"; do "$ROOT/usr/lib64"; do
[[ -d "${dir}.usrmove-new" ]] && rm -fr "${dir}.usrmove-new" [[ -d "${dir}.usrmove-new" ]] && rm -fr -- "${dir}.usrmove-new"
if [[ -d "${dir}.usrmove-old" ]]; then if [[ -d "${dir}.usrmove-old" ]]; then
mv "$dir" "${dir}.del~" mv "$dir" "${dir}.del~"
mv "${dir}.usrmove-old" "$dir" mv "${dir}.usrmove-old" "$dir"
rm -fr "${dir}.del~" rm -fr -- "${dir}.del~"
fi fi
done done
} }
@@ -126,7 +126,7 @@ set -e
# merge / and /usr in new dir in /usr # merge / and /usr in new dir in /usr
for dir in bin sbin lib lib64; do for dir in bin sbin lib lib64; do
rm -rf "$ROOT/usr/${dir}.usrmove-new" rm -rf -- "$ROOT/usr/${dir}.usrmove-new"
[[ -L "$ROOT/$dir" ]] && continue [[ -L "$ROOT/$dir" ]] && continue
[[ -d "$ROOT/$dir" ]] || continue [[ -d "$ROOT/$dir" ]] || continue
echo "Make a copy of \`$ROOT/usr/$dir'." echo "Make a copy of \`$ROOT/usr/$dir'."
@@ -150,7 +150,7 @@ done
for dir in bin sbin lib lib64; do for dir in bin sbin lib lib64; do
[[ -d "$ROOT/usr/${dir}.usrmove-new" ]] || continue [[ -d "$ROOT/usr/${dir}.usrmove-new" ]] || continue
echo "Switch to new \`$ROOT/usr/$dir'." echo "Switch to new \`$ROOT/usr/$dir'."
rm -fr "$ROOT/usr/${dir}.usrmove-old" rm -fr -- "$ROOT/usr/${dir}.usrmove-old"
mv "$ROOT/usr/$dir" "$ROOT/usr/${dir}.usrmove-old" mv "$ROOT/usr/$dir" "$ROOT/usr/${dir}.usrmove-old"
mv "$ROOT/usr/${dir}.usrmove-new" "$ROOT/usr/$dir" mv "$ROOT/usr/${dir}.usrmove-new" "$ROOT/usr/$dir"
done done
@@ -160,7 +160,7 @@ for dir in bin sbin lib lib64; do
[[ -L "$ROOT/$dir" ]] && continue [[ -L "$ROOT/$dir" ]] && continue
[[ -d "$ROOT/$dir" ]] || continue [[ -d "$ROOT/$dir" ]] || continue
echo "Create \`$ROOT/$dir' symlink." echo "Create \`$ROOT/$dir' symlink."
rm -rf "$ROOT/${dir}.usrmove-old" || : rm -fr -- "$ROOT/${dir}.usrmove-old" || :
mv "$ROOT/$dir" "$ROOT/${dir}.usrmove-old" mv "$ROOT/$dir" "$ROOT/${dir}.usrmove-old"
ln -sfn usr/$dir "$ROOT/$dir" ln -sfn usr/$dir "$ROOT/$dir"
done done
@@ -178,9 +178,9 @@ done
for dir in bin sbin lib lib64; do for dir in bin sbin lib lib64; do
[[ -d "$ROOT/usr/${dir}.usrmove-old~" ]] \ [[ -d "$ROOT/usr/${dir}.usrmove-old~" ]] \
&& rm -rf "$ROOT/usr/${dir}.usrmove-old~" || : && rm -rf -- "$ROOT/usr/${dir}.usrmove-old~" || :
[[ -d "$ROOT/${dir}.usrmove-old~" ]] \ [[ -d "$ROOT/${dir}.usrmove-old~" ]] \
&& rm -rf "$ROOT/${dir}.usrmove-old~" || : && rm -rf -- "$ROOT/${dir}.usrmove-old~" || :
done done
for dir in lib lib64; do for dir in lib lib64; do

View File

@@ -9,7 +9,7 @@ setup_interface() {
bcast=$new_broadcast_address bcast=$new_broadcast_address
gw=${new_routers%%,*} gw=${new_routers%%,*}
domain=$new_domain_name domain=$new_domain_name
search=$(printf "$new_domain_search") search=$(printf -- "$new_domain_search")
namesrv=$new_domain_name_servers namesrv=$new_domain_name_servers
hostname=$new_host_name hostname=$new_host_name
@@ -25,8 +25,7 @@ setup_interface() {
if ! ip link set $netif mtu $mtu ; then if ! ip link set $netif mtu $mtu ; then
ip link set $netif down ip link set $netif down
ip link set $netif mtu $mtu ip link set $netif mtu $mtu
ip link set $netif up linkup $netif
wait_for_if_up $netif
fi fi
fi fi
@@ -51,6 +50,7 @@ PATH=/usr/sbin:/usr/bin:/sbin:/bin
export PS4="dhclient.$interface.$$ + " export PS4="dhclient.$interface.$$ + "
exec >>/run/initramfs/loginit.pipe 2>>/run/initramfs/loginit.pipe exec >>/run/initramfs/loginit.pipe 2>>/run/initramfs/loginit.pipe
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
type ip_to_var >/dev/null 2>&1 || . /lib/net-lib.sh
# We already need a set netif here # We already need a set netif here
netif=$interface netif=$interface
@@ -61,8 +61,7 @@ netif=$interface
case $reason in case $reason in
PREINIT) PREINIT)
echo "dhcp: PREINIT $netif up" echo "dhcp: PREINIT $netif up"
ip link set $netif up linkup $netif
wait_for_if_up $netif
;; ;;
BOUND) BOUND)
echo "dhcp: BOND setting $netif" echo "dhcp: BOND setting $netif"
@@ -89,7 +88,8 @@ case $reason in
echo "source_hook initqueue/online $netif" echo "source_hook initqueue/online $netif"
[ -e /tmp/net.$netif.manualup ] || echo "/sbin/netroot $netif" [ -e /tmp/net.$netif.manualup ] || echo "/sbin/netroot $netif"
echo "> /tmp/setup_net_$netif.ok" echo "> /tmp/setup_net_$netif.ok"
echo "rm -f $hookdir/initqueue/setup_net_$netif.sh" echo "> /tmp/setup_net_\$(cat /sys/class/net/$netif/address).ok"
echo "rm -f -- $hookdir/initqueue/setup_net_$netif.sh"
} > $hookdir/initqueue/setup_net_$netif.sh } > $hookdir/initqueue/setup_net_$netif.sh
echo "[ -f /tmp/setup_net_$netif.ok ]" > $hookdir/initqueue/finished/dhclient-$netif.sh echo "[ -f /tmp/setup_net_$netif.ok ]" > $hookdir/initqueue/finished/dhclient-$netif.sh

View File

@@ -17,27 +17,28 @@ type ip_to_var >/dev/null 2>&1 || . /lib/net-lib.sh
# $netif reads easier than $1 # $netif reads easier than $1
netif=$1 netif=$1
use_bridge='false'
use_vlan='false'
# enslave this interface to bond? # enslave this interface to bond?
if [ -e /tmp/bond.info ]; then for i in /tmp/bond.*.info; do
. /tmp/bond.info [ -e "$i" ] || continue
unset bondslaves
unset bondname
. "$i"
for slave in $bondslaves ; do for slave in $bondslaves ; do
if [ "$netif" = "$slave" ] ; then if [ "$netif" = "$slave" ] ; then
netif=$bondname netif=$bondname
break 2
fi fi
done done
fi done
# bridge this interface? if [ -e /tmp/team.info ]; then
if [ -e /tmp/bridge.info ]; then . /tmp/team.info
. /tmp/bridge.info for slave in $teamslaves ; do
for ethname in $ethnames ; do if [ "$netif" = "$slave" ] ; then
if [ "$netif" = "$ethname" ]; then netif=$teammaster
if [ "$netif" = "$bondname" ] && [ -n "$DO_BOND_SETUP" ] ; then
: # We need to really setup bond (recursive call)
else
netif="$bridgename"
fi
fi fi
done done
fi fi
@@ -47,12 +48,34 @@ if [ -e /tmp/vlan.info ]; then
if [ "$netif" = "$phydevice" ]; then if [ "$netif" = "$phydevice" ]; then
if [ "$netif" = "$bondname" ] && [ -n "$DO_BOND_SETUP" ] ; then if [ "$netif" = "$bondname" ] && [ -n "$DO_BOND_SETUP" ] ; then
: # We need to really setup bond (recursive call) : # We need to really setup bond (recursive call)
elif [ "$netif" = "$teammaster" ] && [ -n "$DO_TEAM_SETUP" ] ; then
: # We need to really setup team (recursive call)
else else
netif="$vlanname" netif="$vlanname"
use_vlan='true'
fi fi
fi fi
fi fi
# bridge this interface?
if [ -e /tmp/bridge.info ]; then
. /tmp/bridge.info
for ethname in $ethnames ; do
if [ "$netif" = "$ethname" ]; then
if [ "$netif" = "$bondname" ] && [ -n "$DO_BOND_SETUP" ] ; then
: # We need to really setup bond (recursive call)
elif [ "$netif" = "$teammaster" ] && [ -n "$DO_TEAM_SETUP" ] ; then
: # We need to really setup team (recursive call)
elif [ "$netif" = "$vlanname" ] && [ -n "$DO_VLAN_SETUP" ]; then
: # We need to really setup vlan (recursive call)
else
netif="$bridgename"
use_bridge='true'
fi
fi
done
fi
# disable manual ifup while netroot is set for simplifying our logic # disable manual ifup while netroot is set for simplifying our logic
# in netroot case we prefer netroot to bringup $netif automaticlly # in netroot case we prefer netroot to bringup $netif automaticlly
[ -n "$2" -a "$2" = "-m" ] && [ -z "$netroot" ] && manualup="$2" [ -n "$2" -a "$2" = "-m" ] && [ -z "$netroot" ] && manualup="$2"
@@ -84,30 +107,34 @@ do_ipv6auto() {
echo 0 > /proc/sys/net/ipv6/conf/$netif/forwarding echo 0 > /proc/sys/net/ipv6/conf/$netif/forwarding
echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_ra echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_ra
echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_redirects echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_redirects
ip link set $netif up linkup $netif
wait_for_if_up $netif wait_for_ipv6_auto $netif
[ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname [ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
return 0
} }
# Handle static ip configuration # Handle static ip configuration
do_static() { do_static() {
strstr $ip '*:*:*' && load_ipv6 strstr $ip '*:*:*' && load_ipv6
ip link set $netif up linkup $netif
wait_for_if_up $netif [ -n "$macaddr" ] && ip link set address $macaddr dev $netif
[ -n "$macaddr" ] && ip link set address $macaddr [ -n "$mtu" ] && ip link set mtu $mtu dev $netif
[ -n "$mtu" ] && ip link set mtu $mtu
if strstr $ip '*:*:*'; then if strstr $ip '*:*:*'; then
# note no ip addr flush for ipv6 # note no ip addr flush for ipv6
ip addr add $ip/$mask dev $netif ip addr add $ip/$mask ${srv+peer $srv} dev $netif
else else
ip addr flush dev $netif ip addr flush dev $netif
ip addr add $ip/$mask brd + dev $netif ip addr add $ip/$mask ${srv+peer $srv} brd + dev $netif
fi fi
[ -n "$gw" ] && echo ip route add default via $gw dev $netif > /tmp/net.$netif.gw [ -n "$gw" ] && echo ip route add default via $gw dev $netif > /tmp/net.$netif.gw
[ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname [ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
> /tmp/setup_net_${netif}.ok
return 0
} }
# loopback is always handled the same way # loopback is always handled the same way
@@ -118,11 +145,12 @@ if [ "$netif" = "lo" ] ; then
fi fi
# start bond if needed # start bond if needed
if [ -e /tmp/bond.info ]; then if [ -e /tmp/bond.${netif}.info ]; then
. /tmp/bond.info . /tmp/bond.${netif}.info
if [ "$netif" = "$bondname" ] && [ ! -e /tmp/net.$bondname.up ] ; then # We are master bond device if [ "$netif" = "$bondname" ] && [ ! -e /tmp/net.$bondname.up ] ; then # We are master bond device
modprobe bonding modprobe bonding
echo "+$netif" > /sys/class/net/bonding_masters
ip link set $netif down ip link set $netif down
# Stolen from ifup-eth # Stolen from ifup-eth
@@ -143,13 +171,12 @@ if [ -e /tmp/bond.info ]; then
fi fi
done done
ip link set $netif up linkup $netif
for slave in $bondslaves ; do for slave in $bondslaves ; do
ip link set $slave down ip link set $slave down
echo "+$slave" > /sys/class/net/$bondname/bonding/slaves echo "+$slave" > /sys/class/net/$bondname/bonding/slaves
ip link set $slave up linkup $slave
wait_for_if_up $slave
done done
# add the bits to setup the needed post enslavement parameters # add the bits to setup the needed post enslavement parameters
@@ -163,6 +190,28 @@ if [ -e /tmp/bond.info ]; then
fi fi
fi fi
if [ -e /tmp/team.info ]; then
. /tmp/team.info
if [ "$netif" = "$teammaster" ] && [ ! -e /tmp/net.$teammaster.up ] ; then
# We shall only bring up those _can_ come up
# in case of some slave is gone in active-backup mode
working_slaves=""
for slave in $teamslaves ; do
ip link set $slave up 2>/dev/null
if wait_for_if_up $slave; then
working_slaves+="$slave "
fi
done
# Do not add slaves now
teamd -d -U -n -t $teammaster -f /etc/teamd/$teammaster.conf
for slave in $working_slaves; do
# team requires the slaves to be down before joining team
ip link set $slave down
teamdctl $teammaster port add $slave
done
ip link set $teammaster up
fi
fi
# XXX need error handling like dhclient-script # XXX need error handling like dhclient-script
@@ -175,10 +224,13 @@ if [ -e /tmp/bridge.info ]; then
for ethname in $ethnames ; do for ethname in $ethnames ; do
if [ "$ethname" = "$bondname" ] ; then if [ "$ethname" = "$bondname" ] ; then
DO_BOND_SETUP=yes ifup $bondname -m DO_BOND_SETUP=yes ifup $bondname -m
elif [ "$ethname" = "$teammaster" ] ; then
DO_TEAM_SETUP=yes ifup $teammaster -m
elif [ "$ethname" = "$vlanname" ]; then
DO_VLAN_SETUP=yes ifup $vlanname -m
else else
ip link set $ethname up linkup $ethname
fi fi
wait_for_if_up $ethname
brctl addif $bridgename $ethname brctl addif $bridgename $ethname
done done
fi fi
@@ -187,10 +239,10 @@ fi
get_vid() { get_vid() {
case "$1" in case "$1" in
vlan*) vlan*)
return ${1#vlan} echo ${1#vlan}
;; ;;
*.*) *.*)
return ${1##*.} echo ${1##*.}
;; ;;
esac esac
} }
@@ -199,11 +251,13 @@ if [ "$netif" = "$vlanname" ] && [ ! -e /tmp/net.$vlanname.up ]; then
modprobe 8021q modprobe 8021q
if [ "$phydevice" = "$bondname" ] ; then if [ "$phydevice" = "$bondname" ] ; then
DO_BOND_SETUP=yes ifup $phydevice -m DO_BOND_SETUP=yes ifup $phydevice -m
elif [ "$phydevice" = "$teammaster" ] ; then
DO_TEAM_SETUP=yes ifup $phydevice -m
else else
ip link set "$phydevice" up linkup "$phydevice"
fi fi
wait_for_if_up "$phydevice" ip link add dev "$vlanname" link "$phydevice" type vlan id "$(get_vid $vlanname)"
ip link add dev "$vlanname" link "$phydevice" type vlan id "$(get_vid $vlanname; echo $?)" ip link set "$vlanname" up
fi fi
# setup nameserver # setup nameserver
@@ -225,6 +279,7 @@ if [ -z "$ip" ]; then
fi fi
fi fi
# Specific configuration, spin through the kernel command line # Specific configuration, spin through the kernel command line
# looking for ip= lines # looking for ip= lines
for p in $(getargs ip=); do for p in $(getargs ip=); do
@@ -233,7 +288,9 @@ for p in $(getargs ip=); do
[ "$autoconf" = "ibft" ] && continue [ "$autoconf" = "ibft" ] && continue
# If this option isn't directed at our interface, skip it # If this option isn't directed at our interface, skip it
[ -n "$dev" ] && [ "$dev" != "$netif" ] && continue [ -n "$dev" ] && [ "$dev" != "$netif" ] && \
[ "$use_bridge" != 'true' ] && \
[ "$use_vlan" != 'true' ] && continue
# Store config for later use # Store config for later use
for i in ip srv gw mask hostname macaddr; do for i in ip srv gw mask hostname macaddr; do

View File

@@ -64,7 +64,8 @@ installkernel() {
{ find_kernel_modules_by_path drivers/net; if [ "$_arch" = "s390" -o "$_arch" = "s390x" ]; then find_kernel_modules_by_path drivers/s390/net; fi; } \ { find_kernel_modules_by_path drivers/net; if [ "$_arch" = "s390" -o "$_arch" = "s390x" ]; then find_kernel_modules_by_path drivers/s390/net; fi; } \
| net_module_filter | instmods | net_module_filter | instmods
instmods =drivers/net/phy ecb arc4 bridge stp llc ipv6 bonding 8021q af_packet virtio_net #instmods() will take care of hostonly
instmods =drivers/net/phy ecb arc4 bridge stp llc ipv6 bonding 8021q af_packet virtio_net =drivers/net/team
} }
install() { install() {
@@ -72,6 +73,8 @@ install() {
dracut_install ip arping dhclient sed dracut_install ip arping dhclient sed
dracut_install -o ping ping6 dracut_install -o ping ping6
dracut_install -o brctl dracut_install -o brctl
dracut_install -o teamd teamdctl teamnl
inst_simple /etc/libnl/classid
inst_script "$moddir/ifup.sh" "/sbin/ifup" inst_script "$moddir/ifup.sh" "/sbin/ifup"
inst_script "$moddir/netroot.sh" "/sbin/netroot" inst_script "$moddir/netroot.sh" "/sbin/netroot"
inst_script "$moddir/dhclient-script.sh" "/sbin/dhclient-script" inst_script "$moddir/dhclient-script.sh" "/sbin/dhclient-script"
@@ -82,6 +85,7 @@ install() {
inst_hook cmdline 91 "$moddir/dhcp-root.sh" inst_hook cmdline 91 "$moddir/dhcp-root.sh"
inst_hook cmdline 95 "$moddir/parse-vlan.sh" inst_hook cmdline 95 "$moddir/parse-vlan.sh"
inst_hook cmdline 96 "$moddir/parse-bond.sh" inst_hook cmdline 96 "$moddir/parse-bond.sh"
inst_hook cmdline 96 "$moddir/parse-team.sh"
inst_hook cmdline 97 "$moddir/parse-bridge.sh" inst_hook cmdline 97 "$moddir/parse-bridge.sh"
inst_hook cmdline 98 "$moddir/parse-ip-opts.sh" inst_hook cmdline 98 "$moddir/parse-ip-opts.sh"
inst_hook cmdline 99 "$moddir/parse-ifname.sh" inst_hook cmdline 99 "$moddir/parse-ifname.sh"
@@ -91,5 +95,7 @@ install() {
inst_libdir_file {"tls/$_arch/",tls/,"$_arch/",}"libnss_dns.so.*" \ inst_libdir_file {"tls/$_arch/",tls/,"$_arch/",}"libnss_dns.so.*" \
{"tls/$_arch/",tls/,"$_arch/",}"libnss_mdns4_minimal.so.*" {"tls/$_arch/",tls/,"$_arch/",}"libnss_mdns4_minimal.so.*"
dracut_need_initqueue
} }

View File

@@ -2,61 +2,90 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh # ex: ts=8 sw=4 sts=4 et filetype=sh
# pxelinux provides macaddr '-' separated, but we need ':' getargbool 0 rd.neednet && NEEDNET=1
fix_bootif() {
local macaddr=${1}
local IFS='-'
macaddr=$(for i in ${macaddr} ; do echo -n $i:; done)
macaddr=${macaddr%:}
# strip hardware type field from pxelinux
[ -n "${macaddr%??:??:??:??:??:??}" ] && macaddr=${macaddr#??:}
# return macaddr with lowercase alpha characters expected by udev
echo $macaddr | sed 'y/ABCDEF/abcdef/'
}
# Don't continue if we don't need network # Don't continue if we don't need network
if [ -z "$netroot" ] && [ ! -e "/tmp/net.ifaces" ] && ! getargbool 0 rd.neednet >/dev/null; then if [ -z "$netroot" ] && [ ! -e "/tmp/net.ifaces" ] && [ "$NEEDNET" != "1" ]; then
return return
fi fi
command -v fix_bootif >/dev/null || . /lib/net-lib.sh
# Write udev rules # Write udev rules
{ {
# bridge: attempt only the defined interface # bridge: attempt only the defined interface
if [ -e /tmp/bridge.info ]; then if [ -e /tmp/bridge.info ]; then
. /tmp/bridge.info . /tmp/bridge.info
IFACES+=" ${ethnames%% *}" IFACES="$IFACES ${ethnames%% *}"
MASTER_IFACES="$MASTER_IFACES $bridgename"
fi fi
# bond: attempt only the defined interface (override bridge defines) # bond: attempt only the defined interface (override bridge defines)
if [ -e /tmp/bond.info ]; then for i in /tmp/bond.*.info; do
. /tmp/bond.info [ -e "$i" ] || continue
unset bondslaves
unset bondname
. "$i"
# It is enough to fire up only one # It is enough to fire up only one
IFACES+=" ${bondslaves%% *}" IFACES="$IFACES ${bondslaves%% *}"
MASTER_IFACES="$MASTER_IFACES ${bondname}"
done
if [ -e /tmp/team.info ]; then
. /tmp/team.info
IFACES="$IFACES ${teamslaves}"
MASTER_IFACES="$MASTER_IFACES ${teammaster}"
fi fi
if [ -e /tmp/vlan.info ]; then if [ -e /tmp/vlan.info ]; then
. /tmp/vlan.info . /tmp/vlan.info
IFACES+=" $phydevice" IFACES="$IFACES $phydevice"
MASTER_IFACES="$MASTER_IFACES ${vlanname}"
fi
if [ -z "$IFACES" ]; then
[ -e /tmp/net.ifaces ] && read IFACES < /tmp/net.ifaces
fi
if [ -e /tmp/net.bootdev ]; then
bootdev=$(cat /tmp/net.bootdev)
fi fi
ifup='/sbin/ifup $env{INTERFACE}' ifup='/sbin/ifup $env{INTERFACE}'
[ -z "$netroot" ] && ifup="$ifup -m" [ -z "$netroot" ] && ifup="$ifup -m"
# BOOTIF says everything, use only that one runcmd="RUN+=\"/sbin/initqueue --onetime $ifup\""
BOOTIF=$(getarg 'BOOTIF=')
if [ -n "$BOOTIF" ] ; then
BOOTIF=$(fix_bootif "$BOOTIF")
printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="%s"\n' "$BOOTIF" "/sbin/initqueue --onetime $ifup"
# If we have to handle multiple interfaces, handle only them. # We have some specific interfaces to handle
elif [ -n "$IFACES" ] ; then if [ -n "$IFACES" ]; then
for iface in $IFACES ; do echo 'SUBSYSTEM!="net", GOTO="net_end"'
printf 'SUBSYSTEM=="net", ENV{INTERFACE}=="%s", RUN+="%s"\n' "$iface" "/sbin/initqueue --onetime $ifup" echo 'ACTION=="remove", GOTO="net_end"'
for iface in $IFACES; do
case "$iface" in
??:??:??:??:??:??) # MAC address
cond="ATTR{address}==\"$iface\"" ;;
??-??-??-??-??-??) # MAC address in BOOTIF form
cond="ATTR{address}==\"$(fix_bootif $iface)\"" ;;
*) # an interface name
cond="ENV{INTERFACE}==\"$iface\"" ;;
esac
# The GOTO prevents us from trying to ifup the same device twice
echo "$cond, $runcmd, GOTO=\"net_end\""
done done
echo 'LABEL="net_end"'
for iface in $MASTER_IFACES; do
if [ "$bootdev" = "$iface" ] || [ "$NEEDNET" = "1" ]; then
echo "[ -f /tmp/setup_net_${iface}.ok ]" >$hookdir/initqueue/finished/wait-$iface.sh
fi
done
# Default: We don't know the interface to use, handle all # Default: We don't know the interface to use, handle all
# Fixme: waiting for the interface as well.
else else
printf 'SUBSYSTEM=="net", RUN+="%s"\n' "/sbin/initqueue --onetime $ifup" > /etc/udev/rules.d/91-default-net.rules cond='ACTION=="add", SUBSYSTEM=="net"'
# if you change the name of "91-default-net.rules", also change modules.d/80cms/cmssetup.sh
echo "$cond, $runcmd" > /etc/udev/rules.d/91-default-net.rules
fi fi
# if you change the name of "90-net.rules", also change modules.d/80cms/cmssetup.sh
} > /etc/udev/rules.d/90-net.rules } > /etc/udev/rules.d/90-net.rules

View File

@@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
get_ip() { get_ip() {
local iface="$1" ip="" local iface="$1" ip=""
@@ -12,6 +14,11 @@ iface_for_remote_addr() {
echo $5 echo $5
} }
iface_for_ip() {
set -- $(ip -o addr show to $1)
echo $2
}
iface_for_mac() { iface_for_mac() {
local interface="" mac="$(echo $1 | sed 'y/ABCDEF/abcdef/')" local interface="" mac="$(echo $1 | sed 'y/ABCDEF/abcdef/')"
for interface in /sys/class/net/*; do for interface in /sys/class/net/*; do
@@ -32,6 +39,45 @@ iface_has_link() {
# XXX Do we need to reset the flags here? anaconda never bothered.. # XXX Do we need to reset the flags here? anaconda never bothered..
} }
find_iface_with_link() {
local iface_path="" iface=""
for iface_path in /sys/class/net/*; do
iface=${iface_path##*/}
str_starts "$iface" "lo" && continue
if iface_has_link $iface; then
echo "$iface"
return 0
fi
done
return 1
}
# get the iface name for the given identifier - either a MAC, IP, or iface name
iface_name() {
case $1 in
??:??:??:??:??:??|??-??-??-??-??-??) iface_for_mac $1 ;;
*:*:*|*.*.*.*) iface_for_ip $1 ;;
*) echo $1 ;;
esac
}
# list the configured interfaces
configured_ifaces() {
local IFACES="" iface_id="" rv=1
[ -e "/tmp/net.ifaces" ] && read IFACES < /tmp/net.ifaces
if { pidof udevd || pidof systemd-udevd; } > /dev/null; then
for iface_id in $IFACES; do
echo $(iface_name $iface_id)
rv=0
done
else
warn "configured_ifaces called before udev is running"
echo $IFACES
[ -n "$IFACES" ] && rv=0
fi
return $rv
}
all_ifaces_up() { all_ifaces_up() {
local iface="" IFACES="" local iface="" IFACES=""
[ -e "/tmp/net.ifaces" ] && read IFACES < /tmp/net.ifaces [ -e "/tmp/net.ifaces" ] && read IFACES < /tmp/net.ifaces
@@ -59,7 +105,7 @@ ifdown() {
ip link set $netif down ip link set $netif down
ip addr flush dev $netif ip addr flush dev $netif
echo "#empty" > /etc/resolv.conf echo "#empty" > /etc/resolv.conf
rm -f /tmp/net.$netif.did-setup rm -f -- /tmp/net.$netif.did-setup
# TODO: send "offline" uevent? # TODO: send "offline" uevent?
} }
@@ -132,11 +178,23 @@ set_ifname() {
strstr "$n" "$mac" && echo ${n%%:*} && return strstr "$n" "$mac" && echo ${n%%:*} && return
done done
# otherwise, pick a new name and use that # otherwise, pick a new name and use that
while [ -e /sys/class/$name$num ]; do num=$(($num+1)); done while [ -e /sys/class/net/$name$num ]; do num=$(($num+1)); done
echo "ifname=$name$num:$mac" >> /etc/cmdline.d/45-ifname.conf echo "ifname=$name$num:$mac" >> /etc/cmdline.d/45-ifname.conf
echo "$name$num" echo "$name$num"
} }
# pxelinux provides macaddr '-' separated, but we need ':'
fix_bootif() {
local macaddr=${1}
local IFS='-'
macaddr=$(for i in ${macaddr} ; do echo -n $i:; done)
macaddr=${macaddr%:}
# strip hardware type field from pxelinux
[ -n "${macaddr%??:??:??:??:??:??}" ] && macaddr=${macaddr#??:}
# return macaddr with lowercase alpha characters expected by udev
echo $macaddr | sed 'y/ABCDEF/abcdef/'
}
ibft_to_cmdline() { ibft_to_cmdline() {
local iface="" mac="" dev="" local iface="" mac="" dev=""
local dhcp="" ip="" gw="" mask="" hostname="" local dhcp="" ip="" gw="" mask="" hostname=""
@@ -157,6 +215,7 @@ ibft_to_cmdline() {
hostname=$(read a < ${iface}/hostname; echo $a) hostname=$(read a < ${iface}/hostname; echo $a)
echo "ip=$ip::$gw:$mask:$hostname:$dev:none" echo "ip=$ip::$gw:$mask:$hostname:$dev:none"
fi fi
echo $mac > /tmp/net.${dev}.has_ibft_config
done done
) >> /etc/cmdline.d/40-ibft.conf ) >> /etc/cmdline.d/40-ibft.conf
# reread cmdline # reread cmdline
@@ -269,12 +328,20 @@ ip_to_var() {
case $# in case $# in
0) autoconf="error" ;; 0) autoconf="error" ;;
1) autoconf=$1 ;; 1) autoconf=$1 ;;
2) dev=$1; autoconf=$2 ;; 2) [ -n "$1" ] && dev=$1; [ -n "$2" ] && autoconf=$2 ;;
3) dev=$1; autoconf=$2; mtu=$3 ;; 3) [ -n "$1" ] && dev=$1; [ -n "$2" ] && autoconf=$2; [ -n "$3" ] && mtu=$3 ;;
4) dev=$1; autoconf=$2; mtu=$3; macaddr=$4 ;; 4) [ -n "$1" ] && dev=$1; [ -n "$2" ] && autoconf=$2; [ -n "$3" ] && mtu=$3; [ -n "$4" ] && macaddr=$4 ;;
*) ip=$1; srv=$2; gw=$3; mask=$4; hostname=$5; dev=$6; autoconf=$7; mtu=$8; macaddr=$9 ;; *) [ -n "$1" ] && ip=$1; [ -n "$2" ] && srv=$2; [ -n "$3" ] && gw=$3; [ -n "$4" ] && mask=$4;
[ -n "$5" ] && hostname=$5; [ -n "$6" ] && dev=$6; [ -n "$7" ] && autoconf=$7; [ -n "$8" ] && mtu=$8;
if [ -n "${9}" -a -n "${10}" -a -n "${11}" -a -n "${12}" -a -n "${13}" -a -n "${14}" ]; then
macaddr="${9}:${10}:${11}:${12}:${13}:${14}"
fi
;;
esac esac
# anaconda-style argument cluster
# ip=<ipv4-address> means anaconda-style static config argument cluster:
# ip=<ip> gateway=<gw> netmask=<nm> hostname=<host> mtu=<mtu>
# ksdevice={link|bootif|ibft|<MAC>|<ifname>}
if strstr "$autoconf" "*.*.*.*"; then if strstr "$autoconf" "*.*.*.*"; then
ip="$autoconf" ip="$autoconf"
gw=$(getarg gateway=) gw=$(getarg gateway=)
@@ -283,9 +350,12 @@ ip_to_var() {
dev=$(getarg ksdevice=) dev=$(getarg ksdevice=)
autoconf="none" autoconf="none"
mtu=$(getarg mtu=) mtu=$(getarg mtu=)
# handle special values for ksdevice
case "$dev" in case "$dev" in
# ignore fancy values for ksdevice=XXX bootif|BOOTIF) dev=$(fix_bootif $(getarg BOOTIF=)) ;;
link|bootif|BOOTIF|ibft|*:*:*:*:*:*) dev="" ;; link) dev="" ;; # FIXME: do something useful with this
ibft) dev="" ;; # ignore - ibft is handled elsewhere
esac esac
fi fi
} }
@@ -315,3 +385,62 @@ parse_ifname_opts() {
esac esac
} }
# some network driver need long time to initialize, wait before it's ready.
wait_for_if_link() {
local cnt=0
local li
while [ $cnt -lt 600 ]; do
li=$(ip -o link show dev $1 2>/dev/null)
[ -n "$li" ] && return 0
sleep 0.1
cnt=$(($cnt+1))
done
return 1
}
wait_for_if_up() {
local cnt=0
local li
while [ $cnt -lt 200 ]; do
li=$(ip -o link show up dev $1)
[ -n "$li" ] && return 0
sleep 0.1
cnt=$(($cnt+1))
done
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
}
wait_for_ipv6_auto() {
local cnt=0
local li
while [ $cnt -lt 400 ]; do
li=$(ip -6 addr show dev $1)
strstr "$li" "dynamic" && return 0
sleep 0.1
cnt=$(($cnt+1))
done
return 1
}
linkup() {
wait_for_if_link $1 2>/dev/null\
&& ip link set $1 up 2>/dev/null\
&& wait_for_if_up $1 2>/dev/null
}
type hostname >/dev/null 2>&1 || \
hostname() {
cat /proc/sys/kernel/hostname
}

View File

@@ -20,13 +20,22 @@ command -v setup_net >/dev/null || . /lib/net-lib.sh
netif=$1 netif=$1
[ -e "/tmp/net.bootdev" ] && read netif < /tmp/net.bootdev [ -e "/tmp/net.bootdev" ] && read netif < /tmp/net.bootdev
case "$netif" in
??:??:??:??:??:??) # MAC address
for i in /sys/class/net/*/address; do
mac=$(cat $i)
if [ "$mac" = "$netif" ]; then
i=${i%/address}
netif=${i##*/}
break
fi
done
esac
# Figure out the handler for root=dhcp by recalling all netroot cmdline # Figure out the handler for root=dhcp by recalling all netroot cmdline
# handlers when this is not called from manually network bringing up. # handlers when this is not called from manually network bringing up.
if [ -z "$2" ]; then if [ -z "$2" ]; then
if [ "$netroot" = "dhcp" ] || [ "$netroot" = "dhcp6" ] ; then if [ "$netroot" = "dhcp" ] || [ "$netroot" = "dhcp6" ] ; then
# Unset root so we can check later
unset root
# Load dhcp options # Load dhcp options
[ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts [ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
@@ -67,6 +76,7 @@ source_hook netroot $netif
# Run the handler; don't store the root, it may change from device to device # Run the handler; don't store the root, it may change from device to device
# XXX other variables to export? # XXX other variables to export?
if $handler $netif $netroot $NEWROOT; then if $handler $netif $netroot $NEWROOT; then
rm -f -- $hookdir/initqueue/finished/dhcp.sh
# Network rootfs mount successful - save interface info for ifcfg etc. # Network rootfs mount successful - save interface info for ifcfg etc.
save_netinfo $netif save_netinfo $netif
fi fi

View File

@@ -54,8 +54,8 @@ if getarg bond >/dev/null; then
fi fi
# Make it suitable for initscripts export # Make it suitable for initscripts export
bondoptions=$(str_replace "$bondoptions" ";" ",") bondoptions=$(str_replace "$bondoptions" ";" ",")
echo "bondname=$bondname" > /tmp/bond.info echo "bondname=$bondname" > /tmp/bond.${bondname}.info
echo "bondslaves=\"$bondslaves\"" >> /tmp/bond.info echo "bondslaves=\"$bondslaves\"" >> /tmp/bond.${bondname}.info
echo "bondoptions=\"$bondoptions\"" >> /tmp/bond.info echo "bondoptions=\"$bondoptions\"" >> /tmp/bond.${bondname}.info
return return
fi fi

View File

@@ -37,12 +37,6 @@ parsebridge() {
unset bridgename ethnames unset bridgename ethnames
iface=eth0 iface=eth0
if [ -e /tmp/bond.info ]; then
. /tmp/bond.info
if [ -n "$bondname" ] ; then
iface=$bondname
fi
fi
# Parse bridge for bridgename and ethnames # Parse bridge for bridgename and ethnames
if bridge="$(getarg bridge)"; then if bridge="$(getarg bridge)"; then

View File

@@ -17,14 +17,7 @@
command -v getarg >/dev/null || . /lib/dracut-lib.sh command -v getarg >/dev/null || . /lib/dracut-lib.sh
command -v ibft_to_cmdline >/dev/null || . /lib/net-lib.sh command -v ibft_to_cmdline >/dev/null || . /lib/net-lib.sh
# Don't mix BOOTIF=macaddr from pxelinux and ip= lines if [ -n "$netroot" ] && [ -z "$(getarg ip=)" ] && [ -z "$(getarg BOOTIF=)" ]; then
getarg ip= >/dev/null && getarg BOOTIF= >/dev/null && \
die "Mixing BOOTIF and ip= lines is dangerous"
# No more parsing stuff, BOOTIF says everything
[ -n "$(getarg BOOTIF)" ] && return
if [ -n "$netroot" ] && [ -z "$(getarg ip=)" ] ; then
# No ip= argument(s) for netroot provided, defaulting to DHCP # No ip= argument(s) for netroot provided, defaulting to DHCP
return; return;
fi fi
@@ -54,6 +47,12 @@ fi
for p in $(getargs ip=); do for p in $(getargs ip=); do
ip_to_var $p ip_to_var $p
# make first device specified the BOOTDEV
if [ -z "$BOOTDEV" ] && [ -n "$dev" ]; then
BOOTDEV="$dev"
[ -n "$NEEDBOOTDEV" ] && warn "Setting bootdev to '$BOOTDEV'"
fi
# skip ibft since we did it above # skip ibft since we did it above
[ "$autoconf" = "ibft" ] && continue [ "$autoconf" = "ibft" ] && continue
@@ -112,6 +111,12 @@ for p in $(getargs ip=); do
done done
# put BOOTIF in IFACES to make sure it comes up
if BOOTIF="$(getarg BOOTIF=)"; then
BOOTDEV=$(fix_bootif $BOOTIF)
IFACES="$BOOTDEV $IFACES"
fi
# This ensures that BOOTDEV is always first in IFACES # This ensures that BOOTDEV is always first in IFACES
if [ -n "$BOOTDEV" ] && [ -n "$IFACES" ] ; then if [ -n "$BOOTDEV" ] && [ -n "$IFACES" ] ; then
IFACES="${IFACES%$BOOTDEV*} ${IFACES#*$BOOTDEV}" IFACES="${IFACES%$BOOTDEV*} ${IFACES#*$BOOTDEV}"
@@ -121,6 +126,3 @@ fi
# Store BOOTDEV and IFACES for later use # Store BOOTDEV and IFACES for later use
[ -n "$BOOTDEV" ] && echo $BOOTDEV > /tmp/net.bootdev [ -n "$BOOTDEV" ] && echo $BOOTDEV > /tmp/net.bootdev
[ -n "$IFACES" ] && echo $IFACES > /tmp/net.ifaces [ -n "$IFACES" ] && echo $IFACES > /tmp/net.ifaces
# We need a ip= line for the configured bootdev=
[ -n "$NEEDBOOTDEV" ] && [ -z "$BOOTDEVOK" ] && die "Bootdev Argument '$BOOTDEV' not found"

View File

@@ -0,0 +1,44 @@
#!/bin/sh
#
# Format:
# team=<teammaster>:<teamslaves>
#
# teamslaves is a comma-separated list of physical (ethernet) interfaces
#
# return if team already parsed
[ -n "$teammaster" ] && return
# Check if team parameter is valid
if getarg team= >/dev/null ; then
:
fi
parseteam() {
local v=${1}:
set --
while [ -n "$v" ]; do
set -- "$@" "${v%%:*}"
v=${v#*:}
done
unset teammaster teamslaves
case $# in
2) teammaster=$1; teamslaves=$(str_replace "$2" "," " ") ;;
*) die "team= requires two parameters" ;;
esac
}
unset teammaster teamslaves
if getarg team>/dev/null; then
# Read team= parameters if they exist
team="$(getarg team=)"
if [ ! "$team" = "team" ]; then
parseteam "$(getarg team=)"
fi
echo "teammaster=$teammaster" > /tmp/team.info
echo "teamslaves=\"$teamslaves\"" >> /tmp/team.info
return
fi

View File

@@ -4,14 +4,6 @@
# NFS root might have reached here before /tmp/net.ifaces was written # NFS root might have reached here before /tmp/net.ifaces was written
udevadm settle --timeout=30 udevadm settle --timeout=30
# Don't write anything if we don't know our bootdev
[ -f /tmp/net.ifaces ] || return 1
read IFACES < /tmp/net.ifaces
if [ -e /tmp/bond.info ]; then
. /tmp/bond.info
fi
if [ -e /tmp/bridge.info ]; then if [ -e /tmp/bridge.info ]; then
. /tmp/bridge.info . /tmp/bridge.info
@@ -83,12 +75,27 @@ print_s390() {
echo "OPTIONS=\"${OPTIONS}\"" echo "OPTIONS=\"${OPTIONS}\""
} }
for netup in /tmp/net.*.did-setup ; do
[ -f $netup ] || continue
for netif in $IFACES ; do netif=${netup%%.did-setup}
netif=${netif##*/net.}
[ -e /tmp/ifcfg/ifcfg-$netif ] && continue [ -e /tmp/ifcfg/ifcfg-$netif ] && continue
# bridge?
unset bridge unset bridge
unset bond unset bond
unset bondslaves
unset bondname
unset bondoptions
unset uuid
unset ip
unset gw
unset mtu
unset mask
unset macaddr
unset slave
unset ethname
[ -e /tmp/bond.${netif}.info ] && . /tmp/bond.${netif}.info
uuid=$(cat /proc/sys/kernel/random/uuid) uuid=$(cat /proc/sys/kernel/random/uuid)
if [ "$netif" = "$bridgename" ]; then if [ "$netif" = "$bridgename" ]; then
bridge=yes bridge=yes
@@ -99,39 +106,46 @@ for netif in $IFACES ; do
cat /sys/class/net/$netif/address > /tmp/net.$netif.hwaddr cat /sys/class/net/$netif/address > /tmp/net.$netif.hwaddr
{ {
echo "# Generated by dracut initrd" echo "# Generated by dracut initrd"
echo "DEVICE=$netif" echo "DEVICE=\"$netif\""
echo "ONBOOT=yes" echo "ONBOOT=yes"
echo "NETBOOT=yes" echo "NETBOOT=yes"
echo "UUID=$uuid" echo "UUID=\"$uuid\""
[ -n "$mtu" ] && echo "MTU=$mtu" if [ -f /tmp/dhclient.$netif.lease ]; then
if [ -f /tmp/net.$netif.lease ]; then [ -f /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
strstr "$ip" '*:*:*' && strstr "$ip" '*:*:*' && echo "IPV6INIT=yes"
echo "IPV6INIT=yes" if [ -f /tmp/net.$netif.has_ibft_config ]; then
echo "DHCPV6C=yes" echo "BOOTPROTO=ibft"
echo "BOOTPROTO=dhcp" else
cp /tmp/net.$netif.lease /tmp/ifcfg-leases/dhclient-$uuid-$netif.lease echo "BOOTPROTO=dhcp"
fi
cp /tmp/dhclient.$netif.lease /tmp/ifcfg-leases/dhclient-$uuid-$netif.lease
else else
# If we've booted with static ip= lines, the override file is there # If we've booted with static ip= lines, the override file is there
[ -e /tmp/net.$netif.override ] && . /tmp/net.$netif.override [ -e /tmp/net.$netif.override ] && . /tmp/net.$netif.override
if strstr "$ip" '*:*:*'; then if strstr "$ip" '*:*:*'; then
echo "IPV6INIT=yes" echo "IPV6INIT=yes"
echo "IPV6_AUTOCONF=no" echo "IPV6_AUTOCONF=no"
echo "IPV6ADDR=$ip/$mask" echo "IPV6ADDR=\"$ip/$mask\""
else else
echo "BOOTPROTO=none" if [ -f /tmp/net.$netif.has_ibft_config ]; then
echo "IPADDR=$ip" echo "BOOTPROTO=ibft"
if strstr "$mask" "."; then
echo "NETMASK=$mask"
else else
echo "PREFIX=$mask" echo "BOOTPROTO=none"
echo "IPADDR=\"$ip\""
if strstr "$mask" "."; then
echo "NETMASK=\"$mask\""
else
echo "PREFIX=\"$mask\""
fi
fi fi
fi fi
if strstr "$gw" '*:*:*'; then if strstr "$gw" '*:*:*'; then
echo "IPV6_DEFAULTGW=$gw" echo "IPV6_DEFAULTGW=\"$gw\""
elif [ -n "$gw" ]; then elif [ -n "$gw" ]; then
echo "GATEWAY=$gw" echo "GATEWAY=\"$gw\""
fi fi
fi fi
[ -n "$mtu" ] && echo "MTU=\"$mtu\""
} > /tmp/ifcfg/ifcfg-$netif } > /tmp/ifcfg/ifcfg-$netif
# bridge needs different things written to ifcfg # bridge needs different things written to ifcfg
@@ -139,14 +153,14 @@ for netif in $IFACES ; do
# standard interface # standard interface
{ {
if [ -n "$macaddr" ]; then if [ -n "$macaddr" ]; then
echo "MACADDR=$macaddr" echo "MACADDR=\"$macaddr\""
else else
echo "HWADDR=\"$(cat /sys/class/net/$netif/address)\"" echo "HWADDR=\"$(cat /sys/class/net/$netif/address)\""
fi fi
print_s390 $netif print_s390 $netif
echo "TYPE=Ethernet" echo "TYPE=Ethernet"
echo "NAME=\"Boot Disk\"" echo "NAME=\"$netif\""
[ -n "$mtu" ] && echo "MTU=$mtu" [ -n "$mtu" ] && echo "MTU=\"$mtu\""
} >> /tmp/ifcfg/ifcfg-$netif } >> /tmp/ifcfg/ifcfg-$netif
fi fi
@@ -155,22 +169,22 @@ for netif in $IFACES ; do
{ {
# This variable is an indicator of a bond interface for initscripts # This variable is an indicator of a bond interface for initscripts
echo "BONDING_OPTS=\"$bondoptions\"" echo "BONDING_OPTS=\"$bondoptions\""
echo "NAME=\"Boot Disk\"" echo "NAME=\"$netif\""
echo "TYPE=Bond"
} >> /tmp/ifcfg/ifcfg-$netif } >> /tmp/ifcfg/ifcfg-$netif
for slave in $bondslaves ; do for slave in $bondslaves ; do
# Set ONBOOT=no to prevent initscripts from trying to setup already bonded physical interface
# write separate ifcfg file for the raw eth interface # write separate ifcfg file for the raw eth interface
{ {
echo "# Generated by dracut initrd" echo "# Generated by dracut initrd"
echo "DEVICE=$slave" echo "DEVICE=\"$slave\""
echo "TYPE=Ethernet" echo "TYPE=Ethernet"
echo "ONBOOT=no" echo "ONBOOT=yes"
echo "NETBOOT=yes" echo "NETBOOT=yes"
echo "HWADDR=$(cat /sys/class/net/$slave/address)" echo "HWADDR=\"$(cat /sys/class/net/$slave/address)\""
echo "SLAVE=yes" echo "SLAVE=yes"
echo "MASTER=$netif" echo "MASTER=\"$netif\""
echo "NAME=$slave" echo "NAME=\"$slave\""
} >> /tmp/ifcfg/ifcfg-$slave } >> /tmp/ifcfg/ifcfg-$slave
done done
fi fi
@@ -179,52 +193,50 @@ for netif in $IFACES ; do
# bridge # bridge
{ {
echo "TYPE=Bridge" echo "TYPE=Bridge"
echo "NAME=\"Boot Disk\"" echo "NAME=\"$netif\""
} >> /tmp/ifcfg/ifcfg-$netif } >> /tmp/ifcfg/ifcfg-$netif
if [ "$ethname" = "$bondname" ] ; then if [ "$ethname" = "$bondname" ] ; then
{ {
# Set ONBOOT=no to prevent initscripts from trying to setup already bridged bond interface
echo "# Generated by dracut initrd" echo "# Generated by dracut initrd"
echo "DEVICE=$bondname" echo "DEVICE=\"$bondname\""
echo "ONBOOT=no" echo "ONBOOT=yes"
echo "NETBOOT=yes" echo "NETBOOT=yes"
# This variable is an indicator of a bond interface for initscripts # This variable is an indicator of a bond interface for initscripts
echo "BONDING_OPTS=\"$bondoptions\"" echo "BONDING_OPTS=\"$bondoptions\""
echo "BRIDGE=$netif" echo "BRIDGE=\"$netif\""
echo "NAME=\"$bondname\"" echo "NAME=\"$bondname\""
} >> /tmp/ifcfg/ifcfg-$bondname } >> /tmp/ifcfg/ifcfg-$bondname
for slave in $bondslaves ; do for slave in $bondslaves ; do
# write separate ifcfg file for the raw eth interface # write separate ifcfg file for the raw eth interface
# Set ONBOOT=no to prevent initscripts from trying to setup already bridged physical interface
{ {
echo "# Generated by dracut initrd" echo "# Generated by dracut initrd"
echo "DEVICE=$slave" echo "DEVICE=\"$slave\""
echo "TYPE=Ethernet" echo "TYPE=Ethernet"
echo "ONBOOT=no" echo "ONBOOT=yes"
echo "NETBOOT=yes" echo "NETBOOT=yes"
echo "HWADDR=$(cat /sys/class/net/$slave/address)" echo "HWADDR=\"$(cat /sys/class/net/$slave/address)\""
echo "SLAVE=yes" echo "SLAVE=yes"
echo "MASTER=$bondname" echo "MASTER=\"$bondname\""
echo "NAME=$slave" echo "NAME=\"$slave\""
} >> /tmp/ifcfg/ifcfg-$slave } >> /tmp/ifcfg/ifcfg-$slave
done done
else else
# write separate ifcfg file for the raw eth interface # write separate ifcfg file for the raw eth interface
{ {
echo "# Generated by dracut initrd" echo "# Generated by dracut initrd"
echo "DEVICE=$ethname" echo "DEVICE=\"$ethname\""
echo "TYPE=Ethernet" echo "TYPE=Ethernet"
echo "ONBOOT=no" echo "ONBOOT=yes"
echo "NETBOOT=yes" echo "NETBOOT=yes"
echo "HWADDR=$(cat /sys/class/net/$ethname/address)" echo "HWADDR=\"$(cat /sys/class/net/$ethname/address)\""
echo "BRIDGE=$netif" echo "BRIDGE=\"$netif\""
echo "NAME=$ethname" echo "NAME=\"$ethname\""
} >> /tmp/ifcfg/ifcfg-$ethname } >> /tmp/ifcfg/ifcfg-$ethname
fi fi
fi fi
i=1 i=1
for ns in $(getargs nameserver); do for ns in $(getargs nameserver); do
echo "DNS${i}=${ns}" >> /tmp/ifcfg/ifcfg-$netif echo "DNS${i}=\"${ns}\"" >> /tmp/ifcfg/ifcfg-$netif
i=$((i+1)) i=$((i+1))
done done
done done

View File

@@ -12,6 +12,7 @@ depends() {
} }
install() { install() {
local _dir _crt _found
inst_simple "$moddir/url-lib.sh" "/lib/url-lib.sh" inst_simple "$moddir/url-lib.sh" "/lib/url-lib.sh"
dracut_install curl dracut_install curl
# also install libs for curl https # also install libs for curl https
@@ -20,11 +21,17 @@ install() {
inst_libdir_file "libsoftokn3.so*" inst_libdir_file "libsoftokn3.so*"
inst_libdir_file "libsqlite3.so*" inst_libdir_file "libsqlite3.so*"
mkdir -m 0755 -p "$initdir/etc/ssl/certs" for _dir in $libdirs; do
if ! inst_any -t /etc/ssl/certs/ca-bundle.crt \ [[ -d $_dir ]] || continue
/etc/ssl/certs/ca-bundle.crt \ _crt=$(grep -F --binary-files=text -z .crt $_dir/libcurl.so)
/etc/ssl/certs/ca-certificates.crt; then [[ $_crt ]] || continue
dwarn "Couldn't find SSL CA cert bundle; HTTPS won't work." [[ $_crt == /*/* ]] || continue
fi if ! inst_simple "$_crt"; then
dwarn "Couldn't install '$_crt' SSL CA cert bundle; HTTPS might not work."
continue
fi
_found=1
done
[[ $_found ]] || dwarn "Couldn't find SSL CA cert bundle; HTTPS won't work."
} }

View File

@@ -23,7 +23,7 @@ fetch_url() {
local handler="$(get_url_handler $url)" local handler="$(get_url_handler $url)"
[ -n "$handler" ] || return 254 [ -n "$handler" ] || return 254
[ -n "$url" ] || return 255 [ -n "$url" ] || return 255
$handler "$url" "$outloc" "$handler" "$url" "$outloc"
} }
# get_url_handler URL # get_url_handler URL
@@ -54,14 +54,17 @@ add_url_handler() {
export CURL_HOME="/run/initramfs/url-lib" export CURL_HOME="/run/initramfs/url-lib"
mkdir -p $CURL_HOME mkdir -p $CURL_HOME
curl_args="--location --retry 3 --fail --show-error" curl_args="--globoff --location --retry 3 --fail --show-error"
getargbool 0 rd.noverifyssl && curl_args+=" --insecure" getargbool 0 rd.noverifyssl && curl_args="$curl_args --insecure"
proxy=$(getarg proxy=)
[ -n "$proxy" ] && curl_args="$curl_args --proxy $proxy"
curl_fetch_url() { curl_fetch_url() {
local url="$1" outloc="$2" local url="$1" outloc="$2"
echo "$url" > /proc/self/fd/0 echo "$url" > /proc/self/fd/0
if [ -n "$outloc" ]; then if [ -n "$outloc" ]; then
curl $curl_args --output "$outloc" "$url" || return $? curl $curl_args --output "$outloc" -- "$url" || return $?
else else
local outdir="$(mkuniqdir /tmp curl_fetch_url)" local outdir="$(mkuniqdir /tmp curl_fetch_url)"
( cd "$outdir"; curl $curl_args --remote-name "$url" || return $? ) ( cd "$outdir"; curl $curl_args --remote-name "$url" || return $? )
@@ -103,18 +106,18 @@ nfs_fetch_url() {
local filepath="${path%/*}" filename="${path##*/}" mntdir="" local filepath="${path%/*}" filename="${path##*/}" mntdir=""
# skip mount if server:/filepath is already mounted # skip mount if server:/filepath is already mounted
mntdir=$(nfs_already_mounted $server $path) mntdir=$(nfs_already_mounted "$server" "$path")
if [ -z "$mntdir" ]; then if [ -z "$mntdir" ]; then
local mntdir="$(mkuniqdir /run nfs_mnt)" local mntdir="$(mkuniqdir /run nfs_mnt)"
mount_nfs $nfs:$server:$filepath${options:+:$options} $mntdir mount_nfs "$nfs:$server:$filepath${options:+:$options}" "$mntdir"
# lazy unmount during pre-pivot hook # lazy unmount during pre-pivot hook
inst_hook --hook pre-pivot --name 99url-lib-umount-nfs umount -l $mntdir inst_hook --hook pre-pivot --name 99url-lib-umount-nfs umount -l -- "$mntdir"
fi fi
if [ -z "$outloc" ]; then if [ -z "$outloc" ]; then
outloc="$mntdir/$filename" outloc="$mntdir/$filename"
else else
cp -f "$mntdir/$filename" "$outloc" || return $? cp -f -- "$mntdir/$filename" "$outloc" || return $?
fi fi
[ -f "$outloc" ] || return 253 [ -f "$outloc" ] || return 253
if [ -z "$2" ]; then echo "$outloc" ; fi if [ -z "$2" ]; then echo "$outloc" ; fi

View File

@@ -0,0 +1,63 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
return 255
}
depends() {
return 0
}
installkernel() {
local _modname
# Include KMS capable drm drivers
drm_module_filter() {
local _drm_drivers='drm_crtc_init'
local _ret
# subfunctions inherit following FDs
local _merge=8 _side2=9
function nmf1() {
local _fname _fcont
while read _fname; do
case "$_fname" in
*.ko) _fcont="$(< $_fname)" ;;
*.ko.gz) _fcont="$(gzip -dc $_fname)" ;;
*.ko.xz) _fcont="$(xz -dc $_fname)" ;;
esac
[[ $_fcont =~ $_drm_drivers
&& ! $_fcont =~ iw_handler_get_spy ]] \
&& echo "$_fname"
done
}
function rotor() {
local _f1 _f2
while read _f1; do
echo "$_f1"
if read _f2; then
echo "$_f2" 1>&${_side2}
fi
done | nmf1 1>&${_merge}
}
# Use two parallel streams to filter alternating modules.
set +x
eval "( ( rotor ) ${_side2}>&1 | nmf1 ) ${_merge}>&1"
[[ $debug ]] && set -x
return 0
}
for _modname in $(find_kernel_modules_by_path drivers/gpu/drm \
| drm_module_filter) ; do
# if the hardware is present, include module even if it is not currently loaded,
# as we could e.g. be in the installer; nokmsboot boot parameter will disable
# loading of the driver if needed
if [[ $hostonly ]] && modinfo -F alias $_modname | sed -e 's,\?,\.,g' -e 's,\*,\.\*,g' \
| grep -qxf - /sys/bus/pci/devices/*/modalias 2>/dev/null; then
hostonly='' instmods $_modname
continue
fi
instmods $_modname
done
}

View File

@@ -4,63 +4,11 @@
check() { check() {
[[ "$mount_needs" ]] && return 1 [[ "$mount_needs" ]] && return 1
[[ -x /sbin/plymouthd && -x /bin/plymouth && -x /usr/sbin/plymouth-set-default-theme ]] type -P plymouthd >/dev/null && type -P plymouth >/dev/null
} }
depends() { depends() {
return 0 echo drm
}
installkernel() {
local _modname
# Include KMS capable drm drivers
drm_module_filter() {
local _drm_drivers='drm_crtc_init'
local _ret
# subfunctions inherit following FDs
local _merge=8 _side2=9
function nmf1() {
local _fname _fcont
while read _fname; do
case "$_fname" in
*.ko) _fcont="$(< $_fname)" ;;
*.ko.gz) _fcont="$(gzip -dc $_fname)" ;;
*.ko.xz) _fcont="$(xz -dc $_fname)" ;;
esac
[[ $_fcont =~ $_drm_drivers
&& ! $_fcont =~ iw_handler_get_spy ]] \
&& echo "$_fname"
done
}
function rotor() {
local _f1 _f2
while read _f1; do
echo "$_f1"
if read _f2; then
echo "$_f2" 1>&${_side2}
fi
done | nmf1 1>&${_merge}
}
# Use two parallel streams to filter alternating modules.
set +x
eval "( ( rotor ) ${_side2}>&1 | nmf1 ) ${_merge}>&1"
[[ $debug ]] && set -x
return 0
}
for _modname in $(find_kernel_modules_by_path drivers/gpu/drm \
| drm_module_filter) ; do
# if the hardware is present, include module even if it is not currently loaded,
# as we could e.g. be in the installer; nokmsboot boot parameter will disable
# loading of the driver if needed
if [[ $hostonly ]] && modinfo -F alias $_modname | sed -e 's,\?,\.,g' -e 's,\*,\.\*,g' \
| grep -qxf - /sys/bus/pci/devices/*/modalias; then
hostonly='' instmods $_modname
continue
fi
instmods $_modname
done
} }
install() { install() {
@@ -69,12 +17,16 @@ install() {
. "$moddir"/plymouth-populate-initrd.sh . "$moddir"/plymouth-populate-initrd.sh
else else
PLYMOUTH_POPULATE_SOURCE_FUNCTIONS="$dracutfunctions" \ PLYMOUTH_POPULATE_SOURCE_FUNCTIONS="$dracutfunctions" \
/usr/libexec/plymouth/plymouth-populate-initrd -t $initdir /usr/libexec/plymouth/plymouth-populate-initrd -t "$initdir"
fi fi
inst_hook pre-pivot 90 "$moddir"/plymouth-newroot.sh
inst_hook pre-trigger 10 "$moddir"/plymouth-pretrigger.sh
inst_hook emergency 50 "$moddir"/plymouth-emergency.sh inst_hook emergency 50 "$moddir"/plymouth-emergency.sh
dracut_install readlink dracut_install readlink
if ! dracut_module_included "systemd"; then
inst_hook pre-trigger 10 "$moddir"/plymouth-pretrigger.sh
inst_hook pre-pivot 90 "$moddir"/plymouth-newroot.sh
fi
} }

View File

@@ -1,4 +1,4 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh # ex: ts=8 sw=4 sts=4 et filetype=sh
[ -x /bin/plymouth ] && /bin/plymouth --hide-splash plymouth --hide-splash 2>/dev/null || :

View File

@@ -2,6 +2,6 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh # ex: ts=8 sw=4 sts=4 et filetype=sh
if [ -x /bin/plymouth -a -z "$DRACUT_SYSTEMD" ]; then if type plymouth >/dev/null 2>&1 && [ -z "$DRACUT_SYSTEMD" ]; then
/bin/plymouth --newroot=$NEWROOT plymouth --newroot=$NEWROOT
fi fi

View File

@@ -4,15 +4,14 @@
PLYMOUTH_LOGO_FILE="/usr/share/pixmaps/system-logo-white.png" PLYMOUTH_LOGO_FILE="/usr/share/pixmaps/system-logo-white.png"
PLYMOUTH_THEME=$(plymouth-set-default-theme) PLYMOUTH_THEME=$(plymouth-set-default-theme)
inst /sbin/plymouthd /bin/plymouthd dracut_install plymouthd plymouth \
dracut_install /bin/plymouth \
"${PLYMOUTH_LOGO_FILE}" \ "${PLYMOUTH_LOGO_FILE}" \
/etc/system-release /etc/system-release
mkdir -m 0755 -p "${initdir}/usr/share/plymouth" mkdir -m 0755 -p "${initdir}/usr/share/plymouth"
inst_libdir_file "plymouth/text.so" "plymouth/details.so" inst_libdir_file "plymouth/text.so" "plymouth/details.so"
if [[ $hostonly ]]; then if [[ $hostonly ]]; then
dracut_install \ dracut_install \
"/usr/share/plymouth/themes/details/details.plymouth" \ "/usr/share/plymouth/themes/details/details.plymouth" \

View File

@@ -2,7 +2,7 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh # ex: ts=8 sw=4 sts=4 et filetype=sh
if [ -x /bin/plymouthd -a -z "$DRACUT_SYSTEMD" ]; then if type plymouthd >/dev/null 2>&1 && [ -z "$DRACUT_SYSTEMD" ]; then
if getargbool 1 plymouth.enable && getargbool 1 rd.plymouth -d -n rd_NO_PLYMOUTH; then if getargbool 1 plymouth.enable && getargbool 1 rd.plymouth -d -n rd_NO_PLYMOUTH; then
# first trigger graphics subsystem # first trigger graphics subsystem
udevadm trigger --action=add --attr-match=class=0x030000 >/dev/null 2>&1 udevadm trigger --action=add --attr-match=class=0x030000 >/dev/null 2>&1
@@ -16,8 +16,8 @@ if [ -x /bin/plymouthd -a -z "$DRACUT_SYSTEMD" ]; then
read consoledev rest < /sys/class/tty/console/active read consoledev rest < /sys/class/tty/console/active
consoledev=${consoledev:-tty0} consoledev=${consoledev:-tty0}
[ -x /lib/udev/console_init -a -e "/dev/$consoledev" ] && /lib/udev/console_init "/dev/$consoledev" [ -x /lib/udev/console_init -a -e "/dev/$consoledev" ] && /lib/udev/console_init "/dev/$consoledev"
[ -x /bin/plymouthd ] && /bin/plymouthd --attach-to-session --pid-file /run/plymouth/pid plymouthd --attach-to-session --pid-file /run/plymouth/pid
/bin/plymouth --show-splash 2>&1 | vinfo plymouth --show-splash 2>&1 | vinfo
# reset tty after plymouth messed with it # reset tty after plymouth messed with it
[ -x /lib/udev/console_init -a -e "/dev/$consoledev" ] && /lib/udev/console_init "/dev/$consoledev" [ -x /lib/udev/console_init -a -e "/dev/$consoledev" ] && /lib/udev/console_init "/dev/$consoledev"
fi fi

View File

@@ -32,6 +32,7 @@ function cms_write_config()
cat > /etc/sysconfig/network << EOF cat > /etc/sysconfig/network << EOF
HOSTNAME=$HOSTNAME HOSTNAME=$HOSTNAME
EOF EOF
echo "$HOSTNAME" > /etc/hostname
if [ "$ipv6" ]; then if [ "$ipv6" ]; then
echo "NETWORKING_IPV6=yes" >> /etc/sysconfig/network echo "NETWORKING_IPV6=yes" >> /etc/sysconfig/network
else else

View File

@@ -27,7 +27,7 @@ else
fi fi
{ {
echo "ip=$IPADDR::$GATEWAY:$NETMASK:$HOSTNAME:$DEVICE:none:$MACADDR" echo "ip=$IPADDR::$GATEWAY:$NETMASK:$HOSTNAME:$DEVICE:none:$MTU:$MACADDR"
for i in $DNS1 $DNS2; do for i in $DNS1 $DNS2; do
echo "nameserver=$i" echo "nameserver=$i"
done done

View File

@@ -51,152 +51,152 @@ function dasd_settle_all() {
fi fi
done done
return 0 return 0
} }
# prints a canonocalized device bus ID for a given devno of any format # prints a canonocalized device bus ID for a given devno of any format
function canonicalize_devno() function canonicalize_devno()
{ {
case ${#1} in case ${#1} in
3) echo "0.0.0${1}" ;; 3) echo "0.0.0${1}" ;;
4) echo "0.0.${1}" ;; 4) echo "0.0.${1}" ;;
*) echo "${1}" ;; *) echo "${1}" ;;
esac esac
return 0 return 0
} }
# read file from CMS and write it to /tmp # read file from CMS and write it to /tmp
function readcmsfile() # $1=dasdport $2=filename function readcmsfile() # $1=dasdport $2=filename
{ {
local dev local dev
local numcpus local numcpus
local devname local devname
local ret=0 local ret=0
if [ $# -ne 2 ]; then return; fi if [ $# -ne 2 ]; then return; fi
# precondition: udevd created dasda block device node # precondition: udevd created dasda block device node
if ! dasd_cio_free -d $1 ; then if ! dasd_cio_free -d $1 ; then
echo $"DASD $1 could not be cleared from device blacklist" echo $"DASD $1 could not be cleared from device blacklist"
return 1 return 1
fi fi
modprobe dasd_mod dasd=$CMSDASD modprobe dasd_mod dasd=$CMSDASD
modprobe dasd_eckd_mod modprobe dasd_eckd_mod
udevadm settle udevadm settle
# precondition: dasd_eckd_mod driver incl. dependencies loaded, # precondition: dasd_eckd_mod driver incl. dependencies loaded,
# dasd_mod must be loaded without setting any DASD online # dasd_mod must be loaded without setting any DASD online
dev=$(canonicalize_devno $1) dev=$(canonicalize_devno $1)
numcpus=$( numcpus=$(
while read line; do while read line; do
if strstr "$line" "# processors"; then if strstr "$line" "# processors"; then
echo ${line##*:}; echo ${line##*:};
break; break;
fi; fi;
done < /proc/cpuinfo done < /proc/cpuinfo
) )
if [ ${numcpus} -eq 1 ]; then if [ ${numcpus} -eq 1 ]; then
echo 1 > /sys/bus/ccw/devices/$dev/online echo 1 > /sys/bus/ccw/devices/$dev/online
else else
if ! sysecho /sys/bus/ccw/devices/$dev/online 1; then if ! sysecho /sys/bus/ccw/devices/$dev/online 1; then
echo $"DASD $dev could not be set online" echo $"DASD $dev could not be set online"
return 1 return 1
fi
udevadm settle
if ! dasd_settle $dev ; then
echo $"Could not access DASD $dev in time"
return 1
fi
fi fi
udevadm settle udevadm settle
if ! dasd_settle $dev ; then
echo $"Could not access DASD $dev in time" devname=$(cd /sys/bus/ccw/devices/$dev/block; set -- *; [ -b /dev/$1 ] && echo $1)
return 1 devname=${devname:-dasda}
[[ -d /mnt ]] || mkdir /mnt
if cmsfs-fuse --to=UTF-8 -a /dev/$devname /mnt; then
cat /mnt/$2 > /run/initramfs/$2
umount /mnt || umount -l /mnt
udevadm settle
else
echo $"Could not read conf file $2 on CMS DASD $1."
ret=1
fi fi
fi
udevadm settle if ! sysecho /sys/bus/ccw/devices/$dev/online 0; then
echo $"DASD $dev could not be set offline again"
devname=$(cd /sys/bus/ccw/devices/$dev/block; set -- *; [ -b /dev/$1 ] && echo $1)
devname=${devname:-dasda}
[[ -d /mnt ]] || mkdir /mnt
if cmsfs-fuse --to=UTF-8 -a /dev/$devname /mnt; then
cat /mnt/$2 > /run/initramfs/$2
umount /mnt || umount -l /mnt
udevadm settle
else
echo $"Could not read conf file $2 on CMS DASD $1."
ret=1
fi
if ! sysecho /sys/bus/ccw/devices/$dev/online 0; then
echo $"DASD $dev could not be set offline again"
#return 1 #return 1
fi fi
udevadm settle udevadm settle
# unbind all dasds to unload the dasd modules for a clean start # unbind all dasds to unload the dasd modules for a clean start
( cd /sys/bus/ccw/drivers/dasd-eckd; for i in *.*; do echo $i > unbind;done) ( cd /sys/bus/ccw/drivers/dasd-eckd; for i in *.*; do echo $i > unbind;done)
udevadm settle udevadm settle
modprobe -r dasd_eckd_mod modprobe -r dasd_eckd_mod
udevadm settle udevadm settle
modprobe -r dasd_diag_mod modprobe -r dasd_diag_mod
udevadm settle udevadm settle
modprobe -r dasd_mod modprobe -r dasd_mod
udevadm settle udevadm settle
return $ret return $ret
} }
processcmsfile() processcmsfile()
{ {
source /tmp/cms.conf source /tmp/cms.conf
if [[ $NETTYPE ]]; then if [[ $NETTYPE ]]; then
( (
echo -n $NETTYPE,$SUBCHANNELS echo -n $NETTYPE,$SUBCHANNELS
[[ $PORTNAME ]] && echo ",portname=$PORTNAME" [[ $PORTNAME ]] && echo -n ",portname=$PORTNAME"
[[ $LAYER2 ]] && echo ",layer2=$LAYER" [[ $LAYER2 ]] && echo -n ",layer2=$LAYER2"
[[ "$NETTYPE" = "ctc" ]] && [[ $CTCPROT ]] && echo ",protocol=$CTCPROT" [[ "$NETTYPE" = "ctc" ]] && [[ $CTCPROT ]] && echo -n ",protocol=$CTCPROT"
echo echo
) >> /etc/ccw.conf ) >> /etc/ccw.conf
OLDIFS=$IFS OLDIFS=$IFS
IFS=, IFS=,
read -a subch_array <<< "indexzero,$SUBCHANNELS" read -a subch_array <<< "indexzero,$SUBCHANNELS"
IFS=$OLDIFS IFS=$OLDIFS
devbusid=${subch_array[1]} devbusid=${subch_array[1]}
if [ "$NETTYPE" = "ctc" ]; then if [ "$NETTYPE" = "ctc" ]; then
driver="ctcm" driver="ctcm"
else else
driver=$NETTYPE driver=$NETTYPE
fi
printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="%s", KERNELS=="%s", ENV{INTERFACE}=="?*", RUN+="/sbin/initqueue --onetime --unique --name cmsifup-$env{INTERFACE} /sbin/cmsifup $env{INTERFACE}"\n' "$driver" "$devbusid" > /etc/udev/rules.d/99-cms.rules
# remove the default net rules
rm -f -- /etc/udev/rules.d/91-default-net.rules
[[ -f /etc/udev/rules.d/90-net.rules ]] \
|| printf 'SUBSYSTEM=="net", ACTION=="online", RUN+="/sbin/initqueue --onetime --env netif=$env{INTERFACE} source_hook initqueue/online"\n' >> /etc/udev/rules.d/99-cms.rules
udevadm control --reload
znet_cio_free
fi fi
printf 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="%s", KERNELS=="%s", ENV{INTERFACE}=="?*", RUN+="/sbin/initqueue --onetime --unique --name cmsifup-$env{INTERFACE} /sbin/cmsifup $env{INTERFACE}"\n' "$driver" "$devbusid" > /etc/udev/rules.d/99-cms.rules if [[ $DASD ]]; then
# remove the default net rules echo $DASD | normalize_dasd_arg > /etc/dasd.conf
rm -f /etc/udev/rules.d/61-default-net.rules echo "options dasd_mod dasd=$DASD" > /etc/modprobe.d/dasd_mod.conf
[[ -f /etc/udev/rules.d/60-net.rules ]] \ dasd_cio_free
|| printf 'SUBSYSTEM=="net", ACTION=="online", RUN+="/sbin/initqueue --onetime --env netif=$env{INTERFACE} source_hook initqueue/online"\n' >> /etc/udev/rules.d/99-cms.rules fi
znet_cio_free unset _do_zfcp
fi for i in ${!FCP_*}; do
echo "${!i}" >> /etc/zfcp.conf
_do_zfcp=1
done
[[ $_do_zfcp ]] && zfcp_cio_free
unset _do_zfcp
}
if [[ $DASD ]]; then [[ $CMSDASD ]] || CMSDASD=$(getarg "CMSDASD=")
echo $DASD | normalize_dasd_arg > /etc/dasd.conf [[ $CMSCONFFILE ]] || CMSCONFFILE=$(getarg "CMSCONFFILE=")
echo "options dasd_mod dasd=$DASD" > /etc/modprobe.d/dasd_mod.conf
dasd_cio_free
fi
unset _do_zfcp
for i in ${!FCP_*}; do
echo "${!i}" >> /etc/zfcp.conf
_do_zfcp=1
done
[[ $_do_zfcp ]] && zfcp_cio_free
unset _do_zfcp
}
[[ $CMSDASD ]] || CMSDASD=$(getarg "CMSDASD=")
[[ $CMSCONFFILE ]] || CMSCONFFILE=$(getarg "CMSCONFFILE=")
# Parse configuration # Parse configuration
if [ -n "$CMSDASD" -a -n "$CMSCONFFILE" ]; then if [ -n "$CMSDASD" -a -n "$CMSCONFFILE" ]; then
if readcmsfile $CMSDASD $CMSCONFFILE; then if readcmsfile $CMSDASD $CMSCONFFILE; then
ln -s /run/initramfs/$CMSCONFFILE /tmp/$CMSCONFFILE ln -s /run/initramfs/$CMSCONFFILE /tmp/$CMSCONFFILE
ln -s /run/initramfs/$CMSCONFFILE /tmp/cms.conf ln -s /run/initramfs/$CMSCONFFILE /tmp/cms.conf
processcmsfile processcmsfile
fi
fi fi
fi

View File

@@ -29,4 +29,5 @@ install() {
inst_libdir_file "gconv/*" inst_libdir_file "gconv/*"
#inst /usr/lib/locale/locale-archive #inst /usr/lib/locale/locale-archive
dracut_need_initqueue
} }

View File

@@ -1,11 +1,8 @@
SUBSYSTEM!="block", GOTO="btrfs_end" SUBSYSTEM!="block", GOTO="btrfs_end"
ACTION!="add|change", GOTO="btrfs_end" ACTION!="add|change", GOTO="btrfs_end"
ENV{ID_FS_TYPE}!="btrfs", GOTO="btrfs_end" ENV{ID_FS_TYPE}!="btrfs", GOTO="btrfs_end"
RUN+="/sbin/modprobe btrfs"
RUN+="/sbin/btrfs device scan $env{DEVNAME}" RUN+="/sbin/btrfs device scan $env{DEVNAME}"
RUN+="/sbin/initqueue --finished --unique --name btrfs_finished /sbin/btrfs_finished" RUN+="/sbin/initqueue --finished --unique --name btrfs_finished /sbin/btrfs_finished"
RUN+="/sbin/initqueue --timeout --onetime --unique --name btrfs_timeout /sbin/btrfs_timeout"
LABEL="btrfs_end" LABEL="btrfs_end"

View File

@@ -0,0 +1,21 @@
#!/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
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"
btrfs device ready "$_dev" >/dev/null 2>&1
return $?
fi
return 0
}
btrfs_check_complete $1
exit $?

View File

@@ -5,5 +5,4 @@
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
info "Scanning for all btrfs devices" info "Scanning for all btrfs devices"
/sbin/btrfs device scan 2>&1 | vinfo /sbin/btrfs device scan >/dev/null 2>&1
exit 0

View File

@@ -9,12 +9,10 @@ check() {
type -P btrfs >/dev/null || return 1 type -P btrfs >/dev/null || return 1
[[ $hostonly ]] || [[ $mount_needs ]] && { [[ $hostonly ]] || [[ $mount_needs ]] && {
local _found
for fs in ${host_fs_types[@]}; do for fs in ${host_fs_types[@]}; do
strstr "$fs" "\|btrfs" && _found="1" [[ "$fs" == "btrfs" ]] && return 0
done done
[[ $_found ]] || return 1 return 255
unset _found
} }
return 0 return 0
@@ -26,14 +24,26 @@ depends() {
} }
installkernel() { installkernel() {
instmods btrfs crc32c instmods btrfs
} }
install() { install() {
inst_rules "$moddir/80-btrfs.rules" if ! inst_rules 64-btrfs.rules; then
inst_script "$moddir/btrfs_finished.sh" /sbin/btrfs_finished inst_rules "$moddir/80-btrfs.rules"
inst_script "$moddir/btrfs_timeout.sh" /sbin/btrfs_timeout case "$(btrfs --help)" in
dracut_install btrfsck *device\ ready*)
inst_script "$moddir/btrfs_device_ready.sh" /sbin/btrfs_finished ;;
*)
inst_script "$moddir/btrfs_finished.sh" /sbin/btrfs_finished ;;
esac
fi
if ! dracut_module_included "systemd"; then
inst_script "$moddir/btrfs_timeout.sh" \
/usr/lib/dracut/hooks/initqueue/timeout/btrfs_timeout.sh
fi
dracut_install -o btrfsck btrfs-zero-log
inst $(command -v btrfs) /sbin/btrfs inst $(command -v btrfs) /sbin/btrfs
} }

View File

@@ -2,7 +2,7 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh # ex: ts=8 sw=4 sts=4 et filetype=sh
# close everything which is not busy # close everything which is not busy
rm -f /etc/udev/rules.d/70-luks.rules >/dev/null 2>&1 rm -f -- /etc/udev/rules.d/70-luks.rules >/dev/null 2>&1
if ! getarg rd.luks.uuid -d rd_LUKS_UUID >/dev/null 2>&1 && getargbool 1 rd.luks -d -n rd_NO_LUKS >/dev/null 2>&1; then if ! getarg rd.luks.uuid -d rd_LUKS_UUID >/dev/null 2>&1 && getargbool 1 rd.luks -d -n rd_NO_LUKS >/dev/null 2>&1; then
while true; do while true; do

View File

@@ -47,8 +47,8 @@ ask_for_password() {
{ flock -s 9; { flock -s 9;
# Prompt for password with plymouth, if installed and running. # Prompt for password with plymouth, if installed and running.
if [ -x /bin/plymouth ] && /bin/plymouth --ping; then if type plymouth >/dev/null 2>&1 && plymouth --ping 2>/dev/null; then
/bin/plymouth ask-for-password \ plymouth ask-for-password \
--prompt "$ply_prompt" --number-of-tries=$ply_tries \ --prompt "$ply_prompt" --number-of-tries=$ply_tries \
--command="$ply_cmd" --command="$ply_cmd"
ret=$? ret=$?

View File

@@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
. /lib/dracut-lib.sh . /lib/dracut-lib.sh
@@ -11,18 +13,21 @@ if [ -f /etc/crypttab ]; then
done < /etc/crypttab done < /etc/crypttab
fi fi
allowdiscards="-"
# parse for allow-discards # parse for allow-discards
if strstr "$(cryptsetup --help)" "allow-discards"; then if strstr "$(cryptsetup --help)" "allow-discards"; then
if discarduuids=$(getargs "rd.luks.allow-discards"); then if discarduuids=$(getargs "rd.luks.allow-discards"); then
discarduuids=$(str_replace "$discarduuids" 'luks-' '')
if strstr " $discarduuids " " ${luks##luks-}"; then if strstr " $discarduuids " " ${luks##luks-}"; then
allowdiscards="allow-discards" allowdiscards="allow-discards"
fi fi
elif getargbool rd.luks.allow-discards; then elif getargbool 0 rd.luks.allow-discards; then
allowdiscards="allow-discards" allowdiscards="allow-discards"
fi fi
fi fi
echo "$luks $dev none $allowdiscards" >> /etc/crypttab echo "$luks $dev - timeout=0,$allowdiscards" >> /etc/crypttab
if command -v systemctl >/dev/null; then if command -v systemctl >/dev/null; then
systemctl daemon-reload systemctl daemon-reload

View File

@@ -97,10 +97,11 @@ done
# parse for allow-discards # parse for allow-discards
if strstr "$(cryptsetup --help)" "allow-discards"; then if strstr "$(cryptsetup --help)" "allow-discards"; then
if discarduuids=$(getargs "rd.luks.allow-discards"); then if discarduuids=$(getargs "rd.luks.allow-discards"); then
discarduuids=$(str_replace "$discarduuids" 'luks-' '')
if strstr " $discarduuids " " ${luksdev##luks-}"; then if strstr " $discarduuids " " ${luksdev##luks-}"; then
allowdiscards="--allow-discards" allowdiscards="--allow-discards"
fi fi
elif getargbool rd.luks.allow-discards; then elif getargbool 0 rd.luks.allow-discards; then
allowdiscards="--allow-discards" allowdiscards="--allow-discards"
fi fi
fi fi

View File

@@ -7,25 +7,11 @@ check() {
# if cryptsetup is not installed, then we cannot support encrypted devices. # if cryptsetup is not installed, then we cannot support encrypted devices.
type -P cryptsetup >/dev/null || return 1 type -P cryptsetup >/dev/null || 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 ]] && { [[ $hostonly ]] || [[ $mount_needs ]] && {
for_each_host_dev_fs check_crypt || return 1 for fs in "${host_fs_types[@]}"; do
[[ $fs = "crypto_LUKS" ]] && return 0
done
return 255
} }
return 0 return 0
@@ -41,13 +27,55 @@ installkernel() {
} }
install() { install() {
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
}
for_each_host_dev_fs check_crypt
dracut_install cryptsetup rmdir readlink umount dracut_install cryptsetup rmdir readlink umount
inst_script "$moddir"/cryptroot-ask.sh /sbin/cryptroot-ask inst_script "$moddir"/cryptroot-ask.sh /sbin/cryptroot-ask
inst_script "$moddir"/probe-keydev.sh /sbin/probe-keydev inst_script "$moddir"/probe-keydev.sh /sbin/probe-keydev
inst_hook cmdline 10 "$moddir/parse-keydev.sh" inst_hook cmdline 10 "$moddir/parse-keydev.sh"
inst_hook cmdline 30 "$moddir/parse-crypt.sh" inst_hook cmdline 30 "$moddir/parse-crypt.sh"
inst_hook cleanup 30 "$moddir/crypt-cleanup.sh" if ! dracut_module_included "systemd"; then
[[ $hostonly ]] && inst_simple /etc/crypttab inst_hook cleanup 30 "$moddir/crypt-cleanup.sh"
fi
if [[ $hostonly ]]; then
# filter /etc/crypttab for the devices we need
while read _mapper _dev _rest; do
[[ $_mapper = \#* ]] && continue
[[ $_dev ]] || continue
[[ $_dev == UUID=* ]] && \
_dev="/dev/disk/by-uuid/${_dev#UUID=}"
for _hdev in "${!host_fs_types[@]}"; do
[[ ${host_fs_types[$_hdev]} == "crypto_LUKS" ]] || continue
if [[ $_hdev -ef $_dev ]] || [[ /dev/block/$_hdev -ef $_dev ]]; then
echo "$_mapper $_dev $_rest"
break
fi
done
done < /etc/crypttab > $initdir/etc/crypttab
fi
inst_simple "$moddir/crypt-lib.sh" "/lib/dracut-crypt-lib.sh" inst_simple "$moddir/crypt-lib.sh" "/lib/dracut-crypt-lib.sh"
dracut_install -o \ dracut_install -o \
@@ -60,4 +88,5 @@ install() {
$systemdsystemunitdir/sysinit.target.wants/cryptsetup.target \ $systemdsystemunitdir/sysinit.target.wants/cryptsetup.target \
systemd-ask-password systemd-tty-ask-password-agent systemd-ask-password systemd-tty-ask-password-agent
inst_script "$moddir"/crypt-run-generator.sh /sbin/crypt-run-generator inst_script "$moddir"/crypt-run-generator.sh /sbin/crypt-run-generator
dracut_need_initqueue
} }

View File

@@ -4,7 +4,7 @@
if ! getargbool 1 rd.luks -d -n rd_NO_LUKS; then if ! getargbool 1 rd.luks -d -n rd_NO_LUKS; then
info "rd.luks=0: removing cryptoluks activation" info "rd.luks=0: removing cryptoluks activation"
rm -f /etc/udev/rules.d/70-luks.rules rm -f -- /etc/udev/rules.d/70-luks.rules
else else
{ {
echo 'SUBSYSTEM!="block", GOTO="luks_end"' echo 'SUBSYSTEM!="block", GOTO="luks_end"'
@@ -32,8 +32,8 @@ else
printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", ' printf -- 'ENV{ID_FS_TYPE}=="crypto_LUKS", '
printf -- 'ENV{ID_FS_UUID}=="*%s*", ' $luksid printf -- 'ENV{ID_FS_UUID}=="*%s*", ' $luksid
printf -- 'RUN+="%s --unique --onetime ' $(command -v initqueue) printf -- 'RUN+="%s --unique --onetime ' $(command -v initqueue)
printf -- '--name crypt-run-generator-%%k %s ' $(command -v crypt-run-generator) printf -- '--name systemd-cryptsetup-%%k %s start ' $(command -v systemctl)
printf -- '$env{DEVNAME} luks-$env{ID_FS_UUID}"\n' printf -- 'systemd-cryptsetup@luks$$(dev_unit_name -$env{ID_FS_UUID}).service"\n'
} >> /etc/udev/rules.d/70-luks.rules.new } >> /etc/udev/rules.d/70-luks.rules.new
fi fi

View File

@@ -0,0 +1,15 @@
SUBSYSTEM!="block", GOTO="dm_end"
ACTION!="add|change", GOTO="dm_end"
# Also don't process disks that are slated to be a multipath device
ENV{DM_MULTIPATH_DEVICE_PATH}=="?*", GOTO="dm_end"
KERNEL!="dm-[0-9]*", GOTO="dm_end"
ACTION=="add", GOTO="dm_end"
IMPORT{program}="/sbin/dmsetup info -c --nameprefixes --unquoted --rows --noheadings -o name,uuid,suspended,readonly,major,minor,open,tables_loaded,names_using_dev -j%M -m%m"
ENV{DM_NAME}!="?*", GOTO="dm_end"
ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=="1", GOTO="dm_end"
ENV{DM_UUID}=="CRYPT-TEMP-?*", GOTO="dm_end"
ENV{DM_UUID}!="?*", ENV{DM_NAME}=="temporary-cryptsetup-?*", GOTO="dm_end"
IMPORT BLKID
LABEL="dm_end"

View File

@@ -32,6 +32,9 @@ install() {
inst_rules "$moddir/11-dm.rules" inst_rules "$moddir/11-dm.rules"
inst_rules "$moddir/59-persistent-storage-dm.rules"
prepare_udev_rules 59-persistent-storage-dm.rules
inst_hook shutdown 30 "$moddir/dm-shutdown.sh" inst_hook shutdown 30 "$moddir/dm-shutdown.sh"
} }

View File

@@ -27,8 +27,7 @@ if [ -n "$DM_RAIDS" ] || getargbool 0 rd.auto; then
for s in $SETS; do for s in $SETS; do
if [ "${s##$r}" != "$s" ]; then if [ "${s##$r}" != "$s" ]; then
info "Activating $s" info "Activating $s"
dmraid -ay -i -p --rm_partitions "$s" 2>&1 | vinfo dmraid -ay -i --rm_partitions "$s" 2>&1 | vinfo
[ -e "/dev/mapper/$s" ] && kpartx -a -p p "/dev/mapper/$s" 2>&1 | vinfo
udevsettle udevsettle
fi fi
done done
@@ -37,8 +36,7 @@ if [ -n "$DM_RAIDS" ] || getargbool 0 rd.auto; then
# scan and activate all DM RAIDS # scan and activate all DM RAIDS
for s in $SETS; do for s in $SETS; do
info "Activating $s" info "Activating $s"
dmraid -ay -i -p --rm_partitions "$s" 2>&1 | vinfo dmraid -ay -i --rm_partitions "$s" 2>&1 | vinfo
[ -e "/dev/mapper/$s" ] && kpartx -a -p p "/dev/mapper/$s" 2>&1 | vinfo
done done
fi fi

View File

@@ -8,9 +8,27 @@ check() {
# in trying to support it in the initramfs. # in trying to support it in the initramfs.
type -P dmraid >/dev/null || return 1 type -P dmraid >/dev/null || return 1
[[ $hostonly ]] || [[ $mount_needs ]] && {
for fs in "${host_fs_types[@]}"; do
[[ $fs = *_raid_member ]] && return 0
done
return 255
}
return 0
}
depends() {
echo dm rootfs-block
return 0
}
install() {
local _i
check_dmraid() { check_dmraid() {
local dev=$1 fs=$2 holder DEVPATH DM_NAME local dev=$1 fs=$2 holder DEVPATH DM_NAME
[[ "$fs" = "${fs%%_raid_member}" ]] && return 1 [[ "$fs" != *_raid_member ]] && return 1
DEVPATH=$(udevadm info --query=property --name=$dev \ DEVPATH=$(udevadm info --query=property --name=$dev \
| while read line; do | while read line; do
@@ -37,20 +55,8 @@ check() {
return 0 return 0
} }
[[ $hostonly ]] || [[ $mount_needs ]] && { for_each_host_dev_fs check_dmraid
for_each_host_dev_fs check_dmraid || return 1
}
return 0
}
depends() {
echo dm rootfs-block
return 0
}
install() {
local _i
dracut_install dmraid dracut_install dmraid
dracut_install -o kpartx dracut_install -o kpartx
inst $(command -v partx) /sbin/partx inst $(command -v partx) /sbin/partx

View File

@@ -0,0 +1,13 @@
[Unit]
Description=Media check on %f
DefaultDependencies=no
Before=shutdown.target
[Service]
Type=oneshot
RemainAfterExit=no
ExecStart=/bin/checkisomd5 --verbose %f
StandardInput=tty-force
StandardOutput=inherit
StandardError=inherit
TimeoutSec=0

View File

@@ -19,6 +19,9 @@ livedev="$1"
# specified as their own things # specified as their own things
live_dir=$(getarg rd.live.dir -d live_dir) live_dir=$(getarg rd.live.dir -d live_dir)
[ -z "$live_dir" ] && live_dir="LiveOS" [ -z "$live_dir" ] && live_dir="LiveOS"
squash_image=$(getarg rd.live.squashimg)
[ -z "$squash_image" ] && squash_image="squashfs.img"
getargbool 0 rd.live.ram -d -y live_ram && live_ram="yes" getargbool 0 rd.live.ram -d -y live_ram && live_ram="yes"
getargbool 0 rd.live.overlay.reset -d -y reset_overlay && reset_overlay="yes" getargbool 0 rd.live.overlay.reset -d -y reset_overlay && reset_overlay="yes"
getargbool 0 rd.live.overlay.readonly -d -y readonly_overlay && readonly_overlay="--readonly" || readonly_overlay="" getargbool 0 rd.live.overlay.readonly -d -y readonly_overlay && readonly_overlay="--readonly" || readonly_overlay=""
@@ -31,22 +34,30 @@ if [ "$fs" = "iso9660" -o "$fs" = "udf" ]; then
fi fi
getarg rd.live.check -d check || check="" getarg rd.live.check -d check || check=""
if [ -n "$check" ]; then if [ -n "$check" ]; then
[ -x /bin/plymouth ] && /bin/plymouth --hide-splash type plymouth >/dev/null 2>&1 && plymouth --hide-splash
checkisomd5 --verbose $livedev if [ -n "$DRACUT_SYSTEMD" ]; then
p=$(str_replace "$livedev" "-" '\x2d')
systemctl start checkisomd5@${p}.service
else
checkisomd5 --verbose $livedev
fi
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
die "CD check failed!" die "CD check failed!"
exit 1 exit 1
fi fi
[ -x /bin/plymouth ] && /bin/plymouth --show-splash type plymouth >/dev/null 2>&1 && plymouth --show-splash
fi fi
ln -s $livedev /run/initramfs/livedev ln -s $livedev /run/initramfs/livedev
# determine filesystem type for a filesystem image # determine filesystem type for a filesystem image
det_img_fs() { det_img_fs() {
udevadm settle
blkid -s TYPE -u noraid -o value "$1" blkid -s TYPE -u noraid -o value "$1"
} }
modprobe squashfs
for arg in $CMDLINE; do case $arg in ro|rw) liverw=$arg ;; esac; done for arg in $CMDLINE; do case $arg in ro|rw) liverw=$arg ;; esac; done
# mount the backing of the live image first # mount the backing of the live image first
mkdir -m 0755 -p /run/initramfs/live mkdir -m 0755 -p /run/initramfs/live
@@ -105,18 +116,34 @@ do_live_overlay() {
umount -l /run/initramfs/overlayfs || : umount -l /run/initramfs/overlayfs || :
fi fi
if [ -z "$setup" ]; then if [ -z "$setup" -o -n "$readonly_overlay" ]; then
if [ -n "$devspec" -a -n "$pathspec" ]; then if [ -n "$setup" ]; then
warn "Using temporary overlay."
elif [ -n "$devspec" -a -n "$pathspec" ]; then
warn "Unable to find persistent overlay; using temporary" warn "Unable to find persistent overlay; using temporary"
sleep 5 sleep 5
fi fi
dd if=/dev/null of=/overlay bs=1024 count=1 seek=$((512*1024)) 2> /dev/null dd if=/dev/null of=/overlay bs=1024 count=1 seek=$((512*1024)) 2> /dev/null
losetup $OVERLAY_LOOPDEV /overlay if [ -n "$setup" -a -n "$readonly_overlay" ]; then
RO_OVERLAY_LOOPDEV=$( losetup -f )
losetup $RO_OVERLAY_LOOPDEV /overlay
else
losetup $OVERLAY_LOOPDEV /overlay
fi
fi fi
# set up the snapshot # set up the snapshot
echo 0 `blockdev --getsz $BASE_LOOPDEV` snapshot $BASE_LOOPDEV $OVERLAY_LOOPDEV p 8 | dmsetup create $readonly_overlay live-rw sz=$(blockdev --getsz $BASE_LOOPDEV)
if [ -n "$readonly_overlay" ]; then
echo 0 $sz snapshot $BASE_LOOPDEV $OVERLAY_LOOPDEV p 8 | dmsetup create $readonly_overlay live-ro
base="/dev/mapper/live-ro"
over=$RO_OVERLAY_LOOPDEV
else
base=$BASE_LOOPDEV
over=$OVERLAY_LOOPDEV
fi
echo 0 $sz snapshot $base $over p 8 | dmsetup create live-rw
} }
# live cd helper function # live cd helper function
@@ -156,8 +183,8 @@ if [ -n "$FSIMG" ] ; then
fi fi
# we might have an embedded fs image on squashfs (compressed live) # we might have an embedded fs image on squashfs (compressed live)
if [ -e /run/initramfs/live/${live_dir}/squashfs.img ]; then if [ -e /run/initramfs/live/${live_dir}/${squash_image} ]; then
SQUASHED="/run/initramfs/live/${live_dir}/squashfs.img" SQUASHED="/run/initramfs/live/${live_dir}/${squash_image}"
fi fi
if [ -e "$SQUASHED" ] ; then if [ -e "$SQUASHED" ] ; then

View File

@@ -0,0 +1,38 @@
#!/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
isofile=$1
[ -z "$isofile" ] && exit 1
ismounted "/run/initramfs/isoscan" && exit 1
mkdir -p "/run/initramfs/isoscan"
do_iso_scan() {
local _name
local dev
for dev in /dev/disk/by-uuid/*; do
_name=$(dev_unit_name "$dev")
[ -e /tmp/isoscan-${_name} ] && continue
> /tmp/isoscan-${_name}
mount -t auto -o ro "$dev" "/run/initramfs/isoscan" || continue
if [ -f "/run/initramfs/isoscan/$isofile" ]; then
losetup -f "/run/initramfs/isoscan/$isofile"
rm -f -- "$job"
exit 0
else
umount "/run/initramfs/isoscan"
fi
done
}
do_iso_scan
rmdir "/run/initramfs/isoscan"
exit 1

View File

@@ -16,18 +16,21 @@ depends() {
} }
installkernel() { installkernel() {
instmods squashfs loop instmods squashfs loop iso9660
} }
install() { install() {
dracut_install umount dmsetup blkid dd losetup grep blockdev dracut_install umount dmsetup blkid dd losetup grep blockdev
dracut_install -o checkisomd5 dracut_install -o checkisomd5
inst_hook cmdline 30 "$moddir/parse-dmsquash-live.sh" inst_hook cmdline 30 "$moddir/parse-dmsquash-live.sh"
inst_hook cmdline 31 "$moddir/parse-iso-scan.sh"
inst_hook pre-udev 30 "$moddir/dmsquash-live-genrules.sh" inst_hook pre-udev 30 "$moddir/dmsquash-live-genrules.sh"
inst_hook pre-udev 30 "$moddir/dmsquash-liveiso-genrules.sh" inst_hook pre-udev 30 "$moddir/dmsquash-liveiso-genrules.sh"
inst_hook pre-pivot 20 "$moddir/apply-live-updates.sh" inst_hook pre-pivot 20 "$moddir/apply-live-updates.sh"
inst_script "$moddir/dmsquash-live-root.sh" "/sbin/dmsquash-live-root" inst_script "$moddir/dmsquash-live-root.sh" "/sbin/dmsquash-live-root"
inst_script "$moddir/iso-scan.sh" "/sbin/iso-scan"
# should probably just be generally included # should probably just be generally included
inst_rules 60-cdrom_id.rules inst_rules 60-cdrom_id.rules
inst_simple "$moddir/checkisomd5@.service" "/etc/systemd/system/checkisomd5@.service"
dracut_need_initqueue
} }

View File

@@ -34,6 +34,14 @@ case "$liveroot" in
root="${root#live:}" root="${root#live:}"
root="live:/dev/disk/by-uuid/${root#UUID=}" root="live:/dev/disk/by-uuid/${root#UUID=}"
rootok=1 ;; rootok=1 ;;
live:PARTUUID=*|PARTUUID=*) \
root="${root#live:}"
root="live:/dev/disk/by-partuuid/${root#PARTUUID=}"
rootok=1 ;;
live:PARTLABEL=*|PARTLABEL=*) \
root="${root#live:}"
root="live:/dev/disk/by-partlabel/${root#PARTLABEL=}"
rootok=1 ;;
live:/*.[Ii][Ss][Oo]|/*.[Ii][Ss][Oo]) live:/*.[Ii][Ss][Oo]|/*.[Ii][Ss][Oo])
root="${root#live:}" root="${root#live:}"
root="liveiso:${root}" root="liveiso:${root}"

View File

@@ -0,0 +1,14 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
# live images are specified with
# root=live:backingdev
isofile=$(getarg iso-scan/filename)
if [ -n "$isofile" ]; then
{
printf 'KERNEL=="loop0", RUN+="/sbin/initqueue --settled --unique /sbin/iso-scan %s"\n' \
"'${isofile}'"
} >> /etc/udev/rules.d/99-isofile-mount.rules
fi

View File

@@ -35,15 +35,21 @@ installkernel() {
return 0 return 0
} }
hostonly='' instmods sr_mod sd_mod scsi_dh scsi_dh_rdac scsi_dh_emc ata_piix \ hostonly='' instmods sr_mod sd_mod scsi_dh ata_piix \
pcmcia firewire-ohci yenta_socket \ ehci-hcd ehci-pci ehci-platform ohci-hcd uhci-hcd xhci-hcd hid_generic \
usb_storage sdhci sdhci-pci \
sdhci_esdhc_imx mmci sdhci_tegra mvsdio \
omap omapdrm omap_hsmmc sdhci_dove ahci_platform pata_imx sata_mv \
atkbd i8042 usbhid hid-apple hid-sunplus hid-cherry hid-logitech \
hid-logitech-dj hid-microsoft ehci-hcd ohci-hcd uhci-hcd xhci-hcd hid_generic \
unix unix
instmods yenta_socket scsi_dh_rdac scsi_dh_emc \
atkbd i8042 usbhid hid-apple hid-sunplus hid-cherry hid-logitech \
hid-logitech-dj hid-microsoft firewire-ohci \
pcmcia usb_storage nvme hid-hyperv hv-vmbus
if [[ "$(uname -p)" == arm* ]]; then
# arm specific modules
hostonly='' instmods sdhci_esdhc_imx mmci sdhci_tegra mvsdio omap omapdrm \
omap_hsmmc panel-tfp410 sdhci_dove ahci_platform pata_imx sata_mv
fi
# install virtual machine support # install virtual machine support
instmods virtio virtio_blk virtio_ring virtio_pci virtio_scsi \ instmods virtio virtio_blk virtio_ring virtio_pci virtio_scsi \
"=drivers/pcmcia" =ide "=drivers/usb/storage" "=drivers/pcmcia" =ide "=drivers/usb/storage"
@@ -59,18 +65,19 @@ installkernel() {
instmods '=fs' instmods '=fs'
fi fi
else else
inst_fs() { for i in $(host_fs_all); do
[[ $2 ]] || return 1 hostonly='' instmods $i
hostonly='' instmods $2 done
}
for_each_host_dev_fs inst_fs
fi fi
fi fi
:
} }
install() { install() {
dracut_install -o /lib/modprobe.d/*.conf dracut_install -o /lib/modprobe.d/*.conf
[[ $hostonly ]] && dracut_install -o /etc/modprobe.d/*.conf /etc/modprobe.conf [[ $hostonly ]] && dracut_install -o /etc/modprobe.d/*.conf /etc/modprobe.conf
inst_hook cmdline 01 "$moddir/parse-kernel.sh" if ! dracut_module_included "systemd"; then
inst_hook cmdline 01 "$moddir/parse-kernel.sh"
fi
inst_simple "$moddir/insmodpost.sh" /sbin/insmodpost.sh inst_simple "$moddir/insmodpost.sh" /sbin/insmodpost.sh
} }

View File

@@ -2,6 +2,15 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh # ex: ts=8 sw=4 sts=4 et filetype=sh
_modprobe_d=/etc/modprobe.d
if [ -d /usr/lib/modprobe.d ] ; then
_modprobe_d=/usr/lib/modprobe.d
elif [ -d /lib/modprobe.d ] ; then
_modprobe_d=/lib/modprobe.d
elif [ ! -d $_modprobe_d ] ; then
mkdir -p $_modprobe_d
fi
for i in $(getargs rd.driver.pre -d rdloaddriver=); do for i in $(getargs rd.driver.pre -d rdloaddriver=); do
( (
IFS=, IFS=,
@@ -11,19 +20,22 @@ for i in $(getargs rd.driver.pre -d rdloaddriver=); do
) )
done done
[ -d /etc/modprobe.d ] || mkdir -p /etc/modprobe.d
for i in $(getargs rd.driver.blacklist -d rdblacklist=); do for i in $(getargs rd.driver.blacklist -d rdblacklist=); do
( (
IFS=, IFS=,
for p in $i; do for p in $i; do
echo "blacklist $p" >> /etc/modprobe.d/initramfsblacklist.conf echo "blacklist $p" >> $_modprobe_d/initramfsblacklist.conf
done done
) )
done done
for p in $(getargs rd.driver.post -d rdinsmodpost=); do for p in $(getargs rd.driver.post -d rdinsmodpost=); do
echo "blacklist $p" >> /etc/modprobe.d/initramfsblacklist.conf echo "blacklist $p" >> $_modprobe_d/initramfsblacklist.conf
_do_insmodpost=1 _do_insmodpost=1
done done
[ -n "$_do_insmodpost" ] && initqueue --settled --unique --onetime insmodpost.sh [ -n "$_do_insmodpost" ] && initqueue --settled --unique --onetime insmodpost.sh
unset _do_insmodpost unset _do_insmodpost _modprobe_d

View File

@@ -14,5 +14,6 @@ install() {
inst_hook cmdline 29 "$moddir/parse-livenet.sh" inst_hook cmdline 29 "$moddir/parse-livenet.sh"
inst_hook initqueue/online 95 "$moddir/fetch-liveupdate.sh" inst_hook initqueue/online 95 "$moddir/fetch-liveupdate.sh"
inst_script "$moddir/livenetroot.sh" "/sbin/livenetroot" inst_script "$moddir/livenetroot.sh" "/sbin/livenetroot"
dracut_need_initqueue
} }

View File

@@ -125,7 +125,7 @@ if [ -z "$LVS" -o -n "$VGS" ]; then
fi fi
if [ "$lvmwritten" ]; then if [ "$lvmwritten" ]; then
rm -f /etc/lvm/lvm.conf rm -f -- /etc/lvm/lvm.conf
fi fi
unset lvmwritten unset lvmwritten

View File

@@ -3,26 +3,14 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh # ex: ts=8 sw=4 sts=4 et filetype=sh
check() { check() {
local _rootdev _activated
# No point trying to support lvm if the binaries are missing # No point trying to support lvm if the binaries are missing
type -P lvm >/dev/null || return 1 type -P lvm >/dev/null || return 1
check_lvm() {
local DM_VG_NAME DM_LV_NAME DM_UDEV_DISABLE_DISK_RULES_FLAG
eval $(udevadm info --query=property --name=/dev/block/$1|egrep '(DM_VG_NAME|DM_LV_NAME|DM_UDEV_DISABLE_DISK_RULES_FLAG)=')
[[ "$DM_UDEV_DISABLE_DISK_RULES_FLAG" = "1" ]] && return 1
[[ ${DM_VG_NAME} ]] && [[ ${DM_LV_NAME} ]] || return 1
if ! strstr " ${_activated[*]} " " ${DM_VG_NAME}/${DM_LV_NAME} "; then
if ! [[ $kernel_only ]]; then
echo " rd.lvm.lv=${DM_VG_NAME}/${DM_LV_NAME} " >> "${initdir}/etc/cmdline.d/90lvm.conf"
fi
push _activated "${DM_VG_NAME}/${DM_LV_NAME}"
fi
return 0
}
[[ $hostonly ]] || [[ $mount_needs ]] && { [[ $hostonly ]] || [[ $mount_needs ]] && {
for_each_host_dev_and_slaves check_lvm || return 1 for fs in "${host_fs_types[@]}"; do
[[ $fs = LVM*_member ]] && return 0
done
return 255
} }
return 0 return 0
@@ -36,8 +24,31 @@ depends() {
install() { install() {
local _i local _i
local _needthin
local _activated
inst lvm inst lvm
check_lvm() {
local DM_VG_NAME DM_LV_NAME DM_UDEV_DISABLE_DISK_RULES_FLAG
eval $(udevadm info --query=property --name=$1 | egrep '(DM_VG_NAME|DM_LV_NAME|DM_UDEV_DISABLE_DISK_RULES_FLAG)=')
[[ "$DM_UDEV_DISABLE_DISK_RULES_FLAG" = "1" ]] && return 1
[[ ${DM_VG_NAME} ]] && [[ ${DM_LV_NAME} ]] || return 1
if ! [[ " ${_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
if ! [[ $_needthin ]]; then
[[ $(lvs --noheadings -o segtype ${DM_VG_NAME} 2>/dev/null) == *thin* ]] && _needthin=1
fi
return 0
}
for_each_host_dev_fs check_lvm
inst_rules "$moddir/64-lvm.rules" inst_rules "$moddir/64-lvm.rules"
if [[ $hostonly ]] || [[ $lvmconf = "yes" ]]; then if [[ $hostonly ]] || [[ $lvmconf = "yes" ]]; then
@@ -59,5 +70,10 @@ install() {
inst_hook cmdline 30 "$moddir/parse-lvm.sh" inst_hook cmdline 30 "$moddir/parse-lvm.sh"
inst_libdir_file "libdevmapper-event-lvm*.so" inst_libdir_file "libdevmapper-event-lvm*.so"
if [[ $_needthin ]]; then
dracut_install -o thin_dump thin_restore thin_check
fi
} }

View File

@@ -2,7 +2,7 @@
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh # ex: ts=8 sw=4 sts=4 et filetype=sh
if [ -e /etc/lvm/lvm.conf ] && ! getargbool 1 rd.lvm.conf -d -n rd_NO_LVMCONF; then if [ -e /etc/lvm/lvm.conf ] && ! getargbool 1 rd.lvm.conf -d -n rd_NO_LVMCONF; then
rm -f /etc/lvm/lvm.conf rm -f -- /etc/lvm/lvm.conf
fi fi
LV_DEVS="$(getargs rd.lvm.vg -d rd_LVM_VG=) $(getargs rd.lvm.lv -d rd_LVM_LV=)" LV_DEVS="$(getargs rd.lvm.vg -d rd_LVM_VG=) $(getargs rd.lvm.lv -d rd_LVM_LV=)"
@@ -10,7 +10,7 @@ LV_DEVS="$(getargs rd.lvm.vg -d rd_LVM_VG=) $(getargs rd.lvm.lv -d rd_LVM_LV=)"
if ! getargbool 1 rd.lvm -d -n rd_NO_LVM \ if ! getargbool 1 rd.lvm -d -n rd_NO_LVM \
|| ( [ -z "$LV_DEVS" ] && ! getargbool 0 rd.auto ); then || ( [ -z "$LV_DEVS" ] && ! getargbool 0 rd.auto ); then
info "rd.lvm=0: removing LVM activation" info "rd.lvm=0: removing LVM activation"
rm -f /etc/udev/rules.d/64-lvm*.rules rm -f -- /etc/udev/rules.d/64-lvm*.rules
else else
for dev in $LV_DEVS; do for dev in $LV_DEVS; do
wait_for_dev "/dev/$dev" wait_for_dev "/dev/$dev"

View File

@@ -0,0 +1,23 @@
SUBSYSTEM!="block", GOTO="md_end"
ACTION!="add|change", GOTO="md_end"
# Also don't process disks that are slated to be a multipath device
ENV{DM_MULTIPATH_DEVICE_PATH}=="?*", GOTO="md_end"
KERNEL!="md[0-9]*|md_d[0-9]*|md/*", KERNEL!="md*", GOTO="md_end"
# partitions have no md/{array_state,metadata_version}
ENV{DEVTYPE}=="partition", GOTO="md_ignore_state"
# container devices have a metadata version of e.g. 'external:ddf' and
# never leave state 'inactive'
ATTR{md/metadata_version}=="external:[A-Za-z]*", ATTR{md/array_state}=="inactive", GOTO="md_ignore_state"
TEST!="md/array_state", GOTO="md_end"
ATTR{md/array_state}=="|clear|inactive", GOTO="md_end"
LABEL="md_ignore_state"
IMPORT{program}="/sbin/mdadm --detail --export $tempnode"
IMPORT BLKID
OPTIONS+="link_priority=100"
OPTIONS+="watch"
LABEL="md_end"

View File

@@ -0,0 +1,16 @@
#!/bin/sh
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
_do_mdmon_takeover() {
local ret
mdmon --takeover --all
ret=$?
[ $ret -eq 0 ] && info "Taking over mdmon processes."
return $ret
}
if command -v mdmon >/dev/null; then
_do_mdmon_takeover $1
else
:
fi

View File

@@ -29,9 +29,6 @@ _md_force_run() {
_path_d="${_path_s%/*}/degraded" _path_d="${_path_s%/*}/degraded"
[ ! -r "$_path_d" ] && continue [ ! -r "$_path_d" ] && continue
# workaround for mdmon bug
[ "$(cat "$_path_d")" -gt "0" ] && mdmon $_offroot --takeover "$md"
done done
} }

View File

@@ -7,27 +7,11 @@ check() {
# No mdadm? No mdraid support. # No mdadm? No mdraid support.
type -P mdadm >/dev/null || return 1 type -P mdadm >/dev/null || return 1
check_mdraid() {
local dev=$1 fs=$2 holder DEVPATH MD_UUID
[[ "$fs" = "${fs%%_raid_member}" ]] && 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 ]] && { [[ $hostonly ]] || [[ $mount_needs ]] && {
for_each_host_dev_fs check_mdraid || return 1 for fs in "${host_fs_types[@]}"; do
[[ "$fs" == *_raid_member ]] && return 0
done
return 255
} }
return 0 return 0
@@ -48,23 +32,39 @@ install() {
inst $(command -v partx) /sbin/partx inst $(command -v partx) /sbin/partx
inst $(command -v mdadm) /sbin/mdadm inst $(command -v mdadm) /sbin/mdadm
# XXX: mdmon really needs to run as non-root? check_mdraid() {
# If so, write only the user it needs in the initrd's /etc/passwd (and maybe /etc/group) local dev=$1 fs=$2 holder DEVPATH MD_UUID
# in a similar fashion to modules.d/95nfs. Do not copy /etc/passwd and /etc/group from [[ "$fs" != *_raid_member ]] && return 1
# the system into the initrd.
# dledford has hardware to test this, so he should be able to clean this up.
# inst /etc/passwd
# inst /etc/group
inst_rules 64-md-raid.rules MD_UUID=$(/sbin/mdadm --examine --export $dev \
# remove incremental assembly from stock rules, so they don't shadow | while read line; do
# 65-md-inc*.rules and its fine-grained controls, or cause other problems [[ ${line#MD_UUID} = $line ]] && continue
# when we explicitly don't want certain components to be incrementally eval "$line"
# assembled echo $MD_UUID
sed -i -r -e '/RUN\+?="[[:alpha:]/]*mdadm[[:blank:]]+(--incremental|-I)[[:blank:]]+(\$env\{DEVNAME\}|\$tempnode)"/d' "${initdir}${udevdir}/rules.d/64-md-raid.rules" 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
}
for_each_host_dev_fs check_mdraid
inst_rules 64-md-raid.rules
# remove incremental assembly from stock rules, so they don't shadow
# 65-md-inc*.rules and its fine-grained controls, or cause other problems
# when we explicitly don't want certain components to be incrementally
# assembled
sed -i -r -e '/RUN\+?="[[:alpha:]/]*mdadm[[:blank:]]+(--incremental|-I)[[:blank:]]+(\$env\{DEVNAME\}|\$tempnode)"/d' "${initdir}${udevdir}/rules.d/64-md-raid.rules"
inst_rules "$moddir/65-md-incremental-imsm.rules" inst_rules "$moddir/65-md-incremental-imsm.rules"
inst_rules "$moddir/59-persistent-storage-md.rules"
prepare_udev_rules 59-persistent-storage-md.rules
# guard against pre-3.0 mdadm versions, that can't handle containers # guard against pre-3.0 mdadm versions, that can't handle containers
if ! mdadm -Q -e imsm /dev/null >/dev/null 2>&1; then if ! mdadm -Q -e imsm /dev/null >/dev/null 2>&1; then
inst_hook pre-trigger 30 "$moddir/md-noimsm.sh" inst_hook pre-trigger 30 "$moddir/md-noimsm.sh"
@@ -88,5 +88,10 @@ install() {
inst_hook shutdown 30 "$moddir/md-shutdown.sh" inst_hook shutdown 30 "$moddir/md-shutdown.sh"
inst_script "$moddir/mdraid-cleanup.sh" /sbin/mdraid-cleanup inst_script "$moddir/mdraid-cleanup.sh" /sbin/mdraid-cleanup
inst_script "$moddir/mdraid_start.sh" /sbin/mdraid_start inst_script "$moddir/mdraid_start.sh" /sbin/mdraid_start
if dracut_module_included "systemd"; then
if [ -e $systemdsystemunitdir/mdmon@.service ]; then
inst_simple $systemdsystemunitdir/mdmon@.service
fi
fi
inst_hook pre-shutdown 30 "$moddir/mdmon-pre-shutdown.sh"
} }

View File

@@ -32,11 +32,11 @@ fi
if [ -e /etc/mdadm.conf ] && getargbool 1 rd.md.conf -d -n rd_NO_MDADMCONF; then if [ -e /etc/mdadm.conf ] && getargbool 1 rd.md.conf -d -n rd_NO_MDADMCONF; then
udevproperty rd_MDADMCONF=1 udevproperty rd_MDADMCONF=1
rm -f $hookdir/pre-pivot/*mdraid-cleanup.sh rm -f -- $hookdir/pre-pivot/*mdraid-cleanup.sh
fi fi
if ! getargbool 1 rd.md.conf -d -n rd_NO_MDADMCONF; then if ! getargbool 1 rd.md.conf -d -n rd_NO_MDADMCONF; then
rm -f /etc/mdadm/mdadm.conf /etc/mdadm.conf rm -f -- /etc/mdadm/mdadm.conf /etc/mdadm.conf
ln -s $(command -v mdraid-cleanup) $hookdir/pre-pivot/31-mdraid-cleanup.sh 2>/dev/null ln -s $(command -v mdraid-cleanup) $hookdir/pre-pivot/31-mdraid-cleanup.sh 2>/dev/null
fi fi

View File

@@ -15,7 +15,7 @@ check() {
} }
[[ $hostonly ]] || [[ $mount_needs ]] && { [[ $hostonly ]] || [[ $mount_needs ]] && {
for_each_host_dev_and_slaves is_mpath || return 1 for_each_host_dev_and_slaves is_mpath || return 255
} }
return 0 return 0
@@ -75,6 +75,7 @@ install() {
mpath_wait \ mpath_wait \
multipath \ multipath \
multipathd \ multipathd \
mpathpersist \
xdrgetuid \ xdrgetuid \
xdrgetprio \ xdrgetprio \
/etc/xdrdevices.conf \ /etc/xdrdevices.conf \
@@ -85,8 +86,15 @@ install() {
inst_libdir_file "libmultipath*" "multipath/*" inst_libdir_file "libmultipath*" "multipath/*"
inst_hook pre-trigger 02 "$moddir/multipathd.sh" if dracut_module_included "systemd"; then
inst_hook cleanup 02 "$moddir/multipathd-stop.sh" dracut_install \
$systemdsystemunitdir/multipathd.service
mkdir -p "${initdir}${systemdsystemconfdir}/sysinit.target.wants"
ln -rfs "${initdir}${systemdsystemunitdir}/multipathd.service" "${initdir}${systemdsystemconfdir}/sysinit.target.wants/multipathd.service"
else
inst_hook pre-trigger 02 "$moddir/multipathd.sh"
inst_hook cleanup 02 "$moddir/multipathd-stop.sh"
fi
inst_rules 40-multipath.rules 62-multipath.rules 65-multipath.rules 66-kpartx.rules inst_rules 40-multipath.rules 62-multipath.rules 65-multipath.rules 66-kpartx.rules
} }

View File

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

View File

@@ -8,7 +8,12 @@ depends() {
echo crypt echo crypt
} }
installkernel() {
instmods loop
}
install() { install() {
dracut_install losetup dracut_install losetup
inst "$moddir/crypt-loop-lib.sh" "/lib/dracut-crypt-loop-lib.sh" inst "$moddir/crypt-loop-lib.sh" "/lib/dracut-crypt-loop-lib.sh"
dracut_need_initqueue
} }

View File

@@ -18,9 +18,9 @@ echo server: $server
echo path: $path echo path: $path
echo options: $options echo options: $options
mount.cifs //$server/$path $NEWROOT -o $options && { [ -e /dev/root ] || >/dev/root ; } mount.cifs //$server/$path $NEWROOT -o $options && { [ -e /dev/root ] || ln -s null /dev/root ; }
# inject new exit_if_exists # inject new exit_if_exists
echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm "$job"' > $hookdir/initqueue/cifs.sh echo 'settle_exit_if_exists="--exit-if-exists=/dev/root"; rm -f -- "$job"' > $hookdir/initqueue/cifs.sh
# force udevsettle to break # force udevsettle to break
> $hookdir/initqueue/work > $hookdir/initqueue/work

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