Return to the main UEFI-and-BIOS page


Easy way to get installed Ubuntu 20.04 LTS that boots in UEFI and BIOS

This is an update, basically using the method described below, but making things a bit easier.

Template file

There is a compressed image file, that can be used to set up the boot structure to boot in both UEFI and BIOS mode. It is easy to extract and clone to a USB pendrive or other drive (SSD or HDD), and after that it can be used directly to boot into an iso file, and indirectly (after some tweaks) into an installed system.

Compressed image file (2.6 MB) - dd_grub-boot-template-for-uefi-n-bios.img.xz

Check with the md5sum in md5sum.txt.asc

Method

I will describe the method that I used to create the system in the compressed image file

dd_unb_ubuntu-20.04_15GB_2020-06-26.img.xz

This file will not be used here. (But if you want to make it easy, you can download and check it with the md5sum in md5sum.txt.asc. Then extract, clone and fix the system directly.)

  • From the template file you extract, clone and fix a boot system in the target drive. It is easy, (one simgle step) with mkusb, but you can perform each step with other tools in Linux or Windows.

    • There is an alternative to create a grub-n-iso drive described at .../isoboot, but here we use this template for an installed system, that will be portable if installed in an external drive.

  • It helps to get things correct if you unplug, disconnect or otherwise disable the internal drive.
  • Boot in BIOS mode into the Ubuntu 20.04 LTS live system because it will be easier to control where to put the bootloader.
  • Use gparted to create an ext4 partition (and it will be partition #1 although it will be at the tail end of the drive.
  • Start the installer and select 'Something else' at the partitioning window.
  • Select the target drive and the first partition /dev/sdx1 as for the root file system, /

  • Select the same first partition /dev/sdx1 for the bootloader, in other words as PBR (not MBR), so that it will not interfere with the boot system already set up in the template.
  • Finish the installation.
  • Now you could copy the grub.cfg of the root file system to overwrite that of the usbboot partition (partition #3) and it would work at least in the beginning. But when the installed system is upgraded with new kernels you will have to copy grub.cfg from the root file system to overwrite that of the usbboot partition again.
    • A useful thing to do in the menuentries is to point to the links in the root partition for vmlinuz and initrd to make the boot system independent of upgrades of the kernel, because they have the same name but will be upgraded and point to the two most current kernels.

  • Instead I saved 'backup' copies of the two grub.cfg files and made a hybrid version in the active location in the usbboot partition (partition #3). The head and tail of the file is from the isoboot version and the middle with menuentries from Ubuntu root. I have modified the menuentries to use the links for vmlinuz and initrd to make it independent of upgrades of the kernel.

  • Other useful tweaks are described separately at #Tweak_the_system

The future will show if this boot system can resist upgrades of Windows and Ubuntu.

So, if there are problems, please send a mail to: nio dot wiklund at gmail dot com.

Simple and stable portable system for UEFI and BIOS

Current system, seems very stable so far

The current system contains an installed system, and both work in UEFI and BIOS mode. The compressed image files

  • Standard Ubuntu
    • dd_Ubuntu_16.04-gamma-UEFI-n-BIOS-12GB.img.xz (old)
    • dd_Ubuntu_16.04-gamma-UEFI-n-BIOS-4-pendrive-12GB.img.xz
    • dd_Ubuntu_16.04.1_2017-01-17_UEFI-n-BIOS-12GB.img.xz (961MiB)
  • Mini system with text screen user interface

    • dd_text_16.04-UEFI-n-BIOS_2017-01-15_intel-4-pendrive-7.8GB.img.xz
    • dd_text_16.04-UEFI-n-BIOS_2017-05-07_intel-4-pendrive-7.8GB.img.xz (349MiB)
  • Light-weight desktop LXDE and mkusb-dus pre-installed
    • dd_dus-lxde_16.04-UEFI-n-BIOS_2017-05-07_intel-4-pendrive-7.8GB.img.xz (544 MiB)

were created according to the following description (written from memory, I may have forgotten some detail).

Origins

  • The Ubuntu image files were made starting from an Ubuntu Xenial 64-bit daily iso file (shortly before the release, more than beta, 'gamma').
  • The image file of the mini system with text screen was made starting from the Ubuntu Server 16.04 64-bit iso file. A minimal system was created as a starting point for any of the Ubuntu flavours including Ubuntu Server.
  • The image file with light-weight desktop LXDE and mkusb-dus pre-installed was made from the from the Ubuntu Server 16.04 64-bit iso file via the the mini system with text screen.

Remove or replace the internal drive of the computer you intend to use

This is because it wants to use /dev/sda for the EFI partition.

Boot into the live system

Boot into the live system, but if the target is also a USB pendrive, plug it in before continuing from the grub menu.

Install this Ubuntu system into a drive with at least 16 GB (pendrive, other external drive, or internal drive). Install this text system into a drive with at least 8 GB. If you install to a pendrive it should be a fast pendrive.

Create a partition table

Create a partition table with mkusb/wipe using mkusb-11 'classic mode',

Advanced: create GUID partition table (skeleton for installing an OS)

After that, use gparted to get a partition table with partitions for EFI, root and swap.

09-gparted.png

Install

Boot into Ubuntu live alias 'Try Ubuntu' from an amd64 iso file in UEFI mode. (It might work in BIOS mode, but I did not try that.)

Start the installer. At the partitioning window, select Something else and install into the root partition 3 and swap partition 4.

Create boot-loading systems for external drives

While running the live system in UEFI mode

sudo mkdir /mnt/efi
sudo mount /dev/sdx1 /mnt/efi
sudo mkdir /mnt/root
sudo mount /dev/sdx3 /mnt/root
sudo grub-install --force --removable --no-floppy \
 --boot-directory=/mnt/root/boot --efi-directory=/mnt/efi /dev/sdx

It is best if you manage to make the computer see the target drive as /dev/sda (that x is a).

Reboot the live system into BIOS mode, install grub-pc and install the bootloader for BIOS mode

sudo apt-get install grub-pc
sudo mkdir /mnt/root
sudo mount /dev/sdx3 /mnt/root
sudo grub-install --force --removable --no-floppy --boot-directory=/mnt/root/boot /dev/sdx

If some minor detail goes wrong, you may need to repeat the installation of the bootloaders (trial and error).

gpt-fix

If you clone the compressed iso files, you need to fix the GUID partition table, GPT, because in most cases you clone to another drive size, and GPT is sensitive to that (which is different from the old MSDOS partition table). I made a shellscript file, gpt-fix, that does the work for you. It works for the cases that I have tested. gpt-fix uses gdisk under the hood, and you may need to install it. Run gpt-fix in the directory, where you downloaded it (or install it into a directory in $PATH).

sudo apt-get install gdisk  # install if necessary

sudo bash gpt-fix /dev/sdx  # in the directory, where you downloaded gpt-fix

where x is the drive letter.

Alternate link: gpt-fix

Comments and screenshots

The method described above seems to create a stable system when used in a USB pendrive and also in an SSD connected via eSATA and USB. It is tested in three different laptops, a Toshiba Satellite and an HP Elitebook and a Lenovo X131e and in an ultra-small desktop computer, Intel NUC 6i3SYH, and it has survived such adventures in UEFI and BIOS mode.

It might or might not work to flash the pendrive image directly from a compressed image file to an SSD or HDD drive depending on the sector sizes. The sector size according to parted, 512b/512b, is shown in screenshot #2, in the output from parted.

Ubuntu

Screenshot of 'Ubuntu 20.04 LTS - installed'

../25-dd_unb_ubuntu-20.04_15GB_2020-06-26.png

Pendrive version

hostname: uefi-n-bios

In BIOS mode:

11-booted-in-bios-mode.png

In UEFI mode:

10-dd_Ubuntu_16.04-gamma-UEFI-n-BIOS-4-pendrive-12GB.png

In the HP computer it boots via eSATA, where it also works when installed according to the description above. It is possible to boot from USB via chainloading. (This HP computer does not want to boot directly from USB if there is a GPT partition table).

HDD/SSD version

hostname: UEFI-n-BIOS

12-dd_Ubuntu_16.04-gamma-UEFI-n-BIOS-4-HDD-SSD-12GB.png

Mini system with 'text' screen user interface

Text mode, main menu:

When Fluxbox is installed, it can be started from here.

13-text-mode-menu-64.png

Font submenu:

15-font-submenu-64.png

Prompt to update and dist-upgrade the system before installing meta-packages:

16-prompt-to-update.png

Installer submenu:

17-installer-submenu-with-tasksel-64.png

Tasksel menu:

Move the cursor with the arrow keys and select (the item at the cursor) with the space bar.

18-tasksel-menu.png

Tasksel menu example with selected items marked with asterisks:

18-tasksel-menu-selected.png

These screenshots of the text menus are no real screenshots from the console. They were actually made after installing openssh-server and logging in remotely, they are screenshots from 'xterm -fa default -fs 13'.

The partitions and file systems are listed by parted and lsblk in the following code block:

guru@uefi-n-bios:~$ sudo parted /dev/sda print
[sudo] password for guru: 
Model: ATA Samsung SSD 850 (scsi)
Disk /dev/sda: 250GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system     Name  Flags
 1      1049kB  316MB   315MB   fat32                 boot, esp
 2      316MB   317MB   1049kB                        bios_grub
 3      317MB   7262MB  6946MB  ext2            root
 4      7262MB  7799MB  537MB   linux-swap(v1)

[1]+  Done                    xterm -fa default -fs 13
guru@uefi-n-bios:~$ lsblk -o MODEL,NAME,FSTYPE,LABEL,MOUNTPOINT,SIZE /dev/sda
MODEL            NAME   FSTYPE LABEL MOUNTPOINT   SIZE
Samsung SSD 850  sda                            232.9G
                 |-sda1 vfat   EFI   /boot/efi    300M
                 |-sda2                             1M
                 |-sda3 ext4   root  /            6.5G
                 `-sda4 swap         [SWAP]       512M
guru@uefi-n-bios:~$ 


Tweak the system

Decrease wear for a pendrive

Add the mount option noatime in /etc/fstab

# / was on /dev/sdb3 during installation
UUID=4c518694-d97c-4910-bb7b-eeb6a6b73874  /  ext4  noatime,errors=remount-ro 0  1

Do not copy this line. Add noatime to your own line.

Maybe remove swap

It is also possible to remove the swap partition and the swap entry in /etc/fstab in order to avoid wear due to swapping.

Remove journaling

sudo tune2fs -O ^has_journal /dev/sdxy

where x is the drive letter and y is the partition number of the root partition, in my case /dev/sda3

Move swap and grow root partition

Move the swap partition and grow the root partition to use the whole drive. See this link

http://phillw.net/isos/linux-tools/uefi-n-bios/GrowIt.pdf

Login and password for the system to download

The systems in the compressed image files described at ../#Installation_from_a_compressed_image_file have the following user and password

user:     guru
password: changeme


Install from compressed image file

Remember to check with md5sum, that the download of the compressed image file was successful.

It is straight-forward to install from a compressed image file with mkusb or mkusb-nox.

After this cloning operation you should run gpt-fix in order to match the gpt data to the current drive size (unless you are running mkusb version 10.6.6 or newer versions of mkusb, where gpt_zap and gpt_fix are built-in).

See the detailed description at this link: ../#Installation_from_a_compressed_image_file


Return to the main UEFI-and-BIOS page

Installation/UEFI-and-BIOS/stable-alternative (last edited 2020-06-27 11:48:49 by nio-wiklund)