Jump to content











Photo
- - - - -

Grub4dos for UEFI for beginners [Questions and Help topic]

grub4dos for uefi beginners

  • Please log in to reply
115 replies to this topic

#76 Atari800XL

Atari800XL

    Frequent Member

  • Advanced user
  • 192 posts
  •  
    Netherlands

Posted 28 August 2021 - 02:51 PM

The EFI folder has nothing to do with it.

Tell that to Alacran :-) Just kidding, we're all just trying stuff here.

 

Now for the difference between vol 0 and vol 1:

Volume 0 is the selected volume.

Partition 2
Type    : ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
Hidden  : No
Required: No
Attrib  : 0X8000000000000000
Offset in Bytes: 105906176

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
* Volume 0         Windows      NTFS   Partition     40 GB  Healthy

Volume 1 is the selected volume.

Partition 3
Type    : ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
Hidden  : No
Required: No
Attrib  : 0000000000000000
Offset in Bytes: 43055579136

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
* Volume 1     C   Windows      NTFS   Partition     40 GB  Healthy

Hey, I notice a difference in the "Attrib" value!!!

So once again: What is this telling us? And are there ways of changing this Attribute ourselves?

 



#77 Atari800XL

Atari800XL

    Frequent Member

  • Advanced user
  • 192 posts
  •  
    Netherlands

Posted 28 August 2021 - 02:56 PM

Found this, but not sure yet how to issue the "gpt" command...

 

https://docs.microso...ws-commands/gpt

gpt attributes=<n>

Parameters
Parameters
Parameter 	Description
attributes=<n> 	Specifies the value for the attribute that you want to apply to the partition with focus. The gpt attribute field is a 64-bit field that contains two subfields. The higher field is interpreted only in the context of the partition ID, while the lower field is common to all partition IDs. Accepted values include:

    0x0000000000000001 - Specifies that the partition is required by the computer to function properly.
    0x8000000000000000 - Specifies that the partition won't receive a drive letter by default when the disk is moved to another computer, or when the disk is seen for the first time by a computer.
    0x4000000000000000 - Hides a partition's volume so it's not detected by the mount manager.
    0x2000000000000000 - Specifies that the partition is a shadow copy of another partition.
    0x1000000000000000 - Specifies that the partition is read-only. This attribute prevents the volume from being written to.

EDIT: Aah, it's just a Diskpart command... Testing right now!



#78 Atari800XL

Atari800XL

    Frequent Member

  • Advanced user
  • 192 posts
  •  
    Netherlands

Posted 28 August 2021 - 03:06 PM

Diskpart "gpt" command:

On basic GUID partition table (GPT) disks, assigns the GPT attribute(s) to
the partition with focus.

Syntax:  GPT ATTRIBUTES=<N>

ATTRIBUTES=<N>

The hexadecimal value indicating the attributes to apply to the
partition with focus. The GPT attribute field is a 64-bit field
that contains two subfields. The higher field is interpreted
only in the context of a particular partition type GUID, while
the lower field is common to all partition types.

The following attribute can be set on any partition:

0x0000000000000001 marks the partition as required. This
indicates to all disk management utilities that the partition
should not be deleted. The EFI System partition contains only
those binaries necessary to start the operating system. This
makes it easy for original equipment manufacturer (OEM) or
operating system-specific binaries to be placed in other
partitions.

For basic data partitions, the following attributes are defined:

0x8000000000000000
GPT_BASIC_DATA_ATTRIBUTE_NO_DRIVE_LETTER
Prevents the partition from having a drive
letter automatically assigned. By default, each partition is
assigned a new drive letter and a volume GUID pathname. Both
the drive letter and the volume GUID pathname can be used to
open the volume using Win32 APIs. Setting this attribute ensures
that when a disk is moved to a new computer, a new drive letter
will not be automatically generated. Instead, the user can
manually assign drive letters.

