Skip to content

VMC Command in ChromeOS: Virtual Machine Management

The vmc command in ChromeOS is a versatile tool for creating, managing, and interacting with virtual machines (VMs) within the ChromeOS environment. This guide provides an overview of its features and usage.

Virtual Machine Operations

Starting a Virtual Machine

Launch a virtual machine with optional configurations:

bash vmc start [OPTIONS] <vm name>

Options: - --enable-gpu: Enable GPU support for the VM. - --enable-dgpu-passthrough: Pass through a dedicated GPU to the VM. - --enable-big-gl: Enable OpenGL acceleration. - --enable-virtgpu-native-context: Use the Virtio GPU context. - --vtpm-proxy: Enable vTPM proxy for enhanced security. - --extra-disk PATH: Attach an extra disk to the VM.

Example: bash vmc start --enable-gpu my-vm

Stopping a Virtual Machine

Terminate a running VM:

bash vmc stop <vm name>

Example: bash vmc stop my-vm

Listing Virtual Machines

View all available VMs:

bash vmc list

This command shows all VMs on the system, including their status.

Creating and Managing Virtual Machines

Creating a New Virtual Machine

Initialize a VM with an optional source media:

bash vmc create [OPTIONS] <vm name> [<source media>] [<removable storage name>]

Options: - --size SIZE: Specify the disk size for the VM. - -p: Preallocate the disk space.

Example: bash vmc create --size 20G my-vm

Resizing a Virtual Machine Disk

Expand the disk size of an existing VM:

bash vmc resize <vm name> <size>

Example: bash vmc resize my-vm 30G

Exporting a Virtual Machine

Save a VM to an external file:

bash vmc export <vm name> <file name>

Example: bash vmc export my-vm /path/to/backup.vm

Importing a Virtual Machine

Load a VM from an external file:

bash vmc import <vm name> <file name>

Example: bash vmc import my-vm /path/to/backup.vm

Destroying a Virtual Machine

Delete a VM and its associated data:

bash vmc destroy <vm name>

Example: bash vmc destroy my-vm

Advanced Features

Sharing Files with a Virtual Machine

Share a directory or file with a VM:

bash vmc share <vm name> <path>

To unshare: bash vmc unshare <vm name> <path>

USB Device Management

Attach or detach USB devices to a VM:

Attach: bash vmc usb-attach <vm name> <bus>:<device>

Detach: bash vmc usb-detach <vm name> <port>

Debugging and Logs

Access VM logs for troubleshooting:

bash vmc logs <vm name>

Best Practices

  1. VM Initialization
  2. Use vmc create with appropriate disk size to avoid future resizing.
  3. Enable GPU acceleration for better performance in graphics-intensive applications.

  4. Backup and Restore

  5. Regularly use vmc export to back up critical VMs.
  6. Use vmc import to restore VMs on new devices.

  7. Resource Management

  8. Monitor disk usage and resize when necessary.
  9. Share files selectively to control VM access.

  10. Debugging

  11. Check logs using vmc logs for detailed VM status.
  12. Use USB attach/detach commands to test hardware connectivity.

Common Use Cases

Setting Up a Development Environment

```bash

Create a VM

vmc create --size 50G dev-vm

Start the VM with GPU support

vmc start --enable-gpu dev-vm

Share a project directory

vmc share dev-vm /home/user/projects ```

Backing Up a VM

```bash

Export a VM

vmc export dev-vm /backup/dev-vm.vm ```

Debugging a VM

```bash

Check VM logs

vmc logs dev-vm