Provide a command that searches for the Proxmox host data storage for OS boot discs…
- User
Provide a command that searches for the Proxmox host data storage for OS boot discs (.ISO) where the filename matches a particular keyword. Use the qm command.
Assistant
Of course.
While the
qmcommand is for managing virtual machines (creating, configuring, starting, stopping), the correct command-line tool for managing and searching Proxmox storage ispvesm(Proxmox Storage Manager).Here is the command to search all of your Proxmox storage locations for an ISO file matching a keyword.
The Command
This one-liner will loop through all active storage pools, list the ISOs in each, and filter the results for your keyword.
for storage in $(pvesm status --enabled 1 --output-format=json-pretty | jq -r '.[].storage'); do pvesm list "$storage" --iso 2>/dev/null; done | grep -i 'KEYWORD'Replace
KEYWORDwith the term you are searching for (e.g.,ubuntu,server-2022,debian).
Example
To find all ISO files with "ubuntu" in their filename:
for storage in $(pvesm status --enabled 1 --output-format=json-pretty | jq -r '.[].storage'); do pvesm list "$storage" --iso 2>/dev/null; done | grep -i 'ubuntu'Sample Output:
local:iso/ubuntu-22.04.3-live-server-amd64.iso iso nfs-iso:iso/ubuntu-20.04.6-live-server-amd64.iso isoHow the Command Works
Let's break it down:
-
pvesm status --enabled 1 --output-format=json-pretty | jq -r '.[].storage':pvesm status: Lists all configured storage on the Proxmox host.--enabled 1: Filters the list to only show active storage pools.--output-format=json-pretty | jq -r '.[].storage': This is a robust way to get just the names of the storage pools (e.g.,local,nfs-iso, etc.), one per line. It uses thejqtool to parse the JSON output.
-
for storage in $(...):- This is a standard shell
forloop. It iterates through each storage name provided by the command inside the$().
- This is a standard shell
-
do pvesm list "$storage" --iso 2>/dev/null:pvesm list "$storage": Lists the contents of the current storage pool from the loop.--iso: Specifies that we are only interested in theisocontent type.2>/dev/null: This is important. It redirects any error messages to/dev/null. This prevents "content type 'iso' not found on storage" errors from appearing for storage pools that are not configured to hold ISO files (likelocal-lvm).
-
done | grep -i 'KEYWORD':- The output of the entire loop (a combined list of all ISOs from all storages) is piped
|to thegrepcommand. grep -i 'KEYWORD': Searches the list for lines containing yourKEYWORD. The-iflag makes the search case-insensitive.
- The output of the entire loop (a combined list of all ISOs from all storages) is piped
Simpler Version (If you know the storage name)
If you know your ISOs are stored on a specific storage (e.g.,
local), you can use a much simpler command:pvesm list local --iso | grep -i 'KEYWORD'-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.