0x4000000000000000
GPT_BASIC_DATA_ATTRIBUTE_HIDDEN
Defines the partition's volume as hidden.
Setting this attribute specifies that the volume will not be
assigned a drive letter or a volume GUID pathname. Both
the drive letter and the volume GUID pathname can be used to
open the volume using Win32 APIs. A hidden partition's
volume is not reported by Win32 APIs such as FindFirstVolume
and FindNextVolume.

0x2000000000000000
GPT_BASIC_DATA_ATTRIBUTE_SHADOW_COPY
Defines the partition as being a Volume Snapshot Service
shadow copy volume. Fle system filters use this flag to
prevent the filter from attaching to the volume.

0x1000000000000000
GPT_BASIC_DATA_ATTRIBUTE_READ_ONLY
Prevents the volume from being written to.

Other attributes may be added by Microsoft at any time.

GPT partition attributes give additional information about the use of the
partition.

A basic GPT partition must be selected for this operation to succeed.

Caution:

    Changing the GPT attributes might cause your basic data volumes to
    fail to be assigned drive letters, or prevent the file system from
    mounting. Unless you are an original equipment manufacturer (OEM)
    or an IT professional experienced with GPT disks, do not change GPT
    attributes.

Example:

    GPT ATTRIBUTES=0x8000000000000000
    GPT ATTRIBUTES=0xF000000000000001

 



#79 wimb

wimb

    Platinum Member

  • Developer
  • 3756 posts
  • Interests:Boot and Install from USB
  •  
    Netherlands

Posted 28 August 2021 - 03:25 PM

Hey, I notice a difference in the "Attrib" value!!!

So once again: What is this telling us? And are there ways of changing this Attribute ourselves?

 

How about in DISKPART on selected volume simply using assign Or remove ?



#80 Atari800XL

Atari800XL

    Frequent Member

  • Advanced user
  • 192 posts
  •  
    Netherlands

Posted 28 August 2021 - 03:36 PM

Yes, using assign and remove are the best options for now.

The "0x8..." attribute looks promising, as that might make sure the partitions that I use for OS partitions, are not assigned unwanted letters in PE. If none of the 4 partitions get an (unwanted) PE drive letter, I can assign letter C: to the one I need (in PE) and apply the OS from there.

 

I did some quick tests with the "hidden" attribute, but this doesn't seem to do much, at least not in a running Windows: the other OS partitions don't get a drive letter, but they're not as "hidden" as in an MBR disk, this means it's very much possible to assign a letter in disk management.



#81 Atari800XL

Atari800XL

    Frequent Member

  • Advanced user
  • 192 posts
  •  
    Netherlands

Posted 28 August 2021 - 04:58 PM

Yep, knowing about the "0x8..." attribute helps a lot:

"0x8000000000000000 GPT_BASIC_DATA_ATTRIBUTE_NO_DRIVE_LETTER
Prevents the partition from having a drive letter automatically assigned."

 

This helps me in two ways already:

(1) In PE, none of the OS partitions will have a letter, so I can assign C: to the partition I want, then format the partition if needed, and apply OS

(2) I can retry all the previous things I did (creating partitions, EFI folders, Terabyte Image backups/ restores, etc.) and make sure which of these changes the attribute, so I can make sure to issue the DISKPART "GPT ATTRIBUTES=0x8000000000000000" after.

 

Thank you, Wimb!



#82 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 29 August 2021 - 10:21 AM

Sure, let's call these "news":

http://reboot.pro/in...=22544&p=219129

 

Coincidentally, that one is post #42 in this thread.

 

:duff:

Wonko


  • Atari800XL likes this

#83 Atari800XL

Atari800XL

    Frequent Member

  • Advanced user
  • 192 posts
  •  
    Netherlands

Posted 29 August 2021 - 10:45 AM

I knew you were going to say that :-)

I didn't forget about your earlier post, I was just confused by the Diskpart "Detail Partition" report view.

EDIT: And all the talk of "flipping bits" had me believe it was too difficult for me. Little did I know it was just a simple Diskpart command :-)

 

I'm making some nice progress with my tests now, I know which steps to avoid and which check to remember (like resetting the 0x8... after manually assigning drive C: etc. etc.)

I will post some sort of report when I'm done.



#84 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 29 August 2021 - 01:06 PM

Actually it is far from being "simple".

 

Chances of getting 15 0's right is minimal. :ph34r:

 

The good MS guys that invented this (the diskpart GPT command syntax) are clearly completely nuts, much more than the previous MS guys (that invented this stupid "bit-wise" setting in attributes in the lower - please read as higher - part of a 64 bit field, which after all is divided in two subfields, so it is actually two 32 bit fields, one "MS reserved" and one for the rest of the world).

 

Pure madness.

 

:duff:

Wonko


  • Atari800XL likes this

#85 Atari800XL

Atari800XL

    Frequent Member

  • Advanced user
  • 192 posts
  •  
    Netherlands

Posted 29 August 2021 - 01:44 PM

I don't want to write a huge post (yet) with all my notes and findings, but one simple and easy thing I have found is this:

 

- As I've said before, I want to try using several OS partitions (4 on this test laptop) without a standard Microsoft BCD menu

(I want Grub4UEFI instead, which is working thanks to earlier tips on using a UEFI NTFS driver, and also placing EFI folders on the OS partitions, not only on EFI partition).

 

When one of the four is started, only one of the OS partitions should have a drive letter (C:), the others don't have a letter (they don't have to actually be "hidden", like they were on an old Grub4Dos MBR disk).

 

As long as the partitions have the "0x8..." attribute, no letter is automatically handed out, either when booting the OS, or when booting PE (which I use for new OS applies).

 

It turns out the most important thing that turns off the "0x8..." attribute is... :

**Manually** assigning a drive letter. When you actually *boot* the OS, the system partition *also* gets the C: letter, but the fact of booting the OS does *not* remove the "0x8..." attribute, only manually setting the drive letter (for example, in PE) removes the attribute.

 

So a very simple way to avoid this is: Let's say we installed Windows on the first OS partition before, and now we want to install another version (from PE) on the second OS partition: We assign letter C: to a different partition (oops, the "0x8..." attr is removed), and immediately after, we set it again:

 

(p1=EFI, p2=First OS, p3=Second OS, p4=Third OS, p5=Fourth OS)

sel dis 0
sel par 3
assign letter=c
gpt attributes=0x8000000000000000

This seems to work fine.

 

All reboots after this (either to OS or to PE) don't mess up the drive assignments with automatically handed out letters.



#86 wimb

wimb

    Platinum Member

  • Developer
  • 3756 posts
  • Interests:Boot and Install from USB
  •  
    Netherlands

Posted 29 August 2021 - 02:11 PM

More Info on GPT Attributes PARTITION_INFORMATION_GPT - Win32 apps | Microsoft Docs

 

See it as Changing Bytes instead of Flipping Bits makes it easier to understand and to use may be ...

 

When the byte at offset 0x37 from the beginning of GPT entry is changed from hex 00 into 80 then the partition does not get drive letter anymore.

 

In that case the byte just before the Partition Name has changed into the euro sign €   :)

 

gpt | Microsoft Docs  and  GUID Partition Table - Wikipedia  and  Tiny Hexer - MBR_Backup - reboot.pro

 

Releases · wimbrts/MBR_Backup (github.com)

 

GPT_Attributes_2021-08-29_160623.jpg

 

EDIT: 

GPT Attribute byte at offset 0x37 in GPT entry has for GPT partition value 0x40 = @ = Hidden and value 0x80 = € = No Drive Letter


  • Atari800XL likes this

#87 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 29 August 2021 - 03:53 PM

If you see it as "hex dump", otherwise I don't know. :unsure:

 

To me it is easier to imagine (and write)  2^63 than either

