Re: grub install onto a loose drive...



On Sun, 24 Sep 2006 08:09:46 -0700, ivowel wrote:


sorry, I could not think of a better title.

I have a working linux system, and an external enclosure. I would like
to build a booting linux image onto a hard drive that sits in the
enclosure. my intent is to then disconnect the drive, put it into a
different computer as an internal drive, and boot it. It is of course
easy to transfer a linux partition onto the external drive. I need a
differently compiled kernel for my new computer, which I can also build
easily. this part is all easy.

boot sector stuff is not. I am now looking for instructions on how to
install grub onto the external drive, have it point at the external
hard drive's kernel (/dev/sdb1 during installation time), and realize
that although everything currently this boot sector that I want to
write sits on /dev/sdb and the root partition sits on /dev/sdb1, after
I disconnect it and put it into my new machine, /dev/sdb will become
/dev/sda.

pointers appreciated.

sincerely, /iaw

Install grub on the external drive, per the usual drill. You will need the
grub "stage files" on the external drive and the kernel you intend to
boot. For example, if your external drive is mounted at /mnt/sdb1 now,
create a /mnt/sdb1/boot directory and a /mnt/sdb1/boot/grub directory.
Populate the /mnt/sdb1/boot/grub directory with your existing grub stage
files, and populate the /mnt/sdb1/boot with the kernel. If you are
copying an existing setup to the external drive, then the above steps may
be redundant and not be necessary; that is, if the files were already
copied. In either case, as soon as the grub stage files are on the
target, you can setup the grub loader on the drive.

The first trick is to identify your external drive within the grub
environment. You want to ensure that grub is setup on the intended target.
The grub command "geometry" is available for help. Here is a possible
sequence (with Grub's responses omitted):

root@yourbox:~# grub --no-floppy
grub> geometry (hd0)
grub> geometry (hd1)
grub> root (hd1,0)
grub> setup (hd1)
grub> quit

root@yourbox:~#

* In the example, geometry helped to identify/verify that hd1 was the
correct target to be setup with the grub loader.

The only trick left is adjusting the menu.lst entries with correct
parameters for the boot target. grub's root will need to be set correctly,
and the kernel will need to reflect the linux root filesystem target. Here
is an example menu.lst with two stanzas (boot entries):

# Begin menu.lst
title GNU/Linux (k2.6.16.22) drive external
root (hd1,0)
kernel /boot/vmlinuz-2.6.16.22-dm1 ro root=/dev/sdb1
initrd /boot/initrd

title GNU/Linux (k2.6.16.22) drive internal
root (hd0,0)
kernel /boot/vmlinuz-2.6.16.22-dm1 ro root=/dev/hda1

# End menu.lst

Now, install the drive in the new machine and test booting. If for some
reason grub fails to load (maybe because of a bad assumption in menu.lst),
you can still use the grub shell immediately after boot. You can use "c"
and/or "e" to fixup bad entries or create a new stanza on the fly.

--
Douglas Mayne
.



Relevant Pages

  • Re: dual booting computer sheddies to the bridge
    ... I knocked up an old puter with two drives, ... The usual "duel boot" spelling is not entirely accidental. ... Kubuntu drive as master and Win drive as slave grub comes up but there`s ... If I put the winxp disk as master and the linux disk as slave, ...
    (uk.rec.sheds)
  • Re: [SLE] grub refuses to grub
    ... Note before I had Suse 9.0 with Grub and with Suse 9,2 it doesn't work ... > for Windows and 60 gig HD for Linux, a regular CDROM and a CDRW. ... > which distro I try to install and have install Grub, ... > where the actual boot sector is, and I gather, where the actual Grub ...
    (SuSE)
  • Re: Fedora / Windows Boot.
    ... If both hard drives were connected during the Linux installation it ... should have asked you if you wanted to use Grub as the boot loader. ... If Windows is on the primary hard drive it will show up ...
    (Fedora)
  • Re: How install GRUB into partition after Debian install?
    ... > Can Grub keep into the MBR and doesn't give a chance for XP take over ... usually I am setting up linux parts ... > be able to boot my Linux partition after windows reinstallation. ... > if Grub works like I would like to I could change the boot manager. ...
    (Debian-User)
  • RE: Grub failing to work
    ... Take your master CD-DVD for the Distro and boot from it. ... GRUB, while preserving the data on / [root] As a word of warning ... I tried to fix the problem with the boot floppy without success. ...
    (Fedora)