3

I have an industrial PC mounting Linux.

These PC is delivered in two version, each with slightly different internal board and depending on the board type the disk inside the PC is see as hda or hdc.

Until now, to select between the two type of disk boot I simply put two entry inside the grub menu.lst like show below, so at the first start of the PC the maintenance people will select the correct device which will be memorize for future reboot.

default = 0
timeout = 9

title Linux 2.4.34 ( hda )
        root (hd0,0)
        kernel /boot/vmlinuz-2.4.34 ro root=/dev/hda1 console=ttyS0,9600 console=tty0 apm=off

title Linux 2.4.34 ( hdc )
        root (hd0,0)
        kernel /boot/vmlinuz-2.4.34 ro root=/dev/hdc1 console=ttyS0,9600 console=tty0 apm=off

But in most cases this type of PC are delivered without screen and keyboard and the maintenance people are not able to select the boot option so I'm looking for a way that allow the PC to check for the correct boot device before loading the kernel.

In pratical term I need that the boot procedure check if the disk is see as /dev/hdc or as /dev/hda in order to call the boot option with the right value for root device ( ie root=/dev/hda1 or root=/dev/hdc1 )

The problem is that I have no idea if that is possible and how to do that.

Someone have some suggestion about this topic ?

7
  • Well Linux can't detect anything, it's not loaded yet. I'm having a hard time understanding your scenario. If you can configure the bootloader, why not put only the right entry there?
    – Mat
    Dec 11 '12 at 9:18
  • yes, is a complex requirement, I know. And I also know that is quite impossible for linux to make somethink at that early stage because is not yet loaded. Nut I'm looking if there are some way to check what is the right disk in order to select automatically the right boot entry for grub.
    – enzo1959
    Dec 11 '12 at 10:46
  • I can't put myself the right entry because there is a lot of this PC also on far isolated site, and people that go there to do maintenance are not always able to check the right boot disk to the right PC. You have to consider that both PC and disk are spare time that should be changeg when they are damaged and the requirement is to avoid tha maintenance people have to manage with different disk for different type of PC.
    – enzo1959
    Dec 11 '12 at 10:47
  • I still don't understand. Who installs & configures the bootloader? Isn't it installed on the disk we're talking about? Who creates & prepares those disks? Is there more than one disk on those machines?
    – Mat
    Dec 11 '12 at 12:47
  • The disk should be replaced because of a damage. In thies case the new disk should have a default device not compatible with the PC on wich it will be mounted. All this is thinked to allow maintenance by people that didn't know linux.
    – enzo1959
    Dec 11 '12 at 14:31
1

Mat's answer should work for you. I'd like to point out another possibility: use an initramfs/initrd.

You can ship an initrd (I'm pretty sure initramfs is post-2.4, but 2.4 should have initrd) that contains some code to find the rootfs. The advantage of an initrd is that you are running Linux at that point. You can write, e.g., a shell script to do find the root fs. Once you find it, you mount it, pivot_root to it, and exec /sbin/init.

You gain other nice things—for example, if the different boards (now or in the future) need to have different modules loaded to see the hard disk or other boot-critical devices, you can do that.

You could also put various recovery things on there, which may prove useful.

(On a modern Linux distro, the root= option is actually handled by the initramfs.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.