hex 0x8000000000000000

or

dec 9,223,372,036,854,775,808

 

Anyway the Diskpart Attributes command could well have been analogous to the good ol' ATTRIB command:

+R Read only

+D Drive Letter assigned

+H Hidden

+S Shadow copy

+Q ReQuired :w00t:

 

:duff:

Wonko



#88 wimb

wimb

    Platinum Member

  • Developer
  • 3756 posts
  • Interests:Boot and Install from USB
  •  
    Netherlands

Posted 30 August 2021 - 06:01 AM

Your proposal for the gpt attributes command is indeed a lot more user friendly and the Microsoft present command is really very bad designed.

 

For me it helps a lot to see and to know what byte in the GUID Partition Table is changing to make a partition not getting drive letter anymore.



#89 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 30 August 2021 - 07:21 AM

Your proposal for the gpt attributes command is indeed a lot more user friendly and the Microsoft present command is really very bad designed.

 

For me it helps a lot to see and to know what byte in the GUID Partition Table is changing to make a partition not getting drive letter anymore.

Yep, but - being a set of bits - they are "combined" in hex, 80 is only one of the possible values.

Let's take the (stupid) 64 bit field (in a hex dump).

00000000 00000080

of this, first half is not relevant, and we can ignore it, leaving us with only one 32 bit (or four byte) field:

00000080

of this, 3 bytes are not relevant and we remain with:

80

actually, since only 4 bits are used, we can further reduce it to a nibble (and later re-add a trailing 0 to represent it as a byte):

8=0x8 which in binary is 1000 (higher bit set to 1 all other ones 0)

when/if that volume is hidden, the second highest bit is set:

0100=4=0x4

but if the volume is both hidden and "no drive letter assigned, it becomes:

1100=12=0xC

 

Visualizing as binary has its use:





N H S R
o i h e
D d a a
r d d d
i e o o
v n w n
e | | l
L | | y
| | | |
0 0 0 0 0x00 "." No attributes set
0 0 0 1 0x10 "." Read Only
0 0 1 0 0x20 " " Shadow Copy
0 0 1 1 0x30 "0" Shadow Copy+Read Only
0 1 0 0 0x40 "@" Hidden
0 1 0 1 0x50 "P" Hidden+Read Only
0 1 1 0 0x60 "`" Hidden+Shadow Copy
0 1 1 1 0x70 "p" Hidden+Shadow Copy+Read Only
1 0 0 0 0x80 "€" NDL
1 0 0 1 0x90 " " NDL+Read Only
1 0 1 0 0xA0 " " NDL+Shadow Copy
1 0 1 1 0xB0 "°" NDL+Shadow Copy+Read Only
1 1 0 0 0xC0 "À" NDL+Hidden
1 1 0 1 0xD0 "Ð" NDL+Hidden+Read Only
1 1 1 0 0xE0 "à" NDL+Hidden+Shadow Copy
1 1 1 1 0xF0 "ð" NDL+Hidden+Shadow Copy+Read Only


Though most probably not all combinations are possible/make sense.

 

:duff:

Wonko



#90 wimb

wimb

    Platinum Member

  • Developer
  • 3756 posts
  • Interests:Boot and Install from USB
  •  
    Netherlands

Posted 30 August 2021 - 07:33 AM

actually, since only 4 bits are used, we can further reduce it to a nibble (and later re-add a trailing 0 to represent it as a byte):

8=0x8 which in binary is 1000 (higher byte set to 1 all other ones 0)

when/if that volume is hidden, the second highest byte is set:

0100=4=0x4

but if the volume is both hidden and "no drive letter assigned, it becomes:

1100=12=0xC

 

Yes but it should be bit is set instead of byte is set

 

Only @ = Hidden and € = No Drive Letter are easy enough to be useful to remember and to recognise.

For forensic purposes it might be useful to know the position and function of this GPT Attribute byte.



#91 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 30 August 2021 - 08:00 AM

