Hyper-V VM용 Ubuntu 16.04를 미리 설정하면 UEFI 부팅 섹션을 설치하지 못함

Hyper-V VM용 Ubuntu 16.04를 미리 설정하면 UEFI 부팅 섹션을 설치하지 못함

저는 다음을 사용하여 Hyper-V(Win10 및 Win2016) Ubuntu 기본 이미지를 구축하고 있습니다.포장 기계. 머신이 제대로 빌드되고 내보낸 가상 머신을 문제 없이 부팅할 수 있습니다. 그러나 새로 생성된 가상 하드 드라이브로 새 가상 머신을 생성하면 다음과 같은 메시지와 함께 부팅이 실패합니다.

No x64-based UEFI boot loader was found

나는에서 모았다벤 암스트롱의 블로그이는 UEFI 부팅 파일이 디스크의 올바른 위치에 기록되지 않는다는 사실과 관련이 있습니다.

EFI 드라이브와 부팅 드라이브를 생성하기 위해 미리 설정 파일을 업데이트했지만, EFI/부팅 드라이브에 필요한 파일을 설치하기 위해 미리 설정 파일이나 부팅 명령에 무엇을 추가해야 할지 알 수 없습니다. Gen 2 Hyper-V 가상 머신이 포함된 가상 하드 드라이브.

내 패커 구성은 다음과 같습니다.

{
    "variables": {
        "admin_username": "admin",
        "admin_password": "admin",

        "dir_deploy": null,
        "dir_http_user": null,
        "dir_scripts_user": null,
        "dir_temp": null,

        "iso_checksum": null,
        "iso_url": null,

        "vm_name": "not_really_a_vm_name",
        "vm_ram_size_in_mb": "2048",
        "vm_switch_name": "this_switch_does_not_exist",
        "vm_switch_vlan": ""
    },
    "builders": [
        {
            "boot_wait": "5s",
            "boot_command": [
                "<esc><wait10><esc><esc><enter><wait>",
                "set gfxpayload=1024x768<enter>",
                "linux /install/vmlinuz ",
                "preseed/url=http://${NetworkHostIpAddressForPreseed}:{{.HTTPPort}}/preseed.cfg ",
                "debian-installer=en_US auto locale=en_US kbd-chooser/method=us ",
                "hostname={{.Name}} ",
                "fb=false debconf/frontend=noninteractive ",
                "keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ",
                "keyboard-configuration/variant=USA console-setup/ask_detect=false <enter>",
                "initrd /install/initrd.gz<enter>",
                "boot<enter>"
            ],
            "communicator": "ssh",
            "enable_secure_boot": false,
            "generation": 2,
            "guest_additions_mode": "disable",
            "http_directory": "{{ user `dir_http_user` }}",
            "iso_url": "{{user `iso_url`}}",
            "iso_checksum_type": "sha256",
            "iso_checksum": "{{user `iso_checksum`}}",
            "iso_target_path": "{{ user `dir_temp` }}/packer",
            "output_directory": "{{ user `dir_temp` }}/{{ user `vm_name` }}",
            "ram_size": "{{user `vm_ram_size_in_mb`}}",
            "shutdown_command": "echo '{{user `admin_password`}}' | sudo -S -E shutdown -P now",
            "ssh_password": "{{user `admin_password`}}",
            "ssh_timeout": "4h",
            "ssh_username": "{{user `admin_username`}}",
            "switch_name": "{{user `vm_switch_name`}}",
            "type": "hyperv-iso",
            "vm_name": "{{ user `vm_name` }}"
        }
    ],
    "provisioners": [
        {
            "type": "shell",
            "execute_command": "echo '{{user `admin_password`}}' | sudo -S -E sh {{.Path}}",
            "scripts": [
                "{{ user `dir_scripts_user` }}/ubuntu/update.sh",
                "{{ user `dir_scripts_user` }}/ubuntu/network.sh",
                "{{ user `dir_scripts_user` }}/ubuntu/cleanup.sh",
                "{{ user `dir_scripts_user` }}/ubuntu/sysprep.sh"
            ]
        }
    ]
}

사전 설정 파일은 다음과 같습니다:

# preseed configuration file for Ubuntu.
# Based on: https://help.ubuntu.com/lts/installation-guide/armhf/apbs04.html

#
# *** Localization ***
#
# Originally from: https://help.ubuntu.com/lts/installation-guide/armhf/apbs04.html#preseed-l10n
#

d-i debian-installer/locale string en_US.utf8
d-i console-setup/ask_detect boolean false
d-i console-setup/layout string us

d-i kbd-chooser/method select American English


#
# *** Network configuration ***
#
# Originally from: https://help.ubuntu.com/lts/installation-guide/armhf/apbs04.html#preseed-network
#

d-i netcfg/choose_interface select auto
d-i netcfg/dhcp_failed note ignore
d-i netcfg/dhcp_options select Configure network manually
d-i netcfg/confirm_static boolean true
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string unassigned-domain
d-i netcfg/wireless_wep string

#
# *** Account setup ***
#
# Originally from: https://help.ubuntu.com/lts/installation-guide/armhf/apbs04.html#preseed-account
#

