SOLVED - Where will esp go in this linux-on-macbook attempt ?

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post please read how to get help
artgrandi
Level 1
Level 1
Posts: 16
Joined: Wed Aug 26, 2020 4:31 pm

SOLVED - Where will esp go in this linux-on-macbook attempt ?

Post by artgrandi »

I have followed pbear's anthologichal tutorial viewtopic.php?f=42&t=287353&start=20 and succeeded in installing - using the unflag-reflag procedure - Mint19.3 and Manjaro 20.03 to a SSD external drive (GPT table) to be primarily used with my macbook 2.1 (2010)-16 GB ram . Hopefully with many other machines also :wink:

Now I would like to add a third Linux distro to this SSD, in order to progress towards a multiboot but I am unsure of how it will work out as far as placing of the bootloaders and how should I go about it? I sure don't want to mess with my macbook. I want to keep this strictly to the SSD.

The Mint bootloader went into a FAT32 partition named "EFI boot partition" (UEFI /unflag/reflag/simple installation). The Manjaro bootloader went into another Fat32 partition I created after shrinking the Mint partition and creating 3 ext4 partitions intended for different distros, one FAT32 partition(900MB) as some larger "EFI" partition (having read somewhere https://www.tonymacx86.com/threads/mac- ... ps.219975/ that THE EFI system partition could be too small for additional bootloaders and their stuff) and one FAT32 -27 Gb partition (for data). I don't remember if I chose device or partition when I installed Manjaro, but I am pretty sure (not 100% though) - I flagged it as boot,esp under installation trying to follow pbear's advice for the UEFI/reflag/unflag/advanced installation- for the most. It remains with those flags. So I suppose I must have pointed at the partition, which would deviate from pbearś advice, but it was all in good faith.

Now the macbook when booted with alt key pressed down presents icons for both distros at startup. And they both boot swiftly and function well, so far. I have not tested then properly yet.

Funny enough, when I try booting the SSD from my MBR-Fujitsu and my MBR-HP it shows only Mint (which is now flagged as "msftdata") as a boot option, but I guess this should perhaps be the subject of another thread .

One question I haven't been able to answer thus far is whether THE EFI system partition may contain "booting" ( i.e. containing respective bootloader) folders for several OSes and if yes how should I care for all OSes to place their folders there.

And if each OS must have its bootloader in an exclusive Fat32 ("EFI") partition, should i then point their bootloaders at their designed partitions and not at the device ? Would this apply to both fixed and remove devices ?

And in the case of an OS on an external drive - which i have read must be booted as fallback, how can multiboot be achieved ? Is there someway to have SEVERAL fallbacks ?????

Excuse me if I make this complicated, but I am indeed confused after so much googling.
Last edited by artgrandi on Thu May 20, 2021 11:41 am, edited 1 time in total.
bodge99

Re: Where will esp go in this linux-on-macbook attempt ?

Post by bodge99 »

Hi,

The UEFI spec. expects a single EFI partition on the primary drive.. Not really much use with external devices that you want to use on other machines.

Just make your own. Create a 100 - 200 MB fat32 partition at the beginning of the drive. Set the 'boot' & 'esp' flags. I use Gparted for this.
(200 MB size is useful if you want to look at "unusual" booting of certain hardware.. See post No. 6 onwards in viewtopic.php?f=46&t=348615 ).

I multiboot on everything, So I install Grub to the local EFI partition and use a manually created simple 'grub.cfg'. This has menuentries that point to the installed system's 'grub.cfg' or chainloads another bootloader.

Maintenance is easy. Updates will write to the EFI partition, so just make a /EFI-backup/ directory here and copy everything over from '/EFI/'.
Just delete & copy back after any Grub updates etc. This method also solves the "lead grub" problem.. Any installation is totally standard with no interaction with anything else..

This allows the external device and each installed OS to be fully independent of everything. You can easily add Grub Legacy boot (a "one liner" install). This allows you to boot on just about anything.. (host CPU permitting.. obviously).

See viewtopic.php?f=42&t=348629 for the general idea.. (this is a copy of the above.)

Note: Make a copy of the host's EFI partition **contents** before you start...

Bodge99
Last edited by bodge99 on Fri May 07, 2021 2:56 pm, edited 1 time in total.
User avatar
AndyMH
Level 17
Level 17
Posts: 7391
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Where will esp go in this linux-on-macbook attempt ?

Post by AndyMH »

You can have the bootloaders for multiple OSes in the same EFI partition.

Just do as you did before, disable the esp & boot flags in the EFI partition on your main system drive and point the installer at your external SSD as the destination for grub. After installation re-enable the flags on the your main system drive.

Just make sure your EFI partition is big enough.
Homebrew i5-8400+GTX1080 Cinnamon 19.0, 4 x Thinkpad T430 Cinnamon 20.1, 2 x i7-3632 , i5-3320, i5-3210, Thinkpad T60 19.0 Mate
bodge99

Re: Where will esp go in this linux-on-macbook attempt ?

Post by bodge99 »

Hi,

AndyMH: Yes, spot on, but you would have to mod the EFI partition on any machine if you were using an external device.

With mine, you just need to use your machine "boot override".. Works on any EFI or Legacy machine.

Bodge99
artgrandi
Level 1
Level 1
Posts: 16
Joined: Wed Aug 26, 2020 4:31 pm

Re: Where will esp go in this linux-on-macbook attempt ?

Post by artgrandi »

many thanks, AndyMH and bodge99 !

I haven't had time to try your suggestions yet, but I am very pleased anyway, because they are clear, exact, understandable and friendly, and besides all that it sounds like they are what I have been looking for for a very long time.

And I have a strong feeling that this case is solved.

But I will have to eat the pudding before I mark it even though my questions are certainly answered.
bodge99

Re: Where will esp go in this linux-on-macbook attempt ?

Post by bodge99 »

Hi,

artgrandi: If you have any questions at all about my particular method then just post here... It's never a problem answering queries..

Bodge99
artgrandi
Level 1
Level 1
Posts: 16
Joined: Wed Aug 26, 2020 4:31 pm

Re: Where will esp go in this linux-on-macbook attempt ?

Post by artgrandi »

Thanks again bodge99 !

I was in the process of writing these questions below, when you post came in. Kind !

I have not done anything on the SSD yet, but I have read your texts and the provided link carefully. I think I understand all of it but I have been proven wrong in this respect so many times that I would better try to clarify a few points.
Just make your own
In the external SSD, right ?
Maintenance is easy. Updates will write to the EFI partition, so just make a /EFI-backup/ directory here and copy everything over from '/EFI/'.
Keep the back-up inside EFI partition ? And then for every update delete the existing back-up and make a new one?
With mine, you just need to use your machine "boot override"
May I ask what does "boot override" mean ? I have never heard the expression.
Works on any EFI or Legacy machine.
My SSD is pure EFI. I did not want to be too ambitious in a first attempt. But you raised some interest here.
Must I make it Hybrid - or something else - before it can boot a Bios machine ? I understand - perhaps wrong again - that a Bios firmware would not be able to boot my machine without some somehow prepared form of MBR . But it is difficult for me to reason at this level where i am just a beguinner.
bodge99

Re: Where will esp go in this linux-on-macbook attempt ?

Post by bodge99 »

Hi,

The problem in briefly describing something is the potential for misunderstanding.. Been there, done that.. from both sides!

If you want to support Legacy boot from a GPT drive then there is one further step to take that does not apply to the flashdrive EFI setup.
Create an empty partition of 2MB (yes, two MB) at the very beginning of the drive. Set the 'bios-grub' flag. This space is used to hold the Legacy Grub first stage bootloader. Most folk use a 1MB partition here.. I use 2MB as this leaves plenty of room in case any future Legacy Grub versions happen to use a larger first stage boot.. (Not particularly likely, but never say never..)

Just to clarify: The flashdrive example is used to boot an existing operating system on either a Legacy or a UEFI system.
This works because the drive has a legacy partition table ('msdos'). Both Legacy & UEFI Grub are installed here.
Using a similar EFI partition (on a GPT drive), you install one or more operating systems onto the external device. You can then boot this device from any system. Note: You **can** just copy an existing installation.. Ask here before doing this because you need to make a few minor alterations to the copied installation. Important: Don't try to copy a running system.
Both the flashdrive & the external device require a simple manually created 'grub.cfg'.

Create a new EFI partition onto your external drive:

Run 'gparted' and create a partiton of 100 - 200MB in size. Choose 'fat32' as the filesystem. When the filesystem has been created, set the 'esp' and 'boot' flags. This partition now meets the specification for an EFI partition.

New EFI partition layout. Grub is installed here: (Truncated 'tree' due to the number of Grub modules.)
You'll notice that I have UEFI Grub and Legacy (boot) Grub installed. **see below for more on this.

Code: Select all

/EFI
    ├── boot
    │   ├── BOOTX64.EFI
    │   ├── fbx64.efi
    │   ├── grub
    │   │   ├── fonts
    │   │   │   └── unicode.pf2
    │   │   ├── grub.cfg
    │   │   ├── grubenv
    │   │   ├── i386-pc
    │   │   │   ├── 915resolution.mod
    │   │   │   ├── acpi.mod
    :   :   :   :
    │   │   │   ├── zfs.mod
    │   │   │   └── zstd.mod
    │   │   └── x86_64-efi
    │   │       ├── acpi.mod
    │   │       ├── adler32.mod
    :   :       :
    │   │       ├── zfs.mod
    │   │       └── zstd.mod
    │   └── mmx64.efi
    └── ubuntu
        ├── BOOTX64.CSV
        ├── grub.cfg
        ├── grubx64.efi
        ├── mmx64.efi
        └── shimx64.efi
Filesystem tree that shows the '/EFI-backup' directory. You'll see that everything in /EFI/ is copied over to '/EFI-backup'.

Code: Select all

/EFI
│   ├── boot
│   │   ├── BOOTX64.EFI
│   │   ├── fbx64.efi
│   │   ├── grub
│   │   │   ├── fonts
│   │   │   │   └── unicode.pf2
│   │   │   ├── grub.cfg
│   │   │   ├── grubenv
│   │   │   ├── i386-pc
│   │   │   │   ├── 915resolution.mod
│   │   │   │   ├── acpi.mod
:   :   :   :   :
│   │   │   │   ├── zfs.mod
│   │   │   │   └── zstd.mod
│   │   │   └── x86_64-efi
│   │   │       ├── acpi.mod
│   │   │       ├── adler32.mod
:   :   :       :
│   │   │       ├── zfs.mod
│   │   │       └── zstd.mod
│   │   └── mmx64.efi
│   └── ubuntu
│       ├── BOOTX64.CSV
│       ├── grub.cfg
│       ├── grubx64.efi
│       ├── mmx64.efi
│       └── shimx64.efi
└── EFI-backup
    ├── boot
    │   ├── BOOTX64.EFI
    │   ├── fbx64.efi
    │   ├── grub
    │   │   ├── fonts
    │   │   │   └── unicode.pf2
    │   │   ├── grub.cfg
    │   │   ├── grubenv
    │   │   ├── i386-pc
    │   │   │   ├── 915resolution.mod
    │   │   │   ├── acpi.mod
    :   :   :   :
    │   │   │   ├── zfs.mod
    │   │   │   └── zstd.mod
    │   │   └── x86_64-efi
    │   │       ├── acpi.mod
    │   │       ├── adler32.mod
    :   :       :
    │   │       ├── zfs.mod
    │   │       └── zstd.mod
    │   └── mmx64.efi
    └── ubuntu
        ├── BOOTX64.CSV
        ├── grub.cfg
        ├── grubx64.efi
        ├── mmx64.efi
        └── shimx64.efi
Updates will only alter files **within** the '/EFI/' directory. Nothing is touched within the '/EFI-backup' directory.

When/if your EFI files get altered by any Grub updates then its easiest/quicker to just delete the existing '/EFI' directory contents and just copy back from the '/EFI-backup' directory.

If you were using something like 'Midnight Commander" you could just delete (deletes everything including the directory) '/EFI' and copy '/EFI-backup' to (a newly created) '/EFI' directory . Have a play with 'Midnight Commander".. You'll see exactly what I mean.. Easy, graphical & fast.

Boot Override: Most computers allow you to press a key just after the system is powered on.. This opens a window on your screen from which you can select which device or operating system to boot. 'F7' or 'F12' is quite common. You can normally also select what to boot from the 'boot' section of your Bios setup.

Don't worry too much about the following.. just ask any questions if you require help.

UEFI & Legacy boot:

The role of any computer at startup is to boot an operating system that is installed into a drive partition.
The laptop or desktop that you use is one of two types of system.. UEFI or Legacy (boot). The booting mechanism for both is somewhat similar.

Legacy Boot. (somewhat simplified.. sorry good folk!)
The hard drive contains an 'msdos' partition table. This partition table can hold information about (up to) four primary partitions. Originally, this was a "hard limit" on what could be placed on a hard drive. This limit was overcome somewhat with the introduction of the concept of an "extended partition".
This extended partition can have a greater number of logical partitions within it.

At the very beginning of the drive (outside of any partition) there exists the 'master boot record' and the 'first stage bootloader'.
These hold information such as 'is this drive bootable' and 'where is the bootloader'. Only one bootloader can be "pointed to". This is one of the reasons why some folk have OS booting problems. Operating systems such as Windows will overwrite info here with no regard to any other OS at all.
On system start, Grub runs and loads its configuration file ('grub.cfg') See below for a continuation.

UEFI. (Again, somewhat simplified.. sorry good folk!)
A drive here normally uses a 'GPT' partition table. This allows a far greater number of primary partitions to exist.. Needed with today's large drives.
The UEFI spec. states that an EFI partition must exist. This is essentially a fat32 partition with the 'boot' and 'esp' flags set.
On system startup, the Bios looks inside the EFI partition for an EFI executable file. (This can be 'bootx64.efi' or grubx64.efi etc.).
'grubx64.efi' is the actual Grub bootloader/boot manager (yes, it's both).. This then loads a configuration file (/boot/grub/grub.cfg) which then starts to load the Linux kernel. The kernel uses a ram based filesystem (extracted from the initrd [initial ram device/drive or initial ramdisk filesystem]) to configure the system.. After the configuration phase, the initial ram file system is deleted, freeing this memory. Control is then passed to the system 'init'.
On Mint, SystemD is used.. When SystemD has done it's initialisation etc. the GUI is started. Solitare and/or Ebay browsing is now available ;>)

Why have I written all of this??
You'll probably notice that the boot/startup procedure is **identical** from the point the system's 'grub.cfg' starts to load the kernel.
It's either, Legacy Grub starts the kernel **OR** UEFI Grub starts the kernel.

What does this mean?
This means that you **can** boot a legacy installation on a UEFI system **OR** boot a UEFI installation on a Legacy system **Given two provisos**.
Both Legacy and UEFI Grub need to be installed and a GPT hard drive must have a 1-2Mb space (flagged as "Bios-Grub") at the very beginning of the drive.

Clarifications on request..

Bodge99
Last edited by bodge99 on Sun May 09, 2021 11:31 am, edited 7 times in total.
bodge99

Re: Where will esp go in this linux-on-macbook attempt ?

Post by bodge99 »

Hi,

TIP: I assume that you'll need to experiment a bit, until you've fully grasped the concepts.. I'd guess that you will be wanting to make a few test installations etc.

To save you having to mess with flashdrives, you can copy the Iso to your external device and Isoboot the file directly.
An alternative is to copy the Iso **contents** to a small partition somewhere on the external drive. You then configure Grub to boot this directly.

I prefer the second method.. Not all Iso's can be Isobooted (All Ubuntu/Mint Iso's can). It is very easy to configure the extracted Iso contents for booting.
I have a 1TB external SSD that has over 30 Iso extracted installation partitions on it. Using these saves a **considerable** amount of time..
This drive also has about 25 distros installed as well. I use these for demo & testing purposes.

Just ask if you require specific guidance..

Bodge99
Last edited by bodge99 on Sun May 09, 2021 10:12 am, edited 2 times in total.
bodge99

Re: Where will esp go in this linux-on-macbook attempt ?

Post by bodge99 »

Hi,

I'll cover some basics here, just so that we are on the "same page":

Storage Device identification:

Type: Device Name:
HDD/SSD: sda The first Sata drive.
NVMe: nvme0n1 The first NVMe drive.
Emmc: mmcblk0 The first Emmc drive.

Each drive can hold one or more partitions:

For HDD/SSD: The first partition on the first drive is 'sda1', the second is 'sda2' and so on.
NVMe: The third partition on the first drive is 'nvme0n1p3' etc.
Emmc: The fifth partition on the second drive is 'mmcblk1p5' and so on..

Where there is a number, drives normally count from 'zero' and partitions count from 'one'.
The running Linux system "sees" hardware as existing within the 'device' directory.
So, 'sda1' is seen as '/dev/sda1', 'mmcblk0p2' as '/dev/mmcblk0p2' etc.
The important thing to remember is that the drive designations are transient and may change between system boots/reboots.
The act of plugging in a flashdrive may change how the drive is identified by the system on the next boot.

Example: If your main hard drive is identified as 'sda', a plugged in flashdrive could be identified as 'sdb'.
If you now reboot, with the flashdrive still connected, it's now possible for the flashdrive to be identified as 'sda' and the hard drive as 'sdb'.

Because of this, most modern Linux's refer to a filesystem by its UUID. UUID stands for Universally Unique IDentifier and is a unique series of hexadecimal numbers that is assigned to device partition's **filesystem**.
Examples of where these UUIDs are used. Grub (in its 'grub.cfg') and the file system table 'fstab', located at '/etc/fstab'.

An example UUID for an Ext4 filesystem is 60a5679d-b728-4f5c-8b90-2e1fb0eb1efc . These UUIDs are random in nature and are assigned when a partition is formatted.

Top level directory tree for a Linux system:

Code: Select all

/
├── bin
├── boot
├── cdrom
├── dev
├── etc
├── home
├── lib
├── lib32 
├── lib64 
├── libx32
├── media
├── mnt
├── opt
├── proc
├── root
├── run
├── sbin 
├── srv
├── sys
├── tmp
├── usr
└── var
This just shows the first level subdirectories that exist within the system. The full system directory structure is considerably more complex.
We'll look at a couple of directories here shortly.

Connecting a device to Linux:
Linux doesn't use the concept of drive letters. Devices are connected (mounted) to somewhere within the directory structure.
Example:
The (Mint) system will automount a formatted flashdrive to '/media'. Typically:

Code: Select all

/media
└── {user-name}
      └── USB STICK
A label for the flashdrive partition is used here, for ease of reading.
Other distro's may use a different automount location. e.g. Artix Linux uses '/run/media'.

You can also manually mount any partition (that the system recognises) anywhere you wish. Obviously you need to choose sensible locations for this.
By convention, '/mnt' or somewhere within your home directory (full path is '/home/{user-name}/' or (as a shortcut) ' ~/') are typically used.
I tend to use '/mnt1' and '/mnt2' as well.. just for "ease of typing".
So, to mount the flashdrive to '/mnt1' you would use:

Code: Select all

mount /dev/sda1 /mnt1
The '/boot' directory:

Code: Select all

/boot
├── efi
│   ├── EFI
│   │   ├── BOOT
│   │   │   └── grub
│   │   │       ├── fonts
│   │   │       └── x86_64-efi
│   │   └── ubuntu
│   └── EFI-backup
│       └── BOOT
│           └── grub
│               ├── fonts
│               └── x86_64-efi
└── grub
    ├── fonts
    ├── themes
    └── x86_64-efi
This is the directory tree for '/boot' on the laptop that I'm using now. You may notice a familiar EFI directory.. Yes.. you are correct, this is the fat32 EFI partition.
This is automatically mounted when the system starts from an entry in the file system table, 'fstab' (full path is '/etc/fstab').

This is a text file which can be viewed ('cat /etc/fstab') or edited directly (using an editor run using 'sudo' e.g. 'sudo xed /etc/fstab') .

Code: Select all

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system>                       <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda4 during installation
UUID=f9a15e14-ffdf-4221-9fee-06b4e5564bc9 /            ext4    noatime,errors=remount-ro 0       1

# /boot/efi was on /dev/sda1 during installation
UUID=077C-A8CF                          /boot/efi      vfat    umask=0077      0       1

/swapfile                                 none         swap    sw              0       0
The lines beginning with a hash are comments.
Looking at the line 'UUID=077C-A8CF /boot/efi vfat umask=0077 0 1'
This is identical in function to:

Code: Select all

mount /dev/sda1 /boot/efi
The equivalent manual mount command **using the filesystem UUID** is:

Code: Select all

mount UUID=077C-A8CF /boot/efi 
The mount command using 'sda1' will work perfectly fine **IF** you know that the partition you want actually is 'sda1'.
The mount command using the UUID is guaranteed to work..(assuming that the system can recognise the filesystem type, the filesystem exists and is actually available).
Sometimes you have to pass specific parameters to the command.. depending on what you are mounting..
This is why it is important to double check **how** the system has recognised any partition using 'sudo fdisk -l'

Bodge99
Last edited by bodge99 on Thu May 13, 2021 8:19 pm, edited 12 times in total.
bodge99

Re: Where will esp go in this linux-on-macbook attempt ?

Post by bodge99 »

Hi,

Don't worry too much about this.. just a general awareness of the contents should be enough for now.

Simple Grub config file 'grub.cfg'
This is a typical example that will boot from a choice of three Linux installations on your external drive.

Code: Select all

menuentry "Mint 20.1 Cinnamon" {
    search --set=root --fs-uuid e8ab7adf-e4b4-43cc-8c43-bbef6d53f6f1
    set prefix=($root)/boot/grub
    configfile $prefix/grub.cfg
}

menuentry "OpenSuse" {
    search --set=root --fs-uuid 26dfbb44-f794-4f24-9119-8cdda78c3a85
    set prefix=($root)/boot/grub2
    configfile $prefix/grub.cfg
} 

menuentry "Artix Linux Mate" {
    search --set=root --fs-uuid f9a15e14-ffdf-4221-9fee-06b4e5564bc9
    set prefix=($root)/boot/grub
    configfile $prefix/grub.cfg
}  
This boots Mint, OpenSuse and Artix Linux.
All you need here are the UUID's of the target installations' filesystems and the location of the relevant 'grub.cfg'.
Note that OpenSuse uses '/boot/grub2/grub.cfg'.

Each section here consists of a menuentry, a title and Grub commands that are placed between opening & closing braces.

The first line in each command list tells Grub to search for a filesystem by using it's UUID. The result of this is stored in a variable called 'root'.
The second line sets another Grub variable (prefix) to the location of the required Grub configuration file.
The third line tells Grub to continue using a configuration file named 'grub.cfg' which is located at (for Mint) '{drive & partition}/boot/grub/grub.cfg'

Grub refers to drives & partitions in a slightly different way.
e.g. For a GPT drive: The second partition of the first drive would be seen as (hd0,gpt2).
For a Legacy drive: The third partition of the second drive would be seen as (hd1,msdos3) etc.
For both, you can actually use the general form (hd0,2) etc.

To boot correctly, two important Grub variables are required to be set correctly. These are the 'root' and 'prefix' variables.

The system will fail to boot correctly if these variables are incorrect. Hence people's woe when confronted with a Grub prompt or worse, a Grub Rescue prompt.. This is the perfect case for the use of a Grub rescue flashdrive...

Grub variables can be manually set (from within the Grub environment i.e. before the system has booted) by something similar to:

Code: Select all

set mypath=/my-dir/here
set newpath=$mypath/final
So the content of 'newpath' is '/my-dir/here/final'. Note the '$' means "the contents of".

So the above Grub menuentry commands will set the required variables something like this:
The 'root' variable. The UUID search returns something like hd0,gpt3 .
The 'prefix' variable is then set to (hd0,gpt3)/boot/grub .
Finally, the target system's 'grub.cfg' is loaded from (hd0,gpt3)/boot/grub/grub.cfg .
The target system now starts loading the kernel etc.. from the configuration found in its local 'grub.cfg'.

Bodge99
artgrandi
Level 1
Level 1
Posts: 16
Joined: Wed Aug 26, 2020 4:31 pm

Re: Where will esp go in this linux-on-macbook attempt ?

Post by artgrandi »

Thanks bodge99 for so much detailed information masterly presented -really mean it! Amazing

I have just read through it all a first time.I am a quick reader, but it takes me much longer to digest what I read and must read it again and preferably write a summary, which was what I had been doing the last few days when I did not have a cold. I was doing a summary of a selection from what I had collected so far on my questions ans objectives,. and that is way I only saw your posts first today.

I had thought a few days ago that I was ready to install Slackware, that would be my third distro on the ssd. As iI believe I mentioned above, that was what caused my question. I knew I could have one distro installed to the EFI partition and a second one could be safely installed (also at the EFI partition but with the special status) as "Fallback", which solved the problem of dual boot, but let me unsure about multiboots.

Well I thought I had all figured, but when I try to write a step-by-step manus the questions arise.

Your posts I read today went right to some of my latest questions, but as I said (wrote), I must let it all sink in before I can act. It's one in the morning now and I must rest. I will return as soon as have something interesting to report.

Once again thank you so much for taking so much time to help. I may well find some additional questions. Time will tell.






I thought I was ready to install Slackware, my next distro to
bodge99

Re: Where will esp go in this linux-on-macbook attempt ?

Post by bodge99 »

Hi,

Sackware is a superb distro.. Be aware that it has quite a steep learning curve and that it doesn't use Grub by default. You'll learn how to do most things "manually".
You can obviously install Grub.. but be aware that it's quite easy to miss this step during installation..
Don't worry if you do.. just don't bother installing lilo/elilo.
TIP: It's a good idea to keep a copy of a working kernel, initrd and the relevant modules somewhere safe.. for those times when you forget to create your new initrd.
Also have a look how to use the "huge" kernel.. (no initrd for this one.)

At a pinch, You can "transplant" Grub from Mint (yes.. directly copy the /boot/grub/* files across..). A 'bodge' yes, but enough to get the system booted.
You can then install Grub properly using the 'slackpkg' tools. Just PM me for specific details.

If you have the time & interest, have a look at Devuan (no SystemD) and possibly Artix Linux (no SystemD, it is a rolling release).
Another nicely "polished" distro to consider is OpenSuse (uses SystemD).

IMHO, Using Mint will teach you the Ubuntu "world".. Devuan is the closest you'll get to traditional Debian.
Slackware (also SystemD free) is the closest to a true Unix that you'll find within the Linux ecosystem.

Bodge99
artgrandi
Level 1
Level 1
Posts: 16
Joined: Wed Aug 26, 2020 4:31 pm

Re: Where will esp go in this linux-on-macbook attempt ?

Post by artgrandi »

HI!

Thanks for many new good tips!

I still haven't thoroughly read your post from yesterday, have had some urgent matters keeping me away from my experiments.I was going to do it now while waiting for a meeting, when i noticed your post.

Mint was my first Linux I think I will never leave it behind.I know I can always count on it., in part because it is the one I have used the longest. I think Artix is a very nice distro, NO systemd and easier than Arch, I have it in my 2 main machines, and in a multiiso usb stick, but I haven 't given it the time to learn setting ethernet properly, not to mention wifi (which I seldom use).

I have been running Core 2 duo computers for a decade, now I have managed to buy a 2nd hand i5 and
a second hand i7 (both Fujitsus). The i5 is stlil pure Windows -as there are still a few things i cant do with Linux and I need a machine for emergencies - but I mostly use it with live usb sticks of different Linux distros. The i7, I haven't touched it yet, so far it is a reserve machine for the future or for a new project when I finish with my present experimenting with the Core 2s. I spent almost 3 years trying to run Gentoo on imac G3, before i gave it up and installed Lubuntu and later Debian in 20 minutes. Still works and i have used it occasionallly. I will be glad to look into Devuan considering the age of my hardware, thanks for that. I Had looked into, but your recommendation made a difference.


OpenSuse was my second most frustrating distro after Gentoo (which by the way i like a lot, but is too much work for me at my level). Had it once running in the beguining, then even tried to compile it from their online platform but was also to much work, to many options to consider.

When I finally started looking into Slackware about 2 years ago, it was pretty scary, but I took it easy and kept reading and visiting occasionally, until I found out about Slackware Live and it was very easy to use on a persistent usb. After a about a year using it often I decided to try (full) installing it on a USB stick and that was a really weirdo experience. I got friendly support from the people at Linuxquestions
and ended up installing it on my 2 main Core 2s. And they all (3 installs, since in one of them there were 2 versions work fine.

Main problem there was that I needed to install Audacity, Rosengarden, MuseScore, Jack and QSynth and even though Bob Alien even offers ready packages for some of them, at least Audacity I am sure, I still haven gathered the courage and time to go that way. But I am sure going to try it.

My HP Core 2 died last week, and although I could have it fixed it I dont think its worth. I will rather focus on the macbook now, an I hope to start using multiboot data and external disks on all my machines.

I have never installed grub on my Slackwares, since they have always been on multiboots (bios/MBR) where I use a base-ArchLinux to install grub and boot "everybody". Now I am understanding that I might just install grub (to the MBR) without installing ArchLinux. Is that correct ?

One (theorethical) question upon you post from yesterday would be if I could place Slackware on the grub.cfg of another distro, and then boot to that distro's grub.menu and start Slackware therefrom - now I am at GPT/UEFI/EFI and pretty unsure about things. But today you are telling me I can borrow mints grub. Does that mean I would drop to Mint's grub prompt and then start Slackware therefrom ? If not I wonder how would the the Mint-grub know about Slackware as a target and where to find the necessary items to start it. This is just intellectual curiosity not a practical problem I am having.. I wonder also whether it is allowed to maintain such digressions here.

Well i have extended myself perhaps a bit too much and it is now time for the meeting. I guess the reading of yesterdays post will move on to "mañana".

Once again many thanks for your generous interest.
bodge99

Re: Where will esp go in this linux-on-macbook attempt ?

Post by bodge99 »

Hi,

Re: "Borrowing" Grub for use on Slackware:
What I meant here is physically copying the /boot/grub/* files from Mint (or any other distro) and placing them into the equivalent location in Slackware.
You also add a temporary 4 line 'grub.cfg' which just starts the local kernel & initrd. This is enough to boot Slackware. You then install Grub using the Slackware tools. After this, you run 'update-grub' as normal.. This then produces a 'tailored' 'grub.cfg' to suit your particular setup... as per normal.

Obviously, on a multiboot system something has to link to the Slackware's 'grub.cfg'. This is where the use of the following pays dividends.

The 'Install to the EFI partition' technique can also be used with a Legacy system as well.. I'll explain.

UEFI boot:
Traditional Grub setup:
The Bios locates and runs an .efi executable file within the EFI partition. Grubx64.efi (the actual bootloader) generates a menu using the contents of the target system's 'grub.cfg' (at /boot/grub/grub.cfg). A default or user choice then starts to load a specific kernel. Grub variables are used to allow Grub to locate everything it requires at each stage (especially the 'grub.cfg' file.) precisely. All of the Grub ancillary files (modules etc.) are installed in the system's '/boot/grub/' You can obviously boot other installations from here.

Problems occur if you want to delete this particular installation. As this system has overall Grub control (what I call 'lead Grub').. booting problems will occur if this overall boot control is removed. Other problems can occur due to differing Grub versions that a particular distro may use (e.g. different module versions etc.). I've seen it.. it happens!

My Method:
The method that I use starts in exactly the same way. The Grub variables are configured to point to and use a simple manually created 'grub.cfg' that is placed in the EFI partition.
The rest of Grub is also installed here, so Grub can load any modules, fonts etc. from here. The local Grub menu is then displayed. A selection here then passes control to the target system's 'grub.cfg'.. from where a normal boot continues. The important thing is that no installation has "lead Grub". Control is solely from the EFI partition.

Legacy boot:

Traditional Grub setup:
The bios reads the primary drive bootsector etc. The Grub first stage bootloader points to the Grub second stage files at /boot/grub/i386-pc. Grub now generates its Grub menu from the system's 'grub.cfg'. A choice here either starts the kernel load on the primary system or a secondary load on another filesystem. This has the same overall problems as the standard UEFI boot setup. 'Lead Grub' and the potential for incompatible Grub module use.

My Method:
The method that I use simply uses a separate partition in exactly the same way as with my UEFI method. Grub is installed here. An initial 'grub.cfg'
gives a choice of which installation to boot (identical to my UEFI method).
If I need more than 4 primary partitions then I'll just prepare the drive as GPT (this needs a 2MB empty partition at the beginning of the drive.. this holds the first stage Grub bootloader.).
Everything is totally separate from everything else. Again, the important thing is that no installation has "lead Grub". Control is solely from this small partition.

Both methods support the use of a mix of Legacy and UEFI installations on any particular machine.
You can also use this method to boot any 64-bit UEFI or legacy installation on a (64-bit) machine that has a 32-bit UEFI Bios.

Re: Your flashdrive boots.. If you happen to have a USB external drive (a great use for an old laptop HDD or SSD.. placed into a cheap caddy) then you could copy the **contents** of each Iso to a separate partition and boot each one simply. You'll find that this is much faster and certainly more reliable.
I use this method a great deal as not all Iso's can be loopback booted or Isobooted.

I personally much prefer using a simple booting mechanism on **every multiboot device** where everything is totally independent from everything else.

There is a lot of info here.. sorry. I just hope that I haven't confused you too much. If you would like more specific information on any of this, then just ask here.

Bodge99
Last edited by bodge99 on Thu May 13, 2021 2:15 pm, edited 1 time in total.
bodge99

Re: Where will esp go in this linux-on-macbook attempt ?

Post by bodge99 »

Hi,

Example EFI partition 'grub.cfg': Very easy to add installations here.

Code: Select all

menuentry "Devuan"{
    search --set=root --fs-uuid 2bbad497-b1f9-4614-9a21-c53104d24986
    set prefix=($root)/boot/grub
    configfile $prefix/grub.cfg
}

menuentry "Mint 20.1 Cinnamon"{
    search --set=root --fs-uuid 2ef6f6af-70b2-4031-b584-60446939c97f
    set prefix=($root)/boot/grub
    configfile $prefix/grub.cfg
}

menuentry "Slackware" { 
    search --set=root --fs-uuid e8ab7adf-e4b4-43cc-8c43-bbef6d53f6f1
    set prefix=($root)/boot/grub
    configfile $prefix/grub.cfg
#linux /boot/vmlinuz root=/dev/nvme0n1p8
#initrd /boot/initrd.gz
}
All you need is the filesystem UUID and the (relative) location of the installation's 'grub.cfg'.
You'll see the "remains" of the Slackware direct kernel boot..
artgrandi
Level 1
Level 1
Posts: 16
Joined: Wed Aug 26, 2020 4:31 pm

Re: Where will esp go in this linux-on-macbook attempt ?

Post by artgrandi »

@bodge99
Yes very much info indeed, but not confusing at all. I have read inumerable explanations of booting process but never one that was so complete and clear. Having stated that, it does not mean I can formulate a logic of it yet. I may have to ask you to clarify a few things, but I must re-read it and think what is it that I am missing. It may well be some term which i don' t interpret correctly or some assumption that is obvious to you but not me.

You've have offered so much useful info I must study that i haven't been able to start my attempt to install Slackware to the external SSD. But that is no problem it is a good thing that I will be much better informed when I finally do it.

Once again thank you so much! I will return as soon as I make some progress - practical or "theorethical" (/conceptual?). Or if I feel stuck :wink:
bodge99

Re: Where will esp go in this linux-on-macbook attempt ?

Post by bodge99 »

Hi,

Any questions.. just ask away.. It's never a problem answering queries.
I'm in the process of writing up how to create a fully independent external drive that is bootable on any 32 or 64-bit UEFI or Legacy boot computer.
You can even use this as an emergency boot for one or more installations **anywhere**, You just need to prepare a simple 'grub.cfg' in advance.
The techniques used here are equally applicable for use on any computer.. Legacy boot or UEFI.. It doesn't matter.

##### The first part of the writeup: ####

Universal Boot External Drive

Fully independent bootable external drive that will boot on any computer that has a 64-bit processor and a USB socket.
This will boot on any 32/64-bit UEFI or Legacy system that supports USB booting (i.e. virtually everything that has a USB socket).

Overview. This is a fully worked example that uses a 250 GB SSD/HDD drive that is fitted into a cheap external USB caddy.
A good way of putting that old laptop drive to good use.

The choice of type and size of the device used here is totally arbitrary. Just use what ever is available that is large enough for your selected purposes.

You can have any combination of the following with multiple instances of each, space permitting. Every instance here is totally independent from each other with a single small partition that has overall control. Partition size choice is totally up to you.

This drive will be prepared as described below:

Partition
Description:

Bootloader - Required for Legacy booting.
EFI - Used for UEFI and Legacy booting. Everything is controlled from here.
Install - Installation files are stored here.
System - A full Linux installation.
Archive - General purpose storage area for Linux use.
Archive-W - General purpose storage area for Windows use.
Swap - Used with memory constrained systems.

Bodge99
artgrandi
Level 1
Level 1
Posts: 16
Joined: Wed Aug 26, 2020 4:31 pm

Re: Where will esp go in this linux-on-macbook attempt ?

Post by artgrandi »

@bodge99

You are writting the document I have been looking for for years.

Things seem to be getting clear to me now. I have just realized that you had presented your method in the clearest form in the 2nd and 3rd paragraphs of your 1st post here. But I had been unable to recall it, peobably because I have not yet managed to organize all the new info in a logical system.

This last post has given me some form of - still unverified - "Aha!" experience. I have a feeling that you have pointed at an explanation of why my non-mac computers boot only LinuxMint while my macbook boots both LinuxMint and Manjaro. I suspect that macs have some form of boot management at the (EFI) firmware level that allows for the presentation of startup icons for any OS "properly" registered at some FAT32 partitions when opt/alt key is held during boot - prior to any grub take-over.. My (old) non-mac UEFI pc firmware seems to handle action directly to grub which I interpret as a sign that there is no boot manager in a "real sense" of being able to deal with more than one bootloader .

I think I understand your method now. Up to now it had been a series of undigested statements.

One question ar this point - I still haven't processed all your info so as to be able to present questions in any systematic way - is to confirm whether I should copy and not move all the conten in /"EFI/" to "/EFI-backup/". I can not figure out the difference in outcome.

Another loose question is if it is any problem that Manjaro's "booting stuff" is "properly" placed at another FAT32 partition - I will explain the quoted expressions, if too misty. The reason for this is that after I had installed Mint, I read somewhere that EFI partition should be large enough in case of multiboot devices. As my EFI partition has 200MB and I did not want to start all over again to create a larger "real" EFI partition I created a larger FAT32, this time at the end of the disk. I would "correct" this once I feel I am done with all "testing" and then restart only once (hopefully) for a final installation
bodge99

Re: Where will esp go in this linux-on-macbook attempt ?

Post by bodge99 »

Hi.

You're getting it.. just ask for clarification if you need it.

In reverse order.. (because the latter query is quicker to answer).

Within the EFI **partition**, everything is contained within an EFI **directory**.
The full path of this (as seen from a running system) is '/boot/efi/EFI' .
If you look at your 'fstab' ( cat /etc/fstab ) you'll see that the EFI partition is mounted to '/boot/efi' . i.e. the mountpoint (just a directory that is used to mount a filesystem to). This exists on your system partition.

The top level directory on the EFI partition is /EFI and everything exists in subdirectories of this.
Now, any Grub updates will alter or add files here which will alter the boot procedure. The updaters assume that the currently running system (i.e. the one which is actually updating Grub at this time) has 'lead Grub'. A fair assumption, as most folk use a single OS with a standard configuration.
As is, a reboot now will cause this system to boot **by default**. This causes some folk much confusion.. as any other installation's 'grub.cfg's haven't been changed. Each system's Grub menu is different.. This is no problem if you are aware of the cause.

EDIT: A potentially serious problem here is this: If you happen to have a kernel update on the 'lead Grub' system then any other multibooted system here won't show this change within its own 'grub.cfg' **until** you have run the local version of 'grub-update'. If the previous 'lead Grub's system's kernel **has been removed** then this boot will fail. oops!
My boot method won't fix this, but the danger of a boot fail is drastically reduced.. You'll soon get out of the habit of booting Artix from Mint's Grub menu, for example. In fact I don't particularly care **what** any local 'grub.cfg' actually displays.. The EFI partition's 'grub.cfg' controls everything.
If I want to boot Mint, I select it here.. control passes to Mint's 'grub.cfg'.. Just pressing 'Enter' here causes the Mint to boot normally. You could set the Grub timeout to zero here to remove this trivial step if you wanted to.

Example. Assume that you have Mint and Artix Linux in a standard dual boot configuration.
You've installed Mint first and Artix a week later. After Artix has been installed, it will have 'lead Grub'. All fine & dandy.
A week later, you run Mint and find that you have 20 updates to install.. If it so happens that a Grub update is performed, then it will reconfigure the boot procedure and **become 'lead Grub'**. Everything still boots.. but slightly differently.
The overriding reason why this occurs to due to Grub having to comply with the UEFI spec. I'll cover this in my next post.

Back to '/EFI' and '/EFI-backup': The changes made to the contents of '/EFI' after a Grub update are actually easy to "unpick"..
I don't bother, It's easier and quicker to just delete '/EFI' (and its contents) and copy '/EFI-backup' over as '/EFI'.
If you forget to do this (or cannot, due to time constraints etc.) and you find that your computer boots to a 'lead Grub' system then you just perform the task now.. and you're back to "controlled booting".

I'll continue in the next post..

Bodge99
Last edited by bodge99 on Fri May 14, 2021 7:31 am, edited 1 time in total.
Post Reply