LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-21-2011, 10:18 AM   #1
SkyerSK
Member
 
Registered: Oct 2010
Location: Europe
Distribution: Gentoo
Posts: 206

Rep: Reputation: 10
Putting grub1 into MBR without having it installed


Hello,
I am currently trying to install Sabayon linux, and it expects to use Grub1 for booting from usb (what am I trying to do). So I copied grub files into boot section, but now I need to "root and setup" it - and that's what I can't do, because I don't use Grub1 normally, since I am on Ubuntu which uses Grub2.

(I decided to use Grub1 instead of Grub2 because Sabayon could have some special params, and I am not that much experienced to copy them in new format to grub2 configuration file).

So my question is - is there a way to copy grub1 to MBR without having it installed? (using some utility or something like that).

Thanks much.
 
Old 01-21-2011, 10:39 AM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
As far as I am aware, "installing" grub means putting it in the MBR. You can always re-install Grub2 afterwards
 
Old 01-21-2011, 10:48 AM   #3
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Well, the MBR is a small, fixed size, part of a drive, so putting anything there will overwrite anything that's currently in there. In other words, no, you can't make a "temporary" change to your MBR. (You could, of course, copy your current MBR, let the install change the MBR, and then restore the old MBR from the copy. The dd command is useful for this. Then use the Ubuntu script - I forget the name - to create an updated boot menu, and you should be "golden.")

What you could do is check to see if the distribution you're trying to install does, in fact, set any kernel parameters in its boot process. (This is almost never done, since the distribution will have been compiled with any required kernel settings. The kernel settings in the GRUB kernel stanza are only needed when your hardware in not properly detected by the RAM disk boot image.)

That being said, adding those settings to a GRUB2 boot stanza is no more difficult than doing so in a GRUB kernelline, so you should have no problem using GRUB2 to boot your new distribution.
 
Old 01-21-2011, 10:55 AM   #4
Soadyheid
Senior Member
 
Registered: Aug 2010
Location: Near Edinburgh, Scotland
Distribution: Cinnamon Mint 17.3 and 18 at present.
Posts: 1,256

Rep: Reputation: 270Reputation: 270Reputation: 270
The MBR is only 512 bytes long as far as I know. I believe it mearly acts as a pointer to the bootable image. Grub will exist on your Linux Partition/disk but it changes the MBR to point at itself rather than the usual Windows Volume Boot Record... or maybe not!
Checkout http://en.wikipedia.org/wiki/Master_boot_record

Play Bonny!
 
Old 01-21-2011, 11:06 AM   #5
SkyerSK
Member
 
Registered: Oct 2010
Location: Europe
Distribution: Gentoo
Posts: 206

Original Poster
Rep: Reputation: 10
Thanks for replies,
sorry I wrote my question wrong probably.
I am trying to make bootable usb with sabayon image. I follow installation, copied almost everything needed, but now I need to install Grub into MBR of pen drive to boot. Installer talks about using Grub1, which can be installed into MBR using it's interface, which I can't get to, since I don'ŧ have Grub1 installed (instead, I've Grub2).

Hope it's more clear.
 
Old 01-21-2011, 02:49 PM   #6
grizlbr
LQ Newbie
 
Registered: Sep 2010
Posts: 26

Rep: Reputation: 0
Question

At this point I had just made pen bootable and copied the cd to drive, boot usb was an option in bios. It booted just like the cd. Look for Make boot disk under System Administation Ubuntu 10.10 live cd as the start. Once the Disk is prepared copy your cd files to root it will appear to be cd file system and boot like an install.
kiss is my moto if it works or get a bigger hammer!
 
Old 01-21-2011, 02:55 PM   #7
grizlbr
LQ Newbie
 
Registered: Sep 2010
Posts: 26

Rep: Reputation: 0
While waiting for edit option: warning my 2G drive was Fat32 MBR! If you dd the usb mbr to hard drive it will kill your partitions, so dd your harddrive mbr to backup first!
 
Old 01-21-2011, 03:13 PM   #8
grizlbr
LQ Newbie
 
Registered: Sep 2010
Posts: 26

Rep: Reputation: 0
Exclamation

