Advertisement
Guest User

multiboot

a guest
Apr 6th, 2016
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.26 KB | None | 0 0
  1. !BAT
  2.  
  3. ::small batch to shift HD possitions by Ilko
  4. ::the purpose is to set USB disk last or make sure it is, even if boot grub4dos from a CD, shifting all other hard disks one possition up
  5. ::if it was seen as a floppy call PLoP
  6.  
  7. clear
  8. echo Shifting USB disk to be last...
  9.  
  10. ::debug off
  11. errorcheck off
  12. ::find if PLoP is already loaded
  13. ::http://forum.plop.at/index.php/topic,165.0.html
  14. cat --hex --locate=PoLPu@ (md)0x3D0+0x130 > nul && goto :plop_detected
  15. goto :start
  16.  
  17. :start
  18. ::echo Locating usbdrive.tag
  19. ls /usbdrive.tag > nul || find --set-root --devices=hf /usbdrive.tag > nul
  20. checkrange 0x80 read 0x82A0 > nul && goto :usb_is_hd0
  21. checkrange 0x00,0x01 read 0x82A0 > nul && goto :usb_is_fd
  22. checkrange 0x00,0x01,0x80 read 0x82A0 > nul || goto :usb_is_not_hd0
  23.  
  24. :plop_detected
  25. echo
  26. echo It seems PLoP has been loaded
  27. checkrange 0:2 calc *0x475&0xff > nul && goto :start
  28. set /a hdn=*0x475 & 0xff > nul
  29. set /a hdm=%hdn% - 1 > nul
  30. map (hd-1) (hd-2)
  31. map --harddrives=%hdm%
  32. map --rehook
  33. goto :start
  34.  
  35. :usb_is_not_hd0
  36. ::http://cvwyg-blog.appspot.com/grub/GRUB4DOS5mlsy.htm
  37. ::http://reboot.pro/16069/page__view__findpost__p__145675
  38. ::Other internal variables in README_GRUB4DOS.txt
  39. ::get current root drive
  40. set /a cur_drv=*0x82A0 & 0x7F > nul
  41. ::number of hard disks as BIOS reports them
  42. set /a hdn=*0x475 & 0xff > nul
  43. set /a hdm=%hdn% - 1 > nul
  44. if %cur_drv%==%hdm% echo USB disk is already last- hd%cur_drv% && set /a HDCNT=%hdn% && set /a RDSK=%cur_drv% && goto :s_end
  45. echo USB disk was not hd0, setting it hd0
  46. map () (hd0)
  47. map (hd0) ()
  48. map --rehook
  49. goto :usb_is_hd0
  50.  
  51. :usb_is_hd0
  52. checkrange 2 calc *0x475 & 0xFF > nul && goto :hd2
  53. checkrange 1 calc *0x475 & 0xFF > nul && goto :hd1
  54. checkrange 3 calc *0x475 & 0xFF > nul && goto :hd3
  55. checkrange 4 calc *0x475 & 0xFF > nul && goto :hd4
  56. checkrange 5 calc *0x475 & 0xFF > nul && goto :hd5
  57. checkrange 6:999 calc *0x475 & 0xFF > nul && goto :hd6
  58.  
  59. goto :s_end
  60.  
  61. :hd6
  62. echo Found more than 5 hard disks or mass storage devices attached!
  63. echo It's safer to shut down the computer and disconnect or disable temporarily the unneeded ones
  64. echo if you want to install Windows 2000/XP/2003 on the disk numbered above 4 and you boot from USB disk.
  65. echo Will set USB disk as hd4 so it should be safe to install to hd0-hd3.
  66. pause Press any key to continue...
  67. goto :hd5
  68.  
  69. :hd5
  70. set /a HDCNT=5 > nul
  71. set /a RDSK=%HDCNT% - 1 > nul
  72. map (hd0) (hd4)
  73. map (hd1) (hd0)
  74. map (hd2) (hd1)
  75. map (hd3) (hd2)
  76. map (hd4) (hd3)
  77. map --rehook
  78. echo Found %HDCNT% disks, set USB disk hd%RDSK%
  79. ::pause --wait=1
  80. goto :s_end
  81.  
  82. :hd4
  83. set /a HDCNT=4 > nul
  84. set /a RDSK=%HDCNT% - 1 > nul
  85. map (hd0) (hd3)
  86. map (hd1) (hd0)
  87. map (hd2) (hd1)
  88. map (hd3) (hd2)
  89. map --rehook
  90. echo Found %HDCNT% disks, set USB disk hd%RDSK%
  91. ::pause --wait=1
  92. goto :s_end
  93.  
  94. :hd3
  95. set /a HDCNT=3 > nul
  96. set /a RDSK=%HDCNT% - 1 > nul
  97. map (hd0) (hd2)
  98. map (hd1) (hd0)
  99. map (hd2) (hd1)
  100. map --rehook
  101. echo Found %HDCNT% disks, set USB disk hd%RDSK%
  102. ::pause --wait=1
  103. goto :s_end
  104.  
  105. :hd2
  106. set /a HDCNT=2 > nul
  107. set /a RDSK=%HDCNT% - 1 > nul
  108. map (hd0) (hd1)
  109. map (hd1) (hd0)
  110. map --rehook
  111. echo Found %HDCNT% disks, set USB disk hd%RDSK%
  112. ::pause --wait=1
  113. goto :s_end
  114.  
  115. :hd1
  116. set /a HDCNT=1 > nul
  117. set /a RDSK=%HDCNT% - 1 > nul
  118. echo Found %HDCNT% disks, set USB disk hd%RDSK%
  119. ::pause --wait=1
  120. goto :s_end
  121.  
  122. :usb_is_fd
  123. ::start PLoP
  124. ::find if PLoP is already loaded
  125. ::http://forum.plop.at/index.php/topic,165.0.html
  126. ::cat --hex --locate=PoLPu@ (md)0x3D0 0x130 && goto XXX
  127. cat --hex --locate=PoLPu@ (md)0x3D0 0x130 && echo It seems PLoP was already loaded && goto :s_end
  128. echo It seems your USB disk was seen as a Floppy/ZIP disk by BIOS.
  129. echo Will try to launch PLoP boot manager which might help to make the USB disk seen as a hard disk.
  130. echo This is experimental and is not guaranteed to work as expected.
  131. echo If you are using USB keyboard, you won't be able to use it after the menu reloads.
  132. echo
  133. echo The highlighted menu entry will auto start after 10 seconds. You can shut down or reset the computer if it's not the desired one.
  134. echo
  135. pause --wait=20 Press any key to continue or wait 20 seconds to timeout
  136. ls /plpbt.bin > nul || find --set-root --devices=hf /plpbt.bin
  137. savedefault
  138. ::debug on
  139. chainloader /plpbt.bin
  140. boot
  141. goto :s_end
  142.  
  143. :s_end
  144. echo
  145. errorcheck on
  146. ::debug on
  147. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement