0

我试图在 vSphere 中使用下面的 HCL 自动构建 Ubuntu Desktop 21.04 的 Packer。我后来发现这只会从 21.10开始用于桌面图像。

看:

https://discourse.ubuntu.com/t/refreshing-the-ubuntu-desktop-installer/20659/76?u=nathanto

下面的原始问题是为了帮助其他人。

关键部分是引导命令定义seedfrom. user-data从从未加载的意义上说,这似乎不起作用。VM 启动,并net.ifnames=0应用来自 boot 命令的参数(接口名为eth0)。

开机命令的逻辑是按下c进入grub>提示符,然后输入命令boot_command如下图。

我看到/proc/cmdline引导命令已正确应用。

我看不到任何迹象表明user-data已加载。如果我查看启动命令中显示的 Web 服务器,使用已启动 VM 中的 Firefox,则user-datameta-data文件在那里并且可以访问。

请问有人对如何调试有任何想法吗?

source "vsphere-iso" "dev_vm" {
  username            = var.vcenter_username
  password            = var.vcenter_password
  vcenter_server      = var.vcenter_server
  cluster             = var.vcenter_cluster
  datacenter          = var.vcenter_datacenter
  datastore           = var.vcenter_vm_datastore
  guest_os_type       = "ubuntu64Guest"
  insecure_connection = "true"
  iso_checksum        = "sha256:fa95fb748b34d470a7cfa5e3c1c8fa1163e2dc340cd5a60f7ece9dc963ecdf88"
  iso_urls            = ["https://releases.ubuntu.com/21.04/ubuntu-21.04-desktop-amd64.iso"]
  http_directory      = "./http"

  vm_name             = "dev_vm"
  CPUs                = 2
  RAM                 = 2048
  RAM_reserve_all     = true
  boot_wait           = "3s"
  convert_to_template = false
  boot_command        = [
    "c",
    "linux /casper/vmlinuz --- autoinstall ds='nocloud-net;seedfrom=http://{{.HTTPIP}}:{{.HTTPPort}}/' net.ifnames=0 ",
    "<enter><wait>",
    "initrd /casper/initrd<enter><wait>",
    "boot<enter>"
  ]
  network_adapters {
    network      = "xxx"
    network_card = "e1000"
  }
  storage {
    disk_size             = 40960
    disk_thin_provisioned = true
  }

  ssh_username = "xx"
  ssh_password = "xx"
  ssh_timeout  = "60m"
}

build {
  sources = [
    "source.vsphere-iso.dev_vm"
  ]
...
}

4

1 回答 1

0

我正在使用带有自动安装功能的 virtualbox 安装 Ubuntu 服务器 20.04 的打包程序,我观察了安装过程的发生。我看到的是 cloud init 正在运行,然后在它达到 20.04 服务器自行重启的点后,图形安装程序启动。

我已经尝试了 8 或 9 个版本的 boot_command,人们发誓它们可以工作,但到目前为止还没有。我正在寻找人们如何创建 boot_command。我是 Ubuntu 自动安装和打包程序的新手,所以我正在学习。他们还在改造无处不在 https://discourse.ubuntu.com/t/refreshing-the-ubuntu-desktop-installer/20659/73

所以这也可能影响你。

于 2022-01-27T16:51:48.507 回答