LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 08-11-2009, 02:43 AM   #1
galapogos
Member
 
Registered: May 2008
Posts: 227

Rep: Reputation: 30
Disassociating kernel/boot loader from drive position


Hi,

It seems that the kernel and boot loader are both associated with the drive position/device name. For example if I have 2 SATA hard drives with Linux installed in each of them as the boot drive(/dev/sda), and I try to plug them both into 1 PC, only the one plugged into the lower SATA port would work as it would resolve to /dev/sda, while the other would resolve to /dev/sdb. Is there a way without recompiling the kernel and rerunning LILO that this could be done automatically?
 
Old 08-11-2009, 10:10 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
It isn't clear what exactly you want to do. The boot disk is determined by the host BIOS, at least in the case of a typical desktop PC. The BIOS finds a bootloader on the Master Boot Record of the first disk. From there, a boot loader must be able to find a boot directory, on a filesystem type known to it. That includes most common filesystems, but not Logical Volumes as used by the LVM system. In the case of the grub bootloader, it has it's own vision of a 'root' filesystem, which you can manipulate in grub-install.
Code:
grub_prefix=/boot/grub
This defines where grub will look for kernels and it's config file, grub.conf.
Grub sets up the root/first partition for the kernel, and is subject to your control by modifying grub.conf:
Code:
root (hd0,0)
You can use any partition that is readable by grub (LVM restictions).
The way you tell the kernel to find it's root directory is via commandline arguments, and this can be modified in grub.conf.
Code:
kernel /vmlinuz-version ro root=/dev/VolGroup/LogVolRoot
Here is where LVM can be put into play.

I cannot remember if LILO is as flexible. I do know that you would need to re-run LILO to modify the boot capabilities.
You do not need to rebuild kernels just to put them in a different boot directory, but you may have to tell it where to find its root directory.

--- rod.
 
Old 08-11-2009, 10:20 PM   #3
galapogos
Member
 
Registered: May 2008
Posts: 227

Original Poster
Rep: Reputation: 30
Thanks. Sorry for not being clear. Here's my problem.

I have a couple of SATA storage devices that boot up to an application, i.e. not a full fledged Linux OS with full user control, but simply uses Linux as the OS to boot up a specialized application. Think of them as kiosk applications, such as ATM, or something like that.

I'm using a custom built Linux 2.6 kernel whose rootdev is set to sda. I'm using LILO as the boot loader, and lilo.conf points to the kernel and root is set to sda also.

From my own experiments, the way sda/sdb is assigned depends on the which SATA port the device is connected to. A lower number SATA port will have a lower alphabet assignment. For example, if device 1 is connected to the SATA0 port and device 2 is connected to the SATA2 port, and nothing else is connected, then device 1 will resolve to sda and device 2 to sdb. Take away device 1 and reboot, and device 2 will now be sdb even though it's in the SATA2 port, because nothing is connected to a lower SATA port.

In the above example, if I set the BIOS 1st boot priority to device 1, everything is fine as device 1 resolves to sda. However, if I set the 1st boot priority to device 2, it will kernel panic while booting up since device 2's boot loader expects to find the kernel in sda, however it is actually sdb now.

So, I'm asking if there is a way to solve this problem automatically w/o having to rerun LILO or recompiling the kernel or even having the user choose from the menu which kernel to boot. Since this is for a kiosk like application it needs to be transparent to the user.

Hope that is clear enough.

Last edited by galapogos; 08-11-2009 at 10:21 PM.
 
Old 08-12-2009, 10:08 AM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Okay, I understand. To re-state your question, you want to know if/how the BIOS &/or bootloader can have a 'fallback' or ordered preference of boot devices. This would operate in principle like the usual BIOS 'Boot Order' system where you specify typically 'Floppy - CD/DVD - Hard-disk' boot device order.
AFAIK, this is not a feature supported by common bootloaders, although it may be supported by many BIOSes, where there is the capability to have multiple hard-disks in the ordered list of boot preference. In principle, where this capability is present, you can get what you want, as long as all of the necessary boot-time ingredients are present on the 'backup' (SDB, in your example) drive. These ingredients would include, at least,
1. MBR flagged as bootable (so BIOS knows to expect a bootloader).
2. A full /boot directory, correctly configured to provide a root directory on the remaining drive.
3. The specified kernel and its parts, loaded on the /boot directory.
4. A functional root directory for the kernel to boot from.

You should be able to use either Grub or Lilo as bootloaders in this scenario. To get such a configuration assembled, I believe you would have to modify the hardware configuration once or twice to use Lilo. To use grub, you should only need to modify the grub-install script to create the bootloaders on each disk.

I use this method for dual-booting Windows and Linux. The Windows disk is a fully independent drive, and when not booted by grub on the main boot disk, it will self-boot as the primary disk, as long as the BIOS treats it as the 'first' disk. I guess having a second Linux bootable drive would/could work the same way.

--- rod.
 
  


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
Boot loader offloaded to USB thumb drive wwnexc Linux - Software 6 05-15-2008 05:57 AM
no /boot/loader and no /boot/kernel/kernel error message on a free bsd install chownuseradd Linux - Newbie 1 02-09-2008 08:05 PM
Which boot loader for an external USB drive aikempshall Slackware 2 04-06-2005 06:53 PM
boot loader on different hard drive verify_reality Linux - Newbie 1 05-25-2004 01:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 02:52 AM.

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