Jump to content











Photo
- - - - -

Effective way to determine Linux's sda/hda disks and partitions equivalents in Grub4dos

linux sda hda

  • Please log in to reply
26 replies to this topic

#26 steve6375

steve6375

    Platinum Member

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

Posted 11 January 2017 - 11:16 AM

If you are booting from a USB drive, then it is not enough to translate the grub4dos root drive to the linux device name as your clever script does.

Under grub4dos, the booting USB device will be hd0 and the first internal hdd will be hd1.

So if you wanted to boot to hd1 and set that as root before calling your code, you would get sdb which is incorrect because the first internal hdd will be sda under linux.

So in the context of booting to grub4dos from USB, your code will need modifying.

 

My use of changing and then re-setting the root device is not very elegant. I would prefer a way to temporarily save the current root device, set the desired device as root, and then restore the original root device to whatever it was before. Any bright ideas?



#27 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 11 January 2017 - 01:47 PM

This will bring us back to the "old" issue about the *need* of a "shift" or "rotate" devices command, i.e. something that will "reset" devices the same way they would be IF the boot was not initiated from USB (thus shifting the USB device to hd0 and shifting/rotating all the later ones).

http://reboot.pro/to...upts-windows-7/

 

Maybe use calc *0x475&0xff-1 :dubbio:?



!BAT
debug 1
calc *0x82a0-80 >nul
set g4ddisk=%@retval%
calc *0x829e&255 > nul
set g4dvolid=(hd%g4ddisk%,%@retval%)

calc *0x82a0-31 | call Fn.2 | set LXdisk=sd

calc *0x475&0xff+96 | call Fn.2 | set USBLXdisk=sd

calc *0x829e&255+1 > nul
set LXvoln=%@retval%

echo
echo Grub4dos boot device is %g4dvolid%
echo this would translate to Linux %LXdisk%%%LXvoln%
echo BUT if the boot disk is USB, then
echo the Linux ID will be (maybe) %USBLXdisk%%%LXvoln%

I still however believe that shifting/rotating back the devices would be more "elegant", the issue about _orig and _curr still is unresolved, so using the batch in:
http://reboot.pro/to...ows-7/?p=191758

would do, but what is missing right now to make a "universal" something  is a sure way to determine if the boot was from USB.

 

Otherwise one needs to call the SHIFTDSK.G4B when booting from USB and not call it if booting "normally".

 

:duff:

Wonko







Also tagged with one or more of these keywords: linux, sda, hda

1 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users


    Google (1)