Bug 866608
| Summary: | virt-install --initrd-inject does not work for RHEL 4.x guests (ext2 initrd) | |||
|---|---|---|---|---|
| Product: | [Community] Virtualization Tools | Reporter: | Patrick J. LoPresti <lopresti> | |
| Component: | virt-manager | Assignee: | Cole Robinson <crobinso> | |
| Status: | CLOSED UPSTREAM | QA Contact: | ||
| Severity: | high | Docs Contact: | ||
| Priority: | unspecified | |||
| Version: | unspecified | CC: | acathrow, berrange, crobinso, cwei, dallan, lcui, mkletzan, mzhan, tzheng | |
| Target Milestone: | --- | |||
| Target Release: | --- | |||
| Hardware: | All | |||
| OS: | Linux | |||
| Whiteboard: | ||||
| Fixed In Version: | Doc Type: | Bug Fix | ||
| Doc Text: | Story Points: | --- | ||
| Clone Of: | ||||
| : | 924526 (view as bug list) | Environment: | ||
| Last Closed: | 2013-09-02 20:11:54 UTC | Type: | Bug | |
| Regression: | --- | Mount Type: | --- | |
| Documentation: | --- | CRM: | ||
| Verified Versions: | Category: | --- | ||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | ||
| Cloudforms Team: | --- | Target Upstream Version: | ||
| Embargoed: | ||||
| Bug Depends On: | ||||
| Bug Blocks: | 924526 | |||
|
Description
Patrick J. LoPresti
2012-10-15 17:47:42 UTC
I decided I do not have time to learn Python right now... So I worked around this issue in my shell script wrapper. I am including my approach here in case it can help someone else or provide a basis for a real patch.
The below fragment of shell script code assumes that $location is what you plan to pass to "virt-install --location=...". The code locates the pxeboot/initrd.img file within $location and determines whether it is an ext2 compressed image. If so, it creates a temporary directory, copies the vmlinuz and initrd.img files into it, and adds "file1", "file2", and "file3" to the initrd.img. Then it modifies $location to point to the temporary directory. (It also arranges to remove the temporary directory when the containing shell script exits.)
So, once this fragment finishes, your script just does "virt-install --location=$location ..." to get the installation going. You can even include "--initrd-inject=..." lines, although they will of course have no effect when the initrd is actually ext2. In this way you can wind up with a generic install script.
I hope this basic approach can be adapted to DistroInstaller.py by someone better versed in Python. It does assume that e2fstools is installed (for debugfs), and it will fail if the ext2 initrd does not already have enough free space on it to hold the injected files. This is good enough for my application and would probably be a reasonable assumption for an initial patch.
Shell script fragment follows.
---
# At this point, "$location" refers to the OS distro
pxeboot_dir=$(find "$location"/. -name example -prune -o -type d -name pxeboot -print)
initrd="$pxeboot_dir"/initrd.img
[ -f "$initrd" ] \
&& file_initrd=$(file -z "$initrd")
if [ -f "$initrd" ] && [ "$file_initrd" != "${file_initrd#* ext2 }" ] ; then
# This is awful. "virt-install --initrd-inject=..." does not
# handle compressed ext2 images (RHEL 4 and below). So hack
# around it. (If
# https://bugzilla.redhat.com/show_bug.cgi?id=866608 is ever
# fixed, all of this can be removed.)
echo "$0: Looks like $initrd ext2... Engaging hack"
# Create temporary directory and arrange to remove it on script exit.
temp_dir=$(mktemp -d)
trap "rm -rf $temp_dir" EXIT
mkdir -p $temp_dir/images/pxeboot
cp -a "$pxeboot_dir"/vmlinuz $temp_dir/images/pxeboot/.
temp_initrd=$temp_dir/images/pxeboot/initrd.img
# "-f" just in case initrd is not compressed
zcat -f "$initrd" > $temp_initrd
# Inject files into temp initrd.
for file in file1 file2 file3 ; do
/sbin/debugfs -w -R "write $file ${file##*/}" $temp_initrd
done
location=$temp_dir
fi
# Now we can run virt-install --location=$location ...
This is fixed upstream now:
commit 018fcbbb4abb15974463cf2b3f76eecdabb02e5e
Author: Cole Robinson <crobinso>
Date: Mon Sep 2 16:10:28 2013 -0400
distroinstaller: Support --initrd-inject for RHEL4 (bz 866608)
RHEL4 kernels are gzip'd ext2 images, so unzip it, use debugfs to inject
files, and zip it back up. Based on shell code from Patrick J. LoPresti.
|