メモ。Packer で起動した Ubuntu で Pressed が動かない
By takagiwa on Monday, February 7 2022, 21:28 - Linux - Permalink
そもそも Ubuntu (というか Xubuntu) Desktop で Pressed が動くのかどうかよくわからない。検索すると、デスクトップ環境が欲しいなら Ubuntu Server インストール後に Desktop のパッケージを入れれば良い、という情報もある。
Pressed のファイルは、live OS 上のブラウザからもアクセスできるし、起動ログにもロードしたらしい情報があるのに動いてくれないので、次は Ubuntu Server で試してみるしかなさそう。
この辺でうごいてくれたら、Packer 関係無く Ubuntu の話だ。
試した Packer ファイルはこちら
variable "build_directory" { default = "./build" } variable "boot_wait" { default = "5s" } variable "cpus" { default = 1 } variable "disk_size" { default = 50000 } variable "headless" { default = false } variable "http_directory" { default = "./http" } variable "iso_url" { type = string } variable "iso_checksum" { type = string } variable "memory" { default = 1024 } variable "username" { default = "vagrant" } variable "vm_name" { type = string } variable "provider_name" { default = "virtualbox" } variable "ssh_timeout" { default = "45m" } source "virtualbox-iso" "ubuntu20041" { boot_command = [ "<esc><wait>", "<esc><wait>", "<esc><wait>", "<enter><wait>", "/casper/vmlinuz<wait>", " file=/cdrom/preseed/xubuntu.seed boot=casper initrd=/casper/initrd", " noninteractive", " preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed_2.cfg", " -- <wait>", "<enter><wait>" ] boot_wait = var.boot_wait cpus = var.cpus disk_size = var.disk_size guest_os_type = "Ubuntu_64" hard_drive_interface = "sata" headless = var.headless http_directory = var.http_directory iso_url = var.iso_url iso_checksum = var.iso_checksum memory = var.memory output_directory = "${var.build_directory}/packer-${var.provider_name}" shutdown_command = "echo '${var.username}' | sudo -S shutdown -P now" ssh_timeout = var.ssh_timeout ssh_username = var.username ssh_password = var.username vm_name = var.vm_name } build { sources = ["sources.virtualbox-iso.ubuntu20041"] }
boot_command に対しては、いろいろ書いてみたけどわからない(全部一気に書いたわけではない)。
" auto-install/enable=true", " debconf/priority=critical", " ksdevice=enp0s3 interface=enp0s3", " debug-ubiquity automatic-ubiquity only-ubiquity noninteractive",
そもそも起動するまでも紆余曲折だった。
boot_wait を 10s に設定していたら、boot_command が始まるのが間に合わなかったので 5s に短縮。これは実機合わせが必要だと思う。
boot_command の最初の
"<esc><wait>", "<esc><wait>", "<esc><wait>", "<enter><wait>",
これも実際に動かして確認。
"/casper/vmlinuz<wait>", " file=/cdrom/preseed/xubuntu.seed boot=casper initrd=/casper/initrd",
ここはしばらくかかった。ISO で起動したときの boot オプションを参照しなければいけない。けど Ubuntu18 のインストーラは vmlinuz 書いてないからわからなかった。古いやつなら /install/vmlinuz でいいはず。実際に ISO をマウントして確認したパスを設定。なので、ここも実際の ISO を確認しながら作っていかなければいけない。