# Import OS images or migrate VMs from other hypervisors sing the CLI

> Upload and import OS images, cloud templates, and virtual machines into CubeCOS via command-line interface. Comprehensive guide for v2v migrations from VMware, p2v migrations, Hyper-V, and other hypervisors to prepare VMs for deployment.

Use the CLI to upload and import OS images into CubeCOS before deploying virtual machines. Image uploads follow a staged process.

:::info

Pre-built cloud images are available on our website. [**Go to Downloads**](../../downloads/cloud_image.md)

:::

## Upload image over SCP or winscp {#upload-image-over-scp-or-winscp}

Transfer your image file to the CubeCOS storage path using SCP (or WinSCP on Windows):

Replace the following variables:

- `<image-name>`: The name of the image
- `<format>`: Any of the following supported virtual disk formats.
  - qcow2
  - raw
  - vmdk
  - vhd
  - ova
  - img
  - kernel
- `<your-cluster-vip>`: Replace with your cluster VIP. For single node deployments, use the management IP of the node.

```bash title="The local terminal"
scp <image-name>.<format> root@<your-cluster-vip>:/mnt/cephfs/glance/.
```

## Connect to the CLI {#connect-to-the-cli}

SSH into the appliance as the admin user:

```bash title="The local terminal"
$ ssh admin@<your-cluster-vip>
Password:
Welcome to the Cube Appliance
Enter "help" for a list of available commands
controller>
```

## Import the image {#import-the-image}

Choose the import mode based on what you're importing:

1. **As an image**: For cloud OS images and templates used to provision new virtual machines.
2. **As a volume**: For VM disks exported from another platform (such as VMware or Hyper-V), imported directly into a project as a bootable volume.

1. Run the image import command:

   ```bash title="Admin CLI terminal"
   controller> iaas image import
   ```

2. Select the image source location.

   Choose `local` to import from the local filesystem or `usb` to import form a USB device.

   :::info[USB storage devices are blocked by default]

   To enable USB access, log in as admin and set the tuning option `cubesys.probeusb` to `true` via **CLI > tuning > configure**.

   :::

   ```bash title="Admin CLI terminal"
   1: usb
   2: local
   Enter index: 2
   ```

3. Select the image file to import.

   Replace the following variables:
   - `<image-name>`: The name of the image
   - `<format>`: Any of the following supported virtual disk formats: qcow2, raw, vmdk, vhd, ova, img, and kernel.

   ```bash title="Admin CLI terminal"
   1: <image-template-name>.<format>
   # ubuntu2204.qcow2 is an example image to be imported
   Enter index: 1
   ```

4. Enter a name for the image:

   Replace the following variable:
   - `<imported-image-name>`: Set the image name that will be displayed after the image is imported to CubeCOS.

   ```bash title="Admin CLI terminal"
   Specify image name: <imported-image-name>
   ```

5. Select the domain:

   ```bash title="Admin CLI terminal"
   1: default
   Enter index: 1
   ```

6. Select the tenant:

   There might be many tenants (projects) within your CubeCOS cluster. Select the tenant (project) as the destination for your image.

   ```bash title="Admin CLI terminal"
   1: admin
   Enter index: 1
   ```

7. To import template images or cloud images, select **from Bigstack** for native CubeCOS images:

   ```bash title="Admin CLI terminal"
   Image source:
   1: from Bigstack
   2: from another hypervisor
   Enter index: 1
   ```

8. Select the visibility of the imported template image.
   1. `public` image: This will be available to all projects in the cluster.
   2. `private` image: This will only be available to the destination project.

   ```bash title="Admin CLI terminal"
   Visibility:
   1: public
   2: private
   Enter index: 1
   ```

9. Select the storage destination:

   The default Ceph SDS is labelled as `CubeStorage` or any additional integrated external storage.

   ```bash title="Admin CLI terminal"
   1: CubeStorage
   Enter index: 1
   ```

10. Select the guest operating system.

    :::warning[Selecting the correct OS is important]

    Choosing the wrong type can significantly impact performance:

    :::

    ```bash title="Admin CLI terminal"
    Select OS (big impacts to performance if it's windows):
    1: CentOS
    2: Fedora
    3: Ubuntu
    4: Debian
    5: Windows
    6: Rocky
    7: FreeBSD
    8: CoreOS
    9: Arch
    10: Others
    Enter index: 10
    ```

