Return to the main iso2usb page


Instructions to make a boot drive, that boots both in UEFI and BIOS mode

Cloning - read-only drive

If you are happy with a read-only partition table and file system, you can clone the Ubuntu and Ubuntu community flavour iso files. This is very reliable but you cannot store data on the drive, and you cannot make it a persistent live drive (unless you start again for example with mkusb). Return if this is what you want.

Do it yourself - with the isoboot alias grub-n-iso method

This method is designed to work with

  • Ubuntu: 64-bit Ubuntu desktop and Ubuntu community flavour desktop iso files:

    • It is rather easy to create a separate (USB) boot drive using ISO boot alias grub-n-iso from a template. This can be used
      • directly with or without persistence, 'basic method', but also
      • to create a multiboot drive for example as a demo drive with all Ubuntu family flavours, or
      • to create an installed system, that can boot both in UEFI and BIOS mode (alias CSM alias legacy mode).
    • The 'basic method' is described here (in this Ubuntu help page).
  • Other linux distros and versions: This method may or may not work in UEFI and/or BIOS mode depending on the boot structure. It helps if it is very similar to Ubuntu's boot structure.

  • You will probably have better luck with cloning, the extracting method at this link: ../diy, or with mkusb for non-Ubuntu distros.

Do it yourself - instructions

Download a compressed image file

Partition table and boot structure from an image file

A compressed image file can be extracted and flashed to the target drive in order to get partition table and the boot structure necessary for booting via grub in BIOS mode. This works also when you are running an installed system booted in UEFI mode, when there are problems to install 'grub-pc' and run 'grub-install' in order to install the bootloader (for BIOS mode).

Do also this step manually

Otherwise, in BIOS mode and running a live system, it is possible to create the boot structure for BIOS mode with a FAT32 partition and extract from the iso file into it and install the bootloader.

sudo grub-install

So if you want to do also this step yourself, boot in BIOS mode and create it. You may need to add some flags to the FAT32 partition to make a computer want to boot into it also in UEFI mode.

The structure created, when you use the compressed image file can be used to check what you need in order to get a system that works in both boot modes. (This is easiest, if you have two USB pendrives, one where you do it yourself, and one with the extracted partition table and boot structure.)

Download the image file and a checksum file

In Ubuntu:

Download this compressed image file: dd_grub-boot-template-for-uefi-n-bios.img.xz

Check that the md5sum is correct with the following file: md5sum.txt.asc

In some cases, for example if you have a small USB drive and/or if you do not use mkusb, the following new file should work better:

Download this compressed image file: dd_grub-boot-template-for-uefi-n-bios_new.img.xz

Check that the md5sum is correct with the following file: grub-boot-templates-for-uefi-n-bios.md5.asc

In Windows:

If you are working in Windows, the following file should work with 7-zip and Rufus:

Download this compressed image file: mkusb_grub-boot-template-for-uefi-n-bios_fat32_4GB_use-in-wins.img.xz

Check that the md5sum is correct with the following file: grub-boot-templates-for-uefi-n-bios.md5.asc

If you have an old [for example HP] computer, that wants an MSDOS partition table to boot grub via USB

Download this compressed image file: dd_grub-boot-template-for-uefi-n-bios_msdos.img.xz

Check that the md5sum is correct with the following file: grub-boot-templates-for-uefi-n-bios.md5.asc


You may want a higher level of security. This file is signed with gpg and you can verify it according to the following commands.

gpg --keyserver keyserver.ubuntu.com --recv-keys EB0FC2C8
gpg --verify md5sum.txt.asc

The warning "was NOT verified" means that there is no chain of trusted keys between your computer's keyring and the key, that was used to sign the checksums (the key of sudodus). Check that the result matches with the following output, when you verify it,

tester@xenial32 ~ $ gpg --keyserver keyserver.ubuntu.com --recv-keys EB0FC2C8
gpg: directory `/home/tester/.gnupg' created
gpg: new configuration file `/home/tester/.gnupg/gpg.conf' created
gpg: WARNING: options in `/home/tester/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/home/tester/.gnupg/secring.gpg' created
gpg: keyring `/home/tester/.gnupg/pubring.gpg' created
gpg: requesting key EB0FC2C8 from hkp server keyserver.ubuntu.com
gpg: /home/tester/.gnupg/trustdb.gpg: trustdb created
gpg: key EB0FC2C8: public key "Nio Sudden Wiklund (sudodus) <address@mailserver.com>" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)