d-i passwd/user-fullname string admin
d-i passwd/username string admin
d-i passwd/user-password password password
d-i passwd/user-password-again password password
d-i user-setup/encrypt-home boolean false
d-i user-setup/allow-password-weak boolean true
d-i user-setup/encrypt-home boolean false


#
# *** Clock and time zone setup ***
#
# Originally from: https://help.ubuntu.com/lts/installation-guide/armhf/apbs04.html#preseed-time
#

d-i clock-setup/utc boolean true
d-i clock-setup/utc-auto boolean true
d-i time/zone string UTC

#
# *** Partitioning ***
#
# Originally from: https://help.ubuntu.com/lts/installation-guide/armhf/apbs04.html#preseed-partman
#

d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman-auto/method string lvm
d-i partman-auto/purge_lvm_from_device boolean true
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-lvm/device_remove_lvm_span boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-auto-lvm/guided_size string max
d-i partman-auto-lvm/new_vg_name string system
d-i partman-auto/choose_recipe select grub-efi-boot-root
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/default_filesystem string ext4

d-i partman-auto/expert_recipe string       \
    grub-efi-boot-root ::                   \
        1 1 1 free                          \
            $bios_boot{ }                   \
            method{ biosgrub }              \
        .                                   \
        256 256 256 fat32                   \
            $primary{ }                     \
            method{ efi }                   \
            format{ }                       \
        .                                   \
        512 512 512 ext4                    \
            $primary{ }                     \
            $bootable{ }                    \
            method{ format }                \
            format{ }                       \
            use_filesystem{ }               \
            filesystem{ ext4 }              \
            mountpoint{ /boot }             \
        .                                   \
        4096 4096 4096 linux-swap           \
            $lvmok{ }                       \
            method{ swap }                  \
            format{ }                       \
        .                                   \
        10000 20000 -1 ext4                 \
            $lvmok{ }                       \
            method{ format }                \
            format{ }                       \
            use_filesystem{ }               \
            filesystem{ ext4 }              \
            mountpoint{ / }                 \
        .

d-i partman-partitioning/no_bootable_gpt_biosgrub boolean false
d-i partman-partitioning/no_bootable_gpt_efi boolean false

# enforce usage of GPT - a must have to use EFI!
d-i partman-basicfilesystems/choose_label string gpt
d-i partman-basicfilesystems/default_label string gpt
d-i partman-partitioning/choose_label string gpt
d-i partman-partitioning/default_label string gpt
d-i partman/choose_label string gpt
d-i partman/default_label string gpt

# Keep that one set to true so we end up with a UEFI enabled
# system. If set to false, /var/lib/partman/uefi_ignore will be touched
d-i partman-efi/non_efi_system boolean true


#
# *** base system installation ***
#
# Originally from: https://help.ubuntu.com/lts/installation-guide/armhf/apbs04.html#preseed-apt
#

d-i base-installer/kernel/override-image string linux-server

#
# *** Package selection ***
#
# originally from: https://help.ubuntu.com/lts/installation-guide/armhf/apbs04.html#preseed-pkgsel
#

tasksel tasksel/first multiselect standard, ubuntu-server

# Minimum packages (see postinstall.sh). This includes the hyper-v tools
d-i pkgsel/include string openssh-server ntp linux-tools-$(uname -r) linux-cloud-tools-$(uname -r) linux-cloud-tools-common
d-i pkgsel/upgrade select none
d-i pkgsel/update-policy select none
d-i pkgsel/install-language-support boolean false

#
# Boot loader installation
#

d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
d-i grub-installer/bootdev  string /dev/sda

# grub-install –target=x86_64-efi –efi-directory=/boot/efi –no-nvram –removable

#
# *** Preseed other packages ***
#

d-i debconf debconf/frontend select Noninteractive
d-i finish-install/reboot_in_progress note

choose-mirror-bin mirror/http/proxy string

답변1

설정하면 d-i grub-installer/force-efi-extra-removable boolean trueGrub이 EFI/boot/bootx64.efi로 설치되지만 Grub은 Microsoft 키로 서명되지 않으므로 보안 부팅을 사용하는 경우 보안 부팅이 중단됩니다.

또 다른 접근 방식은 EFI/ubuntu에 설치된 Shim + Grub 설정을 복사하는 이것을 사용하는 것입니다.

d-i preseed/late_command string \
    mkdir -p /target/boot/efi/EFI/BOOT && \
    cp /target/boot/efi/EFI/ubuntu/* /target/boot/efi/EFI/BOOT && \
    cd /target/boot/efi/EFI/BOOT/ && mv shimx64.efi BOOTX64.EFI

편집: 참고 사항 /target대상 시스템의 파일 시스템따라서 이 경로는 미리 설정 파일의 디스크 섹션에 나타나지 않아야 합니다.

답변2

미리 설정 파일에 다음 줄을 추가하면 GRUB가 파티션에 UEFI 부트스트래퍼를 설치하게 됩니다 efi.

d-i grub-installer/force-efi-extra-removable boolean true

해당 줄을 추가하면 UEFI 부트스트래퍼가 가상 하드 드라이브에서 종료됩니다. 즉, 가상 머신 구성과 별도로 드라이브를 재사용할 수 있습니다.

관련 정보