Ubuntu
帶有 lz4 壓縮核心的 Xen pvgrub
我正在使用 pvgrub 在 xen 4.11 上執行 PV 來賓。最近發布的 ubuntu (>19.04) 看起來已經切換到 lz4 壓縮核心。這些核心在直接引導下工作正常,但在 pvgrub 和 pvgrub2 下它們似乎不可引導。
最新版本的 ubuntu 焦點 20.04。來賓核心 5.4.0-28。
error: not xen image. [ vmlinuz-5.4.0-28-gen 10B 0% 0.17B/s ] error: you need to load the kernel first. Press any key to continue...
相同的設置適用於較舊的核心(例如 4.19)
我注意到這個更新檔到 xen 本身有一個問題,有沒有人讓這些核心與 pvgrub 一起工作?
感謝 Andy 在 xen-users 郵件列表上的一些建議,我有一個臨時工作。從它的聲音來看,lz4 尚不支持。
特定於 Ubuntu PV 來賓,我編寫了以下內容作為 apt 鉤子,使用 extract-vmlinux 在安裝期間解壓縮核心。 https://raw.githubusercontent.com/torvalds/linux/master/scripts/extract-vmlinux
該鉤子在某處需要extract-linux(我使用了/usr/local/bin)並進入/etc/kernel/postinst.d/
#!/bin/bash KERNEL_VERSION="$1" KERNEL_PATH="$2" # extract-vmlinux is in /usr/local/bin PATH="${PATH}:/usr/local/bin" # Ensure we have the extract-linux tool if ! command -v extract-vmlinux > /dev/null; then echo >&2 "Command 'extract-vmlinux' is not available (https://raw.githubusercontent.com/torvalds/linux/master/scripts/extract-vmlinux), Aborting" exit 1 fi # The KERNEL_PATH must be valid if [ ! -f "${KERNEL_PATH}" ]; then echo >&2 "Kernel file '${KERNEL_PATH}' not found. Aborting" exit 1 fi # Create a temp file TEMP_FILE=$(mktemp /tmp/decompress-kernel-XXXXX) trap "rm -f ${TEMP_FILE}" 0 # If the given kernel file is still a bzimage see if its needs decompression if echo "$(file -b "${KERNEL_PATH}")" | grep -q "^Linux kernel x86 boot executable bzImage"; then # Kernel is probably lz4 if there are lz4 headers in it LZ4_HEADER="$(printf '\002!L\030')" if ! grep -aqo "${LZ4_HEADER}" ${KERNEL_PATH}; then echo "No lz4 compression headers found, skipping..." exit 0 fi echo "Decompressing '${KERNEL_PATH}'..." # Extract the kernel and replace existing if successful if extract-vmlinux ${KERNEL_PATH} > ${TEMP_FILE}; then # Double check the kernel is a valid ELF image if ! readelf -h ${TEMP_FILE} > /dev/null; then echo >&2 "Decompression of kernel file '${KERNEL_PATH}' failed!, not a valid ELF image" exit 1 fi echo "Decompression of kernel file '${KERNEL_PATH}' successful" cp -v ${TEMP_FILE} ${KERNEL_PATH} else echo >&2 "Decompression of kernel file '${KERNEL_PATH}' failed!" exit 1 fi # Perhaps its already been decompressed elif echo "$(file -b "${KERNEL_PATH}")" | grep -q "^ELF 64-bit LSB executable"; then echo "Kernel file '${KERNEL_PATH}' appears to be decompressed already. skipping" else echo >&2 "Unable to determine the state of kernel file '${KERNEL_PATH}'" exit 1 fi