LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Putting grub1 into MBR without having it installed (https://www.linuxquestions.org/questions/linux-newbie-8/putting-grub1-into-mbr-without-having-it-installed-857810/)

SkyerSK 01-21-2011 10:18 AM

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.

Snark1994 01-21-2011 10:39 AM

As far as I am aware, "installing" grub means putting it in the MBR. You can always re-install Grub2 afterwards :)

PTrenholme 01-21-2011 10:48 AM

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.

Soadyheid 01-21-2011 10:55 AM

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! :D
Checkout http://en.wikipedia.org/wiki/Master_boot_record

Play Bonny! :hattip:

SkyerSK 01-21-2011 11:06 AM

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.

grizlbr 01-21-2011 02:49 PM

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!

grizlbr 01-21-2011 02:55 PM

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!

grizlbr 01-21-2011 03:13 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!

---------- 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!

syg00 01-21-2011 04:28 PM

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 ...

SkyerSK 01-22-2011 03:16 AM

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...

grizlbr 01-22-2011 12:58 PM

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?!

PTrenholme 01-22-2011 01:06 PM

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, :)


All times are GMT -5. The time now is 05:47 PM.