- How do I create an EFI-bootable ISO of a customized version of Ubuntu?
- UEFI
- Boot and install
- Test if running in UEFI mode
- Stable portable systems — good for USB sticks
- Persistent USB drive that works with UEFI and BIOS
- One pendrive for all PC (Intel/AMD) computers
- A new and so far successful attempt to create a stable portable system, that works in UEFI and BIOS mode
- Installed system: add an ESP to an existing installation with MBR
- Creating an EFI-only image
- Ubuntu single boot in UEFI mode
How do I create an EFI-bootable ISO of a customized version of Ubuntu?
You need to make a dual boot catalog ISO so that it will boot EFI and MBR. The standard Ubuntu 14.04 x64 ISO file works this way but there are no instructions available to make a new 14.04 bootable ISO for EFI systems. I was able to piece together the right steps to create an ISO like this.
These instructions will let you create a custom Ubuntu 14.04 Server ISO that can boot EFI and MBR. When EFI booting on a system with a blank, uninitialized disk (for example on a new Generation 2 VM in Hyper-V), setup will start automatically, then automatically wipe the disk and install the base ubuntu-server packages and OpenSSH. This is designed for automatically provisioning new systems with Ubuntu 14.04 using LVM and auto-partitioning. If you use this ISO on an existing Linux system then the installer will stop when it detects existing disks and wait for input. If you use this ISO on a non-EFI system (for example a Generation 1 Hyper-V VM) then it will wait at the graphical installer startup screen and require input before continuing to the auto installer.
The result is a base Ubuntu Server installation with ubuntu-server and openssh-server only.
Here are the steps to create an EFI-bootable ISO:
wget http://releases.ubuntu.com/14.04/ubuntu-14.04-server-amd64.iso
Mount it and extract its contents to a new folder:
sudo mkdir -p ~/iso sudo mount -o loop ubuntu-14.04-server-amd64.iso.iso ~/iso sudo mkdir ~/ubuntu sudo cp -rT ~/iso ~/ubuntu
Change into the directory where we will be doing our work:
Set the language to English:
sudo -i echo en >/home/user/ubuntu/isolinux/lang exit
Create a preseed file that will use LVM to auto-partition the disk using all available space:
sudo nano ~/ubuntu/ks.preseed
Replace the file contents with this:
d-i partman-auto/method string lvm d-i partman-auto-lvm/guided_size string max d-i partman-auto/choose_recipe select atomic d-i partman-partitioning/confirm_write_new_label boolean true d-i partman/confirm_write_new_label boolean true d-i partman/choose_partition select finish d-i partman/confirm_nooverwrite boolean true d-i partman/confirm boolean true d-i partman-auto/purge_lvm_from_device boolean true d-i partman-lvm/device_remove_lvm boolean true d-i partman-lvm/confirm boolean true d-i partman-lvm/confirm_nooverwrite boolean true d-i partman-auto/init_automatically_partition select Guided - use entire disk and set up LVM d-i partman/choose_partition select Finish partitioning and write changes to disk d-i partman-auto-lvm/no_boot boolean true d-i partman-md/device_remove_md boolean true d-i partman-md/confirm boolean true d-i partman-md/confirm_nooverwrite boolean true
Create a kickstart file that will configure Ubuntu during the installation: (make sure you change the username part, and you should use encrypted passwords)
Replace the file contents with this:
lang en_US langsupport en_US keyboard us mouse timezone America/Los_Angeles rootpw --disabled user USERNAME --fullname "USERNAME" --password "PASSWORD" reboot text install cdrom auth --useshadow --enablemd5 network --bootproto=dhcp --device=eth0 firewall --disabled skipx %packages @ ubuntu-server openssh-server
Edit the grub configuration file so when the ISO performs an EFI boot the bootloader uses the right options to use our preseed and configuration files:
sudo nano ~/ubuntu/boot/grub/grub.cfg
Replace the file contents with this:
if loadfont /boot/grub/font.pf2 ; then set gfxmode=auto insmod efi_gop insmod efi_uga insmod gfxterm terminal_output gfxterm fi set menu_color_normal=white/light-blue set menu_color_highlight=light-blue/light-gray set timeout=10 set default=0 menuentry "Automatically Install Ubuntu Server with Custom Config" < set gfxpayload=keep linux /install/vmlinuz file=/cdrom/preseed/ubuntu-server.seed quiet ks=cdrom:/ks.cfg preseed/file=/cdrom/ks.preseed -- initrd /install/initrd.gz >menuentry "OEM install (for manufacturers)" < set gfxpayload=keep linux /install/vmlinuz file=/cdrom/preseed/ubuntu-server.seed quiet oem-config/enable=true -- initrd /install/initrd.gz >menuentry "Multiple server install with MAAS" < set gfxpayload=keep linux /install/vmlinuz modules=maas-enlist-udeb vga=788 initrd=/install/initrd.gz quiet -- initrd /install/initrd.gz >menuentry "Check disc for defects" < set gfxpayload=keep linux /install/vmlinuz MENU=/bin/cdrom-checker-menu quiet -- initrd /install/initrd.gz >menuentry "Rescue a broken system" < set gfxpayload=keep linux /install/vmlinuz rescue/enable=true -- initrd /install/initrd.gz >
Edit the isolinux boot menu for non-EFI booting (MBR booting) to use the custom config and custom preseed:
sudo nano ~/ubuntu/isolinux/txt.cfg
Replace the file contents with this:
default install label install menu label ^Install Ubuntu Server with Custom Config kernel /install/vmlinuz append file=/cdrom/preseed/ubuntu-server.seed initrd=/install/initrd.gz ks=cdrom:/ks.cfg preseed/file=/cdrom/ks.preseed -- label cloud menu label ^Multiple server install with MAAS kernel /install/vmlinuz append modules=maas-enlist-udeb vga=788 initrd=/install/initrd.gz quiet -- label check menu label ^Check disc for defects kernel /install/vmlinuz append MENU=/bin/cdrom-checker-menu vga=788 initrd=/install/initrd.gz quiet -- label memtest menu label Test ^memory kernel /install/mt86plus label hd menu label ^Boot from first hard disk localboot 0x80
This command is a modified version of the command shown at http://petersmithphotog.no-ip.biz/wiki/index.php/Unattended_Install. Those instructions do not work for Ubuntu 14.04 because they point to the wrong locations for the file efi.img. (should be in ./boot/grub/ on the ISO)
sudo mkisofs -U -A "Custom1404" -V "Custom1404" -volset "Custom1404" -J -joliet-long -r -v -T -o ../Custom1404.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -e boot/grub/efi.img -no-emul-boot .
Verify the ISO has the correct style boot catalogs:
The original ISO you downloaded from Ubuntu:
dumpet -i ~/ubuntu-14.04-server-amd64.iso
Validation Entry: Header Indicator: 0x01 (Validation Entry) PlatformId: 0x00 (80x86) ID: "" Checksum: 0x55aa Key bytes: 0x55aa Boot Catalog Default Entry: Entry is bootable Boot Media emulation type: no emulation Media load segment: 0x0 (0000:7c00) System type: 0 (0x00) Load Sectors: 4 (0x0004) Load LBA: 8446 (0x000020fe) Section Header Entry: Header Indicator: 0x91 (Final Section Header Entry) PlatformId: 0xef (EFI) Section Entries: 1 ID: "" Boot Catalog Section Entry: Entry is bootable Boot Media emulation type: no emulation Media load address: 0 (0x0000) System type: 0 (0x00) Load Sectors: 4672 (0x1240) Load LBA: 24754 (0x000060b2)
Validation Entry: Header Indicator: 0x01 (Validation Entry) PlatformId: 0x00 (80x86) ID: "" Checksum: 0x55aa Key bytes: 0x55aa Boot Catalog Default Entry: Entry is bootable Boot Media emulation type: no emulation Media load segment: 0x0 (0000:7c00) System type: 0 (0x00) Load Sectors: 4 (0x0004) Load LBA: 3100 (0x00000c1c) Section Header Entry: Header Indicator: 0x91 (Final Section Header Entry) PlatformId: 0xef (EFI) Section Entries: 1 ID: "" Boot Catalog Section Entry: Entry is bootable Boot Media emulation type: no emulation Media load address: 0 (0x0000) System type: 0 (0x00) Load Sectors: 4672 (0x1240) Load LBA: 1932 (0x0000078c)
You can compare this output to the output you get from an ISO constructed using the instructions at How do I create a completely unattended install of Ubuntu?: (they create an MBR only ISO, not an dual boot catalog ISO)
sudo mkisofs -D -r -V "non-efi-ubuntu" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ../non-efi-ubuntu.iso .
Validation Entry: Header Indicator: 0x01 (Validation Entry) PlatformId: 0x00 (80x86) ID: "" Checksum: 0x55aa Key bytes: 0x55aa Boot Catalog Default Entry: Entry is bootable Boot Media emulation type: no emulation Media load segment: 0x0 (0000:7c00) System type: 0 (0x00) Load Sectors: 4 (0x0004) Load LBA: 1925 (0x00000785)
UEFI
There is a good wiki page about booting with UEFI, and a good tutorial thread, UEFI Installing — Tips.
Boot and install
If you want to boot in UEFI mode and install your Ubuntu flavour alongside Windows, you should use a 64-bit ISO file, for example
ubuntu-18.04.x-desktop-amd64.iso
Make the boot drive with for example mkusb, Disks, the new Ubuntu Startup Disk Creator (version 0.3.2) or the Win32 Disk Imager. These tools clone the iso file and are likely to succeed. Some ‘grub and ISO’ systems work in UEFI mode, others work only in BIOS mode. Syslinux does not work in UEFI mode.
If you have problems, try another tool to create the USB boot drive. You can also try the simple extraction described in this link. It works [only] in UEFI mode.
Test if running in UEFI mode
You may want to test if your Ubuntu flavour is running in [U]EFI mode. An installed system and a live system too is using the directory /sys/firmware/efi, so you can run the following command line,
test -d /sys/firmware/efi && echo efi || echo bios
The following command line is more robust and also easier to understand, so you may prefer it (if you copy & paste and are not bothered by typing a long command line),
if test -d /sys/firmware/efi; then echo efi; else echo bios; fi
Stable portable systems — good for USB sticks
Persistent USB drive that works with UEFI and BIOS
A persistent USB install of *buntu, usable with both Legacy and UEFI systems is described in the following post at the Ubuntu Forums
One pendrive for all PC (Intel/AMD) computers
You may want a ‘Swiss Army Knife’ pendrive, that works in most computers, from old 32-bit computers via 64-bit computers in BIOS mode to computers running in UEFI mode. It is useful for travelling and borrowing computers or for installing. There is a compressed image file and also a recipe how to make it, so that you can extend it or change it for what you need. See this tutorial about One pendrive for all (Intel/AMD) PC computers.
A new and so far successful attempt to create a stable portable system, that works in UEFI and BIOS mode
Installed system: add an ESP to an existing installation with MBR
Adding required partitions for different platforms
Platforms: Legacy PC, UEFI-based Windows computer, Apple computer
Creating an EFI-only image
If you need to install Ubuntu in EFI-only mode, you might want to create an EFI only image. Askubuntu describes how to do this.
Ubuntu single boot in UEFI mode
- to keep the systems separated, Ubuntu in one drive and Windows in another drive (so it will actually be a dual boot system, but not during the installation). Probably stable when installed in an internal drive.
- to make a portable installed Ubuntu USB pendrive for UEFI mode (portable alias works in many computers). Not stable when installed in an external drive (USB stick) because Windows can tamper with it, particularly during major updates [of Windows].
It is straight-forward to install Ubuntu 16.04.1 LTS (64-bit), ubuntu-16.04.1-desktop-amd64.iso in UEFI mode to the whole drive, when no other drive is connected in the computer.
This installation works without any tweaks. You need not run Boot Repair to make it work in UEFI mode, so version 16.04.1 LTS and newer versions work well with UEFI.
See this link with detailed instructions.
Installation/FromUSBStick/uefi (последним исправлял пользователь nio-wiklund 2020-01-24 08:34:22)
The material on this wiki is available under a free license, see Copyright / License for details
You can contribute to this wiki, see Wiki Guide for details