Jump to content











Photo
- - - - -

Install Grub2 on a USB key without an existing Linux installation

grub2 install usb mbr

  • Please log in to reply
9 replies to this topic

#1 Monsieur Z

Monsieur Z

    Member

  • Developer
  • 51 posts
  • Location:France
  • Interests:Computers, C# and spaghetti
  •  
    France

Posted 26 January 2016 - 12:08 PM

I've been searching for some time here and on other websites for a way to install Grub(legacy)/Grub2 (NOT GRUB4DOS) on a USB key/drive, but I didn't find anything.

I need a way that can be automated (so something like the command-line grubinst.exe would be nice)

I saw that grubinst.exe from Grub4DOS has a --grub2 command-line parameter, but if I use it it requires a file called 'g2ldr' and I can't find it. I found g2ldr.mbr and g2ldr.img in the grubutil packages, but I didn't find the real g2ldr file (apart some dead mirror links).

What's the best way to install Grub/Grub2 on a USB drive from Windows?

 

Thanks

 

EDIT: I've just found two g2ldr files, and I've tried putting them on an USB key with grubinst.exe --grub2 ran on them:

Grub 1.98+20100804-14 ftp://ftp.nz.freebsd.org/pub/squeeze64-bpo-3.2/g2ldr

Grub 1.96 http://kebo.pens.ac.id/debian-hp/g2ldr



#2 memoarfaa

memoarfaa

    Member

  • Members
  • 82 posts
  •  
    Egypt

Posted 27 January 2016 - 07:05 PM

Thanks
 
EDIT: I've just found two g2ldr files, and I've tried putting them on an USB key with grubinst.exe --grub2 ran on them:
Grub 1.98+20100804-14 ftp://ftp.nz.freebsd.org/pub/squeeze64-bpo-3.2/g2ldr
Grub 1.96 http://kebo.pens.ac.id/debian-hp/g2ldr

 
 but there are very old

create your own with grub2 v2.2 with command line 
 
copy 2 binaries to one binary  g2hdr.bin + core.img
 
in Linux "cat g2hdr.bin core.img > g2ldr"

in windows "copy /b g2hdr.bin +core.img g2ldr"

 

if you want to no how to create  core.img show this page 

http://manpages.ubun...-mkimage.1.html



#3 Monsieur Z

Monsieur Z

    Member

  • Developer
  • 51 posts
  • Location:France
  • Interests:Computers, C# and spaghetti
  •  
    France

Posted 27 January 2016 - 07:07 PM

Yes but where is g2hdr.bin ?



#4 memoarfaa

memoarfaa

    Member

  • Members
  • 82 posts
  •  
    Egypt

Posted 27 January 2016 - 07:19 PM

here is the link 

http://download.gna....-bin-w32-10.zip



#5 Monsieur Z

Monsieur Z

    Member

  • Developer
  • 51 posts
  • Location:France
  • Interests:Computers, C# and spaghetti
  •  
    France

Posted 27 January 2016 - 07:24 PM

Yes but now I need the core.img file I have built Grub 2.02~beta2 on Cygwin how can I generate core.img?



#6 wimb

wimb

    Platinum Member

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

Posted 27 January 2016 - 07:40 PM

UEFI_MULTI.exe has option to make USB-stick booting with Grub2

 

http://reboot.pro/to...ve/#entry168079



#7 Monsieur Z

Monsieur Z

    Member

  • Developer
  • 51 posts
  • Location:France
  • Interests:Computers, C# and spaghetti
  •  
    France

Posted 27 January 2016 - 07:42 PM

I need a way to be able to do it programmatically, but I've managed to use grubinst for that. The thing I need now is a way to get the latest g2ldr file.



#8 memoarfaa

memoarfaa

    Member

  • Members
  • 82 posts
  •  
    Egypt

Posted 27 January 2016 - 08:18 PM

the best way is 

1- download grub-2.02~beta2-for-windows link

http://alpha.gnu.org...for-windows.zip

 

extract it open cmd then

path to grub-2.02~beta2 folder (cd /d path )

then type this command

grub-mkimage.exe -d I386-PC -p /Grub2/BIOS -o Core.img -O i386-pc biosdisk part_msdos fat exfat ext2 ntfs normal iso9660 search_fs_file



