- kube-scheduler: The Kubernetes scheduler - Fri, Sep 29 2023
- Kubernetes logs: Pod logs, container logs, Docker logs, kubelet logs, and master node logs - Mon, Sep 25 2023
- Kubernetes DaemonSets - Wed, Sep 6 2023
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:
Similarly, if you click the Proxmox storage (local in our case) and then select the VM Disks tab, you can view the disk format.
To view the disk configuration with the command line, use the pvesm list local command, where local is the name of the storage.
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."
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:
- Make sure your VM is stopped.
- 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.
- Now, select the appropriate storage under the Target Storage field.
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.
- 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.
You will now see the progress in the Task Viewer window, as shown below:
Once the disk is moved, you will notice that the Take Snapshot option is now available.
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.
- SSH into your Proxmox server, or use the built-in Shell option in the Proxmox web GUI.
- Now type qm list command to view all the VMs:
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.
- Run the qm config 103 command to view the VM configuration, where 103 is the VM ID.
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.
- 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
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.
- Once the above command is complete, you can run the qm config and pvesm list commands again to verify the updated VM config.
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:
- Make sure your container is stopped.
- Go to the Resources tab and select the Root Disk.
- Now click the Volume Action menu, and select the Move Storage option, as shown in the screenshot.
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.
- After moving the volume to supported storage, you will be able to take snapshots.
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!
- SSH into your Proxmox server.
- Run the pct list command to view all the containers.
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.
- Now run the pct config 104 command to view the container's config, where 104 is the container ID.
Make note of the name of the volume to move. It is rootfs in our case.
- Run the pct move-volume command, as shown below:pct move-volume 104 rootfs lvm-datastore --delete
- You can now run the pct config and pvesm list commands to verify that the container's volume was moved successfully to new storage.
- 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.