How to import ISO image to disk in Proxmox

28 Jul 2024 - 4 min read
How to import ISO image to disk in Proxmox

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

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

  1. Log in to the Proxmox Web Interface:

    • Open your browser and go to https://<your-proxmox-ip>:8006.
  2. Navigate to the Storage View:

    • Click on the Datacenter in the sidebar.
    • Select the Storage where you want to upload the ISO (e.g., local or local-lvm).
  3. 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

  1. Upload the ISO using scp:

    Terminal
    scp /path/to/your.iso root@<your-proxmox-ip>:/var/lib/vz/template/iso/

    Replace /path/to/your.iso with 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.

  1. Convert ISO to Disk Image

    Use qemu-img to convert the ISO:

    Terminal
    qemu-img convert -O qcow2 /path/to/storage/your-iso-file.iso /path/to/storage/your-disk-image.qcow2

    Replace /path/to/storage/your-iso-file.iso with the path to your ISO file and /path/to/storage/your-disk-image.qcow2 with the path where you want to save the disk image.

    Notes:

    • qcow2 is a commonly used disk image format. You can also use raw format:

      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

  1. Identify Your Storage

    List available storages with:

    Terminal
    pvesm status
  2. Import Disk Image

    Use the qm importdisk command to import the disk image:

    Terminal
    qm importdisk VMID /path/to/storage/your-disk-image.qcow2 STORAGE --format qcow2

    Replace VMID with a temporary or placeholder VM ID, /path/to/storage/your-disk-image.qcow2 with the path to your disk image, and STORAGE with the storage name.

Step 4: Attach the Imported Disk to an Existing VM (Optional)

  1. Attach Disk Image to VM

    Use qm set to attach the imported disk to an existing VM:

    Terminal
    qm set EXISTING_VMID --scsi0 STORAGE:vm-disk.qcow2

    Replace EXISTING_VMID with your VM ID, STORAGE with the storage name, and vm-disk.qcow2 with the name of the imported disk.

  2. 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:

Terminal
modprobe nbd max_part=8

Step 2: Connect ISO to nbd Device

Connect the ISO file to an nbd device:

Terminal
qemu-nbd --connect=/dev/nbd0 /path/to/your-iso-file.iso

Step 3: Copy ISO Content to Disk Image

Create a new disk image and copy the ISO content:

Terminal
dd if=/dev/nbd0 of=/path/to/disk-image.img bs=4M

Step 4: Disconnect the ISO

Disconnect the nbd device:

Terminal
qemu-nbd --disconnect /dev/nbd0

Step 5: Import the Disk Image

Import the disk image into Proxmox:

Terminal
qm importdisk VMID /path/to/disk-image.img STORAGE

Summary

  • Convert ISO to Disk Image: Use qemu-img for conversion.
  • Import Disk Image: Use qm importdisk for importing.
  • Attach Disk Image: Use qm set to attach the disk to a VM.
  • Alternative: Use qemu-nbd for direct ISO attachment.

This guide provides steps to convert and manage ISO files within Proxmox effectively.

ThinhHV

About ThinhHV

DevOps • Fullstack Developer • Amateur Photographer