Uefi and porteus 3.0

Post tutorials, HOWTO's and other useful resources here.
User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Uefi and porteus 3.0

Post#1 by Ed_P » 09 Jun 2014, 13:44

FYI & FWIW

It is possible to create a single partition USB flash drive with Porteus on it that boots on both GPT and non-GPT systems. And the rEFInd menu boots the Windows 8 system on the hard drive.
Ed

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: Uefi and porteus 3.0

Post#2 by brokenman » 10 Jun 2014, 13:54

The term 'GPT system' does not make sense to me. GPT is a disk format with a partition table very different to the traditional ones. A GPT disk does not contain a real mother boot record. They are two different animals. From the title I imagine you are talking about UEFI systems, which require a GPT disk to boot from. The GPT disk uses a GUID in place of an MBR and therefore NON-UEFI systems (that require a real MBR) will not boot from it. The is the reason many laptops have a hybrid UEFI/BIOS system. So that you can switch between UEFI (containing firmware in motherboard that looks for GPT partitions) and CMS (NON UEFI) that looks for traditional disk formats with a real MBR.

So the answer is no.

http://msdn.microsoft.com/en-us/library ... 85%29.aspx
How do i become super user?
Wear your underpants on the outside and put on a cape.

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

Re: Uefi and porteus 3.0

Post#3 by Ed_P » 10 Jun 2014, 15:03

brokenman wrote:The term 'GPT system' does not make sense to me.
Oh. I got the term from reading the description of the GDISK f parameter. http://www.rodsbooks.com/gdisk/gdisk.html GDISK being the utility you use in your uefi-usb installer script.
So the answer is no.
?? There was no question.

It is possible to create a single partition flash drive that boots in UEFI and non-UEFI systems. I've done it.
Ed

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: Uefi and porteus 3.0

Post#4 by brokenman » 10 Jun 2014, 22:48

So you gonna share or just tell us it is possible?

Remember you need to start from a blank USB, nothing on it including any MBR or GPT. The F option needs an existing MBR to load. Why are you posting useless generalized statements in the development section? I will remove this thread tomorrow if there is nothing valid to offer.
How do i become super user?
Wear your underpants on the outside and put on a cape.

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

Uefi and porteus 3.0

Post#5 by Ed_P » 11 Jun 2014, 05:58

brokenman wrote:So you gonna share or just tell us it is possible?
Well, I don't know. You didn't say please. :D

Yes, of course I'm going to share. But I needed to do some real life things first. Good grief.

I started by nuking the flash drive using your instructions previously. I tried using a script:

Code: Select all

#!/bin/sh
# https://forum.porteus.org/viewtopic.php?f=81&t=3227&start=15#p25341

if [ `whoami` != "root" ]; then
  ktsuss "$0"
  exit
fi

umount /mnt/sdb1
parted -s /dev/sdb mklabel msdos 
but usually ended up doing it manually.

I then partitioned and formatted the drive using GParted. A script to do the nuking and partitioning automatically would be nice and I may use your latest posting to do that in the future. Flash Drive with Ext4 and Windows-compatible filesystem

The next part was a different script.

Code: Select all

#!/bin/sh
## https://forum.porteus.org/viewtopic.php?f=81&t=3227#p25266 
## https://forum.porteus.org/viewtopic.php?f=81&t=3227&p=25308#p25308 

if [ `whoami` != "root" ]; then
  ktsuss "$0"
  exit
fi

## Run GParted to partition and format the USB drive.

