You are not logged in.

#1 2016-07-05 10:03:01

dakota
Member
Registered: 2016-05-20
Posts: 415

[SOLVED] Multiboot USB Drive - Questions about the Wiki

I would like to create a bootable usb flash drive so that I can demo different Linux distros for friends.

Some computers will have UEFI and some will have BIOS.

It looks like this wiki article might work, but I am having trouble understanding several of the instructions.

1. Must the GUID Partition Table start at at sector 0? Or do I just have to make sure there is nothing before it on the disk? (gdisk shows that the first available sector is 34 and the default starting location as 2048. Will there be problems if I start the GPT at sector 2048?)

$ gdisk /dev/sdc

Command (? for help): n
Partition number (1-128, default 1): 
First sector (34-241339358, default = 2048) or {+-}size{KMGTP}: 
Last sector (2048-241339358, default = 241339358) or {+-}size{KMGTP}: +2M
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): ef02
Changed type of partition to 'BIOS boot partition'

2. The wiki example shows the BIOS and EFI system partitions using the default hex code of EF. Shouldn't these be ef02 and ef00, respectively?

Creating entry for GPT partition #1 (MBR partition #2)
Enter an MBR hex code (default EF): 
Set the bootable flag? (Y/N): N

Creating entry for GPT partition #2 (MBR partition #3)
Enter an MBR hex code (default EF): 
Set the bootable flag? (Y/N): N

3. The wiki states that the EFI system partition must be formatted FAT 32. Yet, when I format it as FAT 32, it shows up as vFAT. Is this a problem?

$ sudo mkfs.fat -F 32 /dev/sdc2

$ lsblk -f
sdc                                                            
├─sdc1  vfat              9DB2-AA0F                            
├─sdc2  vfat              6CDB-4205                            /mnt/efi
└─sdc3  ext4              72cf7b9e-f124-4d01-a104-c30eb2c9b918 /mnt/data

4. The grub-install commands should be run as root, correct? (The wiki shows them being run as a normal user.)

5. After I mount the EF system partition and the data partition, I run grub-install (as root) and get:

sudo mount /dev/sdc2 /mnt/efi
sudo mount /dev/sdc3 /mnt/data

$ sudo grub-install --target=x86-efi --efi-directory=/mnt/efi --boot-directory=/mnt/data/boot --removable --recheck
grub-install: error: /usr/lib/grub/x86-efi/modinfo.sh doesn't exist. Please specify --target or --directory.

$ pacman -Q grub
grub 1:2.02.beta2-6

Note: my system is i686, not x86_64.

6. Does the BIOS partition need to be formatted with a file system? If I don't format it I get:

$ sudo grub-install --target=i386-pc --boot-directory=/mnt/data/boot --recheck /dev/sdc3
Installing for i386-pc platform.

