How to import ISO image to disk in Proxmox
28 Jul 2024 - 4 min read
Importing an ISO image to a disk in Proxmox involves several steps. This guide will walk you through the process of converting an ISO to a disk image and managing it using Proxmox tools like qm and qemu-img.
Table of Contents
- How to Import an ISO to Disk in Proxmox Using
qm - Alternative: Using
qemu-nbdto Attach an ISO Directly
How to Import an ISO to Disk in Proxmox Using qm
Step 1: Upload the ISO to Proxmox
Before importing an ISO, you need to upload it to your Proxmox server. You can use either the web interface or the command line.
Upload via Web Interface
-
Log in to the Proxmox Web Interface:
- Open your browser and go to
https://<your-proxmox-ip>:8006.
- Open your browser and go to
-
Navigate to the Storage View:
- Click on the Datacenter in the sidebar.
- Select the Storage where you want to upload the ISO (e.g.,
localorlocal-lvm).
-
Upload ISO:
- Click on the Content tab.
- Click Upload.
- Choose ISO Image from the Content dropdown.
- Select the ISO file from your local machine and click Upload.
Upload via Command Line
-
Upload the ISO using
scp:Terminal scp /path/to/your.iso root@<your-proxmox-ip>:/var/lib/vz/template/iso/Replace
/path/to/your.isowith the path to your ISO file and<your-proxmox-ip>with the IP address of your Proxmox server.
Step 2: Convert ISO to Disk Image
The next step involves converting the ISO to a disk image format (e.g., QCOW2 or RAW) that can be used by Proxmox.
-
Convert ISO to Disk Image
Use
qemu-imgto convert the ISO:Terminal qemu-img convert -O qcow2 /path/to/storage/your-iso-file.iso /path/to/storage/your-disk-image.qcow2Replace
/path/to/storage/your-iso-file.isowith the path to your ISO file and/path/to/storage/your-disk-image.qcow2with the path where you want to save the disk image.Notes:
-
qcow2is a commonly used disk image format. You can also userawformat:Terminal qemu-img convert -O raw /path/to/storage/your-iso-file.iso /path/to/storage/your-disk-image.raw
-
Step 3: Import the Disk Image into Proxmox Storage
-
Identify Your Storage
List available storages with:
Terminal pvesm status -
Import Disk Image
Use the
qm importdiskcommand to import the disk image:Terminal qm importdisk VMID /path/to/storage/your-disk-image.qcow2 STORAGE --format qcow2Replace
VMIDwith a temporary or placeholder VM ID,/path/to/storage/your-disk-image.qcow2with the path to your disk image, andSTORAGEwith the storage name.
Step 4: Attach the Imported Disk to an Existing VM (Optional)
-
Attach Disk Image to VM
Use
qm setto attach the imported disk to an existing VM:Terminal qm set EXISTING_VMID --scsi0 STORAGE:vm-disk.qcow2Replace
EXISTING_VMIDwith your VM ID,STORAGEwith the storage name, andvm-disk.qcow2with the name of the imported disk. -
Verify the Disk is Attached
Check the VM’s configuration with:
Terminal qm config EXISTING_VMID
Alternative: Using qemu-nbd to Attach an ISO Directly
If you need to attach an ISO directly to a disk image without creating a VM, use qemu-nbd.
Step 1: Load nbd Kernel Module
Load the nbd kernel module:
modprobe nbd max_part=8Step 2: Connect ISO to nbd Device
Connect the ISO file to an nbd device:
qemu-nbd --connect=/dev/nbd0 /path/to/your-iso-file.isoStep 3: Copy ISO Content to Disk Image
Create a new disk image and copy the ISO content:
dd if=/dev/nbd0 of=/path/to/disk-image.img bs=4MStep 4: Disconnect the ISO
Disconnect the nbd device:
qemu-nbd --disconnect /dev/nbd0Step 5: Import the Disk Image
Import the disk image into Proxmox:
qm importdisk VMID /path/to/disk-image.img STORAGESummary
- Convert ISO to Disk Image: Use
qemu-imgfor conversion. - Import Disk Image: Use
qm importdiskfor importing. - Attach Disk Image: Use
qm setto attach the disk to a VM. - Alternative: Use
qemu-nbdfor direct ISO attachment.
This guide provides steps to convert and manage ISO files within Proxmox effectively.