grub ?

Programming, for all ages and all languages.
Post Reply
User avatar
Sam111
Member
Member
Posts: 385
Joined: Mon Nov 03, 2008 6:06 pm

grub ?

Post by Sam111 »

I have downloaded and installed grub
sudo apt-get install grub

from here I had an old usb thumb drive lying around so I used gparted gui to reformat/repartition the thumb drive.
Then I issued sudo grub-install /dev/sdb (which is the device file for this thumb drive)

It gives me output at the terminal as

Code: Select all

Searching for GRUB installation directory ... found: /boot/grub
Installing GRUB to /dev/sdb as (hd1)...
Installation finished. No error reported.
This is the contents of the device map /boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.

(fd0)	/dev/fd0
(hd0)	/dev/sda
(hd1)	/dev/sdb

which looks fine.

But when I try to go to the thumb drive their is no boot folder or boot\grub folder at all?
how do I get this grub folder to be made ...

This is strange since I have done this before in the passed and it wrote out a grub boot folder with a default menu.lst that I had to modify. If I remember correct.

Maybe I am missing something not an expert in this area
Or maybe its not writting out the boot folder because it is finding the boot folder already exists on my main HDD. Don't know how to work around this.
Probably something simple and stupid though.
User avatar
Velko
Member
Member
Posts: 153
Joined: Fri Oct 03, 2008 4:13 am
Location: Ogre, Latvia, EU

Re: grub ?

Post by Velko »

Most likely you've just created GRUB thumb drive, which will load second stage from your hard disk (/dev/sda).

--root-directory option might help.
If something looks overcomplicated, most likely it is.
User avatar
Sam111
Member
Member
Posts: 385
Joined: Mon Nov 03, 2008 6:06 pm

Re: grub ?

Post by Sam111 »

Ok , I think I got it when I used the directory parameter like you said.

Code: Select all

 sudo grub-install --root-directory=/media/GRUBTESTER /dev/sdb
It created a folder boot/grub and a bunch of files in it

Code: Select all

default        fat_stage1_5       minix_stage1_5     stage2
device.map     installed-version  reiserfs_stage1_5  xfs_stage1_5
e2fs_stage1_5  jfs_stage1_5       stage1 
I am just wondering on a few last things.

1) where is the menu.lst ? ( can I just create it by hand and grub will find it, or do I have to tell grub where it is after I create it)

2) when I did the command

Code: Select all

 sudo grub-install --root-directory=/media/GRUBTESTER /dev/sdb
Did that place grub on the first sector of the sdb drive with stage1 pointing to stage2.
So I am all set with the stage1 finding stage2 and stage1 being loaded at boot time by the bios when I select boot from usb,...etc
Or do I have to do something more with the stage files?
User avatar
Sam111
Member
Member
Posts: 385
Joined: Mon Nov 03, 2008 6:06 pm

Re: grub ?

Post by Sam111 »

using hexedit /dev/sdb and looking at the first few sectors.
I see a string saying grub and AA55 so I am assuming it is installed correctly
Looking at the sectors passed the first I see strings /boot/grub/stage2 /boot/grub/menu.lst
So by default it seems grub hardcodes the paths to the stage2 , menu.lst so I think it should work now.
If I create the menu.lst and have all the critical grub boot files in the /boot/grub directory

Curious if their is away to tell grub to use another directory like having the stage files in /stage but the other grub files under /boot/grub ?

Maybe it's not possible you can only specify one root directory for all grub files
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: grub ?

Post by Solar »

Sam111 wrote:Curious if their is away to tell grub to use another directory like having the stage files in /stage but the other grub files under /boot/grub ?
I don't know about grub-install. I always used grub directly, i.e. calling "sudo grub", and then calling the install command directly. I know it's deprecated, but here goes:

Code: Select all

install (hd0,4)/grub/stage1 (hd0) (hd0,4)/grub/stage2 (hd0,4)/grub/menu.lst
This tells GRUB to install the grub/stage1 file from the fifth partition on the first hard drive (my values, yours will differ) to the first hard drive's MBR, hardcoding the location of the grub/stage2 file and reading its configuration from the grub/menu.lst file. It should be easy to insert any desired adaptions to your needs.
Every good solution is obvious once you've found it.
User avatar
Sam111
Member
Member
Posts: 385
Joined: Mon Nov 03, 2008 6:06 pm

Re: grub ?

Post by Sam111 »

OK , I am getting error 17 cann't mount selected partition
The usb device is ext3.

My menu.lst is

Code: Select all

#boot the compiled kernel


title           Debian GNU/Linux, kernel 3.0 Complied!!! 
root            (hd1,0)
kernel          /boot/vmlinux 
#root=/dev/hdb1 ro
#initrd          /boot/initrd.img-2.6.25
savedefault
boot
shoud I change hd1 to sdb or hd0 --> for first harddisk
I am selecting usb boot from the bios so maybe the bios orders the drives differently then grub has them

Code: Select all

sudo grub-install --root-directory=/media/GRUBTESTER /dev/sdb
Installing GRUB to /dev/sdb as (hd1)...
Installation finished. No error reported.
This is the contents of the device map /media/GRUBTESTER/boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.

(fd0)	/dev/fd0
(hd0)	/dev/sda
(hd1)	/dev/sdb
User avatar
Sam111
Member
Member
Posts: 385
Joined: Mon Nov 03, 2008 6:06 pm

Re: grub ?

Post by Sam111 »

when i change hdb1 to hdb0 in the menu.lst
I get error 13
"Error 13: Invalid or unsupported executable format"

Is vmlinux not the kernel when I complied the linux source it gave me a few things
is bzImage the file I want instead?

I just don't get what could be going wrong?

miss typed hda for hdb
Last edited by Sam111 on Wed Oct 19, 2011 11:42 am, edited 2 times in total.
User avatar
JackScott
Member
Member
Posts: 1031
Joined: Thu Dec 21, 2006 3:03 am
Location: Hobart, Australia
Contact:

Re: grub ?

Post by JackScott »

Sam111 wrote:I just don't get what could be going wrong?
You have a serial inability to read documentation. That's what is wrong. Here's an exercise for you: go read the GRUB documentation, and then think a bit about how what you've read applies to your situation. Then change your code/files/design/etc based on what you think. Rinse and repeat until you get it right. That's called debugging.

GRUB legacy (and probably the other versions) has absolutely no clue about devices named sda, sdb, etc. They're Linux-specific. GRUB only cares about devices named (hd0,0) or (cd0) or things along those lines. Trying to use "hda" in your menu.lst, as far as I know, is completely incorrect.
Post Reply