11. Wait for the import to complete:

    ```bash title="Admin CLI terminal"
    Importing...
    [14:23:44] Converting image to RAW format ...
        (100.00/100%)
    [14:23:50] Importing image migrate-vol21 ...
    [=============================>] 100%
    # output truncated
    | visibility          | public                                                                           |
    +---------------------+----------------------------------------------------------------------------------+
    [14:26:08] Finished creating image migrate-vol21
    Importing migrate-vol21 complete. It is safe to remove the local image file.
    ```

1. Run the image import command:

   ```bash title="Admin CLI terminal"
   controller> iaas image import
   ```

2. Select the image source location.

   Choose `local` to import from the local filesystem or `usb` to import form a USB device.

   :::info[USB storage devices are blocked by default]

   To enable USB access, log in as admin and set the tuning option `cubesys.probeusb` to `true` via **CLI > tuning > configure**.

   :::

   ```bash title="Admin CLI terminal"
   1: usb
   2: local
   Enter index: 2
   ```

3. Select the image file to import.

   Replace the following variables:
   - `<image-name>`: The name of the image
   - `<format>`: Any of the following supported virtual disk formats: qcow2, raw, vmdk, vhd, ova, img, and kernel.

   ```bash title="Admin CLI terminal"
   1: <image-template-name>.<format>
   # ubuntu2204.qcow2 is an example image to be imported
   Enter index: 1
   ```

4. Enter a name for the image:

   Replace the following variable:
   - `<imported-image-name>`: Set the image name that will be displayed after the image is imported to CubeCOS.

   ```bash title="Admin CLI terminal"
   Specify image name: <imported-image-name>
   ```

5. Select the domain:

   ```bash title="Admin CLI terminal"
   1: default
   Enter index: 1
   ```

6. Select the tenant:

   There might be many tenants (projects) within your CubeCOS cluster. Select the tenant (project) as the destination for your image.

   ```bash title="Admin CLI terminal"
   1: admin
   Enter index: 1
   ```

7. To import template images or cloud images, select **from Bigstack** for native CubeCOS images:

   All CLI imported

   ```bash title="Admin CLI terminal"
   Image source:
   1: from Bigstack
   2: from another hypervisor
   Enter index: 2
   ```

8. Select the storage destination:

   The default Ceph SDS is labelled as `CubeStorage` or any additional integrated external storage.

   ```bash title="Admin CLI terminal"
   1: CubeStorage
   Enter index: 1
   ```

9. Select the guest operating system.

   :::warning[Selecting the correct OS is important]

   Choosing the wrong type can significantly impact performance:

   :::

   ```bash title="Admin CLI terminal"
   Select OS (big impacts to performance if it's windows):
   1: CentOS
   2: Fedora
   3: Ubuntu
   4: Debian
   5: Windows
   6: Rocky
   7: FreeBSD
   8: CoreOS
   9: Arch
   10: Others
   Enter index: 10
   ```

10. Wait for the import to complete:

    ```bash title="Admin CLI terminal"
    Importing...
    [14:31:03] Converting image to RAW format ...
    [   0.0] Setting up the source: -i disk /mnt/cephfs/glance/rocky_9.qcow2
    [   1.1] Opening the source
    [   9.6] Inspecting the source
    [  14.2] Checking for sufficient free disk space in the guest
    [  14.2] Converting Rocky Linux 9.5 (Blue Onyx) (rocky9) to run on KVM
    virt-v2v: This guest has virtio drivers installed.
    [  71.6] Setting a random seed
    [  71.7] SELinux relabelling
    [  77.3] Mapping filesystem data to avoid copying unused and blank areas
    [  78.8] Closing the overlay
    [  79.0] Assigning disks to buses
    [  79.0] Checking if the guest needs BIOS or UEFI to boot
    [  79.0] Setting up the destination: -o disk -os /tmp
    [  80.0] Copying disk 1/1
    [  84.5] Creating output metadata
    [  84.5] Finishing off
    [14:32:37] Importing image migrate-vmdk21 ...
    Importing image: 100% complete...done.
    [14:32:58] Finished creating image migrate-vmdk21
    Importing migrate-vmdk21 complete. It is safe to remove the local image file.
    ```
