You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何让Terraform修改Proxmox的scsi1存储而非Cloud-Init scsi0?

调整Terraform配置以修改Proxmox VM的scsi1存储而非Cloud-Init scsi0

你的Terraform配置当前会默认修改scsi0设备(该设备被Cloud-Init占用),要改为修改scsi1驱动器,只需在磁盘配置中明确指定插槽,并确保启动盘设置正确,具体调整如下:

修改后的完整配置

resource "proxmox_vm_qemu" "fuse-pri" {
  name        = "fuse-pri"
  vmid        = "302"
  desc        = "Primary Fuse PostgreSQL DB - built by terraform"
  target_node = "pve"

  # VM Advanced General Settings
  onboot = true

  ### Clone (template name)
  clone      = var.rocky_vm_template
  full_clone = true

  # VM System Settings (important for QEMU agent). 
  # 因为模板未安装QEMU agent,所以设为"0"
  agent = 0

  # VM CPU Settings
  cores   = 8
  sockets = 1
  cpu     = "host"
  numa    = true

  # VM RAM Settings
  memory  = 16384
  balloon = 0

  # VM Network Settings
  network {
    bridge = "vmbr1" # 位于pfSense LAN
    model  = "virtio"
    tag    = 10
  }

  # VM Cloud-Init Settings
  os_type = "cloud-init"

  scsihw = "virtio-scsi-single"
  bootdisk = "scsi0" # 保持模板原有系统盘为启动盘

  # 指定磁盘挂载到scsi1插槽
  disk {
    slot     = 1
    size     = "100G"
    type     = "scsi"
    storage  = "supersonic"
    iothread = 1
    discard  = "on"
    ssd      = 1
    backup   = true
  }
}

关键调整说明

  • 添加slot = 1:强制将该磁盘分配到scsi1插槽,避免覆盖模板中默认的scsi0设备(系统盘或Cloud-Init占用的设备)
  • 保留bootdisk = "scsi0":确保虚拟机从模板原有的系统盘启动,而非新增的scsi1磁盘
  • 调整后,Terraform会在克隆模板的基础上新增scsi1磁盘并应用配置,Cloud-Init将继续使用模板默认的CD-ROM设备,不会被修改

内容的提问来源于stack exchange,提问作者Shery

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 22:20:29