5 March, 2021 by
| No comments yet

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

  • Ubuntu
    • dd_Ubuntu_16.04-gamma-UEFI-n-BIOS-12GB.img.xz

    • dd_Ubuntu_16.04-gamma-UEFI-n-BIOS-4-pendrive-12GB.img.xz

  • Mini system with text screen user interface

    • dd_text_16.04-UEFI-n-BIOS_2016-05-27_4-pendrive-7.8GB.img.xz

    • dd_text_16.04-UEFI-n-BIOS_2016-05-27_intel-4-pendrive-7.8GB.img.xz


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


  • 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.

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

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.



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).


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.

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.


Pendrive version

hostname: uefi-n-bios

In BIOS mode:


In UEFI mode:


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


Mini system with ‘text’ screen user interface

Text mode, main menu:

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


Font submenu:


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


Installer submenu:


Tasksel menu:

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


Tasksel menu example with selected items marked with asterisks:


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
Samsung SSD 850  sda                            232.9G
                 |-sda1 vfat   EFI   /boot/efi    300M
                 |-sda2                             1M
                 |-sda3 ext4   root  /            6.5G
                 `-sda4 swap         [SWAP]       512M

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

Login and password for the system to download

The systems that are installed from the compressed image files

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 from 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

Sign in to leave a comment