virt-filesystems

virt-filesystems is a command-line utility that is part of the libvirt suite of tools, which provides information about the filesystems used by virtual machines (VMs). It allows administrators to query and manage the disk resources in a virtualized environment, especially when dealing with virtual machine images (such as .qcow2 or .raw formats).

This tool can be used to inspect the disk images used by VMs, identify the types of filesystems within these images, and gather other useful information such as file system labels, sizes, and partitions.

Key Features of virt-filesystems

  1. List Filesystems: It can list all filesystems in a virtual disk image.

  2. Inspect Disk Images: It allows administrators to inspect and identify filesystems within virtual machine disk images (like .qcow2, .raw, .vmdk, etc.).

  3. Display Disk Partitions: It shows partition tables and partitions inside disk images, useful for checking how virtual disks are structured.

  4. Check Filesystem Types: It helps determine which types of filesystems are in use within a VM image, such as ext4, xfs, or btrfs.

  5. Mount Information: virt-filesystems can show mounted points for virtual disks.

Basic Syntax

virt-filesystems [options] [domain]
  • domain: The name or ID of the virtual machine (VM) you want to inspect (optional).

Common Options

  • -a, --add: Add one or more disk image files to the operation.

  • -l, --long: Provides a long listing format, showing more detailed information (e.g., filesystem size, type, mount points).

  • -m, --mount: Displays the mount points for each filesystem inside the disk image.

  • -t, --type: Filters the output by filesystem type (e.g., ext4, xfs).

  • -h, --help: Displays help for the command and available options.

Common Use Cases for virt-filesystems

  1. List Filesystems in a Virtual Disk Image:

    To list all the filesystems contained within a disk image, you can run:

    virt-filesystems -a /path/to/disk-image.qcow2

    This command will list all the filesystems inside the given disk image file.

  2. Display Filesystem Types and Sizes:

    If you want to get more detailed information about the filesystem types and their sizes within a disk image, use the -l option:

    virt-filesystems -l -a /path/to/disk-image.qcow2

    This will show the type, size, and mount point of each filesystem in the image.

  3. List Filesystems in a Virtual Machine:

    If you want to check the filesystems in a running VM (instead of an image file), you can specify the VM's domain name:

    virt-filesystems --domain vm_name
  4. Filter by Filesystem Type:

    If you want to list only filesystems of a certain type, for example, ext4, you can use the -t option:

    virt-filesystems -t ext4 -a /path/to/disk-image.qcow2

    This will only show ext4 filesystems in the disk image.

  5. Display Mount Points:

    To show the mount points for all filesystems in a virtual disk image, use the -m option:

    virt-filesystems -m -a /path/to/disk-image.qcow2
  6. Inspect a Running Virtual Machine:

    To inspect a running VM, specify the VM domain name and disk images will be automatically listed:

    virt-filesystems --domain vm_name

Example Outputs

  • Example 1: List all filesystems in a virtual machine disk image (/path/to/disk-image.qcow2):

    virt-filesystems -a /path/to/disk-image.qcow2

    Output:

    /dev/sda1: ext4
    /dev/sda2: swap
  • Example 2: Get detailed information about the filesystems, including their sizes and mount points:

    virt-filesystems -l -a /path/to/disk-image.qcow2

    Output:

    /dev/sda1: ext4, size: 100G, mount point: /
    /dev/sda2: swap, size: 4G, mount point: none
  • Example 3: List filesystems of type ext4 in a disk image:

    virt-filesystems -t ext4 -a /path/to/disk-image.qcow2

    Output:

    /dev/sda1: ext4

Why Use virt-filesystems?

  • VM Disk Inspection: It provides a quick and easy way to inspect virtual disk images for filesystem details.

  • Virtual Machine Management: When managing virtual machines, knowing the types of filesystems and mount points can help with maintenance, backups, or troubleshooting.

  • Simplified Troubleshooting: If a virtual machine's disk is not mounting properly, you can use this tool to identify the partitions and filesystems within the image.

Conclusion

virt-filesystems is an essential tool for system administrators and those working with virtualized environments to inspect virtual machine disk images and file systems. Whether you're troubleshooting, planning for backups, or ensuring the correct partitioning and file system types, this tool simplifies access to the underlying disk structure of virtualized systems.

Last updated