tester@xenial32 ~ $ gpg --verify md5sum.txt.asc
gpg: Signature made mån 18 sep 2017 21:48:47 CEST using RSA key ID EB0FC2C8
gpg: Good signature from "Nio Sudden Wiklund (sudodus) <nio.wiklund@gmail.com>"
gpg: WARNING: not a detached signature; file 'grub-do-it-yourself.img.xz.md5' was NOT verified!
tester@xenial32 ~ $ 

Then there is reason to trust that nobody else has written the checksums. The date of the signature will change at updates, and the text might be translated to your local language, but it should be clear that it is a 'Good signature from "Nio Sudden Wiklund (sudodus)"'.

If you have the compressed image file and the md5sum file in the same directory, you can use the md5sum program to check like this,

md5sum -c md5sum.txt.asc

The 'improperly formatted lines' are the lines belonging to the gpg signature.

Or with a clean output (selecting only the checksum test for this particular file)

$ grep dd_grub-boot-template-for-uefi-n-bios.img.xz md5sum.txt.asc | md5sum -c
dd_grub-boot-template-for-uefi-n-bios.img.xz: OK

or if you prefer (selecting the only good output)

$ md5sum -c md5sum.txt.asc 2> /dev/null|grep OK
dd_grub-boot-template-for-uefi-n-bios.img.xz: OK

Dark or bright background in grub

The default grub theme has a dark grey background with a faint watermark (mkusb logo). There is also a bright grub theme with 'sky blue' and the mkusb logo, that you get if you download this compressed image file:

dd_grub-boot-template-for-uefi-n-bios_bright-bg.img.xz

Check that the md5sum is correct with the following file: md5sum.txt.asc

$ grep dd_grub-boot-template-for-uefi-n-bios_bright-bg.img.xz md5sum.txt.asc | md5sum -c
dd_grub-boot-template-for-uefi-n-bios_bright-bg.img.xz: OK

Download the iso file

Download the iso file

64-bit Ubuntu desktop or Ubuntu community flavour desktop iso file

http://releases.ubuntu.com or for the community flavours http://cdimage.ubuntu.com

If the iso files of the version with the longest remaining support are not found via those links, you can find them via the following general link,

http://old-releases.ubuntu.com

or

64-bit Debian live iso file

You find current Debian iso files via www.debian.org/CD/live/

Check with md5sum that the iso file was downloaded correctly

Check the md5sum result with the uploaded values via this link: UbuntuHashes

Examples:

md5sum ubuntu-18.04.1-desktop-amd64.iso

md5sum ubuntu-20.04-desktop-amd64.iso

Install mkusb if you want to clone safely and easily (optional)

https://help.ubuntu.com/community/mkusb

Clone 'dd_grub-boot-template-for-uefi-n-bios.img.xz' to the target drive

Normally you would clone dd_grub-boot-template-for-uefi-n-bios.img.xz to a USB pendrive or memory card, minimum size 4GB. The image extracts to a boot partition with 258 MB (247 MiB). The head end of the drive contains a grub bootloader for BIOS mode. There are files for the UEFI bootloader and BIOS bootloader in this boot partition. The intention is that you add partitions manually (easy with gparted).

Use mkusb or Disks

Use mkusb or Disks to clone in a safe way, via the GUI or using mkusb-dus

dus dd_grub-boot-template-for-uefi-n-bios.img.xz

or

Use dd to clone in a risky way

Avoid this method if you can, because it is risky.

Identify the target drive. You can use lsblk without options or better, copy and paste the following command line

lsblk -d -o name,vendor,model,type,size,hotplug

Make sure there are no mounted partitions in the target drive

sudo umount /dev/sdX?

where X is the drive letter of the target drive, and then use the correct drive letter in the cloning command line

xzcat -c dd_grub-boot-template-for-uefi-n-bios.img.xz | sudo dd of=/dev/sdX bs=4096

where X is the drive letter of the target drive. Check that the drive letter is correct, and double-check the details of the whole command line. A minor typing error might overwrite your family pictures.

Flush the buffers and inform the kernel of the new partition table

sync

sudo partprobe

Use Win32 Disk Imager to clone in Windows

Create partitions with gparted

