首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >自动安装支持EFI和Legacy引导

自动安装支持EFI和Legacy引导
EN

Ask Ubuntu用户
提问于 2022-11-03 14:03:45
回答 1查看 676关注 0票数 0

我正在尝试使用自动安装安装Ubuntu22.04。我生成的包含userdata.yml (主自动安装文件)的ISO有storage部分,应该同时支持EFI和Legacy引导,但是我找不到实现它的方法。

userdata.yml中只支持EFI引导的存储部分:

代码语言:javascript
复制
  storage:
    config:
    - ptable: gpt
      path: /dev/sda
      wipe: superblock-recursive
      preserve: false
      name: ''
      grub_device: false
      type: disk
      id: disk-sda
    - device: disk-sda
      size: 1127219200
      wipe: superblock
      flag: boot
      number: 1
      preserve: false
      grub_device: true
      type: partition
      id: partition-0
    - fstype: fat32
      volume: partition-0
      preserve: false
      type: format
      id: format-0
    - device: disk-sda
      size: 1073741824
      wipe: superblock
      flag: ''
      number: 2
      preserve: false
      grub_device: false
      type: partition
      id: partition-1
    - fstype: ext4
      volume: partition-1
      preserve: false
      type: format
      id: format-1
    - device: disk-sda
      size: 54760833024
      wipe: superblock
      flag: ''
      number: 3
      preserve: false
      grub_device: false
      type: partition
      id: partition-2
    - name: myvg
      devices:
      - partition-2
      preserve: false
      type: lvm_volgroup
      id: lvm_volgroup-0
    - name: slashlv
      volgroup: lvm_volgroup-0
      size: 53687091200B
      wipe: superblock
      preserve: false
      type: lvm_partition
      id: lvm_partition-0
    - fstype: ext4
      volume: lvm_partition-0
      preserve: false
      type: format
      id: format-2
    - path: /
      device: format-2
      type: mount
      id: mount-2
    - path: /boot
      device: format-1
      type: mount
      id: mount-1
    - path: /boot/efi
      device: format-0
      type: mount
      id: mount-0

userdata.yml中只支持遗产引导的存储部分:

代码语言:javascript
复制
  storage:
    config:
    - ptable: gpt
      path: /dev/sda
      wipe: superblock-recursive
      preserve: false
      name: ''
      grub_device: true
      type: disk
      id: disk-sda
    - device: disk-sda
      size: 1048576
      flag: bios_grub
      number: 1
      preserve: false
      grub_device: false
      type: partition
      id: partition-0
    - device: disk-sda
      size: 1073741824
      wipe: superblock
      flag: ''
      number: 2
      preserve: false
      grub_device: false
      type: partition
      id: partition-1
    - fstype: ext4
      volume: partition-1
      preserve: false
      type: format
      id: format-1
    - device: disk-sda
      size: 54760833024
      wipe: superblock
      flag: ''
      number: 3
      preserve: false
      grub_device: false
      type: partition
      id: partition-2
    - name: myvg
      devices:
      - partition-2
      preserve: false
      type: lvm_volgroup
      id: lvm_volgroup-0
    - name: slashlv
      volgroup: lvm_volgroup-0
      size: 53687091200B
      wipe: superblock
      preserve: false
      type: lvm_partition
      id: lvm_partition-0
    - fstype: ext4
      volume: lvm_partition-0
      preserve: false
      type: format
      id: format-2
    - path: /
      device: format-2
      type: mount
      id: mount-1
    - path: /boot
      device: format-1
      type: mount
      id: mount-0

当我试图用只支持遗留引导的userdata.yml安装EFI时,我失败了(相反)-

代码语言:javascript
复制
2022-11-03 09:48:37,448 ERROR root:39 finish: subiquity/Filesystem/apply_autoinstall_config: FAIL: autoinstall config did not create needed bootloader partition
2022-11-03 09:48:37,448 ERROR root:39 finish: subiquity/apply_autoinstall_config: FAIL: autoinstall config did not create needed bootloader partition

同样,我需要在同一个userdata.yml文件中同时支持EFI和Legacy引导。

谢谢!

EN

回答 1

Ask Ubuntu用户

发布于 2022-11-03 23:02:46

在官方上,您不能创建一个同时支持BIOS和UEFI的存储配置。grub_device设置不兼容。引用安装程序(子)开发人员之一的话

是的,可能吧。实际上,我想清理这整个区域,并使配置清理器(例如,它确实应该能够安装一个系统,它将启动遗留和UEFI),但看起来我不会在不久的时间内解决这个问题--…

作为一种解决方法,可以使用early-commands来使单个配置工作。下面是我使用过的一个示例user-data片段。它将根据/autoinstall.yaml文件的存在修改/sys/firmware/efi文件。

代码语言:javascript
复制
#cloud-config
autoinstall:
  storage:
    config:
    - type: disk
      match:
        size: largest
      ptable: gpt
      preserve: false
      name: ''
      grub_device: true
      id: disk-sda
    - type: partition
      device: disk-sda
      size: 4194304
      wipe: superblock
      flag: bios_grub
      number: 14
      preserve: false
      grub_device: false
      id: partition-14
    - type: partition
      device: disk-sda
      size: 111149056
      wipe: superblock
      flag: boot
      number: 15
      preserve: false
      grub_device: UEFI
      id: partition-15
    - type: partition
      device: disk-sda
      size: -1
      wipe: superblock
      number: 1
      preserve: false
      grub_device: false
      id: partition-1
    - type: format
      fstype: ext4
      volume: partition-1
      preserve: false
      id: format-1
    - type: mount
      path: /
      device: format-1
      id: mount-1
    - type: format
      fstype: fat32
      volume: partition-15
      preserve: false
      id: format-15
    - type: mount
      path: /boot/efi
      device: format-15
      id: mount-15
  early-commands:
    - |
      if [ -e "/sys/firmware/efi" ]; then
        sed -i -e "s/grub_device: UEFI/grub_device: true/" /autoinstall.yaml
      else
        sed -i -e "s/grub_device: UEFI/grub_device: false/" /autoinstall.yaml
      fi
      true

有了这个片段,所有设备都会以相同的分区布局结束,这可能会让人感到困惑。例如,基于BIOS的机器将仍然会有一个安装在/boot/efi上的不必要的ESP分区,而基于UEFI的机器将有一个不必要的bios_grub分区。

云图有一个分区布局,用作此配置的灵感。云映像支持BIOS和UEFI,我想复制它。得到的分区表如下所示,最后的分区填充磁盘。

代码语言:javascript
复制
Partition Table: gpt
Disk Flags:

Number  Start    End       Size      File system  Name  Flags
 1      1.00MiB  5.00MiB   4.00MiB                      bios_grub
 2      5.00MiB  111MiB    106MiB    fat32              boot, esp
 3      111MiB   20479MiB  20368MiB  ext4
票数 2
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1438902

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档