LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.

Notices


Reply
  Search this Thread
Old 06-25-2014, 08:41 PM   #1
jemd13
LQ Newbie
 
Registered: Jun 2014
Posts: 2

Rep: Reputation: Disabled
Using my already existing Grub Bootloader for LFS


Hello everyone, I'm new here, and decided to post because I can't seem to find a way to set up my already existing GRUB so that it let's me boot my LFS system. I'm currently on chapter 8.4 of the book, and I'm kinda scared to do something wrong at this point haha.

The laptop I'm working on currently has 3 OS's, Windows 7, Debian and the LFS system I'm working on.

For my Debian instalation I used
sda 5 for /
sda 6 for swap
sda 7 for /home
sda 8 for /boot

And for my LFS system I have :
sda 9 for /
sda 10 for /home
sda 11 for /boot
and the same swap partition as my Debian installation.

Now the problem is that the book says that if I do what it says, it'll overwrite my current bootloader, and I don't want that. After I'm done here I want to be able to boot onto Windows 7,Debian and LFS through GRUB, but I can't seem to find a way to do that.

I'd be grateful if anybody could guide me through this, or point me to a website or thread where this has been solved (For some reason the forum's search function doesn't seem to be working for me or something, so I apologize if this has been asked, but google isn't helping much).

For a reference, I'm running on Debian Wheezy with Linux 3.2.0-4-686 as my host system.

Thanks!
 
Old 06-25-2014, 09:56 PM   #2
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-15.0 Multilib
Posts: 6,558
Blog Entries: 15

Rep: Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097
Okay, LFS by default only comes with Grub to detect the local OS. If you want to add other operating systems you'll need to first uninstall Grub, install os-prober, and then re-install Grub.

Here's how you do this:

First grab a copy of the os-prober sources from any repository (I use Slackware's repo a lot for extra stuff): http://mirrors.slackware.com/slackwa...e/a/os-prober/ Get the source and the ReiserFS patch.

Next unpack the os-prober sources and change directory, and then use this script to install os-prober:

Code:
zcat ../os-prober.reiserfs.diff.gz | patch -p1 --verbose || exit 1
make
cp -a linux-boot-prober os-prober /usr/bin
cp -a linux-boot-probes os-probes /usr/lib
( cd /usr/lib/linux-boot-probes
  for probe in common/* ; do
    ln -sf $probe .
  done
  cd mounted
  for probe in common/* x86/* ; do
    ln -sf $probe .
  done
)
( cd /usr/lib/os-probes
  for probe in common/* ; do
    ln -sf $probe .
  done
  cd init
  for probe in common/* ; do
    ln -sf $probe .
  done
  cd ../mounted
  for probe in common/* x86/* ; do
    ln -sf $probe .
  done
)
cp -a newns /usr/lib/os-prober
cp -a common.sh /usr/share/os-prober
mkdir -p /usr/share/doc/os-prober_1.63
cp -a README TODO /usr/share/doc/os-prober_1.63
Now rebuild and re-install Grub, and it should auto-detect any installed OS on your PC.
 
Old 06-25-2014, 10:00 PM   #3
jemd13
LQ Newbie
 
Registered: Jun 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ReaperX7 View Post
Okay, LFS by default only comes with Grub to detect the local OS. If you want to add other operating systems you'll need to first uninstall Grub, install os-prober, and then re-install Grub.

Here's how you do this:

First grab a copy of the os-prober sources from any repository (I use Slackware's repo a lot for extra stuff): http://mirrors.slackware.com/slackwa...e/a/os-prober/ Get the source and the ReiserFS patch.

Next unpack the os-prober sources and change directory, and then use this script to install os-prober:

Code:
zcat ../os-prober.reiserfs.diff.gz | patch -p1 --verbose || exit 1
make
cp -a linux-boot-prober os-prober /usr/bin
cp -a linux-boot-probes os-probes /usr/lib
( cd /usr/lib/linux-boot-probes
  for probe in common/* ; do
    ln -sf $probe .
  done
  cd mounted
  for probe in common/* x86/* ; do
    ln -sf $probe .
  done
)
( cd /usr/lib/os-probes
  for probe in common/* ; do
    ln -sf $probe .
  done
  cd init
  for probe in common/* ; do
    ln -sf $probe .
  done
  cd ../mounted
  for probe in common/* x86/* ; do
    ln -sf $probe .
  done
)
cp -a newns /usr/lib/os-prober
cp -a common.sh /usr/share/os-prober
mkdir -p /usr/share/doc/os-prober_1.63
cp -a README TODO /usr/share/doc/os-prober_1.63
Now rebuild and re-install Grub, and it should auto-detect any installed OS on your PC.
I appreciate the answer and will try this if there isn't another option, but I was wondering, is there no way to make it work by editing my grub.cfg file in my host system? I'd like to try to do this instead of having a program do it for me.

If there is no other option then of course I will try the above.
 
Old 06-26-2014, 03:50 AM   #4
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-15.0 Multilib
Posts: 6,558
Blog Entries: 15

Rep: Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097
Editing the grub.cfg file is not recommended since it uses shell scripting methods rather than plaintext as Grub-Legacy. It can be done, but due to the complexity it involves, I'll avoid doing so as it could damage your system, and be counter-productive.

Because of this, os-prober is recommended to use as a supplement to Grub for external OS detection.

Last edited by ReaperX7; 06-26-2014 at 04:34 AM.
 
Old 06-26-2014, 04:45 AM   #5
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Void, Linux From Scratch, Slackware64
Posts: 3,153

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
I ALWAYS manually edit the grub config file once grub is installed and working, the automatic detection system of grub is not always accurate and often misses bits, I do a LOT of switching systems I have 12 bootable systems at the moment and when I install a new system or experimental kernel I just manually edit the /media/Boot/grub/grub.cfg file ( the path to your grub.cfg file will be different, I use a separate boot partition with a rescue system on it for when I get it wrong! ).
To add a new system just add something like this:
Code:
menuentry "LFSEudev 3.116 rc1 on (/dev/sda12)" {
	savedefault
	gfxpayload=1280x1024x32,1280x1024
	set root=(hd0,12)
	linux   /boot/bzImage-3.16.0 root=/dev/sda12 ro
}
To the other entries, this was an experimental kernel I was trying on sda12 my main system but I have been mucking about with the kernel so I have a number of such entries, the auto prober would not necessarily detect all the alternate kernels nor would it allow me to set the title of the entry as above.

Before you manually alter your grub.cfg file make a backup and make sure you can boot to an emergency CD to restore it in case you muck it up.
 
Old 06-26-2014, 05:30 AM   #6
oblo
Member
 
Registered: May 2014
Location: Rome, Italy
Distribution: LFS 7.6
Posts: 55

Rep: Reputation: Disabled
I skipped this chapter (no grub on mbr) and i boot from usb.. you can use this way if you want:
http://www.supergrubdisk.org/put-sup...-from-windows/
At boot choose "Detect any grub2 configuration file (grub.cfg)" option.

# Begin /boot/grub/grub.cfg
set default=0
set timeout=5

insmod ext2
set root=(hd1,2)

menuentry "GNU/Linux, Linux 3.13.3-lfs-7.5" {
linux /boot/vmlinuz-3.13.3-lfs-7.5 root=/dev/sda2 ro
}
 
Old 06-26-2014, 03:12 PM   #7
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-15.0 Multilib
Posts: 6,558
Blog Entries: 15

Rep: Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097
If you have multiple hard drives, you can always install LFS to a stand-alone drive and use the BIOS/UEFI boot selection option and use the standard Grub configuration in the book.

Example: If you have Windows 8.1 installed to /dev/sda, and you have LFS installed to /dev/sdb, just use the boot selection. Most PC's have this using ETC or F1 to Select Boot Device.
 
  


Reply



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
[SOLVED] I messed up the GRUB bootloader by installing Android x86 on existing Linux Partition westprogram1 Linux - Kernel 2 11-13-2013 08:31 PM
Grub bootloader overwritten by WinXP bootloader, all other os' gone! craigforsure Linux - Newbie 5 03-29-2010 02:49 AM
Replace GRUB Bootloader with WIN NT Bootloader wombat53 Linux - Software 1 09-04-2009 08:56 AM
How can I disable the grub bootloader and enable the lilo bootloader? abefroman Linux - General 1 08-06-2005 08:53 AM
unable to boot with any existing bootloader kaiserlautern Mandriva 4 06-22-2004 12:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch

All times are GMT -5. The time now is 08:12 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
Open Source Consulting | Domain Registration