#9 Monsieur Z

Monsieur Z

    Member

  • Developer
  • 51 posts
  • Location:France
  • Interests:Computers, C# and spaghetti
  •  
    France

Posted 27 January 2016 - 08:21 PM

I get this:

 
Tom@TOM-PC ~/grub-2.02~beta2
$ grub-mkimage.exe -d I386-PC -o Core.img -O i386-pc biosdisk part_msdos fat exfat ext2 ntfs normal iso9660 search_fs_file
grub-mkimage: error: cannot open `I386-PC/moddep.lst': No such file or directory.

Tom@TOM-PC ~/grub-2.02~beta2
$ grub-mkimage.exe -o Core.img -O i386-pc biosdisk part_msdos fat exfat ext2 ntfs normal iso9660 search_fs_file
grub-mkimage: error: cannot stat `/usr/local/lib/grub/i386-pc/part_msdos.mod': No such file or directory.

Tom@TOM-PC ~/grub-2.02~beta2
$ grub-mkimage.exe -o Core.img -O i386-pc biosdisk fat exfat ext2 ntfs normal iso9660 search_fs_file
grub-mkimage: error: cannot stat `/usr/local/lib/grub/i386-pc/exfat.mod': No such file or directory.

Tom@TOM-PC ~/grub-2.02~beta2
$ grub-mkimage.exe -o Core.img -O i386-pc biosdisk fat ext2 ntfs normal iso9660 search_fs_file
grub-mkimage: error: cannot stat `/usr/local/lib/grub/i386-pc/search_fs_file.mod': No such file or directory.

Tom@TOM-PC ~/grub-2.02~beta2
$ grub-mkimage.exe -o Core.img -O i386-pc biosdisk fat ext2 ntfs normal iso9660
grub-mkimage: error: invalid ELF header.


#10 memoarfaa

memoarfaa

    Member

  • Members
  • 82 posts
  •  
    Egypt

Posted 28 January 2016 - 01:05 AM

It seems you don't understand me so this is link to all file only but them in USB flash drive

http://www.mediafire...3nekxp/grub2.7z

this is how to Install Grub2 on a USB key
Don't use Cygwin only use windows Command Prompt (CMD.exe) follow the steps

1-download grub-2.02~beta2-for-windows from this link

http://alpha.gnu.org...for-windows.zip

2- extract it "grub-2.02~beta2-for-windows" folder to any location in your hard disk

make simple grub.cfg with below code to set prefix (encoding UTF-8 without BOM) and put it in to "grub-2.02~beta2-for-windows" folder

search.file /boot/grub/grub.cfg root
set prefix=/boot/grub
set pager=1
insmod all_video
insmod vbe
insmod vga
insmod video_bochs
insmod video_cirrus
insmod font
insmod gfxterm
insmod gfxmenu
insmod gettext
insmod jpeg
insmod png
###loadfont /boot/grub/Fonts/unicode.pf2
###theme=${prefix}/themes/starfield/theme.txt
set gfxmode=auto
terminal_output gfxterm
set timeout=300
set color_normal=green/black
set color_highlight=white/cyan

menuentry "restart" {
reboot
}

menuentry "shutdown" {
halt
}

3- but the below code with ".bat" extensions in "grub-2.02~beta2-for-windows" folder eg .. makeg2ldr.bat and run
it
@echo off
cd /d %~dp0
grub-mkimage.exe -d I386-PC -p /boot/grub -c grub.cfg -o Core.img -O i386-pc biosdisk part_msdos fat exfat ext2 ntfs normal iso9660 search_fs_file configfile

Copy /B i386-pc\lnxboot.img+Core.img G2ldr

EXIT

now you have G2ldr and grub.cfg in "grub-2.02~beta2-for-windows" folder

4- copy G2ldr to the root of USB flash drive

 

5- copy grub.cfg to /boot/grub/ folder in USB flash drive

 

6- run grubinst.exe with --grub2 command-line parameter


Edited by memoarfaa, 28 January 2016 - 01:59 AM.

  • awengers44 likes this





Also tagged with one or more of these keywords: grub2, install, usb, mbr

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users