How to use the command "qm rescan" (with examples)
The “qm rescan” command is used to rescan all storages of a virtual machine in Proxmox VE and update the disk sizes. It also updates the list of unused disk images. This command allows you to keep the disk sizes accurate and remove any unnecessary disk images from your storage.
Use case 1: Rescan all storages and update disk sizes and unused disk images of a specific virtual machine
Code:
qm rescan vm_id
Motivation: The motivation for using this example is to update the disk sizes and remove any unused disk images for a specific virtual machine. It ensures that your storage is being utilized efficiently and frees up any space occupied by unnecessary disk images.
Explanation:
- “qm rescan” is the command to initiate the rescan process.
- “vm_id” is the ID of the virtual machine for which you want to perform the rescan.
Example output:
Rescanning storages for virtual machine vm_id...
Disk sizes and unused disk images updated successfully.
Use case 2: Perform a dry-run of rescan on a specific virtual machine and do not write any changes to configurations
Code:
qm rescan --dryrun true vm_id
Motivation: The motivation for using this example is to verify the changes that would be made during the rescan process without actually applying those changes. It allows you to preview the potential effects of the rescan before making any modifications to the configurations.
Explanation:
- “qm rescan” is the command to initiate the rescan process.
- “–dryrun true” is an argument used to perform a dry-run, which means that no changes will be made to the configurations.
- “vm_id” is the ID of the virtual machine for which you want to perform the dry-run rescan.
Example output:
Rescanning storages for virtual machine vm_id (dry-run)...
Disk sizes and unused disk images would be updated successfully (no changes made during dry-run).
Conclusion:
The “qm rescan” command in Proxmox VE is a powerful tool for updating disk sizes and removing unused disk images for virtual machines. By using this command, you can ensure optimal storage utilization and maintain accurate disk sizes. Additionally, the “–dryrun” option allows you to preview the changes that would be made during the rescan process without actually applying those changes.