qubes-prepare-vm-kernel: Include kernel and initramfs inside modules.img

This will allow to boot the HVM using provided kernel directly (loaded
by qemu in stubdomain), without need for additional bootloader.

Fixes QubesOS/qubes-issues#2822
This commit is contained in:
Marek Marczykowski-Górecki 2017-10-16 23:43:03 +02:00
parent b227d01a8a
commit e9615899ff
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -35,13 +35,16 @@ function recompile_u2mfn() {
function build_modules_img() { function build_modules_img() {
kver=$1 kver=$1
output_file=$2 initramfs=$2
output_file=$3
mkdir /tmp/qubes-modules-$kver mkdir /tmp/qubes-modules-$kver
truncate -s 400M /tmp/qubes-modules-$kver.img truncate -s 400M /tmp/qubes-modules-$kver.img
mkfs -t ext3 -F /tmp/qubes-modules-$kver.img > /dev/null mkfs -t ext3 -F /tmp/qubes-modules-$kver.img > /dev/null
mount /tmp/qubes-modules-$kver.img /tmp/qubes-modules-$kver -o loop mount /tmp/qubes-modules-$kver.img /tmp/qubes-modules-$kver -o loop
cp -a -t /tmp/qubes-modules-$kver /lib/modules/$kver cp -a -t /tmp/qubes-modules-$kver /lib/modules/$kver
cp "/boot/vmlinuz-$kver" "/tmp/qubes-modules-$kver/vmlinuz"
cp "$initramfs" "/tmp/qubes-modules-$kver/initramfs"
umount /tmp/qubes-modules-$kver umount /tmp/qubes-modules-$kver
rmdir /tmp/qubes-modules-$kver rmdir /tmp/qubes-modules-$kver
mv /tmp/qubes-modules-$kver.img $output_file mv /tmp/qubes-modules-$kver.img $output_file
@ -82,9 +85,10 @@ echo "---> Recompiling kernel module (u2mfn)"
recompile_u2mfn "$kernel_version" recompile_u2mfn "$kernel_version"
mkdir -p "$output_dir" mkdir -p "$output_dir"
cp "/boot/vmlinuz-$kernel_version" "$output_dir/vmlinuz" cp "/boot/vmlinuz-$kernel_version" "$output_dir/vmlinuz"
echo "---> Generating modules.img"
build_modules_img "$kernel_version" "$output_dir/modules.img"
echo "---> Generating initramfs" echo "---> Generating initramfs"
build_initramfs "$kernel_version" "$output_dir/initramfs" build_initramfs "$kernel_version" "$output_dir/initramfs"
echo "---> Generating modules.img"
build_modules_img "$kernel_version" "$output_dir/initramfs" \
"$output_dir/modules.img"
echo "--> Done." echo "--> Done."