Can I erase all partitions including EFI and install only Ubuntu?
The question uses some terminology incorrectly, which can lead to confusion and problems down the road, so I want to address these issues first.
The Extensible Firmware Interface (EFI), or its 2.x version, the Unified EFI (UEFI), is a type of firmware. The EFI is not a partition. That said, there is a partition called the EFI System Partition (ESP), which holds boot loaders. Chances are that lapisdecor meant "ESP" rather than "EFI" in the original question.
Also, the EFI is a type of firmware that replaces the older Basic Input/Output System (BIOS). As such, if your computer uses an EFI, it does not have a BIOS. There are, however, some caveats and exceptions. Most commonly, EFIs provide a feature called the Compatibility Support Module (CSM), which is a sort of BIOS emulator; the CSM is to EFI like what dosemu
is to Linux, in that it enables a newer and more sophisticated environment (EFI or Linux) to run programs designed for an older and simpler system (BIOS or DOS). In other words, "BIOS" in the original question should be "EFI." That said, using "BIOS" in place of "EFI" is a common practice. It's a bad one, but it's common, both among users and among manufacturers. I suspect it's done because people know (more or less) what a BIOS is, whereas "EFI" is an unfamiliar acronym; and since EFI replaces BIOS, using "BIOS" makes the job easier for copywriters. The trouble is that people then drag all their BIOS knowledge up when they read "BIOS," but much of it is inapplicable. EFI boots in a very different way from BIOS, so if you think of EFI as being an enhanced BIOS, you'll have a mental model that's very wrong and you'll make mistakes. Then people like me end up spending a lot of time explaining how it all actually works -- but I digress....
Moving on to real issues: If you're "in legacy mode," that just means that your CSM is active. This does not guarantee a boot in BIOS/CSM/legacy mode, though. On most EFI-based computers, when the CSM is disabled, the boot path is relatively simple; you can boot only EFI-mode boot loaders. Note that you can't "disable the EFI"; the EFI is the firmware, and it's in charge of the computer. Some computers do enable you to disable the ability to boot in EFI mode, but such options are rare -- and some computers provide interfaces that make it sound as if you're disabling EFI-mode booting, but you really aren't. When you activate the CSM, most computers enable either type of boot loader to run, which makes it impossible to predict what will happen when you feed the computer a disk that provides both types of boot loader. This isn't normally a big deal for a single-boot computer; when you install the OS, the installer will detect its boot mode and install the boot loader only for the installer's boot mode, so the computer can boot from the hard disk only in that same mode. If you multi-boot, though, you can easily install one OS in one boot mode and the other OS in the other boot mode. The hair-pulling begins at this point.
In the not-too-distant past, EFI-mode booting was an exercise in frustration because of bugs in EFIs, bugs in boot loaders, and misinformation, which often made enabling the CSM appealing. Today, though, EFI-mode booting poses fewer problems, and my estimate from questions posted here and elsewhere is that the biggest single problem area today is from activated CSMs. Thus, I recommend that the CSM (aka "legacy boot") be disabled on EFI-based computers unless you have a good reason to enable it. To be sure, EFI-mode booting today poses more challenges than BIOS-mode booting did five years ago; but on an EFI-based computer, BIOS-mode booting creates pitfalls that didn't exist five years ago.
So, that long-winded stuff out of the way, let's get back to your original question, re-phrased slightly:
Can I erase all partitions on my computer, including ESP, and install only Ubuntu? Will the EFI work in this case?
Yes and yes.
After you erase your partitions, the Ubuntu installer will create new ones if you select an automatic partitioning option. If you partition manually, you'll need to create appropriate partitions. These may include an ESP if you install in EFI mode or a BIOS Boot Partition if you install to a GPT disk in BIOS mode.
One important caveat is that it's best to use GPT when installing in EFI mode and MBR when installing in BIOS mode. Ubuntu permits using GPT in BIOS mode, but this can create problems on some systems, so I recommend avoiding it if possible. Some people have managed to install to MBR disks in EFI mode, too, but the installer tries to avoid this if possible; and when it's done, it often creates problems.
In Ubuntu, you can determine your boot mode by looking for a directory called /sys/firmware/efi
. If it's present, you've booted in EFI mode; if it's absent, you've booted in BIOS mode.
In sum, you should be aware of your boot mode (BIOS/CSM/legacy or EFI/UEFI) and your partition table type (MBR or GPT), and ideally you should match the two appropriately (BIOS/MBR or EFI/GPT).
Yes, when you completely erase the disk, you can install ubuntu as the single operating system.
When you can disable UEFI in BIOS (mostly you can) you even can install ubuntu in mbr mode.
Boot from ubuntu install media, open GParted and create a new partition table - choose mbr.
In case you can not disable UEFI and/or secure boot you as well can install ubuntu in EFI mode.
Then the installer will create a new EFI partition where the GRUB boot loader will be installed.
You question is not completely clear to me.
If you want to install Ubuntu in UEFI mode here is what you need to do :
You will need to set your BIOS in UEFI mode and to create an UEFI bootable Ubuntu USB key.
Follow this guide to create a UEFI bootable USB. Then simply run the Ubuntu installer ; at step Installation Type, select Something Else and partition your disk as explained in this answer.
If boot mode (UEFI or Legacy) does not matter for you simply install Ubuntu as usual. (Refer to this guide if needed)