grub-install: warning: File system `ext2' doesn't support embedding.
grub-install: warning: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
grub-install: error: will not proceed with blocklists.

... and when I format it with FAT 32, I get:

$ sudo mkfs.fat -F 32 /dev/sdc1
WARNING: Not enough clusters for a 32 bit FAT!

$ gdisk /dev/sdc

Command (? for help): p
Disk /dev/sdc: 241339392 sectors, 115.1 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): A4F968EB-61B3-476C-A2D9-53447391FCD0
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 241339358
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048            6143   2.0 MiB     EF02  BIOS boot partition
   2            6144          620543   300.0 MiB   EF00  EFI System
   3          620544       241339358   114.8 GiB   8300  Linux filesystem

Any help on these issues would be greatly appreciated!

Cheers,

Last edited by dakota (2016-07-07 11:54:54)


"Before Enlightenment chop wood, carry water. After Enlightenment chop wood, carry water." -- Zen proverb

Offline

#2 2016-07-05 12:03:29

EmilyShepherd
Member
From: Bucks, UK
Registered: 2016-03-20
Posts: 45
Website

Re: [SOLVED] Multiboot USB Drive - Questions about the Wiki

dakota wrote:

1. Must the GUID Partition Table start at at sector 0? Or do I just have to make sure there is nothing before it on the disk? (gdisk shows that the first available sector is 34 and the default starting location as 2048. Will there be problems if I start the GPT at sector 2048?)

The UEFI spec requires the GPT partition table to be a certain minimum size. That, along with the protective MBR and GPT header, typically uses up the first 33 sectors which is why gdisk is telling you the first available to you is 34. Essentially, this means the space for the GPT at the start of the disk has already been accounted for.

dakota wrote:

2. The wiki example shows the BIOS and EFI system partitions using the default hex code of EF. Shouldn't these be ef02 and ef00, respectively?

This refers to the MBR hex code, which is just one byte, so EF is correct.

dakota wrote:

3. The wiki states that the EFI system partition must be formatted FAT 32. Yet, when I format it as FAT 32, it shows up as vFAT. Is this a problem?

That's fine.

dakota wrote:

4. The grub-install commands should be run as root, correct? (The wiki shows them being run as a normal user.)

Yes, run as root. (The wiki doesn't not always explicitly add `sudo` if it's implied that the whole operation needs root privileges)

dakota wrote:

5. After I mount the EF system partition and the data partition, I run grub-install (as root) and get:

Try changing the target

$ sudo grub-install --target=i386-efi --efi-directory=/mnt/efi --boot-directory=/mnt/data/boot --removable --recheck
dakota wrote:

6. Does the BIOS partition need to be formatted with a file system? If I don't format it I get:

$ sudo grub-install --target=i386-pc --boot-directory=/mnt/data/boot --recheck /dev/sdc3
$ sudo mkfs.fat -F 32 /dev/sdc1

Why, if you're having an issue with /dev/sdc3, are you attempting to format /dev/sdc1?

Offline

#3 2016-07-06 02:31:26

dakota
Member
Registered: 2016-05-20
Posts: 415

Re: [SOLVED] Multiboot USB Drive - Questions about the Wiki

Thank you very much! Your reply is greatly appreciated!

EmilyShepherd wrote:
dakota wrote:

1. Must the GUID Partition Table start at at sector 0? Or do I just have to make sure there is nothing before it on the disk? (gdisk shows that the first available sector is 34 and the default starting location as 2048. Will there be problems if I start the GPT at sector 2048?)

The UEFI spec requires the GPT partition table to be a certain minimum size. That, along with the protective MBR and GPT header, typically uses up the first 33 sectors which is why gdisk is telling you the first available to you is 34. Essentially, this means the space for the GPT at the start of the disk has already been accounted for.

Got it. I was confused by the numbering. 34 sectors seemed like too much for an MBR (which would be only 512 bytes), but too little for a GPT. But the 34 sectors at the beginning of the disk do NOT include the Secondary GPT Table and Header. They include only the Protective MBR (512 bytes), the Primary GPT Header (512 bytes), and the Primary GPT Table (16 KiB)... which totals 17 KiB... which is 34 sectors at 512 bytes per sector! Very cool.

EmilyShepherd wrote:
dakota wrote:

2. The wiki example shows the BIOS and EFI system partitions using the default hex code of EF. Shouldn't these be ef02 and ef00, respectively?

This refers to the MBR hex code, which is just one byte, so EF is correct.

I was confused by similar menu items when partitioning a volume vs. creating a hybrid GPT. When partitioning a volume, gdisk asks for a 'Hex code or GUID'. It is expecting a two-byte GPT code and will not accept a one-byte entry. However, when creating a hybrid GPT, gdisk asks for 'an MBR hex code' which is the one-byte code.

EmilyShepherd wrote:
dakota wrote:

3. The wiki states that the EFI system partition must be formatted FAT 32. Yet, when I format it as FAT 32, it shows up as vFAT. Is this a problem?

That's fine.

Thanks. wink

EmilyShepherd wrote:
dakota wrote:

4. The grub-install commands should be run as root, correct? (The wiki shows them being run as a normal user.)

Yes, run as root. (The wiki doesn't not always explicitly add `sudo` if it's implied that the whole operation needs root privileges)

This particular section uses $ as a prompt instead of  # (which is used throughout the rest of the article), so I wasn't sure.

EmilyShepherd wrote:
dakota wrote:

5. After I mount the EF system partition and the data partition, I run grub-install (as root) and get:

Try changing the target

$ sudo grub-install --target=i386-efi --efi-directory=/mnt/efi --boot-directory=/mnt/data/boot --removable --recheck

Of course! I should have seen that, but my brain was caught in a vortex.

EmilyShepherd wrote:
dakota wrote:

6. Does the BIOS partition need to be formatted with a file system? If I don't format it I get:

$ sudo grub-install --target=i386-pc --boot-directory=/mnt/data/boot --recheck /dev/sdc3
$ sudo mkfs.fat -F 32 /dev/sdc1

Why, if you're having an issue with /dev/sdc3, are you attempting to format /dev/sdc1?

I was getting mixed up again. The wiki had me create 3 partitions: one for BIOS, one for EFI and one for data. Then it had me install grub to the EFI partition and I was expecting it next to have me install grub to the BIOS partition... so I had sdc1 on my brain. Instead the instruction was to install a backup to the data partition. (I never could get that to work, though).

Anyway, does the BIOS partition need to have a file system installed on it? (I've seen some instructions which say to not install a file system... and others that recommend FAT 32.

Cheers,


"Before Enlightenment chop wood, carry water. After Enlightenment chop wood, carry water." -- Zen proverb

Offline

#4 2016-07-06 02:42:11

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [SOLVED] Multiboot USB Drive - Questions about the Wiki

BIOS isn't a partition. Read this: https://www.happyassassin.net/2014/01/2 … work-then/


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#5 2016-07-06 04:12:02

dakota
Member
Registered: 2016-05-20
Posts: 415

Re: [SOLVED] Multiboot USB Drive - Questions about the Wiki

jasonwryan wrote:

Er... okay.

I've read the first part of that article several times (each time I understand a little bit more, but clearly, I need to read it again), and I understand that BIOS and UEFI are types of firmware.

However, the wiki article that I've been following specifically states:

This configuration is useful for creating an universal USB key, bootable everywhere. First of all you must create a GPT partition table on your device. You need at least 3 partitions:

1. A BIOS boot partition (type EF02)
2. An EFI System partition (type EF00)
3. Your data partition (use a filesystem supported by GRUB)

The BIOS boot partition must be sized 1 MB, while the EFI System partition can be at least as small as 50 MB. The data partition can take up the rest of the space of your drive. 

and the gdisk software, itself, refers to:

Hex code or GUID (L to show codes, Enter = 8300): ef02
Changed type of partition to 'BIOS boot partition'

The terminology is confusing.

In the context of a Hybrid UEFI GPT + BIOS GPT/MBR boot system, it sounds like I need to install a partition, using partition software, that is separate and distinct from the actual BIOS. However, once I have created it, there are no instructions on what to do with it... so I'm not sure what it's for, and I can't decide if it needs a file system or not.

Anyway, I'm stalled on the next step... which is configuring grub... so I'll probably spend the next few days reading the main Grub entry.

Cheers,

EDIT: The first section after the Preface on the Grub page clears up a lot of confusion I've had about the 'BIOS boot partition'. I should have read that first. wink

Last edited by dakota (2016-07-06 04:29:11)


"Before Enlightenment chop wood, carry water. After Enlightenment chop wood, carry water." -- Zen proverb

Offline

#6 2016-07-06 15:47:00

EmilyShepherd
Member
From: Bucks, UK
Registered: 2016-03-20
Posts: 45
Website

Re: [SOLVED] Multiboot USB Drive - Questions about the Wiki

jasonwryan wrote:

BIOS isn't a partition.

The BIOS partition is a hack for GRUB in order to be able to support GPT and MBR. Originally GRUB installed some of its stuff directly after the MBR, but now that the GPT takes up that space, you have to format a new partition for its stuff. Read this: https://en.wikipedia.org/wiki/BIOS_boot_partition

dakota wrote:

This particular section uses $ as a prompt instead of  # (which is used throughout the rest of the article), so I wasn't sure.

Ah, yes, that might be in need of an edit.

dakota wrote:

Anyway, does the BIOS partition need to have a file system installed on it? (I've seen some instructions which say to not install a file system... and others that recommend FAT 32.

I don't think so, but I'm not an authority on GRUB, so don't quote me on that I'm afraid.

Offline

#7 2016-07-07 11:54:35

dakota
Member
Registered: 2016-05-20
Posts: 415

Re: [SOLVED] Multiboot USB Drive - Questions about the Wiki

Thanks Emily! Your answers helped quite a bit!

Cheers,


"Before Enlightenment chop wood, carry water. After Enlightenment chop wood, carry water." -- Zen proverb

Offline

Board footer

Powered by FluxBB