-c|--conf) conffile="$2"; shift;;
-l|--local) allowlocal="yes" ;;
-h|--hostonly) hostonly="-h" ;;
+ -i|--include) include_src="$2"; include_target="$3"; shift 2;;
--skip-missing) skipmissing="yes" ;;
*) break ;;
esac
# make sure that library links are correct and up to date
ldconfig -n -r "$initdir" /lib* /usr/lib*
+[[ $include_src && $include_target ]] && {
+ mkdir -p "$initdir$include_target"
+ cp -a -t "$initdir$include_target" "$include_src"/*
+}
+
( cd "$initdir"; find . |cpio -H newc -o |gzip -9 > "$outfile"; )
--- /dev/null
+#!/bin/bash
+exit 1
--- /dev/null
+#!/bin/sh
+cp -a -t "$NEWROOT" /source/*
\ No newline at end of file
--- /dev/null
+#!/bin/sh
+sfdisk /dev/sda <<EOF
+
+;
+;
+;
+EOF
+cryptsetup -q luksFormat /dev/sda1 <<EOF
+test
+EOF
+cryptsetup luksOpen /dev/sda1 dracut_crypt_test <<EOF
+test
+EOF
+lvm pvcreate -ff -y /dev/mapper/dracut_crypt_test
+lvm vgcreate dracut /dev/mapper/dracut_crypt_test
+lvm lvcreate -l 100%FREE -n root dracut
+udevadm settle --timeout=4
+[ -b /dev/dracut/root ] || emergency_shell
+mke2fs /dev/dracut/root
\ No newline at end of file
--- /dev/null
+#!/bin/sh
+umount "$NEWROOT"
+lvm lvchange -a n /dev/dracut/root
+cryptsetup luksClose /dev/mapper/dracut_crypt_test
+poweroff -f
\ No newline at end of file
--- /dev/null
+#!/bin/sh
+dracut_install sfdisk mke2fs poweroff cp umount
+inst_hook pre-pivot 02 "$moddir/halt.sh"
+inst_hook pre-pivot 01 "$moddir/copy-root.sh"
+inst_hook pre-mount 01 "$moddir/create-root.sh"
\ No newline at end of file
#!/bin/sh
[ -s /cryptroot ] && {
- udevadm control --stop-exec-queue
+ udevadm control --stop_exec_queue
while read cryptopts; do
( exec >/dev/console 2>&1 </dev/console
set $cryptopts
)
done </cryptroot
>/cryptroot
- udevadm control --start-exec-queue
+ udevadm control --start_exec_queue
udevadm settle --timeout=30
}
#!/bin/bash
inst cryptsetup
+instmods dm_crypt =crypto
inst_rules "$moddir/63-luks.rules"
inst_hook mount 10 "$moddir/cryptroot.sh"
\ No newline at end of file
mount -t tmpfs -omode=0755 udev /dev >/dev/null 2>&1
read CMDLINE </proc/cmdline;
-
+getarg debug && set -x
# Make some basic devices first, let udev handle the rest
mknod /dev/ptmx c 5 2
mknod /dev/console c 5 1
[ $i -gt 10 ] && emergency_shell
done
+getarg 'break=pre-pivot' && emergency_shell
+source_all pre-pivot
+
# by the time we get here, the root filesystem should be mounted.
# Try to find init.
for i in "$(getarg init=)" /sbin/init /etc/init /init /bin/sh; do
}
# pre pivot scripts are sourced just before we switch over to the new root.
-getarg 'break=pre-pivot' && emergency_shell
-source_all pre-pivot
+
getarg break && emergency_shell
kill $(pidof udevd)
echo "Switching to real root filesystem $root"
-dracutmodules="kernel-modules udev-rules base"
+dracutmodules="kernel-modules crypt lvm udev-rules base"
modules="ata_piix ext2 sd_mod"
#!/bin/bash
-. ./dracut-functions
-readonly initdir=$(mktemp -d -t initramfs-test-XXXXXXXX)
-readonly mnttarget=$(mktemp -d -t initramfs-test-target-XXXXXXXX)
-trap 'rm -rf "$initdir"' 0
-dracut_install sh df free ls shutdown poweroff stty cat ps ln \
- /lib/terminfo/l/linux mount dmesg
-inst test/test-init /sbin/init
-dd if=/dev/zero of=test/root.ext2 bs=1M count=10
-mke2fs -F test/root.ext2
-mount -o loop -t ext2 test/root.ext2 "$mnttarget"
-cp -a -t "$mnttarget" "$initdir"/*
-(cd "$mnttarget"; mkdir -p dev sys proc etc)
-umount -l "$mnttarget"
-rm -rf "$mnttarget" "$initdir"
\ No newline at end of file
+initdir=$(mktemp -d -t initramfs-test-target-XXXXXXXX)
+kernel=$(uname -r)
+(
+ . ./dracut-functions
+ dracut_install sh df free ls shutdown poweroff stty cat ps ln \
+ /lib/terminfo/l/linux mount dmesg
+ inst test/test-init /sbin/init
+ (cd "$initdir"; mkdir -p dev sys proc etc)
+)
+targetfs="$initdir"
+unset initdir
+dd if=/dev/zero of=test/root.ext2 bs=1M count=20
+./dracut -l -i "$targetfs" /source \
+ -m "dash kernel-modules test crypt lvm udev-rules base" \
+ -d "ata_piix ext2 sd_mod" \
+ -f test/initramfs.makeroot
+
+qemu-kvm -hda test/root.ext2 -m 512M -nographic -net none \
+ -kernel "/boot/vmlinuz-$kernel" \
+ -append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81" \
+ -initrd test/initramfs.makeroot
\ No newline at end of file
[[ -f test/root.ext2 ]] || test/make-test-root
./dracut -c test/dracut.conf.test -l -f test/initramfs.testing || exit
-exec qemu-kvm -hda test/root.ext2 -nographic -net none \
+qemu-kvm -hda test/root.ext2 -m 512M -nographic -net none \
-kernel /boot/vmlinuz-$kernel \
- -append "root=/dev/sda rw rootfstype=ext2 console=ttyS0,115200n81 quiet" \
+ -append "root=/dev/dracut/root rw rootfstype=ext2 quiet console=ttyS0,115200n81" \
-initrd test/initramfs.testing
\ No newline at end of file