3

I'm trying to create a bootable USB drive for 20.04. If I do a 20.04 downloaded image, I can boot the drive properly. However, if I extract all the 20.04 content to a directory, then recreate the ISO and dd that to the drive, the resulting drive won't boot. My zbook just beeps and goes back to the boot menu. The command for creating the ISO I got from several articles. But I'm certain it has to be the created ISO itself. Any ideas?

8
  • 2
    I am curious to why you're extracting the files from the ISO. Ubuntu ships with an application called "Startup Disk Creator" which does exactly as it promises ...
    – matigo
    Jul 30 at 3:13
  • 2
    You are not supposed to "extract" a *.iso file, and then copy all the extracted files to a USB. This is not how to create a bootable ISO. All you did was create a USB with a bunch of random files on it. As @matigo suggests, simply use Startup Disk Creator to "flash" the *.iso file to the USB. If you still want to use dd, take a look at Flashing Ubuntu ISO to USB stick with dd: recommended block size and Using 'dd' command to create bootable USB stick.
    – PJ Singh
    Jul 30 at 3:55
  • 1
    @PJ Singh Extracting an ISO file to USB does work, see below. Both Rufus and UNetbootin use that method. Jul 30 at 4:34
  • 1
    I think this is the problematic step: "then recreate the ISO". It is far from trivial to create an iso file, that when cloned to a USB drive will make that USB drive bootable. -- Either clone directly from the downloaded iso file (the straight-forward way), or create a partition table with at least one file system (and in case of BIOS boot also create a bootloader), and then extract the content of the iso file to the file system (a more difficult way).
    – sudodus
    Jul 30 at 10:10
  • 1
    Do you just want to make a bootable USB drive and use it? Then I suggest that you use of the the available tools with a graphical user interface that make the process relatively safe. -- Or do you want to learn the details and use a set of several basic [maybe command line] tools? Then the instructions by C.S.Cameron will be useful for you. -- Or do you want to create a custom iso file (in principle your own Linux distro)? That is much more advanced but possible, and there are several tutorials for that too.
    – sudodus
    Jul 30 at 10:23
4

There are many ways to make a Bootable USB Flash Drive

The following method extracts the contents of the ISO to a partition

Making a Grub2 booter that uses Persistent partitions is easy.*

  • Boot Installed Ubuntu or Live USB.
  • Insert Target USB.
  • Start GParted.
  • Create a GPT partition table on Target USB.
  • Create a 1MB BIOS boot partition on the left, formatted as unformatted.
  • Add a 300MB FAT32 EFI boot partition next to it.
  • Add an ext4 root partition large enough for the Ubuntu ISO's contents, (~ 3GB for 20.04).
  • Create an ext4 partition labeled casper-rw
  • Add a NTFS data partition if desired.
  • Apply all operations.
  • Flag partition 1 bios_grub.
  • Flag Partition 2 boot, esp
  • Close GParted.

gparted

  • Open the ISO's folder as Administrator, open the ISO using Archive Manager.

  • Extract the ISO's contents to the Target's root partition.

  • Drag and drop the boot and EFI folders from Archive Manager window to the EFI boot partition.

  • Edit sdx2/boot/grub/grub.cfg adding set root=(hd0,3) after the first line that starts with menuentry.

  • Add a space and the word "persistent" after ---.

      set timeout=5
      menuentry "Ubuntu persistent" {
          set root=(hd0,3)
          set gfxpayload=keep
          linux   /casper/vmlinuz  file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash --- persistent
          initrd  /casper/initrd
      }
    
  • Install grub, if in BIOS mode or booted from USB drive run:

      sudo mount /dev/sdx2 /mnt
    
      sudo grub-install --boot-directory=/mnt/boot /dev/sdx
    
  • If in UEFI mode on installed system, boot into the Target drive and run the above.

*Booting based on mkusb by sudodus

Another method to make a bootable USB is to boot ISO files directly

BIOS/UEFI Template Image for Booting ISO Files

1
  • 1
    I didn’t know this was possible. Excellent instructions. I’m bookmarking this for future reference.
    – PJ Singh
    Jul 30 at 17:27
3

tl;dr When you recreate the ISO from the extracted files, you are not (correctly) transferring either the BIOS bootblock, nor the EFI System Partition, or ESP, to the newly created USB drive. Therefore, the system will not be able to boot from this disk.

Problem

Loading the bootloader

The system firmware does not to know how to boot the operating system on the drive, and instead passes on that responsibility to a small program called the bootloader. It is stored on the disk in a specified location where the firmware can find it easily. The location where the bootloader is stored is dependent on the method used by the firmware to boot the disk. There are two different boot methods in use today on x86-64 platforms, the modern EFI and legacy BIOS boot.

I assume your HP Z-Book is new enough to be both x86-64, and support EFI boot. You will be able to enable legacy BIOS support in the system firmware's setup utility, though this may differ on other laptops, and could be subject to change for newer laptops.

EFI System Partition (ESP)

x86-64 EFI-based firmware loads the bootloader by looking for a file called /efi/boot/bootx64.efi (case does not matter) on a special, FAT32-formatted partition with type 0xEF or EFI System Partition (ESP) on the selected boot disk. Some BIOSes can (apparently) also boot from NTFS file systems.

Most Linux distributions, Ubuntu included, now distribute an El Torrito-compliant disk image. This means the same disk can be booted by a legacy BIOS, or modern EFI-based firmware, in their respective boot modes. When you extract or mount the disk (i.e. from GNOME Files, the file manager), the EFI partition is maintained as a separate efi.img file, but this is actually not how the disk is arranged on a CD/DVD burned from this ISO file.

Therefore, the system firmware does not recognise this file as a valid EFI System Partition when it is copied to your USB drive. The drive is rejected by the firmware, because it does not believe the disk to be bootable.

Resolving the problem

You can create an EFI System Partition using GNOME Disks, GParted, or command-line tools such as gdisk. The new partition must have the ESP type, and must be formatted as FAT32.

The contents of efi.img must be extracted to a folder called efi on the target disk, such that bootx64.efi appears at the path /efi/boot/bootx64.efi on the root of the disk.

The rest of the ISO may be extracted to the same partition, and this is what tools such as Rufus does. However, an extra step is often required for most Linux distributions: the file system label is often used to identify the disk from which to boot, and therefore, the file system's label must match that which came on the ISO file. Otherwise (with, for example, Ubuntu), the kernel will not be able to locate the SquashFS root file system to continue booting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.