Created
March 21, 2017 15:22
Star
You must be signed in to star a gist
Process a qcow2 image so that it can be customized as a vagrant box (meant for rhel images mostly)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# The input is a qcow2 image, that gets copied via virt-customize so that it | |
# can be modified to work as a vagrant box. It requires the `create_box.sh` script | |
# from the vagrant-libvirt project:: | |
# | |
# https://github.com/vagrant-libvirt/vagrant-libvirt/blob/master/tools/create_box.sh | |
# | |
# Usage: | |
# | |
# bash process.sh rhel-guest-image-7.4-10.x86_64.qcow2 rhel7.qcow2 | |
initial_image=$1 | |
final_image_name=$2 | |
image_copy="cloned.qcow2" | |
# cleanup removals | |
# Remove the previous copied image | |
rm -f "$image_copy" | |
# Remove any final images that may be around | |
rm -f "$final_image_name" | |
# Create the new base copy | |
qemu-img create -f qcow2 -b $initial_image $image_copy | |
# Run the script to modify the image to make it work with Vagrant | |
# root password can be disabled by appending `--root-password disabled` | |
# Requires the `prepare.sh` script the modifies the image to mage it compatible | |
# with vagrant. | |
virt-customize -v -x -a $image_copy --run prepare.sh | |
# After the customizations are complete, take the copied image and convert it | |
# to a fully functional qcow2 image. | |
qemu-img convert -f qcow2 -O qcow2 -o compat=0.10 $image_copy $final_image_name | |
# Needs: | |
# https://github.com/vagrant-libvirt/vagrant-libvirt/blob/master/tools/create_box.sh | |
bash create_box.sh $final_image_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment