search order for the /porteus folder

Technical issues/questions of an intermediate or advanced nature.
rych
Warlord
Warlord
Posts: 662
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

search order for the /porteus folder

Post#1 by rych » 24 May 2024, 10:00

Suppose I have multiple /porteus (and /porteux) folders on different partitions and disks

I'd like the booting process to find the right one in the following order:

1. All (adjacent) partitions on the current drive -- the drive which we're booting from

2. All partitions on other plugged in drives in whatever order

Is that the case already for both Porteus and PorteuX?

What I DON'T want is the search order to be simply: /mnt/sda*, /mnt/sdb*, /mnt/sdc* etc. :)

porteux
Samurai
Samurai
Posts: 187
Joined: 12 Mar 2023, 22:10
Distribution: PorteuX

search order for the /porteus folder

Post#2 by porteux » 24 May 2024, 12:29

On PorteuX if you run the installer for Linux it will create an UUID in the storage initrd, and that will be used during boot time to try to boot from this unit first (including all partitions).

I couldn't find any other way to identify the booting unit during initrd time, which is the moment we look for the base modules. If you find a better approach, I'll be happy to use it. :)

rych
Warlord
Warlord
Posts: 662
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

search order for the /porteus folder

Post#3 by rych » 24 May 2024, 12:53

porteux wrote:
24 May 2024, 12:29
if you run the installer
Thanks :) I don't run any installers though. In my case a simple grub loader in the /EFI folder loads vmlinuz/initrd passing a from-label cheatcode. But even without that cheatcode the /porteus folder is somehow found anyway! The question is how. I'm going to have to look into initrd myself to find out. I'm preparing for multiple /porteus folders scenario and need to know the search logic. I don't want to use any UUID, LABEL etc., nor any other "from" cheatcode.

User avatar
Ed_P
Contributor
Contributor
Posts: 8437
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

search order for the /porteus folder

Post#4 by Ed_P » 24 May 2024, 17:04

I use grub2 to boot my porteus/x USB systems and in the grub2 boot menu I use Search to find a file on the drive and set Root to the drive's address.

Code: Select all

set bootmgr=/EFI/boot/bootx64.efi          #grubx64.efi    # bootx64.efi

set bootdrv=$root
search -f $bootmgr --set=root
echo bootmgr: $bootmgr
sleep -v -i 3
if [ $root != $bootdrv ]; then
   chainloader $bootmgr
else
   echo "----------------------------------------"
   echo USB drive NOT found.
   echo
   sleep -v -i 10
fi
set root=$bootdrv

-or-

set porteus_parms="volume=33 reboot=cold extramod=/Modules"  
set bootdrv=$root
search -f /boot/syslinux/vmlinuz --set=root
if [ $root != $bootdrv ]; then
   linux  /boot/syslinux/vmlinuz $porteus_parms
   initrd /boot/syslinux/initrd.xz
else
   echo "----------------------------------------"
   echo USB drive NOT found.
   echo
   sleep -v -i 10
fi
set root=$bootdrv
}
I've also used:

search -f /edsdrv.txt --set=root
:) :good:
Ed

porteux
Samurai
Samurai
Posts: 187
Joined: 12 Mar 2023, 22:10
Distribution: PorteuX

search order for the /porteus folder

Post#5 by porteux » 24 May 2024, 22:33

rych wrote:
24 May 2024, 12:53
I don't want to use any UUID, LABEL etc., nor any other "from" cheatcode.
I'm afraid there's no generic/agnostic way to do that.

During initrd time there's no way to know which unit it was loaded from. Putting UUID either inside initrd or in porteu[s/x].cfg seems to be the only way. If you find another way, that would be genious and we would be forever grateful, really :)

rych
Warlord
Warlord
Posts: 662
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

search order for the /porteus folder

Post#6 by rych » 25 May 2024, 13:05

porteux wrote:
24 May 2024, 22:33
During initrd time there's no way to know which unit it was loaded from
Anyway, it is the linuxrc that finds the /porteus folder (aka the location of the porteus-...cfg file and the location of the /porteus/changes) even without any "from" cheatcode. The question is how it chooses the right /porteus folder when there are more than one of those!?

Could you help me with my experiment below? My porteus USB is always recognized as /dev/sdb, but I now have an identical grub loader on my /dev/sda drive which happens to be the system static SSD disk. At boot, in the UEFI menu I choose to boot the grub from /mnt/sda1/EFI. It "successfully" finds the porteus folder on /mnt/sdb2! Actually, it's hard to make it forget that location!

I don't want to unplug the USB yet. Instead I want the initrd to start finding a new, fresh porteus on /mnt/sda2. A simple /mnt2/sda2/porteus folder with the porteus-...cfg file, with properly populated /mnt/sda2/porteus/base, and an empty /mnt/sda2/porteus/changes still aren't enough: initrd even though loaded off /mnt/sda1 is still finding and using the /mnt/sdb2/porteus! Why?! What's so special about that copy of /porteus :) Maybe initrd favours USB drives over static disks? Or does it favor "b" over "a"?

porteux
Samurai
Samurai
Posts: 187
Joined: 12 Mar 2023, 22:10
Distribution: PorteuX

search order for the /porteus folder

Post#7 by porteux » 25 May 2024, 21:04

rych wrote:
25 May 2024, 13:05
The question is how it chooses the right /porteus folder when there are more than one of those!?
It lists the available units using ls /mnt | tac and search in this order. In this case tac will revert the lines that normal ls outputs, and because portable units are usually in the end, by using tac we are most likely booting over portable units, which makes sense given the portable characteristics of the system.

Of course you can change that to be in any order you want, but as I said, there's no way to determine which unit initrd is booting from.

rych
Warlord
Warlord
Posts: 662
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

search order for the /porteus folder

Post#8 by rych » 26 May 2024, 11:14

OK then. We're going to have to help initrd find the right /porteus. After all we know the right one. In my case different /porteus folders live on differently Labelled partitions. So, even if my frugal sda installation will be a copy of my sdb (USB) installation, there will be at least one difference. Let's make /mnt/sda1/local.cfg and /mnt/sdb1/local.cfg with respectively:

Code: Select all

set PorteusLabel=PorteuSX
set PorteuXLabel=PorteuSX
and

Code: Select all

set PorteusLabel=PorteusUSB
set PorteuXLabel=PorteuXUSB
then inside both grub.cfg we have the same lines, for example:

Code: Select all

#get local PorteusLabel, PorteuXLabel
source /local.cfg
menuentry 'Porteus 1920x1080' {
	linux  /boot/vmlinuz from=LABEL:$PorteusLabel changes=EXIT:/porteus login=root load=1920x1080 fsck
	initrd /boot/initrd.zst
}
So no need for either initrd or grub to introspect where they're loading from: the user would have edited the local.cfg with the right Labels in each installation

tome
Contributor
Contributor
Posts: 678
Joined: 26 Jun 2013, 14:03
Distribution: x64 Openbox
Location: Russia is causing the immense damage to humanity
Contact:

search order for the /porteus folder

Post#9 by tome » 28 May 2024, 18:55

Thomas M added from=ask cheatcode, see:
https://github.com/Tomas-M/linux-live/c ... c1ba9b47ff
You have mind and feelings. Be wise and clever.

Post Reply