Jump to content











Photo
- - - - -

IF EXIST or FIND with folder names instead of file names?


  • Please log in to reply
56 replies to this topic

#26 NetFanTom

NetFanTom

    Frequent Member

  • .script developer
  • 117 posts
  •  
    Germany

Posted 31 January 2012 - 03:15 PM

I hope someone can help me here.

Is it possible to grub4dos command "parttype (hd0,
4) 0x00" for a logical partition on a USB flash drive to run?

I've noticed problems with logical partitions.
Please see here:

http://reboot.pro/16274/

For an answer I am grateful.


Regards,
NetFanTom :)

#27 steve6375

steve6375

    Platinum Member

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

Posted 31 January 2012 - 03:18 PM

What does parttype (hd0,4) return?

#28 NetFanTom

NetFanTom

    Frequent Member

  • .script developer
  • 117 posts
  •  
    Germany

Posted 31 January 2012 - 03:32 PM

partition (hd0,0) is 0x07 primary
partition (hd0,1) is 0x0B primary
partition (hd0,2) is 0x07 primary
If partition (hd0,3) is a extented partition (0x0F)
and
(hd0,4) is a 0x07 logical partition

and i run

parttype (hd0,0) 0x00
parttype (hd0,1) 0x00
parttype (hd0,2) 0x00
parttype (hd0,4) 0x00

the partitioning an the USB Stick is crashed - i have no logical partition and the other partitions are not OK:

If i use only primary partitions then all works fine,

Regards,

#29 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 31 January 2012 - 03:43 PM

the partitioning an the USB Stick is crashed - i have no logical partition and the other partitions are not OK:

If i use only primary partitions then all works fine,


What happens if you run:
parttype (hd0,0) 0x00
parttype (hd0,1) 0x00
parttype (hd0,2) 0x00
parttype (hd0,4) 0x00
parttype (hd0,4) 0x07
?


Do you get back (only) the logical partition? :unsure:

What are the "other partitions? (like hd0,5 - hd0,6, etc.)?

What happens when you do:

parttype (hd0,0) 0x00
parttype (hd0,1) 0x00
parttype (hd0,2) 0x00
parttype (hd0,4) 0x17
?
What happens if you do:

parttype (hd0,0) 0x00
parttype (hd0,1) 0x00
parttype (hd0,2) 0x00
parttype (hd0,4) 0x12
?

WHAT :w00t: has this to do with IF EXIST/FIND for file or folder?


:cheers:
Wonko

#30 NetFanTom

NetFanTom

    Frequent Member

  • .script developer
  • 117 posts
  •  
    Germany

Posted 31 January 2012 - 05:20 PM

Hello! :D

WHAT :w00t: has this to do with IF EXIST/FIND for file or folder?


Answer: nothing :ouch:

I hope i get the answer here.

If I use parttype (hd0,X) 0x00 for a logical partition, the partion structure will destroyed.

PTEDIT32.exe makes this job properly.

Regards

#31 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 31 January 2012 - 05:51 PM

Answer: nothing :ouch:

I hope i get the answer here.

If you could perform the EXACT tests suggested and answer EXACTLY to the other asked questions, maybe it would give you more possibiliies to get an answer (here or somewhere else).


:cheers:
Wonko

#32 NetFanTom

NetFanTom

    Frequent Member

  • .script developer
  • 117 posts
  •  
    Germany

Posted 31 January 2012 - 06:29 PM

Sorry, i don't need parttype (hd0,4) 0x12 or parttype (hd0,4) 0x17 (means that not hide?).

I need parttype (hd0,4) 0x00.

