]>
git.ipfire.org Git - thirdparty/dracut.git/blob - dracut
c974fb49f0032332c8cffa895bc22b7ec51d8d6e
3 # Generator script for a dracut initramfs
4 # Tries to retain some degree of compatibility with the command line
5 # of the various mkinitrd implementations out there
7 # Copyright 2008, Red Hat, Inc. Jeremy Katz <katzj@redhat.com>
10 [ -f /etc
/dracut.conf
] && .
/etc
/dracut.conf
12 while [ $# -gt 0 ]; do
19 echo "Usage: $0 [-f] <initramfs> <kernel-version>"
44 outfile
=$
(readlink
-f $1)
46 outfile
="/boot/initrd-$kernel.img"
49 if [ -f "$outfile" -a -z "$force" ]; then
50 echo "Will not override existing initramfs ($outfile) without --force"
54 if [ -n "$allowlocal" -a -f .
/init
]; then
55 source .
/dracut-functions
57 switchroot
=.
/switch_root
60 source /usr
/libexec
/dracut
/functions
61 initfile
=/usr
/libexec
/dracut
/init
62 switchroot
=/usr
/libexec
/dracut
/switch_root
63 rulesdir
=/usr
/libexec
/dracut
/rules.d
66 initdir
=$
(mktemp
-d -t initramfs.XXXXXX
)
68 # executables that we have to have
69 exe
="/bin/bash /bin/mount /bin/mknod /bin/mkdir /sbin/modprobe /sbin/udevd /sbin/udevadm /sbin/nash /bin/kill /sbin/pidof /bin/sleep /bin/echo /usr/sbin/chroot"
71 cryptexe
="/sbin/cryptsetup"
72 # and some things that are nice for debugging
73 debugexe
="/bin/ls /bin/cat /bin/ln /bin/ps /bin/grep /bin/more"
74 # udev things we care about
75 udevexe
="/lib/udev/vol_id"
78 for binary
in $exe $debugexe $udevexe $lvmexe $cryptexe ; do
82 # FIXME: would be nice if we didn't have to know which rules to grab....
83 # ultimately, /lib/initramfs/rules.d or somesuch which includes links/copies
84 # of the rules we want so that we just copy those in would be best
85 mkdir
-p $initdir/lib
/udev
/rules.d
86 for rule
in /lib
/udev
/rules.d
/40-redhat* /lib
/udev
/rules.d
/50* /lib
/udev
/rules.d
/60-persistent-storage.rules
/lib
/udev
/rules.d
/61*edd
* /lib
/udev
/rules.d
/64* /lib
/udev
/rules.d
/80* /lib
/udev
/rules.d
/95* $rulesdir/*.rules
; do
87 cp $rule $initdir/lib
/udev
/rules.d
90 # terminfo bits make things work better if you fall into interactive mode
91 for f
in $
(find /lib
/terminfo
-type f
) ; do cp --parents $f "$initdir" ; done
94 cp $initfile $initdir/init
95 cp $switchroot $initdir/sbin
/switch_root
97 # and create some directory structure
98 mkdir
-p $initdir/etc
$initdir/proc
$initdir/sys
$initdir/sysroot
$initdir/dev
/pts
100 # FIXME: hard-coded module list of doom.
101 [ -z "$modules" ] && modules
="=ata =block =drm dm-crypt aes sha256_generic aes_i586 cbc essiv"
103 mkdir
-p $initdir/lib
/modules
/$kernel
104 # expand out module deps, etc
105 for mod
in $
(resolveAndExpandModules
$modules) ; do
106 installmodule
$mod $initdir
109 /sbin
/depmod
-a -b $initdir $kernel
110 if [ $?
-ne 0 ]; then
111 error
"\"/sbin/depmod -a $kernel\" failed."
116 if [ -x /usr
/libexec
/plymouth
/plymouth-populate-initrd
]; then
117 /usr
/libexec
/plymouth
/plymouth-populate-initrd
-t "$initdir" ||
:
120 pushd $initdir >/dev
/null
121 find . |
cpio -H newc
-o |
gzip -9 > $outfile