if [ ! -f /mnt/sdb1/USB_INSTALLATION.txt ]; then
  echo
  echo Copying porteus ISO files and folders to the USB drive
  echo

  mkdir /mnt/sdb1/boot
  mkdir /mnt/sdb1/porteus
  cp -r /mnt/sda5/porteus/i486files/boot/*               /mnt/sdb1/boot/
  cp -r /mnt/sda5/porteus/i486files/porteussave.dat      /mnt/sdb1/
  cp -r /mnt/sda5/porteus/i486files/porteus/*            /mnt/sdb1/porteus/
  cp -r /mnt/sda5/porteus/i486files/USB_INSTALLATION.txt /mnt/sdb1/

  read -n1 -r -p "Press space to continue..." key
fi

## Run the Porteus installer
echo Installing Porteus to the USB drive

cd /mnt/sdb1/boot
sh Porteus-installer-for-Linux.com

## Unmount the USB drive

if [ -d /mnt/sdb1 ]; then
  umount /dev/sdb1
  echo
fi

read -n1 -r -p "Press space to continue..." key

## Run the modified UEFI Porteus installer
echo Running the modified UEFI Porteus installer
#curl -L  https://www.dropbox.com/s/w1i7b2p4viinnq8/porteus-uefi-usb-installer-v3.0.sh -o porteus-uefi-usb-installer-v3.0.sh
cd /home/guest/
sh porteus-uefi-usb-installer-v3.X.sh
echo
echo Need to tweak the UUID and changes=EXIT codes in
echo the porteus.cfg file in /mnt/sdb1/boot/syslinux/ and   
echo the porteus.conf file in /mnt/sdb1/EFI/BOOT/. 
echo   
This took a while to develop due to my lack of bash knowledge and wasn't exactly what I had planned originally. I knew I needed a piece of your uefi-usb-installer for the rEFInd code but I ended up using it for the gdisk part also, again due to my inexperience.

After initializing the flash drive I copy the Porteus ISO files from a i486 install to the empty flash drive and run the Porteus Linux installer. This creates the MBR, boot menu and Porteus install on the flash drive. I then execute a modified version of your uefi-usb installer which creates the GUID Partition Table (GPT), the rEFInd boot menu for the installed system.

I then manually tweak the two boot menus to add the flash drive's UUID and the changes=EXIT cheatcode which points to the same save.dat file in both boot menus. If I was smarter I would have the script do that. :oops:

The modifications to your Porteus-uefi-usb-installer-v3.0.sh are:

Code: Select all

-rep 282
pink "THIS SCRIPT MAY DESTROY ALL DATA ON THE TARGET DEVICE!!"
-rep 287
read -p "`gettext " Would you like to continue? [Yes/No]"`" -n 1 -r -s && echo
-ins 310
if [ ! -f /mnt/sdb1/USB_INSTALLATION.txt ]; then 
  EDSWAY=N
-rep 313,314
echo "`gettext "Your removable device may be formatted into 2 partitions"`"
echo "`gettext "This is used by some UEFI systems. The first partition"`"
-ins 413
fi
-ins 516

## ==========
## Load MBR and build GPT from it
## ----------
OPT_LOADMBR="f"
build_gpt_fm_mbr() {
$GDISK_BIN $TARG_DISK  << EOF
r
$OPT_LOADMBR
Y
m
t    
ef00
i
w
Y
EOF
}

-ins 517
echo Wipe
set -x
if [ -f /mnt/sdb1/USB_INSTALLATION.txt ]; then 
  EDSWAY=Y
  echo 
  echo "'gettext "Creating GPT partition table on:"'"|tee -a $LOG
  echo "/dev/$BLOCK" | tee -a $LOG
  build_gpt_fm_mbr 2>/dev/null 1>&2
fi

if [ ! -f /mnt/sdb1/USB_INSTALLATION.txt ]; then 
  EDSWAY=N
-ins 553
fi
set +x
-ins 1792
if [ $EDSWAY != 'Y' ]; then
-ins 1798
fi
It's the best I could do without a goto command. The questions for partition sizes and etc are all still there though not used.

Does the process work, yup. Is it perfect, nope. It's taken me about a week to get this far and it's the 1st development I've done on this small screen. It takes me about 2 hrs before my eyes can see distance clearly after working long on it.
Remember you need to start from a blank USB, nothing on it including any MBR or GPT.
Yes, I know.
The F option needs an existing MBR to load.
Yes, I know.

And Yes I know the purpose of the gdisk's f option and it's limitations. I wouldn't recommend this approach on a multi-partitioned hard drive but for a single partitioned flash drive it's perfect. And in that the whole "March 2014 (version 0.8.10), gdisk should be considered beta software" statement the fact that it works at all is wonderful.
Why are you posting useless generalized statements in the development section? I will remove this thread tomorrow if there is nothing valid to offer.
Whatever floats your boat.


= edit =

The /boot/syslinux/porteus.cfg change:

Code: Select all

LABEL razor
MENU LABEL Graphics mode (Razor)
KERNEL vmlinuz
APPEND initrd=initrd.xz changes=EXIT:UUID:AFA2-C646/porteussave.dat 
The /EFI/BOOT/porteus.conf changes:

Code: Select all

menuentry "Porteus-v3.0" {
	icon EFI/BOOT/myicons/os_porteus.icns
	loader /EFI/Porteus-v3.0/vmlinuz
	initrd /EFI/Porteus-v3.0/initrd.xz
	options "from=UUID:AFA2-C646 changes=EXIT:UUID:AFA2-C646/porteussave.dat"
	submenuentry "Boot to text mode" {
		add_options "3"
    }
    submenuentry "Boot always fresh mode" {
		loader /EFI/Porteus-v3.0/vmlinuz
		initrd /EFI/Porteus-v3.0/initrd.xz
		options "from=UUID:AFA2-C646 nomagic base_only norootcopy"	
	}
   	submenuentry "Boot to copy2ram mode" {
		add_options "copy2ram"
    }
    submenuentry "Boot to PXE mode" {
		loader /EFI/Porteus-v3.0/vmlinuz
		initrd /EFI/Porteus-v3.0/initrd.xz
		options "from=UUID:AFA2-C646 pxe"	
	}
}
Last edited by Ed_P on 12 Jun 2014, 00:10, edited 2 times in total.
Ed

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: Uefi and porteus 3.0

Post#6 by brokenman » 11 Jun 2014, 10:32

Now that's more like it. Excellent work! :good:

You've experimented a lot and come up with a solution of sorts that works for you.
How do i become super user?
Wear your underpants on the outside and put on a cape.

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: Uefi and porteus 3.0

Post#7 by brokenman » 11 Jun 2014, 10:39

I have moved the thread to the HOWTO section since it is a tutorial and not a feature for integration into Porteus.
How do i become super user?
Wear your underpants on the outside and put on a cape.

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

Uefi and porteus 3.0

Post#8 by Ed_P » 11 Jun 2014, 14:54

brokenman wrote:not a feature for integration into Porteus.
Oh I don't know. You could incorporate it's functions into the Porteus Installer which is a part of Porteus. ;)
Ed

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: Uefi and porteus 3.0

Post#9 by brokenman » 11 Jun 2014, 15:36

One fat partition for the installation of Porteus on UEFI systems? Not going to happen. Sorry.

Your technique works for you and thats great. Your UEFI firmware supports a BIOS compatible setup. Many do not. The setup you are using is certainly not recommended, in fact it is just a risk to the operating system and I am not willing to take the flashback by releasing an installer like that. Read this, read it well and understand why.

https://www.happyassassin.net/2014/01/2 ... work-then/
How do i become super user?
Wear your underpants on the outside and put on a cape.

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

Re: Uefi and porteus 3.0

Post#10 by Ed_P » 11 Jun 2014, 17:00

No, no, no, not for hard drives, for USB flash drives. Apparently the Porteus Installer doesn't do USB flash drives installs. Sorry I thought it did. I thought I read a posting about installing Porteus to a flash drive using a built in function. Apparently I misread it or don't remember it correctly. :oops:

BTW I copied my hard drive Porteus system's modules folder and save.dat file to the flash drive and now when it boots it has everything my normal system has.
Your UEFI firmware supports a BIOS compatible setup.
No, I boot the flash drive on two different systems. My Windows 7 system is not UEFI and my wife's Windows 8 system is UEFI and I get a different Porteus boot menu depending on which machine I boot it on.

Have you created a Windows 8 Rescue flash drive on your wife's machine yet?
Read this, read it well and understand why.
A very interesting link. Needless to say it will take me a while to read thru it but I like what I have read so far.
Ed

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: Uefi and porteus 3.0

Post#11 by brokenman » 11 Jun 2014, 23:05

No, no, no, not for hard drives, for USB flash drives.
Yes I understood for flash drives. One single FAT partition for Porteus? Not even windows does that for itself ... for good reason.

I have windows 8.1 myself. I created the rescue DVD's in case I have a problem. I honestly have no interest in creating a rescue USB from within windows for myself. I can run the windows rescue installer without that. Anything I create should be done from within Porteus if it is to be included in Porteus. A how to or write up on how to do it (using windows and then Porteus) would probably be appreciated by many, but my interest lies more in native solutions. I've looked at what the windows rescue USB contains but recreating this from within porteus is a different story.

No, I boot the flash drive on two different systems. My Windows 7 system is not UEFI and my wife's Windows 8 system is UEFI and I get a different Porteus boot menu depending on which machine I boot it on
Good luck with that. To save you some reading here is what the website says about it:
I really can’t recommend strongly enough that you do not attempt to mix UEFI-native and BIOS-compatible booting of permanently-installed operating systems on the same computer, and especially not on the same disk. It is a terrible terrible idea and will cause you heartache and pain. If you decide to do it, don’t come crying to me.
This may or may not be your situation, but is important to note in any case. I would extend this warning to mixing UEFI and BIOS booting on the same 'media'.
How do i become super user?
Wear your underpants on the outside and put on a cape.

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

Re: Uefi and porteus 3.0

Post#12 by Ed_P » 12 Jun 2014, 03:21

brokenman wrote:No, no, no, not for hard drives, for USB flash drives.
Yes I understood for flash drives. One single FAT partition for Porteus? Not even windows does that for itself ... for good reason.
Actually i have run Windows PE systems on single FAT partitions for many years. And not as ISOs even.
I have windows 8.1 myself. I created the rescue DVD's in case I have a problem. I honestly have no interest in creating a rescue USB from within windows for myself.
Good to know. The point of creating a Windows 8 rescue USB drive was to show you that Microsoft has no problem creating a flash drive with both MBR and GPT partition tables. The rescue flash drive is bootable by UEFI systems and readable my non-UEFI Windows systems and has a single partition. It could serve you as a real example of how to create a cross platform USB flash drive. While your Porteus-uefi-usb-installer script creates a bootable UEFI flash drive the drive is unreadable in non-UEFI Windows 7 systems because it lacks the MBR partition table.
I've looked at what the windows rescue USB contains but recreating this from within porteus is a different story.
The next time you look, look at it's MBR record.
To save you some reading here is what the website says about it:
I really can’t recommend strongly enough that you do not attempt to mix UEFI-native and BIOS-compatible booting of permanently-installed operating systems on the same computer, and especially not on the same disk. It is a terrible terrible idea and will cause you heartache and pain. If you decide to do it, don’t come crying to me.
This may or may not be your situation, but is important to note in any case. I would extend this warning to mixing UEFI and BIOS booting on the same 'media'.
I appreciate the warning but I don't agree with the concern when referring to removable media. (Maybe naive, maybe stupid). The MBR and GPT tables are separate entities, in separate locations on the drive, so long as the partitions they point to are stable and in sync they should coexist peacefully. Flash drives IMO are fairly stable, so the partitions should be stable also. Especially with Windows not recognizing anything other than the 1st one on removable drives. Flash drives, unlike hard drives, are also somewhat disposable IMO. Why else would one risk using beta software on them. :wink:

GDisk has an n option that creates "a protective MBR" maybe that would work for your uefi-usb script.
Ed

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: Uefi and porteus 3.0

Post#13 by brokenman » 12 Jun 2014, 04:10

I appreciate the warning but I don't agree with the concern when referring to removable media. (Maybe naive, maybe stupid).
Take it or leave it. It comes from empirical testing and I tend to trust the experts there. USB is far less stable than fixed internal drives and in terms of partition structure how are they different at all?

I own a hybrid UEFI/CMS laptop and have experienced first hand, the wrath of windows. Now windows 8.1 gives you around 2 seconds to hit a key before fixing what it considers to be a bad drive or corrupt bootloader. I use windows on a daily basis and have done for decades. Spent many years repairing and building windows machines.

Here is what happened tonight when booting a protective MBR in CMS mode.
https://onedrive.live.com/redir?resid=7 ... oto%2c.jpg
GDisk has an n option that creates "a protective MBR" maybe that would work for your uefi-usb script.
That's exactly it! This MBR is not designed to be used. The only reason the first 512 bytes are left alone is so that you don't hose your GPT when running a BIOS compatible bootloader. It is not designed for being used, hence the name.

It would be nice to have a portable solution between UEFI and BIOS computers but I am not really willing to create something that is unstable and a danger to the installed OS, and release it to others. As you said, Flash drives, unlike hard drives, are also somewhat disposable IMO, so I would recommend getting one for UEFI systems and one for BIOS systems. You can even share your changes between the two, or just use them to boot over a network into your main OS.

In short, a single FAT partition for an operating system either on fixed or removable media is just a bad idea for so many reasons IMHO. A Windows PE disk is not what I would call an operating system by any means. It is literally a "Preinstallation Environment" disk to install a main OS. I remember using floppy disks to do the same thing. The FAT file system is almost as old as me. Let it die gracefullly.
How do i become super user?
Wear your underpants on the outside and put on a cape.

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

Re: Uefi and porteus 3.0

Post#14 by Ed_P » 13 Jun 2014, 05:42

brokenman wrote: USB is far less stable than fixed internal drives and in terms of partition structure how are they different at all?
In Microsoft's world they are quite different. USB partition table very short, single entry. Internal drive many partitions, some primary, some logical, some extended.
Here is what happened tonight when booting a protective MBR in CMS mode.
https://onedrive.live.com/redir?resid=7 ... oto%2c.jpg
GDisk has an n option that creates "a protective MBR" maybe that would work for your uefi-usb script.
That's exactly it! This MBR is not designed to be used. The only reason the first 512 bytes are left alone is so that you don't hose your GPT when running a BIOS compatible bootloader. It is not designed for being used, hence the name.
Have you mentioned this to the creator of GDisk? While I have not tried "a protective MBR" maybe it's designed to support non-UEFI access to a GPT partition rather than booting the partition. But this is a conversation you need to have with the creator of GDisk. It is beta software.
It would be nice to have a portable solution between UEFI and BIOS computers but I am not really willing to create something that is unstable and a danger to the installed OS, and release it to others.
While I certainly support a concern for not damaging the installed OS I don't relate that to working on a USB flash drive. The running OS is on a different drive than the drive being worked on and you should be able to determine that in a script I would think. Maybe I'm wrong?
I would recommend getting one for UEFI systems and one for BIOS systems. You can even share your changes between the two, or just use them to boot over a network into your main OS.
Boot a machine over a network!! I would have no idea how to do that and suspect the average Porteus user configuring a USB flash drive wouldn't either. And sharing changes between two USB drives would be: awkward, extra work, annoying, etc.
In short, a single FAT partition for an operating system either on fixed or removable media is just a bad idea for so many reasons IMHO.
How about a drive that is read/writable by ever OS, portable, and bootable also? I agree with your fixed media concern, just not your removable media concern.
A Windows PE disk is not what I would call an operating system by any means. It is literally a "Preinstallation Environment" disk to install a main OS.
Oh, it can be so much more than that. Check out the old UBCD4Win system for what can be done with a PE system.
http://www.ubcd4win.com/contents.htm
I remember using floppy disks to do the same thing. The FAT file system is almost as old as me. Let it die gracefullly.
Image I remember floppy disks that were actually floppy. I also remember punched cards. :oops:

If you prefer creating a multi-booting USB UEFI/non-UEFI drive formatted as NTFS to run Porteus that could prove interesting.

I assume you know how Porteus-installer-for-Linux.com creates it's MBR, add that code to your uefi-usb script and a gdisk f function and you will have a universal booting Porteus USB drive.

And I am not totally against Porteus on a 2nd partition, so long as it is bootable on UEFI and non-UEFI systems, but the 1st partition needs to be formatted as something Windows can access. But I think the multi-partition concept opens the door for the MBR and GPT tables getting out of sync.
Ed

User avatar
brokenman
Site Admin
Site Admin
Posts: 6105
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v4 all desktops
Location: Brazil

Re: Uefi and porteus 3.0

Post#15 by brokenman » 13 Jun 2014, 13:18

Have you mentioned this to the creator of GDisk?
No need. HE already understands what it is, which is why he called it for what it is. a PROTECTIVE mbr.
In Microsoft's world they are quite different.
They are no different in ANY world. BTW, we are not in MS world here. If they were superior, manufacturers would be using them internally.
While I certainly support a concern for not damaging the installed OS I don't relate that to working on a USB flash drive.
But you do. You clearly mentioned in your original post that it boots the operating system from the HD did you not?

This conversation is going nowhere. You clearly don't comprehend the implications yet continue to argue them. I showed you empirical evidence of what can happen (my screenshot) which you ignored. I won't be creating this, feel free to release it yourself. I'm done. :wall:
How do i become super user?
Wear your underpants on the outside and put on a cape.

Post Reply