Skip to content

Commit 9ccd08e

Browse files
author
Matthew Garrell
committed
CNV11177 Adding info about the virtctl guestfs command
CNV11177 Updates based on code review CNV11177 Fixing additional resources typo CNV11177 Changes made based on code review round 2 CNV 11177 Updating based on QE review CNV 11177 Updating based on peer review CNV 11177 Updating based on peer review 2 CNV 11177 Updating based on peer review 3
1 parent f031b04 commit 9ccd08e

File tree

3 files changed

+103
-1
lines changed

3 files changed

+103
-1
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
=====
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * virt/virt-using-the-cli-tools.adoc
4+
5+
[id="virt-creating-pvc-with-virtctl-guestfs_{context}"]
6+
= Creating a container using virtctl guestfs
7+
8+
You can use the `virtctl guestfs` command to deploy an interactive container with `libguestfs-tools` and a persistent volume claim (PVC) attached to it.
9+
10+
.Procedure
11+
12+
* To deploy a container with `libguestfs-tools`, mount the PVC, and attach a shell to it, run the following command:
13+
+
14+
[source,terminal]
15+
----
16+
$ virtctl guestfs -n <namespace> <pvc_name> <1>
17+
----
18+
<1> The PVC name is a required argument. If you do not include it, an error message appears.

virt/virt-using-the-cli-tools.adoc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,16 @@ The two primary CLI tools used for managing resources in the cluster are:
1414

1515
* You must xref:../virt/install/virt-installing-virtctl.adoc#virt-installing-virtctl[install the `virtctl` client].
1616

17-
include::modules/virt-virtctl-commands.adoc[leveloffset=+1]
1817
include::modules/virt-openshift-client-commands.adoc[leveloffset=+1]
1918

2019
For more comprehensive information on `oc` client commands, see the
2120
xref:../cli_reference/openshift_cli/developer-cli-commands.adoc#cli-developer-commands[{product-title} CLI tools] documentation.
21+
22+
include::modules/virt-virtctl-commands.adoc[leveloffset=+1]
23+
include::modules/virt-creating-pvc-with-virtctl-guestfs.adoc[leveloffset=+1]
24+
include::modules/virt-about-libguestfs-tools-virtctl-guestfs.adoc[leveloffset=+1]
25+
26+
[id="additional-resources_virt-using-the-cli-tools"]
27+
== Additional resources
28+
29+
* link:https://libguestfs.org[Libguestfs: tools for accessing and modifying virtual machine disk images].

0 commit comments

Comments
 (0)