In the future I need parttype (hd0,4) 0x07 or parttype (hd0,4) 0x0B for logical partitions, but as far as I am not yet come, because the partition structure was destroyed.
(Please see http://reboot.pro/16274/ )

Maybe someone can give me an answer to a simple question.
I say again.
Is it possible to grub4dos command "parttype (hd0,4) 0x00" for a logical partition on a USB flash drive to run?

:cheers:

#33 steve6375

steve6375

    Platinum Member

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

Posted 31 January 2012 - 06:46 PM

Using parttype (hd0,4) 0 just sets the partition type in the extended partition table to 0. The extended partition entry (5) is still present.

If you execute parttype (hd0,4) 0 and then edit the extended sector and put the 07 ptn type byte back then all is well. You can use the PTEDIT32 EPBR button when on the Extended primary partition to view the Extended ptn table and then just put the byte (07 or 0B) back in the table.

Your question is not so 'simple'. what do you mean by
'to run'
- to run what? boot - recognized by Windows, usable with EPT, ????
Can you explain what you are trying to do? In what way is the parttype (hd0,4) command not working properly?

#34 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 31 January 2012 - 07:01 PM

Sorry, i don't need parttype (hd0,4) 0x12 or parttype (hd0,4) 0x17 (means that not hide?).
I need parttype (hd0,4) 0x00.


Well, I don't need either, I was only trying to help you, suggesting you a few tests in order to try and understand what the behaviour was, it's your need, not mine.

:cheers:
Wonko

#35 steve6375

steve6375

    Platinum Member

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

Posted 31 January 2012 - 07:06 PM

Well, I don't need either, I was only trying to help you, suggesting you a few tests in order to try and understand what the behaviour was, it's your need, not mine.
Wonko

The problem is that setting the PTYPE to 17 or 27 does not hide the partition from Windows, so you cannot access any ptn which follows it.

e.g. ptn table
17 - Windows shows this ptn only in Explorer
1B
7
17

but if you use
0
B - Windows shows this ptn in Explorer
0
0

So we need to get the ptn to show up in Windows and copy files to it, we need to set the PTYPE to 0 (unless you can think of another way...?).
A further complication is that if you run diskpart on that drive which has 0'd ptn entries, it will erase all the ptn entries from all the PTYPE 0 tables!

#36 tinybit

tinybit

    Gold Member

  • Developer
  • 1175 posts
  •  
    China

Posted 31 January 2012 - 08:43 PM

in disk_io.c, the partition type of 00 is disabled:

#if 1

	    /* disable partition id 00. */

	    if (((int)pc_slice_no) >= PC_SLICE_MAX - 1			  /* if it is a logical partition */

		    && *next_partition_type == PC_SLICE_TYPE_NONE)	  /* ignore the partition with id=00. */

			    goto next_entry;

#else

	    /* enable partition id 00. */

#endif


That means, when you set the partition type to 00, grub4dos would simply ignore the existence of the partition, and you cannot access it again in grub4dos.

you may recompile grub4dos(just change "#if 1" to "#if 0" in the above code), and then partition type 00 will be recognized.

Don't set partition type to 00. Many softwares (including some or all of Microsoft's) will function abnormally when type 00 encountered.

#37 tinybit

tinybit

    Gold Member

  • Developer
  • 1175 posts
  •  
    China

Posted 31 January 2012 - 09:06 PM

The problem is that setting the PTYPE to 17 or 27 does not hide the partition from Windows, so you cannot access any ptn which follows it.

e.g. ptn table
17 - Windows shows this ptn only in Explorer
1B
7
17

but if you use
0
B - Windows shows this ptn in Explorer
0
0

So we need to get the ptn to show up in Windows and copy files to it, we need to set the PTYPE to 0 (unless you can think of another way...?).
A further complication is that if you run diskpart on that drive which has 0'd ptn entries, it will erase all the ptn entries from all the PTYPE 0 tables!


How about setting the ID to "0x12 compaq diagnostic" or "0xDE dell utility", or even "Linux" or "Linux swap" ?

#38 steve6375

steve6375

    Platinum Member

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

Posted 31 January 2012 - 09:18 PM

How about setting the ID to "0x12 compaq diagnostic" or "0xDE dell utility", or even "Linux" or "Linux swap" ?

Yep - Windows likes all of these, 12, DE, 83, FF! It needs to be 0 to be ignored by Windows.

#39 tinybit

tinybit

    Gold Member

  • Developer
  • 1175 posts
  •  
    China

Posted 01 February 2012 - 12:59 AM

Yep - Windows likes all of these, 12, DE, 83, FF! It needs to be 0 to be ignored by Windows.


