kexec: cleanup tarball, use unpack dir to rebuild initrd
This commit is contained in:
parent
2913702b16
commit
2c9a008196
2 changed files with 19 additions and 25 deletions
|
@ -55,7 +55,7 @@ in makeTest' {
|
||||||
# Kexec node1 to the toplevel of node2 via the kexec-boot script
|
# Kexec node1 to the toplevel of node2 via the kexec-boot script
|
||||||
node1.succeed('touch /run/foo')
|
node1.succeed('touch /run/foo')
|
||||||
node1.fail('hello')
|
node1.fail('hello')
|
||||||
node1.succeed('tar -xf ${nodes.node2.config.system.build.kexecTarball}/tarball/nixos-kexec-installer-${pkgs.system}.tar.xz -C /root')
|
node1.succeed('tar -xf ${nodes.node2.config.system.build.kexecTarball}/nixos-kexec-installer-${pkgs.system}.tar.gz -C /root')
|
||||||
node1.execute('/root/kexec/run')
|
node1.execute('/root/kexec/run')
|
||||||
# wait for machine to kexec
|
# wait for machine to kexec
|
||||||
node1.execute('sleep 9999', check_return=False)
|
node1.execute('sleep 9999', check_return=False)
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
set -ex
|
set -ex
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
SCRIPT_DIR=$( cd -- "$( dirname -- "''${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
SCRIPT_DIR=$( cd -- "$( dirname -- "''${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
INITRD_TMP=$(mktemp -d)
|
INITRD_TMP=$(TMPDIR=$SCRIPT_DIR mktemp -d)
|
||||||
cd "$INITRD_TMP"
|
cd "$INITRD_TMP"
|
||||||
pwd
|
pwd
|
||||||
mkdir -p initrd/ssh
|
mkdir -p initrd/ssh
|
||||||
|
@ -30,10 +30,10 @@
|
||||||
done
|
done
|
||||||
find | cpio -o -H newc | gzip -9 > ../extra.gz
|
find | cpio -o -H newc | gzip -9 > ../extra.gz
|
||||||
popd
|
popd
|
||||||
cat "''${SCRIPT_DIR}/initrd.gz" extra.gz > final.gz
|
cat "''${SCRIPT_DIR}/initrd" extra.gz > final-initrd
|
||||||
|
|
||||||
"$SCRIPT_DIR/kexec" --load "''${SCRIPT_DIR}/bzImage" \
|
"$SCRIPT_DIR/kexec" --load "''${SCRIPT_DIR}/bzImage" \
|
||||||
--initrd=final.gz \
|
--initrd=final-initrd \
|
||||||
--command-line "init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams}"
|
--command-line "init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams}"
|
||||||
|
|
||||||
# kexec will map the new kernel in memory so we can remove the kernel at this point
|
# kexec will map the new kernel in memory so we can remove the kernel at this point
|
||||||
|
@ -52,27 +52,21 @@
|
||||||
nohup bash -c "sleep 6 && '$SCRIPT_DIR/kexec' -e" &
|
nohup bash -c "sleep 6 && '$SCRIPT_DIR/kexec' -e" &
|
||||||
'');
|
'');
|
||||||
|
|
||||||
system.build.kexecTarball = pkgs.callPackage (pkgs.path + "/nixos/lib/make-system-tarball.nix") {
|
system.build.kexecTarball = pkgs.runCommand "kexec-tarball" {} ''
|
||||||
fileName = "nixos-kexec-installer-${pkgs.stdenv.hostPlatform.system}";
|
mkdir kexec $out
|
||||||
contents = [
|
cp "${config.system.build.netbootRamdisk}/initrd" kexec/initrd
|
||||||
{
|
cp "${config.system.build.kernel}/${config.system.boot.loader.kernelFile}" kexec/bzImage
|
||||||
target = "/kexec/initrd.gz";
|
cp "${config.system.build.kexecRun}" kexec/run
|
||||||
source = "${config.system.build.netbootRamdisk}/initrd";
|
cp "${pkgs.pkgsStatic.kexec-tools}/bin/kexec" kexec/kexec
|
||||||
}
|
tar -czvf $out/nixos-kexec-installer-${pkgs.stdenv.hostPlatform.system}.tar.gz kexec
|
||||||
{
|
'';
|
||||||
target = "/kexec/bzImage";
|
|
||||||
source = "${config.system.build.kernel}/${config.system.boot.loader.kernelFile}";
|
# IPMI SOL console redirection stuff
|
||||||
}
|
boot.kernelParams = [
|
||||||
{
|
"console=ttyS0,115200n8"
|
||||||
target = "/kexec/run";
|
"console=ttyAMA0,115200n8"
|
||||||
source = config.system.build.kexecRun;
|
"console=tty0"
|
||||||
}
|
|
||||||
{
|
|
||||||
target = "/kexec/kexec";
|
|
||||||
source = "${pkgs.pkgsStatic.kexec-tools}/bin/kexec";
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
};
|
|
||||||
|
|
||||||
documentation.enable = false;
|
documentation.enable = false;
|
||||||
# Not really needed. Saves a few bytes and the only service we are running is sshd, which we want to be reachable.
|
# Not really needed. Saves a few bytes and the only service we are running is sshd, which we want to be reachable.
|
||||||
|
|
Loading…
Reference in a new issue