Managing RHEL 5.1 VMs with the command line interface

With the command line interface, system administrators can minimize the hassles of managing RHEL virtual machines, or VMs.

Deploying virtual machines (VMs) eases administrative tasks and decreases the amount of hardware required for an...

environment to operate; but ease of operating system administration becomes important for Linux administrators only after they have mastered the command line interface for virtualization. This tip covers the command line interface for managing RHEL 5.1 VMs.

Startup and shutdown
Virtual machines can also be gracefully started and shut down using the xm command. For example, to stop the www virtual machine use: xm shutdown www. To restart the www virtual machine, xm create www can be used. A reboot can also be issued with: xm reboot www. The shutdown is clean using the shutdown parameter. In the rare circumstance a virtual machine hangs, a forced shutdown can be achieved with xm destroy - for example, xm destroy www.

Poking around
Whenever inheriting an existing system , it is important to get a feel for this system. It would be a good idea to learn about its configurations and the location of all machines in it. We will cover here how RedHat, through its Xen xm commands, provides several useful parameters.

The xm uptime command shows how long the hypervisor (host) has been up, as well as all virtual machines currently active on the system:

[root@axm1 ~]# xm uptime Name ID Uptime Domain-0 0 41 days, 21:19:52 ftp 8 41 days, 20:35:16 www 9 10 days, 0:57:31

The xm list command provides additional insight into the hypervisor and virtual machines:

[root@xm1 ~]# xm list Name ID Mem(MiB) VCPUs State Time(s) Domain-0 0 515 4 r----- 13464.0 ftp 8 255 1 -r---- 5516.2 www 9 1249 3 -r---- 2581.7

For this particular output, we see the logical IDs of the system, the amount of real (physical) memory assigned to the hypervisor and virtual machines, and the number of virtual processors assigned. The state of each system is also displayed (running:r, blocked:b, paused:p, or shutdown:s)

The virtual machine configuration files are stored in /etc/xen. Each virtual machine will have a configuration file matching that of the virtual machine name. For example, on this system:

[root@xm1 xen]# ls -l /etc/xen/ -rw------- 1 root root 482 Mar 24 18:36 ftp -rw------- 1 root root 485 Mar 24 18:28 www

Examing the www virtual machine file shows the following:

To view this coding, click here.

This config file shows memory, virtual cpus, the Ethernet MAC address, etc., that are used by the virtual machine.

Additional information about the particular hypervisor can also be gleaned using the info parameter:

To view this info parameter, click here.

Additional commands
A few additional commands are very specific and may not be useful in day-to-day operations. However, they can be useful in troubleshooting.

The first, xm top, displays a breakdown of networking and cpu utilization of the hypervisor and the virtual machines. Xm top is interactive so you can see additional information on the screen by pressing N (networks), V (virtual CPUs), or S (sort order). The S actually changes the column you are sorting on starting at its far left (name), then cycles to the right.

The xm dmesg will print out the xm dmesg buffer. The buffer mimicks the normal Unix/Linux dmesg behavior; however, it is specific to Xen. You can also clear this buffer with the -c parameter added: xm -c dmesg.

Troubleshooting virtual machines often requires an analysis of the logs associated with the virtualization. To see Xen's log file, use xm log or cat /var/log/xen/xend.log.

As this article demonstrates, an administrator can manage Xen using the command line interface. These commands allow systems to be managed in many circumstances without having to manage the individual virtual machine from the "inside."

About the author: Ronald McCarty is the founder and CEO of the technology services company Your Net Guard. His work has been published widely in networking, systems and security.

This was last published in May 2008

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.