OK, I will suggest chenall enable parttype 00 next time.

#40 NetFanTom

NetFanTom

    Frequent Member

  • .script developer
  • 117 posts
  •  
    Germany

Posted 01 February 2012 - 08:57 AM

Sorry for the late reply, but I was busy.

Is it possible to grub4dos command "parttype (hd0,4) 0x00" for a logical partition on a USB flash drive to run?

means:
Is it possible to run the grub4dos command "part type (hd0, 4) 0x00" for a logical partition on a USB stick?

Thanks to Steve6375, he understood me exactly. :jump:

Windows will recognize only the parttype 0x00 partition as unused.

If you are renaming 0x07 to 0x17, 0x12, DE, 83, FF, or from
0x01 to 0xFF, then Windows will recognize this as an 0x07 partition anyway.

You can use the PTEDIT32 EPBR button when on the Extended primary partition to view the Extended ptn table and then just put the byte (07 or 0B) back in the table.

I know PTEDIT32 doing this job, I need, however, that grub4dos performs this function properly.

@tinybit:

OK, I will suggest chenall enable parttype 00 next time.

Thanks, that would also allow partitioning of logical partitions on USB flash drives. :fine:
http://reboot.pro/16274/

Best regards,
NetFanTom
:cheers:

#41 steve6375

steve6375

    Platinum Member

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

Posted 01 February 2012 - 09:41 AM

@NetFanTom
Why do you need to disable the other partitions anyway? What problems does having them enabled cause?

#42 steve6375

steve6375

    Platinum Member

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

Posted 01 February 2012 - 10:03 AM

Chenall has made a new version which recognises parttype 0
http://code.google.c.../downloads/list
I haven't tested it yet.

#43 NetFanTom

NetFanTom

    Frequent Member

  • .script developer
  • 117 posts
  •  
    Germany

Posted 01 February 2012 - 10:14 AM

Why do you need to disable the other partitions anyway? What problems does having them enabled cause?

The previous partitions should not be recognized so that Windows auto mounts the current partition on USB flash drive as a hdd drive (e.g. F:).

7 - Windows shows this ptn in Explorer
B
7
7
----------------------------
0
B - Windows shows this ptn in Explorer
7
7
----------------------------

0
0
7 - Windows shows this ptn in Explorer
7
----------------------------
0
0
0
7 - Windows shows this ptn in Explorer

#44 steve6375

steve6375

    Platinum Member

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

Posted 01 February 2012 - 10:35 AM

sorry, I meant why do you need to have grub4dos disable the partitions using parttype (hd0,x) 0 ???

#45 NetFanTom

NetFanTom

    Frequent Member

  • .script developer
  • 117 posts
  •  
    Germany

Posted 01 February 2012 - 11:48 AM

Within the Superstition_Stick project http://reboot.pro/16274/
the Boot order is:

Grub4Dos sequence MBR
grldr (on a not 0x00 Partition)
menu.lst
...

if i take the third partition
e.g. MultiPE
title MultiPE
parttype (hd0,0) 0x00
parttype (hd0,1) 0x00
rootnoverify (hd0,2)
chainloader /bootmgr

MultiPE starts
and auto mounts the third partition as drive with a letter on the USB flash drive.

Regarding

Chenall has made a new version which recognises parttype 0

Many Thanks to chenall, tinybit and the others.
I will test it.

#46 sambul61

sambul61

    Gold Member

  • Advanced user
  • 1568 posts
  •  
    American Samoa

Posted 28 February 2012 - 05:21 PM

I wonder if it makes sense to expend iftitle command functionality? Now it appears to search if an image is present on disks that is listed in G4D Menu, which is fine. But how to make updating image collection on a drive a modular (more structured, seamless, incremental) experience for a novice overwhelmed with new info multiboot requires? For example, what if instead of having a lengthy Grub4DOS menu, make a command like iftitle to amend a menu section supplied with a new image?