Fixed bit/byte :)

 

:duff:

Wonko



#92 alacran

alacran

    Platinum Member

  • .script developer
  • 2710 posts
  •  
    Mexico

Posted 30 August 2021 - 08:13 AM

Starting with G4E version 2021-07-23 we have available the command parttype added by a1ve.

 

I'm not sure if it is only usefull to give us info of current partition attributes (type) or if it is also capable to edit its attibutes.

 

The G4E help do not give many info about its use, only says:

 

parttype [PART] [TYPE]

 

Please see attached picture.

 

alacran

Attached Thumbnails

  • parttype.png


#93 alacran

alacran

    Platinum Member

  • .script developer
  • 2710 posts
  •  
    Mexico

Posted 30 August 2021 - 08:38 AM

Just asked for more info related to parttype command on GitHub Discussions, see: https://github.com/c...discussions/327

 

alacran



#94 wimb

wimb

    Platinum Member

  • Developer
  • 3756 posts
  • Interests:Boot and Install from USB
  •  
    Netherlands

Posted 30 August 2021 - 08:45 AM

Grub4efi parttype command gives info on FileSystem Byte in the partition table of the MBR which is hex 07 = NTFS and 0C = FAT32 for MBR partitioned disk.

 

In case of GPT partitioning all partititions give the value hex EE from the protective MBR, so it does not give the GUID or so and is not very useful.

 

Info on Partition Types



#95 alacran

alacran

    Platinum Member

  • .script developer
  • 2710 posts
  •  
    Mexico

Posted 30 August 2021 - 09:13 AM

Yes, you are right, just tested it in the test machine, so it gives only the type of the partition.

 

BootIce goes further as it let us see the partition type and also change it, I have used it on MBR to change just formated USB flash partitions (Fat-32) 0B to 0C, also have the option to hide unhide a selected partition (which is Atari800XL concern), and both work fine, but haven't tested it on GPT.

 

alacran



#96 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 30 August 2021 - 10:02 AM

Yes, you are right, just tested it in the test machine, so it gives only the type of the partition.

 

BottIce goes further as it let us see the partition type and also change it, I have used it on MBR to change just formated USB flash partitions (Fat-32) 0B to 0C, also have the option to hide unhide a selected partition (which is Atari800XL concern), and both work fine, but haven't tested it on GPT.

 

alacran

 

Oh. noes,. NOT AGAIN! :frusty:  

 

On MBR things are easy.

 

On GPT they are (senselessly) complex.

 

By now *anything* can be done on MBR, including changing MBR partition type with grub4dos (no need to use bootice) or set it hidden, I don't see how grub4efi should be different (on MBR).

 

But here we are talking of GPT (and NOT of MBR).

 

It is trivial to write a grub4dos batch file to get the info from GPT partition table entries.

 

Editing them is a little less trivial because in their infinite wisdom in the GPT partition table the good guys that "designed" the specs added a checksum.

 

The checksum should be a "simple" CRC32 which should be as well implementable in grub4dos batch, but I haven't looked at this in detail.

 

:duff:

Wonko



#97 alacran

alacran

    Platinum Member

  • .script developer
  • 2710 posts
  •  
    Mexico

Posted 30 August 2021 - 10:43 AM

JFYI

 

To run some quick tests, on my 7x64 OS, I deleted a USB flash MBR, convert it to GPT and created a NTFS partition too, of course the EFI partition dos not get a drive letter, and only the NTFS partition gets a drive letter, but BootIce can assing a drive letter to the EFI partition and also remove it, the NTFS partition can be hide and unhide with just a click, I think there is not anything easier than that, BootIce works from the running OS or a PE and is also capable to work in command line.

 

alacran

Attached Thumbnails

  • ESP.png
  • NTFS.png


#98 alacran

alacran

    Platinum Member

  • .script developer
  • 2710 posts
  •  
    Mexico

Posted 30 August 2021 - 11:46 AM

