Jump to content











Photo
- - - - -

Grub4dos "isohybrided"


  • Please log in to reply
55 replies to this topic

#51 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 16 May 2021 - 03:14 PM

That example appears incomplete since the purpose is to find the 1st available partition number on that system for the partnew command. Can it be presented as recursive? Also, due to ISO files added and removed from a disk often due to updates etc, this new partition should be removed somehow automagically upon exiting the booted ISO or even as last Grub4DOS command in the same menu item. Otherwise many of such partitions can be later created at different times, and its unclear what if the user would want to create a REAL new partition on the same drive with Diskpart - what would happen? Its not unheard of even for USB thumbs that are by now exceeding 64-128GB limit.

The example maybe appears incomplete to you, but it does exactly what it is intended to do (and nothing more and nothing less, besides nothing else), i.e. check that the 4th (last) slot in a MBR partition table has a Partition ID of 0x00, and ONLY IF this Partition ID is 0x00, proceed to modify it, either re-setting it to all 00's or writiong a fake partition for a .iso file.

 

Unless it has changed in the (stupid) Windows 10, Diskpart will consider a slot in the partition table with Partition ID of 0x00 as empty or a non-partition, surely Windows as an OS does this.

 

Quick recap:

1) under windows a partition entry with partition ID 0x00 is a non-partition

2) under Linux a partition entry with partition ID 0x00 is a partition IF the LBA and/or CHS data is valid

 

By running any number of times:

partnew (hd0,3) 0 0 0

and/or

partnew (hd0,3) 0 /<whatever.iso>

in  whatever order/sequence you like, the partition ID will always remain 0x00, and as such it will be ignored by windows and mapped by Linux (only if the last command is the second one, otherwise it will be a completely empty entry).

 

In any case you need to explicitly chainload that partition at boot time (via grub4dos or similar) as it is -by design - not an active one if you wanto to boot from the .iso mapped to it.

 

:duff:

Wonko



#52 zammibro

zammibro

    Member

  • Members
  • 59 posts
  •  
    United States

Posted 16 May 2021 - 03:50 PM

 it will be ignored by windows and mapped by Linux (only if the last command is the second one, otherwise it will be a completely empty entry).

 

That sounds a lot better to me, but... what if:

 

a) there are already 4 real partitions created on the target drive with data in each? Some may be even on an extended volume, if more than 4 exist;

e) there is no free space available on the target drive despite it has only 3 or less partitions?

c) when running the above command next time, the 4th slot will already be occupied by the previous created fake partition, so the command and the ISO boot will fail?

d) when servicing the drive with a partitioning tool like Gparted or Paragon HDM, will they see the fake partition, and how they will handle their usual servicing tasks, such as creating new volumes, changing their size etc?

 

Given the multitude of what ifs, its better to explicitly remove such fake partition at the very end of the ISO boot process or as the last G4D menu section command if possible, because it has no real data anyway and is no longer needed(?). Or its needed until the ISO exits?


Edited by zammibro, 16 May 2021 - 04:16 PM.


#53 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 16 May 2021 - 04:01 PM

Your hard drive always boots to grub4dos, so simply add a line into the menu.lst file to clear partition 4 on every boot.
The partnew command will overwrite the existing entry, that is why we test to make sure the partition is 'empty' before using the partnew command.

#54 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 16 May 2021 - 04:17 PM

There is a single pre-requisite which is:

1) one of the four partition entry slots in the MBR needs to be NOT used.

 

Any number of logical volumes inside extended still occupy 1 single slot in the MBR partition tables, or - if you prefer - you can have at most in a MBR:

a. 4 primary partition entries

b. 3 primary partition entries + 1 extended (that can contain any number of logical volumes)

 

If you don't have this pre-requisite you cannot use this method (actually you can but it is complex/tricky as it involves a backup and further modifications of the MBR partition table)

 

NO disk space is used in this setup besides (obviously) the size of the .iso, the SAME extents occupied by the .iso inside the filesystem you copied it to (hence the need for the .iso to be contiguous) are mapped as a partition.

 

The Partition ID is, becomes, remains, has been, was, will be always 0x00, i.e. the check is conceived in such a way that no matter if the rest of the partition entry is 00's, valid data or invalid data, if the ID is 0x00 ( i.e. it is NOT anything different from 0x00 while any and all "real" partitions will have a different from 0x00 ID) the command will either:
1) rewrite the same data that is already written

or

2) write new (valid) data

to that partition slot

 

How Gparted or other tools might see it may vary, but the whole point is that BEFORE "servicing" the volume you can easily remove the fake partition entry (as it will be anyway recreated on-the-fly next time you boot to the grub4dos and choose the related entry), i.e. you boot to grub4dos and run

partnew (hd0,3) 0 0 0

thus completely deleting the entry.

BTW if - during the "servicing" you move/resize the partition where the .iso is saved, the (old) fake partition data may become invalid (and this is yet another reason to re-write it at boot time with "fresh" or current extents data)  

 

You can use

cat --hex --skip=446 (hd0)0+1

in grub4dos to quickly check the partition table or, if you want to check the status of the fourth entry only

cat --hex --skip=494 (hd0)0+1

or optionally use the little mbrview here:

http://reboot.pro/to...l-for-grub4dos/

 

 

:duff:

Wonko



#55 zammibro

zammibro

    Member

  • Members
  • 59 posts
  •  
    United States

Posted 16 May 2021 - 05:16 PM

boot to grub4dos and run

partnew (hd0,3) 0 0 0

thus completely deleting the entry.

 

How to run it automagically at Grub4DOS startup and /or exit, i.e. clicking Reboot menu option?


Edited by zammibro, 16 May 2021 - 05:18 PM.


#56 steve6375

steve6375

    Platinum Member

  • Developer
  • 7566 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films
  •  
    United Kingdom

Posted 16 May 2021 - 05:22 PM

You simply put these  lines at the top of the menu.lst file

# make empty table entry in 4th position in ptn table
parttype (hd0,3) | set check=
set check=%check:~-5,4%
if %check%==0x00 partnew (hd0,3) 0 0 0


#57 Magnetic

Magnetic
  • Members
  • 0 posts
  •  
    Azerbaijan

Posted 10 January 2023 - 01:56 PM

post to be deleted by moderator


Edited by Magnetic, 10 January 2023 - 02:44 PM.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users