Lets say, G4D is installed on a USB Thumb with some generic initial menu crafted by a user, or a default menu. When a user needs to add a new image to boot, s/he copies a folder to the Thumb that contains the source image, appropriate G4D menu section, and in some Linux cases a few extracted from the image files. When Grub4DOS is launched, iftitle or similar command scans predefined disks or folders, and if finds a new folder with an image not yet listed in the common Menu, it auto adds corresponding menu section to the common G4D menu thus making it ready to boot? As well, to remove the image, the user just needs to delete the folder, and next launch G4D will remove its section from the common menu.

It will allow more users to get familiar with G4D, since all they would need to do is find or ask on the forum about a G4D menu section that works with their image and possibly what extra files to extract, and the magic of multiboot will show its friendly face. Just a suggestion to think how to make multiboot and G4D more accessible for novices, and some novice developers not familiar with multiboot tools and concepts. :)

#47 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 28 February 2012 - 06:31 PM

Now it appears to search if an ISO is present on disks that is listed in G4D Menu, which is fine.

I don't get it. :unsure:

Right now the iftitle command is "as generic as it can be" nothing actually directly related to .iso:

iftitle [command] title

where command can be any valid grub4dos command and title is a "normal" grub4dos title.
If command succeeds then title is displayed, if command fails then title is not displayed.

Is your post connected to this :dubbio::
http://reboot.pro/16381/page__st__5


:cheers:
Wonko

#48 steve6375

steve6375

    Platinum Member

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

Posted 28 February 2012 - 06:57 PM

Well you could run a generic batch file which looks for any file ending in .lst (or say .mnu?) in all folders on the drive which are grub4dos menu files. Each menu file would cause a menu entry to be created and added by the batch file to a new virtual menu.lst created in memory and then this menu.lst at (md)/menu.lst which has been created dynamically could be loaded (configfile (md)/menu.lst) and then list each menu that was present on the drive.

So the user just adds 2 files to his multiboot drive - 1. the payload file (iso or img or ima or whatever) and 2. it's menu.mnu file - e.g. Install Windows 7.mnu, to any folder they liked (same folder as payload file) and it would automatically be listed on boot.

e.g. the final menu that appears to a user would be in memory (bd)/menu.lst and consist of entries like this...


title Install Windows 7
root (bd)/afolder/another
configfile (bd)/afolder/another/Install Windows 7.mnu


Naturally, each mnu file will need to be prepared by someone (?) for each iso or payload file and it must expect to find the payload file at the current root. Does this sound like something you want?

#49 sambul61

sambul61

    Gold Member

  • Advanced user
  • 1568 posts
  •  
    American Samoa

Posted 28 February 2012 - 08:56 PM

Yes, its not that I personally want it :), but I think if implemented and polished into G4D, it would open the doors to multiboot to more novices, including developers, because some appear confused by the volume they need to learn, and try to avoid it altogether. So, yes, its one way to implement the idea. Would be nice to test something like this...clear from bugs...possibly implement as standard G4D feature. Not sure, why it needs to be in Root only, since a separate folder (in root) per image would be simpler to add and remove without much confusion and mixing with other files for a novice.

As to preparing a .mnu file or section, its a lot easier, because a user would initially have just one or two images in mind, so a forum search or new question in a post would give him the right menu section in most cases. Nice way to try multiboot and G4D, since its advantages aren't obvious for novices, who never tried - some say its just another "favorite pet". :)

#50 steve6375

steve6375

    Platinum Member

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

Posted 28 February 2012 - 09:14 PM

Well we could have a new topic called 'mnu files for sambul's Multiboot disk' and rebooter's could post their mnu donations on it. So a standard post would be a URL to the download for the 'payload' file plus the mnu as an attachment. So we could build up a library of mnu files (instead of users having to add a menu entry to their menu.lst).

Instructions for a user would be:
1. Create a multiboot basic drive following instructions (e.g. use RMPrepUSB to prepare a drive, install grub4dos, add special menu.lst)
2. Download your ISO (or whatever and copy to your drive)
3. Download mnu file and copy it to the same folder

It would be a lot easier to code if all the mnu files were put in the same folder (and therefore also most of the payload files).

Some payloads will need special instructions (like extract folder xyz from the iso and copy it to xyz on the USB drive for some 'special' ISOs that won't boot from an ISO file!)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users