5

My laptop has no CD-ROM. So I use YUMI to create a bootable USB stick, which seems not support UEFI.

I use legacy mode boot from USB and finish install ubuntu(Only one OS). Now I want to switch to UEFI mode. How to? The official doc says that use livecd from UEFI mode and use boot-repair. But I have no CD-ROM, and USB stick not support UEFI. I can't use this way.

I've already created esp and use GPT, but how to install grub UEFI in legacy mode, any way?

~$ sudo gdisk -l /dev/sda
GPT fdisk (gdisk) version 0.8.8

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/sda: 41943040 sectors, 20.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): E9A1D023-63F1-4014-A152-2C5741B77981
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 41943006
Partitions will be aligned on 2048-sector boundaries
Total free space is 4029 sectors (2.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         1026047   500.0 MiB   EF00  
   2         1026048        41940991   19.5 GiB    8300  

~$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda2 during installation
UUID=d2f2277b-478f-48af-96eb-cc0ee071d0fe /               xfs     defaults        0       1
# /boot/efi was on /dev/sda1 during installation
UUID=E432-31B3  /boot/efi       vfat    utf8,umask=007,gid=46 0       1
3
  • 1
    As far as I know you can not, you have to boot with UEFI enabled. 64 bit ubuntu is capable of booting with UEFI enabled, then install or run boot-repair.
    – Panther
    Commented Aug 11, 2015 at 2:19
  • Your fstab shows the mount of the efi partition. So you are in UEFI mode. Boot-Repair can convert if drive is gpt and your is, from CSM/BIOS to UEFI or from UEFI to CSM/BIOS. But for UEFI you must have the ESP - efi system partition which you have. Or for CSM you must have a 1 or 2MB unformated partition with the bios_grub flag (if using gparted). If using gdisk code is ef02.
    – oldfred
    Commented Aug 11, 2015 at 3:42
  • I'm not in UEFI mode. /boot/efi is manually mounted via ubuntu installer.
    – Feng Yu
    Commented Aug 11, 2015 at 4:25

6 Answers 6

5

First, one question is why you want to switch to EFI-mode booting. Based on your gdisk output, it looks like you've got a single-OS installation, so you don't seem to need to coexist with something else. If you can boot in BIOS/CSM/legacy mode already, why switch? As the saying goes, "if it ain't broke, don't fix it." (OTOH, I see no BIOS Boot Partition, so maybe you can't currently boot in BIOS mode....)

Supposing you have a reason to boot in EFI mode, though, let's start at the beginning....

YUMI is not the only tool for creating a bootable USB flash drive. You can also do it with dd, UNetbootin, Startup Disk Creator, Rufus, and other tools. All of the tools I've named are capable of creating an EFI-bootable USB flash drive, with the caveat that EFI implementations differ, so what works on one might not work on another. Some tools also have options that can affect how well a created disk will work, either in general or on a specific EFI. Thus, creating your installation disk with another tool should enable you to boot it in EFI mode (assuming, of course, that your computer uses an EFI rather than a traditional BIOS). That said, if you've already installed, re-creating your boot medium and re-installing is overkill....

If you have no other bootable OS on the computer, one solution is to install an EFI boot loader as EFI/BOOT/bootx64.efi on the EFI System Partition (ESP; your /dev/sda1). This is easily done if you're installing by hand, but if you're using a tool like grub-install, you'll have to move files around manually after the fact. Specifically, the EFI version of grub-install will put GRUB in EFI/ubuntu/grubx64.efi (perhaps with shimx64.efi in the same directory). You'll have to copy files to the right location to get them to launch when you boot the computer. If Secure Boot is inactive, copy EFI/ubuntu/grubx64.efi to EFI/BOOT/bootx64.efi. You might also need to copy EFI/ubuntu/grub.cfg to EFI/BOOT/grub.cfg, too. If Secure Boot is active, it gets more complex; you must copy shimx64.efi to EFI/BOOT/bootx64.efi and copy grubx64.efi to EFI/BOOT/grubx64.efi. (Note that all these filenames are relative to the ESP's root, so if you were to mount partitions as shown in your /etc/fstab, you must add /boot/efi/ to the start of each path.) With a boot loader installed to EFI/BOOT/bootx64.efi and nothing else referenced in the NVRAM entries, your computer should boot from that "fallback" filename.

Another option is to prepare an Ubuntu installer using one of the tools I mentioned earlier, then boot it in EFI mode. With that done, you should be able to run Boot Repair in EFI mode, so it should be able to set up GRUB in that mode. In fact, even in BIOS mode, Boot Repair should be able to copy EFI files as described in the previous paragraph. (I'm not sure how well this works in practice, though; Boot Repair might just try to do a BIOS-mode repair and not attempt to set up an EFI fallback boot loader.)

Yet another option is to use my rEFInd boot manager to get the process started. You can download the CD-R or USB flash drive version of rEFInd and boot from it. rEFInd should detect your Linux kernel(s) and enable you to boot. If this works, you'll be booted in EFI mode, and you can then install the rEFInd PPA or Debian package to use it permanently (without the USB drive); or you can install GRUB via grub-install and it should set things up correctly. (Note that you'll need the EFI GRUB package, grub-efi, installed for grub-install to set up the EFI version of GRUB.) Whether you install rEFInd or GRUB in this way, it will be able to set up an EFI NVRAM entry, since the boot from the rEFInd USB drive will be into EFI mode, thus enabling the OS to add EFI NVRAM variables.

2
  • Thanks, it's useful. And now I find an article about manually use grub to create a multi boot usb. I'm trying this way.
    – Feng Yu
    Commented Aug 11, 2015 at 13:15
  • One reason it might be useful is my Dell OptiPlex 9010: It can boot in UEFI or CSM mode, but not both. However, for some idiotic reason, it cannot boot USB devices in UEFI mode which means everything installs in CSM mode by default, even if that's less desirable.
    – knghtbrd
    Commented Mar 12, 2020 at 22:26
1

I recently had this problem, and the solution is quite simple.

First, install grub-efi. Next, run these commands to mount the UEFI manually:

sudo mkdir /boot/efi
sudo mount /dev/sda1 /boot/efi

Next, force grub to use EFI and install it to the newly created /boot/efi/ directory:

sudo grub-install --target=x86_64-efi /boot/efi

Verify that there is a grubx64.efi somewhere in /boot/efi/ (eg. /boot/efi/ubuntu/grubx64.efi). Now unmount sda1:

sudo umount /dev/sda1/

Reboot into Windows, and download/install a program called EasyUEFI and run it. You will see two buttons, click on the one that says "Manage EFI Boot Option". Next, click on the second from top button in the middle column (tooltip should say something like "Create new entry."). Select the grubx64.efi file, and change OS to "Linux/other". Finally, select the newly created entry and move it up using the up arrow button in the center column. Reboot to test results.

If it fails, switch back to legacy or manually select windows by selecting it in the Boot Order (it will appear as a separate device). You may also need to disable secure boot from UEFI settings.

Note: EasyUEFI is not necessary to do this, all actions can be executed by bcdedit in cmd. However, this is risky to do and EasyUEFI can prevent user error.

2
  • 1
    Did you read the question? There is only one OS there, and it is NOT windows. And even the first part of the answer has a problem: if ubuntu is loaded in legacy mode, you will have smth like "EFI variables are not supported on this system"
    – avtomaton
    Commented Aug 8, 2018 at 8:47
  • 1
    When I try that I see: root@DevOps:/# grub-install --target=x86_64-efi /boot/efi Installing for x86_64-efi platform. EFI variables are not supported on this system. EFI variables are not supported on this system. grub-install: error: efibootmgr failed to register the boot entry: No such file or directory. Commented Jul 14, 2019 at 8:28
0

Have you tried to install grub-efi (example at this link although the may text is focuses on UEFI+RAID)?

BTW, I'm confused about your real problem. Why to you want to switch to UEFI boot? And I thought that 'legacy boot' was equivalent to MBR boot, as opposed to UEFI/GPT boot.

1
  • Just for fun. And make test about UEFI.
    – Feng Yu
    Commented Aug 11, 2015 at 7:33
0

You can use mkusb to create live-only or persistent live USB boot drives from all current desktop iso files with Ubuntu and Ubuntu family flavours (Kubuntu, Lubuntu ... Xubuntu). mkusb can also create installer USB drives for Ubuntu Server and Ubuntu mini.iso.

64-bit Ubuntu (and Ubuntu family) iso files will be used such that the USB drives can boot in both UEFI and BIOS mode.

See this link and links from it,

help.ubuntu.com/community/mkusb

Edit: This works in legacy mode (alias BIOS mode). It will 'always' work when you make live-only drives with mkusb, because it clones from the iso file, and there is built-in capability to boot in both UEFI and BIOS mode in the iso files.

But there is another limitation: If you install mkusb into an installed system running in UEFI mode, you cannot install the program package grub-pc, which is needed in order to install the bootloader in BIOS mode. So a persistent live USB boot drive will only be able to boot in UEFI mode. You can work around this problem by using a [persistent] live system (install mkusb into a persistent live system), because in such systems the packages grub-efi and grub-pc can be installed alongside each other. You can get such systems by downloading and installing from compressed image files according to this link.

0

First off, you should use unetbootin while installing Ubuntu or any other OS both from a USB boot flash drive or a disk. To use unetbootin to install your OS in legacy mode, you should use your HDD as installation media in live boot mode. To do this, install unetbootin and change the extraction media from USB Drive to Hard Disk in the manner shown below.

unetbootin installation media change

the n install the Ubuntu ISO just as you would prepare a live disk for any other OS. After doing so, reboot and when you boot from your HDD, you will see the unetbootin boot menu instead of booting into your installed OS.

0

I created one possible answer here:

1) dd your iso on an USB stick. real world example:

dd of=/dev/sde if=/mnt/daten_ext3/iso/ubuntu-18.04-desktop-amd64.iso

Forget about the tremendously complicated ways to write the iso on an USB. Just dd it on your media. Simple as is. This is UNIX / linux.

2) Install without UEFI

How to avoid UEFI? Installation without UEFI? How to have Ubuntu 19 w/o UEFI?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .