// Module included in the following assemblies: // // * virt/virtual_machines/creating_vms_custom/virt-creating-vms-uploading-images.adoc :_mod-docs-content-type: PROCEDURE [id="virt-generalizing-linux-vm-image_{context}"] = Generalizing a VM image You can generalize a {op-system-base-full} image to remove all system-specific configuration data before you use the image to create a golden image, a preconfigured snapshot of a virtual machine (VM). You can use a golden image to deploy new VMs. You can generalize a {op-system-base} VM by using the `virtctl`, `guestfs`, and `virt-sysprep` tools. .Prerequisites * You have a {op-system-base} virtual machine (VM) to use as a base VM. * You have installed the OpenShift CLI (`oc`). * You have installed the `virtctl` tool. .Procedure . Stop the {op-system-base} VM if it is running, by entering the following command: + [source,terminal] ---- $ virtctl stop ---- . Optional: Clone the virtual machine to avoid losing the data from your original VM. You can then generalize the cloned VM. . Retrieve the `dataVolume` that stores the root filesystem for the VM by running the following command: + [source,terminal] ---- $ oc get vm -o jsonpath="{.spec.template.spec.volumes}{'\n'}" ---- + .Example output [source,terminal] ---- [{"dataVolume":{"name":""},"name":"rootdisk"},{"cloudInitNoCloud":{...}] ---- . Retrieve the persistent volume claim (PVC) that matches the listed `dataVolume` by running the followimg command: + [source,terminal] ---- $ oc get pvc ---- + .Example output [source,terminal] ---- NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE Bound … ---- + [NOTE] ==== If your cluster configuration does not enable you to clone a VM, to avoid losing the data from your original VM, you can clone the VM PVC to a data volume instead. You can then use the cloned PVC to create a golden image. If you are creating a golden image by cloning a PVC, continue with the next steps, using the cloned PVC. ==== . Deploy a new interactive container with `libguestfs-tools` and attach the PVC to it by running the following command: + [source,terminal] ---- $ virtctl guestfs --uid 107 ---- + This command opens a shell for you to run the next command. . Remove all configurations specific to your system by running the following command: + [source,terminal] ---- $ virt-sysprep -a disk.img ---- . In the {product-title} console, click *Virtualization* -> *Catalog*. . Click *Add volume*. . In the *Add volume* window: .. From the *Source type* list, select *Use existing Volume*. .. From the *Volume project* list, select your project. .. From the *Volume name* list, select the correct PVC. .. In the *Volume name* field, enter a name for the new golden image. .. From the *Preference* list, select the {op-system-base} version you are using. .. From the *Default Instance Type* list, select the instance type with the correct CPU and memory requirements for the version of {op-system-base} you selected previously. .. Click *Save*. The new volume appears in the *Select volume to boot from* list. This is your new golden image. You can use this volume to create new VMs.