• Home
  • About Us
  • Contact
  • Privacy Policy

LinuxAdmin.io

  • Home
  • Tutorials
    • System Administration
    • Linux Tutorials
    • Web Hosting
    • WordPress
    • Virtualization
    • Troubleshooting
    • OpenStack

Virsh KVM Commands For Management

Virsh Commands for KVM

Virsh is a command line executable to control existing virtual machines.  It includes a number of commands to help manage KVM(kernel-based virtual machine) instances. It allows for easy command line management often remotely of virtual machines through SSH access.

To enter the command shell over ssh just type the following:

virsh

From there you can type the help command to view all of the possible commands. We will cover some of the more common commands for managing virtual machines. Virsh commands can also be executed directly from the command line as opposed to starting the virsh enviroment by prefixing each command with virsh.

View all of the virtual machines on this system

# virsh list --all

and you will see a similar output:

 Id Name State
----------------------------------------------------
 5 centos7-1 running
 84 centos7-2 running
 85 centos7-3 running

Start a virtual machine

# virsh start server-name

Replace server-name with the virtual machine you are attempting to start

Stopping a virtual machine

Shutdown a virtual machine:

# virsh shutdown server-name

This will attempt to gracefully stop a virtual machine and power it off.

Power off a virtual machine

# virsh destroy server-name

This will immediately power off a virtual machine. This is the equivalent to removing the power cord on a running physical server.

Reboot a virtual machine

# virsh reboot server-name

Auto start configuration for virtual machines

To have a virtual machine start every time a server reboots type the following:

# virsh  autostart server-name

To prevent a virtual machine from starting every time a  server reboots type the following

# virsh autostart --disable server-name

Attach a console to a virtual machine

To view the console output of a virtual machine type the following

# virsh console server-name

There are many more things virsh can do, this is just the basics to get you through power management of a virtual machine on the command line. If you have not already, please check out multi-part series on setting up KVM:

Part 1: KVM Installation On CentOS
Part 2: Bridged Networking Setup For KVM Virtualization
Part 3: Creating A New Virtual Machine With KVM

May 1, 2017LinuxAdmin.io
0 0 vote
Article Rating
Hot Clone A CentOS Server With RsyncCompile Apache 2.4 From Source
You Might Also Like
 
Journalctl Introduction and Examples
 
KVM installation on CentOS
Subscribe
Notify of
guest
guest
0 Comments
Inline Feedbacks
View all comments
5 years ago Linux System Administration, Virtualization kvm, linux, sysadmin1,002
Recent Posts
  • Laravel Installation Guide For CentOS
  • Openstack Services Explanation And Overview
  • OSSEC Intrusion Detection Installation On Centos 7
  • Configure ProFTPd for SFTP on CentOS
  • How To Check And Repair MyISAM Tables In MySQL
Most Commented
Hot Clone Linux Server with Rsync
Hot Clone A CentOS Server With Rsync
14 Comments
ngx_cache_purge module
Install The ngx_cache_purge Module In Nginx
8 Comments
piwik-nginx
Piwik Analytics on Nginx
8 Comments
Tags
linuxcentosLinux Performance Tuningsysadminkvmnetworkingmemcachedanalyticssystemd
About

We love Linux and are dedicated to creating Linux administration tutorials for System Administrators since 2016.

Most Viewed
Default Gateway
How To Configure A Default Gateway on CentOS
62,995 views
Zend Opcache
Setup and Optimize Zend OpCache
46,714 views
Install ffmpeg
FFMpeg Install On CentOS 7
20,910 views
Archives
Email subscription

Sign up for our newsletter to receive the latest news and event postings.

2018 © LinuxAdmin.io
wpDiscuz