Sorry not into linux long? dd your mbr to a file to backup. Display the contents with a hexeditor the call to grub2 is in ascii. Change to grub1 save file with diferent name dd 512 bytes back to bootdrive just for install. Then restore the original mbr. I do not know the consequenses of renaming the original grub2 file to grub1 to boot your system?
This is hypothetical to address a problem: all risks are yours: backup before attempting this. Or get a bigger Hammer! Use the tools you have on hand and know!

---------- Post added 01-21-11 at 04:14 PM ----------

Sorry not into linux long? dd your mbr to a file to backup. Display the contents with a hexeditor the call to grub2 is in ascii. Change to grub1 save file with diferent name dd 512 bytes back to bootdrive just for install. Then restore the original mbr. I do not know the consequenses of renaming the original grub2 file to grub1 to boot your system?
This is hypothetical to address a problem: all risks are yours: backup before attempting this. Or get a bigger Hammer! Use the tools you have on hand and know!
 
Old 01-21-2011, 04:28 PM   #9
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 15,723

Rep: Reputation: 2120Reputation: 2120Reputation: 2120Reputation: 2120Reputation: 2120Reputation: 2120Reputation: 2120Reputation: 2120Reputation: 2120Reputation: 2120Reputation: 2120
If you have all the grub files on the USB, you can simply (as root) run the grub command from there - say "/media/USB/sbin/grub". Then, do the "root" and "setup" commands from there - make sure you are using the device designation for the USB. (hd1) say ...
 
Old 01-22-2011, 03:16 AM   #10
SkyerSK
Member
 
Registered: Oct 2010
Location: Europe
Distribution: Gentoo
Posts: 206

Original Poster
Rep: Reputation: 10
grizlbr: I have got only grub2 created MBRs, that's why I can't just dd main MBR sector into USB. Also, files are incompatible, but I could try to use grub2 mbr - though I don't expect it to work.

syg00: That's a good idea, thanks for posting. I am not sure if grub1 doesn't hold any other files than /sbin/grub and /boot/grub/* (like grub2 does), but it looks like good way to do this.

Thanks for replies, I'll try to do it in minutes...
 
Old 01-22-2011, 12:58 PM   #11
grizlbr
LQ Newbie
 
Registered: Sep 2010
Posts: 26

Rep: Reputation: 0
From what I read the POST puts the partitions in memory then exacutes the program pointed to in the first 3 bytes of MBR be it IO.SYS NTLOADER or grub/1/2. That is why you have to reboot after making changes to partitions in windows so POST can reload the changes. Change the call change the file name it should still work untill you make a call to the config routine. That would configure the respective grub files edit, the OS changes to the real' file and you have the configuration as the OS sees it. As I boot from cd, flash and hard drive the call to /dev/hda, /dev/sda1, 2, 3...7 changes according to where I boot from and how that OS reads the partitions. Grub starts at 1 grub2 starts at 0 makes a work or not situation: 2 boot options hd0,0 or hd0,1 in menu.lst make debugging boot problems logical? Give me 3 steps Mr?!
 
Old 01-22-2011, 01:06 PM   #12
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
If you have everything but the MBR on the pen drive, you should be able to boot the pen drive from your Ubuntu boot screen. (I.e, plug in the pen drive, run the sudo grub-mkconfig command, reboot, and find the pen drive's distribution in your (new) GRUB2 boot menu.)

Then you can use the grub-install command of the pen drive's distribution to install its GRUB on the pen drive. (Warning: Make sure that you use the the correct drive specification in the grub-install script. Usually doing a mount command - while running the new distribution - will show something like this:
Code:
$ mount | grep "[[:space:]]/[[:space:]]"
/dev/sda8 on / type ext4 (rw)
for your root directory. Noting that the root directory is on sda8 in this example, the correct GRUB install command (for GRUB1) would be sudo grub-install /dev/sda

Good luck,

Last edited by PTrenholme; 01-22-2011 at 01:07 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Lilo vs grub1 vs grub2 honeybadger Linux - General 8 12-03-2010 11:42 AM
grub4dos is grub2 or grub1? zoombee Linux - General 10 07-29-2010 05:25 AM
grub1 floppy chainload grub2 pavel989 Linux - General 3 02-02-2010 10:58 AM
Oh No! I installed a bootloader to the MBR....! Siljrath Linux - Software 4 02-17-2006 07:08 PM
could u guess OS installed by looking at MBR? mohit_garg Linux - Software 4 07-12-2005 07:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration