Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Apr 2008
    Posts
    128

    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?

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,525
    Label the partitions (e2label) and change fstab to use the label instead of device name.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Linux Newbie
    Join Date
    Apr 2008
    Posts
    128
    Sorry but I'm not familiar with this method. Could you perhaps give an example?

  4. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,525
    Quote Originally Posted by galapogos View Post
    Sorry but I'm not familiar with this method. Could you perhaps give an example?
    Before I do, I need to see how the discs are partitioned.

    1. Boot the system into the system associated with /dev/sda
    2. Open a command line window and execute the command "fdisk -l" and post the results here.

    Then I can tell you exactly what to do. Also, please tell us what distribution+version each installation has.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  5. #5
    Linux Newbie
    Join Date
    Apr 2008
    Posts
    128
    This is a SATA storage device that has a custom Linux kernel built and installed in sda1 on an ext2 file system. There are several more partitions, but these are used as raw partitions for raw read/writes and have no file system/OS installed. For all intents and purposes, Linux only resides in sda1 and simply boots up and runs a simple user application. It is using a self-built Linux 2.6.22.19 kernel and LILO 22.8.

    Basically I have a bunch of these storage devices(all identical), and I wish to have them boot up and run the application correctly w/o a kernel panic even if they're in a higher SATA port(hence not sda) than other devices/HDDs in the PC. Is that possible?

  6. #6
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,525
    Ah! Nothing like details, the devil residing therein...

    You should be able to label the system partition on each drive, and edit the /etc/fstab on each, so when it boots it will look for the correct physical drive (identified by label) to remount as root (/). So, boot up the one currently in /dev/sda1, login as root, then do the following from a command line:
    Code:
    e2label /dev/sda1 OS1
    e2label /dev/sdb1 OS2
    e2label /dev/sdc1 OS3
    .
    .
    .
    cd /etc
    cp fstab fstab.1
    # Next, edit fstab to change reference to /dev/sda1 to LABEL=OS1
    mkdir /mnt /mnt/os1 /mnt/os2 /mnt/os3 ...
    mount /dev/sdb1 /mnt/os2
    mount /dev/sdc1 /mnt/os3
    .
    .
    .
    cd /mnt/os2/etc
    cp fstab fstab.2
    # Next, edit fstab to change reference to /dev/sda1 to LABEL=OS2
    cd /mnt/os3/etc
    cp fstab fstab.3
    # Next, edit fstab to change reference to /dev/sda1 to LABEL=OS3
    .
    .
    .
    The horizontal elipses (...) and vertical elipses
    .
    .
    .
    mean "more of the same as before".

    Since these drives are running a 2.6+ kernel, the ext2/ext3 file system drivers and mount commands should handle labeled drives just fine. If you post the contents of /etc/fstab here I can show you specifically what changes to make.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  7. #7
    Linux Newbie
    Join Date
    Apr 2008
    Posts
    128
    OK I'll go see what's in fstab, however I don't think it's even being used right now. This is a really simple kiosk like application(like an ATM) so once the kernel boots up, it runs a shell script that sets up the sysfs,usbfs,necessary daemons,etc, then the application instead of init.

  8. #8
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,525
    Ok. If it isn't using /etc/fstab then you need to find the script(s) that mount the drives and change the mount command to use the label instead of the device name.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  9. #9
    Linux Newbie
    Join Date
    Apr 2008
    Posts
    128
    I looked at the commands you posted earlier, and I don't quite understand the rationale of them. It seems that it's assuming that there's a sda1, sdb1, sdc1 labeled as OS1, OS2 and OS3 respectively. What happens when one or more of them are not around? Won't it try to be mounting a drive that isn't there?

    To be clear, I don't know how many of the devices are going to be plugged in, and which SATA ports they are going to be plugged into. In fact, the devices may not even be homogeneous, i.e. I may have 1 of these devices in 1 SATA port, and a few other regular hard drives in other ports. In most cases this would not happen, but nothing is stopping the user from plugging in random drives into the system, so I'm hoping to find a way such that this will work transparently. It's a pretty dynamic situation

    In this case, is there a way for the Linux/LILO installed in my device to correctly mount itself in whatever device name its assigned to(sda/sdb/sdc/etc) once BIOS is set to boot up from it in boot priority?

    Sorry if my questions are abstruse or if I'm not being clear.

    edit: just looked at my fstab, and nope it doesn't mount the drives there...just /proc, /dev/ram and /dev/fd0. It's not in my script either. That just mounts proc, usbfs and sys, sets up a ramdisk for one of the required daemons to use, and then runs my user application. In any case, kernel panics way before this shell script is run. The message shown when it panics is:

    Code:
    Kernel panic - Not syncing: VFS: Unable to mount root fs on unknown-block (8,1)

  10. #10
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,525
    Quote Originally Posted by galapogos View Post
    I looked at the commands you posted earlier, and I don't quite understand the rationale of them. It seems that it's assuming that there's a sda1, sdb1, sdc1 labeled as OS1, OS2 and OS3 respectively. What happens when one or more of them are not around? Won't it try to be mounting a drive that isn't there?

    To be clear, I don't know how many of the devices are going to be plugged in, and which SATA ports they are going to be plugged into. In fact, the devices may not even be homogeneous, i.e. I may have 1 of these devices in 1 SATA port, and a few other regular hard drives in other ports. In most cases this would not happen, but nothing is stopping the user from plugging in random drives into the system, so I'm hoping to find a way such that this will work transparently. It's a pretty dynamic situation

    In this case, is there a way for the Linux/LILO installed in my device to correctly mount itself in whatever device name its assigned to(sda/sdb/sdc/etc) once BIOS is set to boot up from it in boot priority?

    Sorry if my questions are abstruse or if I'm not being clear.
    If that drive is not specified in the fstab for that particular system, then it will ignore it. Since you have a Linux image on each hard drive, each one will have a different fstab, even though they might look alike because of how they were installed. The issue is that each one knows which drive its file system is to be found on. So, each drive+partition that has a system image on it will have a label that is also found in /etc/fstab on that drive partition. Here is an example from my CentOS (RHEL) system:
    Code:
    LABEL=/                 /                       ext3    defaults        1 1
    /dev/VolGroup00/LogVol00 /home                   ext3    defaults       1 2
    LABEL=/boot1            /boot                   ext3    defaults        1 2
    LABEL=afs-esata-1       /mnt/esata1             ext3    defaults        1 2
    LABEL=afs-esata-2       /mnt/esata2             ext3    defaults        1 2
    LABEL=afs-esata-3       /mnt/esata3             ext3    defaults        1 2
    LABEL=afs-esata-4       /mnt/esata4             ext3    defaults        1 2
    LABEL=afs-esata-tmp     /mnt/esata-tmp          ext3    defaults        1 2
    tmpfs                   /dev/shm                tmpfs   defaults        0 0
    devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
    sysfs                   /sys                    sysfs   defaults        0 0
    proc                    /proc                   proc    defaults        0 0
    LABEL=SWAP-sda2         swap                    swap    defaults        0 0
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •