swapping master & slave HDs: what to change? (solved - pls comment!)

From: SpamHog (n1jpr_at_hotmail.com)
Date: 10/02/04

  • Next message: Alvin Oga: "Re: Recommendations for Linux compatible wireless LAN PCMCIA card"
    Date: 2 Oct 2004 04:08:55 -0700
    To: debian-user@lists.debian.org
    
    

    *Thanks to John Summerfield for the pointers*

    If you have multiple Linuces on a couple of drives,
    and for whatever silly reason you want
    to swap IDE master and slave drives,
    here's what to look out for,
    using GRUB as bootloader and GAG as boot selector.

    1) PREPARE BOOT MEDIA
    1.1) Make a GRUB-only boot floppy or CD, depending on what media your
    comp can boot from. GRUB understands several filesystems and can be
    pointed to any kernel in any partition, and be instructed what
    partition to use as "/".
    1.2) Make a GAG boot diskette. There are both Lin & Win installers
    that make multilingual boot/install diskettes. Once GAG is on a
    diskette, it can be installed to the MBR of the master disk, AND also
    onto another (monolingual) diskette, which can be used to re-intall
    onto HD and back on FD ad infinitum.
    1.3) Also, have recovery CD's and FD's ready, just in case, although
    the risk of messing up is rather modest.

    2) GET INFO
    2.1) Identify all the HDs and check on the manufacturers' websites if
    they have any special jumpering needs: some HD's don't like having the
    slave appear and disappear. My master (an IBM 40GB) has extra jumpers
    to "force slave present".
    2.2) For each installed system get the _exact_ info about which kernel
    is loaded. Assuming each system is booted by its own,
    default-installed bootloader (LILO or GRUB), the info is to found in
    two possible places: either in /etc/lilo.conf or in
    /boot/grub/menu.lst. If you find a reference to a generic "vmlinuz"
    in / , make sure it's not a link - if it is, go find the target.

    3) BACK UP BOOT CODE AND SETTINGS
    3.1) For each installed system, backup /etc/fstab, /etc/lilo.conf or
    /boot/grub/menu.lst.
    3.2) Back up the boot sectors, both the MBR of the master disk and the
    boot records of each partition, using dd.

    * MBR or whole boot sector:
    If you use Lilo, you just need the boot record (first 512 bytes). If
    you use another bootloader like GRUB, you'd better backup the whoe 1st
    SECTOR, i.e. the first 64 records. GRUB stores the so called "stage
    1.5" in trat area. GAG puts code there too.

    * Just the MBR:
            dd count=1 bs=512 if=/dev/hda of=<path><filename>
    * Whole sector:
            dd count=64 bs=512 if=/dev/hda of=<path><filename>

    * Boot partitions' boot records:
            dd count=1 bs=512 if=/dev/hd<xx> of=<path><filename>
    * Boot partitions' whole sectors:
            dd count=64 bs=512 if=/dev/hd<xx> of=<path><filename>

    4) SWAP fstab REFERENCES
    For each installed system, edit /etc/fstab to carefully swap all
    references to hda<x> and hdb<x>.

    5) SWAP CONNECTIONS
    Physically swap the drives, including moving the jumpers as to match
    the position on the IDE ribbon cable. The Master should be attached to
    the plug at the end of the ribbon, the slave at the intermediate plug.

    6) grub JARGON ALERT!
       6.1) Grub uses this numbering to identify drives and partitions:
            - drives are always named between round brackets
            - any numbering begins with zero
            - primary IDE partitions are 0, 1, 2, 3
            - logical IDE partitions are 4, 5, 6, ...
    so translating from "fstabese" to "grubian" /dev/hda will become
    (hd0), and /dev/hdb6 will become (hd1,5).
       6.2) Grub is deliciously ambiguous with the concept of "root".
    Within a couple of lines, root is used FIRST to indicate which
    filesystem should be accessed to find the kernel, THEN to indicate
    where the operating system's root is located, and the two should not
    be confused.

    7) REBOOT
    Reboot using the GRUB boot media. You'll get to the GRUB command line
    interface that allows you to select kernel and root partition, bearing
    in mind the dialect that grub speaks. Under normal circumstances, you
    will have to issue exactly three commands:
    a) SET THE "BOOT" ROOT, specifying the partition where the kernel is.
    b) IDENTIFY THE KERNEL with full path and exact filename, starting
    from the "boot" root defined above, _AND_ SETTING THE "SYSTEM" ROOT
    specifying the partition where the operating system root partition is.
     The two are accomplished in the same command line.
    c) TELL GRUB TO BOOT.

    An example:
    the kernel is the file vmlinuz-2.8.39 sitting in /boot/,
    where /dev/hda5 is mounted on /boot,
    and hda1 is mounted on /.
    (Don't ask, just an example).

    Once you get to the grub prompt:

            root (hd0,4)
            kernel=/vmlinuz-2.8.39 root=(hd0,0)
            boot

    Interesting messages:

    - If you select a "boot" root that grub does not understand,
      it will complain immediately.

    - If you omit the "system" root but specify the kernel,
      and the "boot" root is the same as the "system" root,
      then it's OK, no error message.

    - If you indicate a nonexistent kernel or a messy path,
      it will complain.

    - If the two roots do not correspond,
      and you failed to enter the "system" root, you'll get something
      like:
            "I have no root and I want to scream".

    If all goes well, you'll boot into a fully functioning system, ready
    to reinstall the bootloader(s).

    8) INSTALL GRUB

    Get grub on your system if not there already, as a Debian package. As
    root:
            apt-get install grub

    Prepare a /boot/grub/ directory.
            mkdir /boot/grub

    Grub is larger that most other bootloaders. It puts code in three
    different places:
    1) in the boot record (or the MBR)
    2) in the boot sector ABOVE the boot record (the stage 1.5 goes here)
    3) in the filesystem specified in the "system" root, in /boot/grub/.

    This implies boot will fail if you wipe /boot/ or /boot/grub , even if
    the kernel is somewhere else.

    For a multiboot system, it's my preference to install grub into EACH
    SYSTEM TO BE BOOTED and use the easily reinstalled GAG as
    boot-selector.

    9) INSTALL THE BOOTLOADER

    Write the simplest possible version of /boot/grub/menu.lst:

            default=0
            #boot the 1st (and only) entry

            delay=10
            #delay in s before booting default

            title <entry name, spaces allowed>
            root=(hd0,4)
            kernel=/vmlinuz2.8.39 root=(hd0,0) ro

    Save this file, then run

            grub-install <device>

    Where <device> can be expressed either in grubian language or in
    fstabese language.

    As seen in 8), I prefer to have each system equipped with its own
    bootloader. So, in this case, I would select the boot partition (
    /dev/hda5, aka (hd0,4) ) as the boot device, and use GAG to point
    there.

    ==== ORIGINAL MESSAGE ====
    From: SpamHog (n1jpr@hotmail.com)
    Subject: swapping master & slave HDs: what to change?
    Newsgroups: linux.debian.user Date: 2004-07-16 03:50:08 PST

    -- 
    To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org 
    with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
    

  • Next message: Alvin Oga: "Re: Recommendations for Linux compatible wireless LAN PCMCIA card"

    Relevant Pages

    • fixing grub : mbr fix when windows install after linux
      ... "There is not a boot manager screen at all, ... windows but GRUB boot window does not appear. ... "I forgot to install GRUB, I didn't install GRUB in the MBR, I chose ... Fedora but that was not an active primary partition". ...
      (comp.os.linux.misc)
    • SUMMARY: Moving /usr From Under Root "/" To Its Own Partition
      ... One of the reasons for doing this is to end up with a smaller root ... Install the boot block and boot off the new drive. ... " In order for the root partition to be fscked and remounted ... D> temporarily on the existing disk. ...
      (SunManagers)
    • Re: How do I solve this boot.ini problem with WinXP?
      ... This is the current state of my boot.ini file in Win2K's Root: ... In a Microsoft dual boot ... or Multiple Hard Disk only one can be set as a "Active Partition". ...
      (microsoft.public.windowsxp.newusers)
    • Re: Fedora Core 2/Windows XP dual boot: selecting Linux doesnt work
      ... grub is installed on the /root partition, which is the first partition on hdc: hdc1, or in grub notation. ... Stage1 is the unpatched 512-byte file, that is patched and copied to the boot record during setup. ... This byte is initialized to 0xff in the stage1 file, but patched to 0x81 in your setup, to say "we are booting from disk." ...
      (comp.os.linux.setup)
    • Re: Boot manager for Windows only
      ... And also is GRUB capable of booting any ... > Windows partition or will it always hand over to the XP boot loader? ...
      (comp.os.linux.setup)