Start gparted which has a user-friendly graphical user interface (GUI).

  • Create the partition where you store the iso file.

    • Select a size that is enough for the iso file (add at least 20% to the size of the iso file).
    • It will work well, if you use the filesystem ext4.

    • It is optional to put a label; I suggest isodevice in order to help identifying it later.

  • If you want to create a persistent live drive, you create another partition.

    • You can use the remaining (unallocated) drive space, or part of it if you want one more partition.
    • It will work well, if you use the filesystem ext4

    • Select the label writable for Ubuntu 20.04 LTS and newer versions

    • Select the label casper-rw for older versions

  • Data partition:
    • Create another partition for exchange of data with Windows.
      • It will work well, if you use the filesystem NTFS.

      • It is optional to put a label; I suggest usbdata in order to help identifying it later

    • Or create another partition for exchange of data with Windows and/or MacOS.
      • It will work well, if you use the filesystem FAT32 or exFAT.

      • It is optional to put a label; I suggest usbdata in order to help identifying it later

A separate partition with the label 'casper-rw' for older versions of Ubuntu and with the label 'writable' for Ubuntu 20.04 LTS and newer versions will make the system persistent live. Please notice that you can not use the partition where you have the iso file for this purpose.

There is an obvious advantage with journaling: the file system will be more robust. But if you think your system will be too sluggish, or you must reduce the wear, create an ext2 file system instead of the ext4 file system.

It looks like this in gparted when you start: partitioning-1.png

Configure the partition where you store the iso file: partitioning-2.png

Configure a partition for persistence with label 'writable' for Ubuntu 20.04 LTS and newer: partitioning-3.png

Two partitions are configured but not yet created. Click on the green tick to create them: partitioning-4.png

When done it can look like this: partitioning-5.png

and you can exit from gparted.

Copy the iso file into partition #1

Create mountpoint /mnt/sd1

Create mountpoint only once.

sudo mkdir -p /mnt/sd1

Mount the partition on the USB drive

Identify the target drive. You can use lsblk without options or better, copy and paste the following command line

lsblk -d -o name,vendor,model,type,size,hotplug

or blkid, grep and cut, copy and paste the following command line

sudo blkid |grep 'ext'|grep 'isodevice'|sed 's/: .*//'

and then use the correct drive letter in the mounting command line

sudo mount /dev/sdX1 /mnt/sd1

where X is the drive letter of the target drive. Double-check that the drive letter is correct.

rsync the iso file

The file grub.cfg (in partition #3) assumes that the iso file

  • is located in partition #1 and
  • has the name ubuntu.iso

sudo rsync --info=progress2 file.iso /mnt/sd1/ubuntu.iso

rsync is a reliable program, but I have seen cases, when running in some versions of 32-bit Ubuntu systems, where rsync does not copy big files correctly to USB pendrives. (Maybe we should blame a low level write tool working with the USB interface.) The files were truncated (too small). When this happened the system in the drive did not work. rsync did not notice it; there was no warning or error message about this problem.

Advanced options

You can link from an arbitrary name to 'ubuntu.iso', or you can edit grub.cfg to point to another file name (and in another location). You can also create new menuentries and point to several iso files (make a multiboot drive).

Please notice that different Linux distros have different configurations of the boot system, and it might be difficult to get correct menuentries. So if you want a multiboot system it is easier to use a dedicated tool for that purpose, e.g. 'multiboot-usb' or 'YUMI'.

Flush the buffers

sync

Now you have a live boot drive :-)

Unmount the partition on the target drive and unplug it

sudo umount /mnt/sd1

Check that no partition on the target drive is mounted with

df

In Windows you should eject the drive and wait until it is 'safe to remove the device'.

or

Continue if you wish

Create a new partition for storage

If you left unallocated space (if the drive contains more than 4 GB), create another partition. It is easy to continue using gparted.

After that you have a drive with an extra partition for persistence and/or storage.

Current versions of Windows 10 can use any partition, if there is a Microsoft file system, FAT32, exFAT or NTFS. (Older versions of Windows could not use partition #1 in USB drives.)

Unmount the mounted partition on the target drive and unplug it

sudo umount /mnt/sd1

Check that no partition on the target drive is mounted with

df

Check that your new boot drive works

Check that your new boot drive works as expected, and if not, try again, maybe you missed a step ...

Dark grub background: dd_grub-boot-template-for-uefi-n-bios_dark-bg_1024x576.png

Bright grub background: dd_grub-boot-template-for-uefi-n-bios_bright-bg_1024x576.png


Return to the main iso2usb page

Installation/iso2usb/isoboot (last edited 2022-05-07 08:06:03 by nio-wiklund)