Ran same test but this time booting from PE on UEFI (from internal HD) and same thing any partition on the USB stick can get a drive letter or can be hidden and unhidden, rebooted and changes are permanent, finally I made all partitions hidden an after reboot on PE in UEFI, when plugged the USB stick I was asked to format the device, ignored it and after unhide only the NTFS partition it got a letter.

 

So it seems to me BootIce may work fine for Atari800XL needs, when booting from PE.

 

alacran



#99 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 30 August 2021 - 01:51 PM

Sure :), but here we are talking of grub4dos (for UEFI).

 

The WHOLE point of grub4dos (and of grub4dos for UEFI) revolves around:
1) booting to grub4dos (or grub4dos for UEFI)
2) do whatever changes are needed on the system partitions/volumes/etc.

3) CONTINUE booting to whatever you actually intended to boot

 

Booting to a PE (or to a Linux or DOS or *whatever* else for that matters) is INSTEAD:

1) booting to *something else*
2) do whatever changes are needed on the system partitions/volumes/etc.

3) REBOOT and boot to the whatever you actually intended to boot

 

On BIOS/MBR the "plain" grub4dos can:

1) show AND change the partition type (parttype command)
2) show AND change the partition status, hidden/unhidden (hide and unhide commands)

 

Now grub4EFI can also do the same, but on MBR only.

 

Before or later the same capabilities may be added to grub4EFI (for GPT) partitions by the developers, within the limits of the specifications and of the (stupid) flags MS implemented (that - I have to underline - are ONLY valid for "Basic Data Partitions").

 

:duff:

Wonko



#100 Atari800XL

Atari800XL

    Frequent Member

  • Advanced user
  • 192 posts
  •  
    Netherlands

Posted 30 August 2021 - 03:29 PM

Thank you for your reactions. I couldn't keep up today, had to put in some hours of actual work :-)

 

When I first asked about "hiding" OS partitions from each other in a (UEFI) multiboot scenario like the one I tested, Wonko suggested simply removing the drive letters. This was actually a very good idea, it's always good to keep things simple if possible. So I tested that method, and after learning how to set the "0x8..." attribute, I finally figured out how to prevent letters being "messed up", now I know how to check what was going on, I believe I mentioned that earlier.

 

I will probably try out actually *hiding* GPT partitions as well, but my first (quick) tests didn't yet show a real advantage to this "hide" attribute, it seems to me the partitions are still visible in Disk Management and Diskpart, so to me that doesn't seem be a whole lot more useful than simple "having no drive letter". I',m sure some of you will know more about this.

 

Alacran, thanks for the Bootice recommendation, in fact I use Bootice a lot already, both in command-line mode and GUI mode (it even has its own hotkey in my Autohotkey shell). On MBR multiboot OS installs, I use the silent command-line mode to re-install Grub4Dos after a new OS setup (in my Postinstall system). It never failed me.

 

I think the reason for my first idea being to somehow hide the (GPT) partitions was because this was so easy to do with the "old" Grub4DOS on MBR. But once again: simply removing the letters (and knowing why they might reappear or not) is a workable solution.

 

I did manage to test some simple .ahk code yesterday, that will later be included in my Apply scripts (I never use standard Windows setup from ISO, I think I used that once, after that only WinNTSetup and later on my own PE scripts).

As long as the "OS" partitions (p2, p3, p4, p5) retain their "0x8..." attribute, in PE there should only be two drive letters issued: C for the first Data partition, D: for the second one (*). If this is not the case, I can always display a message like "The drive letter assignments are not as expected, please check this manually with Disk Management".

 

(*) In that scenarion, it's pretty easy to [from a script, of course] rename D to E, then C to D, after that letter C is free to give to one of the OS partitions, of course reset "0x8..." attribute (**), then apply OS. Works great!!!

 

(**) That was the whole point :-)







Also tagged with one or more of these keywords: grub4dos for uefi, beginners

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users