From 91cc532a55fed3c6c27a2e14759e901ed3d72579 Mon Sep 17 00:00:00 2001 From: torben Date: Mon, 13 Apr 2015 20:09:38 +0200 Subject: Code refactoring. --- testModule/hooks/cmdline.sh | 34 ++++++++++++++++++++++++++++++++++ testModule/hooks/pre-mount.sh | 14 ++++++++++++++ testModule/hooks/pre-pivot.sh | 3 +++ 3 files changed, 51 insertions(+) create mode 100644 testModule/hooks/cmdline.sh create mode 100644 testModule/hooks/pre-mount.sh create mode 100644 testModule/hooks/pre-pivot.sh (limited to 'testModule/hooks') diff --git a/testModule/hooks/cmdline.sh b/testModule/hooks/cmdline.sh new file mode 100644 index 00000000..5731242f --- /dev/null +++ b/testModule/hooks/cmdline.sh @@ -0,0 +1,34 @@ +# Converts ip configuration format given by the pxe pre boot provider to a +# dracut compatible static ip configuration. + +# TODO +warn 'LOAD ...........................' +warn 'LOAD ...........................' + +source /usr/lib/test-library.sh + +for parameter in $(getargs ip=); do + local temp="$parameter:" + set -- + while [ -n "$temp" ]; do + set -- "$@" "${temp%%:*}" + temp=${temp#*:} + done + + [ -n "$1" ] && ip=$1 + [ -n "$2" ] && server_ip=$2 + [ -n "$3" ] && gateway_ip=$3 + [ -n "$4" ] && net_mask=$4 + + warn "PXE given net configuration: ip: $ip server_ip: $server_ip gateway_ip: $gateway_ip net_mask: $net_mask" + local final_dracut_ip_config="$ip::$gateway_ip:$net_mask:dracut_test_client:enp0s3:none" + warn "Final dracut ip config: $final_dracut_ip_config" + #final_dracut_ip_config="enp0s3:dhcp" + replace_cmd ip "$final_dracut_ip_config" +done + +# NOTE: Doesn't work since dracuts needed version of mount doesn't support +# binds. +#cat /proc/cmdline | sed --regexp-extended 's/ip=[^ ]+//g' \ +# >"$temporary_kernel_commandline_file_path" && \ +#mount -n --rbind -o ro "$temporary_kernel_commandline_file_path" /proc/cmdline diff --git a/testModule/hooks/pre-mount.sh b/testModule/hooks/pre-mount.sh new file mode 100644 index 00000000..301381e6 --- /dev/null +++ b/testModule/hooks/pre-mount.sh @@ -0,0 +1,14 @@ +# TODO +warn '............START.............' + +insmod /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/dnbd3.ko + +#dnbd3-client --daemon & +#sleep 3 +local dnbd3_device_node="$(dnbd3-client -h 132.230.4.1 -i stage4/torben/test -r 1 -d /dev/dnbd0)" +dnbd3_device_node='/dev/dnbd0' +qemu-img create -f qcow2 -o backing_file="$dnbd3_device_node",backing_fmt=qcow2 /test.qcow2 +insmod /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/nbd.ko +wrap qemu-nbd -c /dev/nbd0 /test.qcow2 + +#wrap /usr/bin/bash -c 'while true; do wget http://10.126.2.184:8080; sleep 10; done' & diff --git a/testModule/hooks/pre-pivot.sh b/testModule/hooks/pre-pivot.sh new file mode 100644 index 00000000..c868fc30 --- /dev/null +++ b/testModule/hooks/pre-pivot.sh @@ -0,0 +1,3 @@ +# TODO +warn '............MOUNT.............' +mount /dev/nbd0 /sysroot/mnt -- cgit v1.2.3-55-g7522 From 75abace71d151e3420e171496c50d2c6a3091163 Mon Sep 17 00:00:00 2001 From: torben Date: Mon, 13 Apr 2015 20:15:29 +0200 Subject: Fix refactoring bugs. --- testModule/hooks/cmdline.sh | 5 ----- testModule/hooks/pre-mount.sh | 7 +------ testModule/module-setup.sh | 6 +++--- 3 files changed, 4 insertions(+), 14 deletions(-) (limited to 'testModule/hooks') diff --git a/testModule/hooks/cmdline.sh b/testModule/hooks/cmdline.sh index 5731242f..340467df 100644 --- a/testModule/hooks/cmdline.sh +++ b/testModule/hooks/cmdline.sh @@ -1,10 +1,6 @@ # Converts ip configuration format given by the pxe pre boot provider to a # dracut compatible static ip configuration. -# TODO -warn 'LOAD ...........................' -warn 'LOAD ...........................' - source /usr/lib/test-library.sh for parameter in $(getargs ip=); do @@ -23,7 +19,6 @@ for parameter in $(getargs ip=); do warn "PXE given net configuration: ip: $ip server_ip: $server_ip gateway_ip: $gateway_ip net_mask: $net_mask" local final_dracut_ip_config="$ip::$gateway_ip:$net_mask:dracut_test_client:enp0s3:none" warn "Final dracut ip config: $final_dracut_ip_config" - #final_dracut_ip_config="enp0s3:dhcp" replace_cmd ip "$final_dracut_ip_config" done diff --git a/testModule/hooks/pre-mount.sh b/testModule/hooks/pre-mount.sh index 301381e6..79ae47fa 100644 --- a/testModule/hooks/pre-mount.sh +++ b/testModule/hooks/pre-mount.sh @@ -2,13 +2,8 @@ warn '............START.............' insmod /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/dnbd3.ko - -#dnbd3-client --daemon & -#sleep 3 local dnbd3_device_node="$(dnbd3-client -h 132.230.4.1 -i stage4/torben/test -r 1 -d /dev/dnbd0)" dnbd3_device_node='/dev/dnbd0' qemu-img create -f qcow2 -o backing_file="$dnbd3_device_node",backing_fmt=qcow2 /test.qcow2 insmod /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/nbd.ko -wrap qemu-nbd -c /dev/nbd0 /test.qcow2 - -#wrap /usr/bin/bash -c 'while true; do wget http://10.126.2.184:8080; sleep 10; done' & +systemd_preserve_process_marker qemu-nbd -c /dev/nbd0 /test.qcow2 diff --git a/testModule/module-setup.sh b/testModule/module-setup.sh index 5451bb42..5e0696b4 100644 --- a/testModule/module-setup.sh +++ b/testModule/module-setup.sh @@ -36,9 +36,9 @@ install() { inst "$moddir/kernel_modules/nbd.ko" /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/nbd.ko # NOTE: Priority has to be greater than the network cmdline parsing hooks # since we have to modify the some kernel parameter before. - inst_hook cmdline 100 "$moddir/cmdline.sh" - inst_hook pre-mount 100 "$moddir/pre-mount.sh" - inst_hook pre-pivot 100 "$moddir/pre-pivot.sh" + inst_hook cmdline 100 "$moddir/hooks/cmdline.sh" + inst_hook pre-mount 100 "$moddir/hooks/pre-mount.sh" + inst_hook pre-pivot 100 "$moddir/hooks/pre-pivot.sh" #inst_hook pre-mount 20 "$moddir/setup_network.sh" inst_multiple lsblk ping ip ifconfig sshd htop dhclient tail head cat vim touch sed lsmod insmod qemu-img qemu-nbd sleep route wget find # FINAL: inst_multiple insmod qemu-img qemu-nbd -- cgit v1.2.3-55-g7522 From 794f3c7fb06a67162554941eaea489a1d30f544a Mon Sep 17 00:00:00 2001 From: torben Date: Mon, 13 Apr 2015 20:31:36 +0200 Subject: Fix hook priority. --- readme.md | 2 ++ testModule/hooks/pre-mount.sh | 5 +++-- testModule/module-setup.sh | 10 ++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) (limited to 'testModule/hooks') diff --git a/readme.md b/readme.md index 2a66be80..1077fb97 100644 --- a/readme.md +++ b/readme.md @@ -306,3 +306,5 @@ dnbd3-client -h 132.230.4.1 -i stage4/torben/test -r 1 > # Installiere qemu-img: @yum install qemu-img@ > # Installiere nbd: @wget http://dl.fedoraproject.org/pub/epel/6/x86_64/nbd-2.9.20-7.el6.x86_64.rpm && rpm -Uvh nbd-2.9.20-7.el6.x86_64.rpm@ + +NOTE: Disable NetworkManager to avoid reloading network on boot: systemctl disable NetworkManager diff --git a/testModule/hooks/pre-mount.sh b/testModule/hooks/pre-mount.sh index 79ae47fa..0bf80e16 100644 --- a/testModule/hooks/pre-mount.sh +++ b/testModule/hooks/pre-mount.sh @@ -4,6 +4,7 @@ warn '............START.............' insmod /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/dnbd3.ko local dnbd3_device_node="$(dnbd3-client -h 132.230.4.1 -i stage4/torben/test -r 1 -d /dev/dnbd0)" dnbd3_device_node='/dev/dnbd0' -qemu-img create -f qcow2 -o backing_file="$dnbd3_device_node",backing_fmt=qcow2 /test.qcow2 +# TODO sysroot normally not available yet. +qemu-img create -f qcow2 -o backing_file="$dnbd3_device_node",backing_fmt=qcow2 /sysroot/test.qcow2 insmod /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/nbd.ko -systemd_preserve_process_marker qemu-nbd -c /dev/nbd0 /test.qcow2 +systemd_preserve_process_marker qemu-nbd -c /dev/nbd0 /sysroot/test.qcow2 diff --git a/testModule/module-setup.sh b/testModule/module-setup.sh index 5e0696b4..698ebf62 100644 --- a/testModule/module-setup.sh +++ b/testModule/module-setup.sh @@ -34,11 +34,13 @@ install() { inst "$moddir/binaries/busybox" /usr/bin/busybox inst "$moddir/kernel_modules/dnbd3.ko" /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/dnbd3.ko inst "$moddir/kernel_modules/nbd.ko" /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/nbd.ko - # NOTE: Priority has to be greater than the network cmdline parsing hooks + # NOTE: Priority has to be lower than the network cmdline parsing hooks # since we have to modify the some kernel parameter before. - inst_hook cmdline 100 "$moddir/hooks/cmdline.sh" - inst_hook pre-mount 100 "$moddir/hooks/pre-mount.sh" - inst_hook pre-pivot 100 "$moddir/hooks/pre-pivot.sh" + inst_hook cmdline 1 "$moddir/hooks/cmdline.sh" + # TODO pre-pivot to pre-mount + inst_hook pre-pivot 10 "$moddir/hooks/pre-mount.sh" + # TODO 11 to 10 + inst_hook pre-pivot 11 "$moddir/hooks/pre-pivot.sh" #inst_hook pre-mount 20 "$moddir/setup_network.sh" inst_multiple lsblk ping ip ifconfig sshd htop dhclient tail head cat vim touch sed lsmod insmod qemu-img qemu-nbd sleep route wget find # FINAL: inst_multiple insmod qemu-img qemu-nbd -- cgit v1.2.3-55-g7522 From 25f9f2ebdd4cd65c01306617cb043837a8be3171 Mon Sep 17 00:00:00 2001 From: torben Date: Mon, 13 Apr 2015 20:35:35 +0200 Subject: Remove debugging lines. --- testModule/hooks/pre-mount.sh | 4 ++-- testModule/hooks/pre-pivot.sh | 2 +- testModule/module-setup.sh | 14 ++++++++------ 3 files changed, 11 insertions(+), 9 deletions(-) (limited to 'testModule/hooks') diff --git a/testModule/hooks/pre-mount.sh b/testModule/hooks/pre-mount.sh index 0bf80e16..b29dbeb4 100644 --- a/testModule/hooks/pre-mount.sh +++ b/testModule/hooks/pre-mount.sh @@ -5,6 +5,6 @@ insmod /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/dnbd3.ko local dnbd3_device_node="$(dnbd3-client -h 132.230.4.1 -i stage4/torben/test -r 1 -d /dev/dnbd0)" dnbd3_device_node='/dev/dnbd0' # TODO sysroot normally not available yet. -qemu-img create -f qcow2 -o backing_file="$dnbd3_device_node",backing_fmt=qcow2 /sysroot/test.qcow2 +qemu-img create -f qcow2 -o backing_file="$dnbd3_device_node",backing_fmt=qcow2 /test.qcow2 insmod /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/nbd.ko -systemd_preserve_process_marker qemu-nbd -c /dev/nbd0 /sysroot/test.qcow2 +systemd_preserve_process_marker qemu-nbd -c /dev/nbd0 /test.qcow2 diff --git a/testModule/hooks/pre-pivot.sh b/testModule/hooks/pre-pivot.sh index c868fc30..8c013496 100644 --- a/testModule/hooks/pre-pivot.sh +++ b/testModule/hooks/pre-pivot.sh @@ -1,3 +1,3 @@ # TODO warn '............MOUNT.............' -mount /dev/nbd0 /sysroot/mnt +mount /dev/nbd0 /mnt diff --git a/testModule/module-setup.sh b/testModule/module-setup.sh index 698ebf62..158800b4 100644 --- a/testModule/module-setup.sh +++ b/testModule/module-setup.sh @@ -23,26 +23,28 @@ installkernel() { mperf libcrc32c sd_mod crc_t10dif crct10dif_common sr_mod cdrom \ ata_generic pata_acpi ahci libahci vboxvideo drm i2c_core ata_piix \ libata vboxguest dm_mirror dm_region_hash dm_log dm_mod + # Production: instmods ext4 mbcache jbd2 } install() { # Loads globally needed useful functions or fixes some native dracut ones. inst "$moddir/library.sh" /usr/lib/test-library.sh + inst "$moddir/binaries/systemd_preserve_process_marker" /usr/bin/systemd_preserve_process_marker inst "$moddir/binaries/endless" /usr/bin/endless inst "$moddir/binaries/dnbd3-client" /usr/bin/dnbd3-client inst "$moddir/binaries/busybox" /usr/bin/busybox + inst "$moddir/kernel_modules/dnbd3.ko" /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/dnbd3.ko inst "$moddir/kernel_modules/nbd.ko" /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/nbd.ko + # NOTE: Priority has to be lower than the network cmdline parsing hooks # since we have to modify the some kernel parameter before. inst_hook cmdline 1 "$moddir/hooks/cmdline.sh" - # TODO pre-pivot to pre-mount - inst_hook pre-pivot 10 "$moddir/hooks/pre-mount.sh" - # TODO 11 to 10 - inst_hook pre-pivot 11 "$moddir/hooks/pre-pivot.sh" - #inst_hook pre-mount 20 "$moddir/setup_network.sh" + inst_hook pre-mount 10 "$moddir/hooks/pre-mount.sh" + inst_hook pre-pivot 10 "$moddir/hooks/pre-pivot.sh" + inst_multiple lsblk ping ip ifconfig sshd htop dhclient tail head cat vim touch sed lsmod insmod qemu-img qemu-nbd sleep route wget find - # FINAL: inst_multiple insmod qemu-img qemu-nbd + # Production: inst_multiple insmod qemu-img qemu-nbd return 0 } -- cgit v1.2.3-55-g7522 From c7332013f0e3aa212c4e4adbccbd518a33947813 Mon Sep 17 00:00:00 2001 From: torben Date: Mon, 13 Apr 2015 20:45:22 +0200 Subject: Fixes. --- testModule/hooks/pre-pivot.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'testModule/hooks') diff --git a/testModule/hooks/pre-pivot.sh b/testModule/hooks/pre-pivot.sh index 8c013496..94e92b1d 100644 --- a/testModule/hooks/pre-pivot.sh +++ b/testModule/hooks/pre-pivot.sh @@ -1,3 +1,4 @@ # TODO warn '............MOUNT.............' +mkdir --parents /mnt && \ mount /dev/nbd0 /mnt -- cgit v1.2.3-55-g7522 From b4a9dea1aed0919448b4fe8fc993eaa04f0d9e8c Mon Sep 17 00:00:00 2001 From: torben Date: Tue, 14 Apr 2015 17:58:35 +0200 Subject: Some tries to fix kernel panic. --- grub2.conf | 3 ++- testModule/hooks/pre-mount.sh | 12 ++++++------ testModule/hooks/pre-pivot.sh | 12 ++++++++++-- testModule/module-setup.sh | 7 +++++-- 4 files changed, 23 insertions(+), 11 deletions(-) (limited to 'testModule/hooks') diff --git a/grub2.conf b/grub2.conf index 556a59c4..41205d4f 100755 --- a/grub2.conf +++ b/grub2.conf @@ -6,7 +6,8 @@ menuentry 'test' --class centos --class gnu-linux --class gnu --class os --unres insmod part_msdos insmod xfs set root='hd0,msdos1' - linux16 /vmlinuz-3.10.0-229.1.2.el7.x86_64 ro vconsole.font=latarcyrheb-sun16 vconsole.keymap=de rd.break root=UUID=6c06919a-389a-4a50-8c6b-b086e65db9b0 rd.udev.log-priority=debug ip=10.0.2.15:132.230.4.2:10.0.2.2:255.255.255.0 # NOTE: Prevents dracut console: console=tty0 console=ttyS0,9600 ip=enp0s3:dhcp rd.debug rd.shell rd.info root=/dev/nbd0 rootfstype=ext4 + linux16 /vmlinuz-3.10.0-229.1.2.el7.x86_64 ro vconsole.font=latarcyrheb-sun16 vconsole.keymap=de rd.break root=UUID=6c06919a-389a-4a50-8c6b-b086e65db9b0 rd.udev.log-priority=debug ip=10.0.2.15:132.230.4.2:10.0.2.2:255.255.255.0 # NOTE: Prevents dracut console: console=tty0 console=ttyS0,9600 ip=enp0s3:dhcp root=/dev/nbd0 rootfstype=ext4 + #linux16 /vmlinuz-3.10.0-229.1.2.el7.x86_64 console=tty0 console=ttyS0,9600 ro vconsole.font=latarcyrheb-sun16 vconsole.keymap=de rd.break rd.debug rd.shell rd.info root=UUID=6c06919a-389a-4a50-8c6b-b086e65db9b0 rd.udev.log-priority=debug ip=10.0.2.15:132.230.4.2:10.0.2.2:255.255.255.0 initrd16 /initramfs-test.img # fully given: selxsrv=132.230.4.2 slxbase=boot/openselx-productive quiet splash vga=current wurstgesicht initrd=http://132.230.4.2/boot/openslx-productive/initramfs-stage31 ip=132.230.4.67:132.230.4.2:132.230.4.254:255.255.255.0 BOOTIF=01-08-00-27-60-49-62 BOOT_IMAGE=http://132.230.4.2/boot/openslx-productive/kernel diff --git a/testModule/hooks/pre-mount.sh b/testModule/hooks/pre-mount.sh index b29dbeb4..7798622e 100644 --- a/testModule/hooks/pre-mount.sh +++ b/testModule/hooks/pre-mount.sh @@ -2,9 +2,9 @@ warn '............START.............' insmod /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/dnbd3.ko -local dnbd3_device_node="$(dnbd3-client -h 132.230.4.1 -i stage4/torben/test -r 1 -d /dev/dnbd0)" -dnbd3_device_node='/dev/dnbd0' -# TODO sysroot normally not available yet. -qemu-img create -f qcow2 -o backing_file="$dnbd3_device_node",backing_fmt=qcow2 /test.qcow2 -insmod /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/nbd.ko -systemd_preserve_process_marker qemu-nbd -c /dev/nbd0 /test.qcow2 +local dnbd3_device_node="$(dnbd3-client -h 132.230.4.1 -i stage4/torben/test \ + -r 1 -d /dev/dnbd0)" +#qemu-img create -f qcow2 -o \ +# backing_file="$dnbd3_device_node",backing_fmt=qcow2 /test.qcow2 +#insmod /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/nbd.ko +#systemd_preserve_process_marker qemu-nbd -c /dev/nbd0 /test.qcow2 diff --git a/testModule/hooks/pre-pivot.sh b/testModule/hooks/pre-pivot.sh index 94e92b1d..8b01779a 100644 --- a/testModule/hooks/pre-pivot.sh +++ b/testModule/hooks/pre-pivot.sh @@ -1,4 +1,12 @@ # TODO warn '............MOUNT.............' -mkdir --parents /mnt && \ -mount /dev/nbd0 /mnt +# TODO +dnbd3_device_node='/dev/dnbd0' +mount -o remount,rw /sysroot +rm /sysroot/test.qcow2 +qemu-img create -f qcow2 -o \ + backing_file="$dnbd3_device_node",backing_fmt=qcow2 /sysroot/test.qcow2 +insmod /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/nbd.ko +systemd_preserve_process_marker qemu-nbd --connect /dev/nbd0 /sysroot/test.qcow2 --socket /sysroot/var/lock/qemu-nbd-TEST +mount /dev/nbd0 /sysroot/TEST +# strace -ff -o /sysroot/log.txt -p PID diff --git a/testModule/module-setup.sh b/testModule/module-setup.sh index 158800b4..513b9068 100644 --- a/testModule/module-setup.sh +++ b/testModule/module-setup.sh @@ -5,7 +5,8 @@ check() { } depends() { - echo base network rootfs-block bash kernel-modules systemd debug + echo base network rootfs-block bash kernel-modules debug + # systemd return 0 } @@ -44,7 +45,9 @@ install() { inst_hook pre-mount 10 "$moddir/hooks/pre-mount.sh" inst_hook pre-pivot 10 "$moddir/hooks/pre-pivot.sh" - inst_multiple lsblk ping ip ifconfig sshd htop dhclient tail head cat vim touch sed lsmod insmod qemu-img qemu-nbd sleep route wget find + inst_multiple lsblk ping ip ifconfig sshd htop dhclient tail head cat vim \ + touch sed lsmod insmod qemu-img qemu-nbd sleep route wget find lsof \ + strace chroot switch_root pivot_root # Production: inst_multiple insmod qemu-img qemu-nbd return 0 } -- cgit v1.2.3-55-g7522