|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * virt/virt-using-the-cli-tools.adoc |
| 4 | + |
| 5 | +[id="virt-about-libguestfs-tools-virtctl-guestfs_{context}"] |
| 6 | += Libguestfs tools and virtctl guestfs |
| 7 | + |
| 8 | +`Libguestfs` tools help you access and modify virtual machine (VM) disk images. You can use `libguestfs` tools to view and edit files in a guest, clone and build virtual machines, and format and resize disks. |
| 9 | + |
| 10 | +You can also use the `virtctl guestfs` command and its sub-commands to modify, inspect, and debug VM disks on a PVC. To see a complete list of possible sub-commands, enter `virt-` on the command line and press the Tab key. For example: |
| 11 | + |
| 12 | +[width="100%",cols="42%,58%",options="header",] |
| 13 | +|=== |
| 14 | +|Command |Description |
| 15 | + |
| 16 | +|`virt-edit -a /dev/vda /etc/motd` |
| 17 | +|Edit a file interactively in your terminal. |
| 18 | + |
| 19 | +|`virt-customize -a /dev/vda --ssh-inject root:string:<public key example>` |
| 20 | +|Inject an ssh key into the guest and create a login. |
| 21 | + |
| 22 | +|`virt-df -a /dev/vda -h` |
| 23 | +|See how much disk space is used by a VM. |
| 24 | + |
| 25 | +|`virt-customize -a /dev/vda --run-command 'rpm -qa > /rpm-list'` |
| 26 | +|See the full list of all RPMs installed on a guest by creating an output file containing the full list. |
| 27 | + |
| 28 | +|`virt-cat -a /dev/vda /rpm-list` |
| 29 | +|Display the output file list of all RPMs created using the `virt-customize -a /dev/vda --run-command 'rpm -qa > /rpm-list'` command in your terminal. |
| 30 | + |
| 31 | +|`virt-sysprep -a /dev/vda` |
| 32 | +|Seal a virtual machine disk image to be used as a template. |
| 33 | +|=== |
| 34 | + |
| 35 | +By default, `virtctl guestfs` creates a session with everything needed to manage a VM disk. However, the command also supports several flag options if you want to customize the behavior: |
| 36 | + |
| 37 | +[width="100%",cols="42%,58%",options="header",] |
| 38 | +|=== |
| 39 | +|Flag Option |Description |
| 40 | + |
| 41 | +|`--h` or `--help` |
| 42 | +|Provides help for `guestfs`. |
| 43 | + |
| 44 | +|`-n <namespace>` option with a `<pvc_name>` argument |
| 45 | +|To use a PVC from a specific namespace. |
| 46 | + |
| 47 | +If you do not use the `-n <namespace>` option, your current project is used. To change projects, use `oc project <namespace>`. |
| 48 | + |
| 49 | +If you do not include a `<pvc_name>` argument, an error message appears. |
| 50 | + |
| 51 | +|`--image string` |
| 52 | +|Lists the `libguestfs-tools` container image. |
| 53 | + |
| 54 | +You can configure the container to use a custom image by using the `--image` option. |
| 55 | + |
| 56 | +|`--kvm` |
| 57 | +|Indicates that `kvm` is used by the `libguestfs-tools` container. |
| 58 | + |
| 59 | +By default, `virtctl guestfs` sets up `kvm` for the interactive container, which greatly speeds up the `libguest-tools` execution because it uses QEMU. |
| 60 | + |
| 61 | +If a cluster does not have any `kvm` supporting nodes, you must disable `kvm` by setting the option `--kvm=false`. |
| 62 | + |
| 63 | +If not set, the `libguestfs-tools` pod remains pending because it cannot be scheduled on any node. |
| 64 | + |
| 65 | +|`--pull-policy string` |
| 66 | +|Shows the pull policy for the `libguestfs` image. |
| 67 | + |
| 68 | +You can also overwrite the image's pull policy by setting the `pull-policy` option. |
| 69 | +|=== |
| 70 | + |
| 71 | +The command also checks if a PVC is used by another pod and fails if the PVC is used by another pod. However, once the `libguestfs-tools` process starts, the setup cannot avoid a new pod using the same PVC. You must verify that there are no active `virtctl guestfs` pods before starting the VM that accesses the same PVC. |
| 72 | + |
| 73 | +[NOTE] |
| 74 | +===== |
| 75 | +The `virtctl guestfs` command accepts only a single PVC attached to the interactive pod. |
| 76 | +===== |
0 commit comments