In my previous post, we discussed creating a VM template in Proxmox. In this post, we will see how to move a Proxmox VM or container to a different disk.

Why move to different storage?

Perhaps you are running out of storage space or want to upgrade to faster SSD storage. While there could be several reasons for moving a Proxmox VM or container to different storage, for the sake of this post, I am assuming the need for live snapshot capability. While provisioning a new VM, you must remember that there are certain requirements for live snapshots in Proxmox. If you choose unsupported storage or an incorrect disk format (e.g., raw), you will not be able to take snapshots of your VM or container later.

For demonstration purposes, I will use multiple VMs and containers configured with a raw disk format and stored in local file-based storage. Note that neither the raw disk format nor file-based storage supports live snapshots. Our objective is to move all the raw disks to block-level storage (thin-lvm), so we can use Proxmox's live snapshot feature. Alternatively, if you can't use block-level storage for some reason, you can convert the disk from raw to QEMU image format (qcow2).

Checking VM configuration

To check the current disk configuration of a VM, click the Hardware tab. You will see the disk configuration under the Hard Disk section, as shown in the screenshot below:

Checking the current VM disk configuration

Checking the current VM disk configuration

Similarly, if you click the Proxmox storage (local in our case) and then select the VM Disks tab, you can view the disk format.

Checking the disk format in Proxmox

Checking the disk format in Proxmox

To view the disk configuration with the command line, use the pvesm list local command, where local is the name of the storage.

Viewing the VM disk configuration with the command line

Viewing the VM disk configuration with the command line

At this point, if you go to the Snapshots option of the VM, you will notice that the Take Snapshot button is grayed out and there is a message stating, "The current guest configuration does not support taking new snapshots."

The Take Snapshot button is grayed out in Proxmox

The Take Snapshot button is grayed out in Proxmox

This message indicates that something is wrong with either your VM disk format or storage, where the VM disk is actually stored. To fix this problem, we will move the VM disk to a different storage.

Moving VM disk with GUI

To move the VM disk to a different storage using the Proxmox GUI, follow these steps:

  1. Make sure your VM is stopped.
  2. Select the VM (srv2, in our case), go to the Hardware tab, select Hard Disk (scsi0), click the Disk Action menu, and finally click Move Storage, as shown in the screenshot below.

    Move the VM disk to different storage in Proxmox with the GUI

    Move the VM disk to different storage in Proxmox with the GUI

  3. Now, select the appropriate storage under the Target Storage field.
    The Move disk dialog box in Proxmox with block level target storage selected

    The Move disk dialog box in Proxmox with block level target storage selected

    You can see in the screenshot that when we select block-level storage (e.g., lvm-datastore), the format option is grayed out because block-level storage supports raw disk format only. We can simply use this option since thin-lvm has out-of-the-box support for live snapshots.

  4. Alternatively, if we select a file-level storage (e.g., nfs-datastore), the format option becomes available. Either way, we will be able to use the snapshots feature, so I will simply choose lvm-datastore and click Move disk.
    The Move disk dialog in Proxmox with file level target storage selected

    The Move disk dialog in Proxmox with file level target storage selected

    You will now see the progress in the Task Viewer window, as shown below:

    Viewing the move disk progress in Proxmox

    Viewing the move disk progress in Proxmox

    Once the disk is moved, you will notice that the Take Snapshot option is now available.

    Verifying that the take snapshot option is available for the VM

    Verifying that the take snapshot option is available for the VM

Moving the VM disk with the CLI

If you like doing things with the command line, follow the steps in this section to move the VM disk.

  1. SSH into your Proxmox server, or use the built-in Shell option in the Proxmox web GUI.
  2. Now type qm list command to view all the VMs:
    Viewing all the virtual machines in Proxmox with the command line

    Viewing all the virtual machines in Proxmox with the command line

    In the previous section, we moved the disk of srv2 (VM ID 102) using the GUI option. This time, we will move the disk of srv3 (VMID 103) using the command line.

  3. Run the qm config 103 command to view the VM configuration, where 103 is the VM ID.
    Viewing the VM configuration in Proxmox with the command line

    Viewing the VM configuration in Proxmox with the command line

    We are only interested in a particular line containing the hard disk information for this VM. The disk we want to move is scsi0, which is currently saved in the local storage.

  4. Once you have the name of the VM disk, run the qm disk move command, as shown below:
    qm disk move 103 scsi0 lvm-datastore --delete
    Moving the VM disk to a different storage in Proxmox with the command line

    Moving the VM disk to a different storage in Proxmox with the command line

    Don't forget to replace lvm-datastore with the name of your new storage. By default, the original disk is retained as an unused disk, so if your VM doesn't work after moving to new storage, you can attach the unused disk and start the VM. The --delete flag removes the source disk after it's moved. Furthermore, if you're moving the disk to file-based storage, you could also use the --format option to specify a format such as qcow2.

  5. Once the above command is complete, you can run the qm config and pvesm list commands again to verify the updated VM config.
    Verify the updated VM config and storage with the command line

    Verify the updated VM config and storage with the command line

    You can now start your VM with the qm start 103 command.

In the next section, we will discuss how to move container volumes.

Moving a container volume with the GUI

Note that Proxmox containers support only the raw disk format, so there is no choice but to move the container's volume to snapshot-supported storage. To do this with the GUI, follow these steps:

  1. Make sure your container is stopped.
  2. Go to the Resources tab and select the Root Disk.
  3. Now click the Volume Action menu, and select the Move Storage option, as shown in the screenshot.
    Moving a container volume with the Proxmox GUI

    Moving a container volume with the Proxmox GUI

    Now, follow the same steps as we did for moving a VM disk. I just moved the root volume of the certbot container with VM ID 100.

  4. After moving the volume to supported storage, you will be able to take snapshots.

    Verify the Take Snapshot option after moving the container volume

    Verify the Take Snapshot option after moving the container volume

Moving a container volume with the CLI

To move a container's volume to another storage with the command line, follow these steps:

Subscribe to 4sysops newsletter!

  1. SSH into your Proxmox server.
  2. Run the pct list command to view all the containers.
    Viewing all containers in Proxmox with the command line

    Viewing all containers in Proxmox with the command line

    Previously, we moved the certbot container (ID 100) volume. Now let's move the root volume of the nginx container (ID 104). If your container is running, use the pct stop command to stop it.

  3. Now run the pct config 104 command to view the container's config, where 104 is the container ID.
    Viewing container configuration in Proxmox with the command line

    Viewing container configuration in Proxmox with the command line

    Make note of the name of the volume to move. It is rootfs in our case.

  4. Run the pct move-volume command, as shown below:pct move-volume 104 rootfs lvm-datastore --delete

    Moving the container volume to a different storage in Proxmox with the command line

    Moving the container volume to a different storage in Proxmox with the command line

  5. You can now run the pct config and pvesm list commands to verify that the container's volume was moved successfully to new storage.

    Verify the updated container config and storage with the command line

    Verify the updated container config and storage with the command line

  6. Now start your container with the pct start 104 command.

Conclusion

You just learned how to move a Proxmox VM disk or container volume to different storage. No matter which method you use, you can now start creating snapshots of your VMs or containers.

0 Comments

Leave a reply

Your email address will not be published. Required fields are marked *

*

© 4sysops 2006 - 2023

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account