Home VM Backup How to Start XenServer VM via Command Line?

How to Start XenServer VM via Command Line?

2024-03-21 | Iris Lee

Table of contents
  • How to start a VM via command line in XenServer?
  • Other commands to manage XenServer VMs
  • How to backup XenServer VMs?
  • Citrix XenServer FAQs
  • Conclusion
Are you looking for a robust XenServer VM backup solution? Try Vinchin Backup & Recovery!↘ Download Free Trial

Citrix XenServer is an industry-leading, open-source platform for cost-effective cloud, server, and desktop virtualization infrastructures. It is known for its powerful management capabilities and comprehensive server virtualization features. XenServer is based on the Xen Project Hypervisor, which is a hypervisor using a microkernel design, providing services that allow multiple computer operating systems to execute on the same computer hardware concurrently. Managing virtual machines can be done using the XenCenter graphical user interface or through the command-line interface on the host running the XenServer.

How to start a VM via command line in XenServer?

To start a virtual machine from the command line in Citrix XenServer, you would typically use the “xe” command-line tool. The “xe” tool is a powerful interface for managing XenServer and Xen Cloud Platform (XCP) hosts and resources.

Here’s a general process on how to start a VM using the command line in Citrix XenServer:

1. List the VMs: To start a VM, you need to know its name-label or UUID. You can list all VMs and their details with the following command:

xe vm-list

This command will display a list of VMs along with their details, including the “uuid” and “name-label”.

2. Start the VM: Once you have the “name-label” or “uuid” of the VM you want to start, you can issue the following command:

Using “name-label”:

xe vm-start name-label="Your VM Name"

Or using “uuid”:

xe vm-start uuid=your-vm-uuid

Replace “Your VM Name” with the actual name label of your VM, or “your-vm-uuid” with the actual UUID.

3. Check the VM's State: After running the start command, you can check the power state of the VM to ensure it has started:

xe vm-list name-label= “Your VM Name” params=power-state

This should show “power-state: running” if the VM has successfully started.

Other commands to manage XenServer VMs

1. To restart a VM

There are two ways to restart a VM: a clean shutdown followed by a start, or a forced reboot which is equivalent to pressing the reset button on a physical machine.

For a clean restart (preferred method):

xe vm-reboot name-label= “Your VM Name”

Or using uuid:

xe vm-reboot uuid=your-vm-uuid

For a hard restart (use with caution as this can cause data loss):

xe vm-reset-powerstate force=true vm-name-label= “Your VM Name”

Or using uuid:

xe vm-reset-powerstate force=true uuid=your-vm-uuid

2. To forcibly shut down a VM

Using name-label:

xe vm-shutdown force=true name-label= “Your VM Name”

Or using uuid:

xe vm-shutdown force=true uuid=your-vm-uuid

3. To create a VM

List available templates:

xe template-list

Clone the chosen template to create a new VM:

VM_UUID=$(xe vm-clone uuid=<Template-UUID> new-name-label= “New VM Name”)

Set VM parameters:

xe vm-param-set uuid=$VM_UUID memory-static-max=4294967296
xe vm-param-set uuid=$VM_UUID memory-dynamic-max=4294967296
xe vm-param-set uuid=$VM_UUID memory-dynamic-min=4294967296
xe vm-param-set uuid=$VM_UUID VCPUs-max=2
xe vm-param-set uuid=$VM_UUID VCPUs-at-startup=2

Create and attach a virtual disk:

xe vm-disk-add uuid=$VM_UUID sr-uuid=<SR-UUID> device=0 size=21474836480

Create a network interface:

NETWORK_UUID=$(xe network-list --minimal)
xe vif-create vm-uuid=$VM_UUID network-uuid=$NETWORK_UUID device=0

Start the VM:

xe vm-start uuid=$VM_UUID

How to backup XenServer VMs?

Backing up VMs in XenServer is an essential part of managing a virtual infrastructure to ensure data integrity and continuity of operations.  

Vinchin Backup & Recovery is a robust backup and disaster recovery solution that supports multiple virtualization platforms, including XenServer/Citrix Hypervisor, VMware, Hyper-V, Red Hat Virtualization, Proxmox, and others, offering agentless, incremental, and full VM backups. It enhances data protection with features like deduplication, compression, V2V migration, instant VM restore, granular file-level recovery, encryption and ransomware protection.

The centralized web console facilitates easy setup and management of backup jobs, scheduling, and monitoring, while also enabling robust disaster recovery. To backup XenServer VMs, just following these 4 steps:

1. Select the backup object.

Select the backup object

2. Select backup destination.

Select backup destination

3. Selecting backup strategies.

Selecting backup strategies

4. Review and submit the job.

Review and submit the job

Vinchin Backup & Recovery has been selected by thousands of companies and you can also start to use this powerful system with a 60-day full-featured trial! Also, contact us and leave your needs, and then you will receive a solution according to your IT environment.

Citrix XenServer FAQs

1. Q: Can I migrate XenServer VMs to Proxmox?

A: Yes, you can migrate XenServer VM to Proxmox by exporting VM through XenCenter and then importing it into Proxmox via QEMU-img tool. Or, using an easier method with the robust V2V feature of Vinchin Backup & Recovery.

2. Q: How can I migrate a VM from one host to another?

A: VMs can be migrated using XenMotion, which allows for live migration of VMs without downtime. This can be done through XenCenter or the command line.

Conclusion

By using “xe” commands, administrators can perform a variety of tasks such as listing VMs, starting, rebooting, and shutting down VMs, as well as creating new VMs, setting their parameters, and configuring network interfaces and virtual disks. Understanding and utilizing these command-line operations allows for efficient management of virtual infrastructures and can be particularly useful for scripting and automation in large-scale deployments or for remote management scenarios.

Share on:

Categories: VM Backup