[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: RAID1 all bootable



Hi Francesco,

As far as I can determine reading this thread you have had a RAID1
with two disks sda and sdb.  The disk sda failed.  But grub was only
installed on the failed sda.  The disk sdb contains a mirror of
everything but does not boot.

Earlier in the thread Lennart gave an excellent suggestion:

Lennart Sorensen wrote:
> You can boot the install disk in rescue mode, select the root
> partition to chroot into, then run grub-install from there.
> 
> When grub asks where to install, you should configure it for both sda
> and sdb.  I think 'dpkg-reconfigure grub-pc' is where that is
> selected.  Might need it to use -plow to asks all levels of questions.
> Not sure.

+1 for this suggestion.  This is definitely the way to go to fix your
problem.

Francesco Pietra wrote:
> In my case, with the sda that contained grub loader replaced by a new
> disk, the rescue mode  (using the same CD installer for amd64 wheezy)
> did not find any partition. Inverting the SATA cables, same result.

No partitions at all?  That is scary.  And I find it to be hard to
believe.  No partitions would mean that the data from your disks were
zeroed out.  Perhaps you were mistaken?  Please try it again.

> In both cases (I mean position of SATA cables) I went to the shell in
> the installer environment:

Don't work from the installer environment.  Work from the target
environment.  That is a critical difference!

> #fisk /dev/sda (or sdb)

"fisk"?  That command does not exist in the installer environment.
You must have been elsewhere.

>  device contains neither a valid DOS partition table, nor Sun, etc
> (expected for a raid)

Try 'cat /proc/partitions' for a simple safe read-only start.

> #dmesg |grep -i sd
>  sda (and sbb): unknown partition table (expected for a raid), however
> md: raid0
> md: raid1
> were identified, along with rai4, 5, 6 etc (unfortunately "| less"
> does not work to see the whole message).
> 
> Am I using the Rescue Mode improperly? I was unable to dig into the HD
> that contains md0 (booth loader, EXT2) and md1 ( LVM partitions home
> tmp usr opt var swap EXT3)

I believe you are using rescue mode improperly.  I have written about
how to use rescue mode several times recently.  Here is one posting:

  http://lists.debian.org/debian-user/2013/01/msg00218.html

Here is the official documentation for it:

  http://www.debian.org/releases/stable/i386/ch08s07.html.en

But that is fairly terse.  Let me say that the rescue mode looks just
like the install mode initially.  It will ask you keyboard and locale
questions and you might wonder if you are rescuing or installing!  But
it will have "Rescue" in the upper left corner so that you can tell
that you are not in install mode and be assured.  Get the tool set up
with keyboard, locale, timezone, and similar and eventually it will
give you a menu with a list of actions.  Here is a quick run-through.

  Advanced options...
  Rescue mode
  keyboard dialog
  ...starts networking...
  hostname dialog
  domainname dialog
  ...apt update release files...
  ...loading additional components, Retrieving udebs...
  ...detecting disks...

Then eventually it will get to a menu "Enter rescue mode" that will
ask what device to use as a root file system.  It will list the
partitions that it has automatically detected.

One of the menu entry items near the bottom will be "Assemble RAID
array".  That will bring up the next dialog menu asking for partitions
to assemble.  Select the appropriate for your system.  Then continue.
Since at this point you have one disk with data and one disk without
it means you must assemble a degraded array with only one disk.
Select the disk with your data on it.  Start the array with that one
disk.

If you used LVM (I always do) then that should produce an additional
set of listings for the lvm volumes on your system including the root
logical volume.  Select it.

At that point it presents a menu "Execute a shell in /dev/...".  That
should get you a shell on your system with the array mounted.  You
should 'cat /proc/mdstat' and verify that you have a degraded array
with one disk.

If you replaced sda with a new sda disk then sdb will contain your
data.  Assuming sdb1 for md0 and sdb5 for md1 would produce the need
for these commands.  Adjust those partitions as needed to match your
case.

Examine the arrays.  Assuming md0 is on your sdb1 then:

  mdadm --detail /dev/md0

  mdadm --examine /dev/sdb1

At that point I would do nothing before sync'ing the array to the new
disk.  If you have multiple arrays then sync each of them.  Adjust
these partition names as appropriate for your case as determined by
the above inspection.

  mdadm --manage /dev/md0 --add /dev/sdb1
  mdadm --manage /dev/md1 --add /dev/sdb5
  mdadm --manage /dev/md2 ... and so forth

If you have /boot on a separate partition then I would let it finish
before installing grub.  Or if it is on the main root partition then I
would let the entire root partition containing /boot finish syncing
before installing grub.

Install grub to both disks.  You said Wheezy.  The way to install grub
2 in wheezy is:

  grub-install /dev/sda
  grub-install /dev/sdb

That will individually install grub to the MBR of each of the disks.
Should work.  I test this by booting each disk individually to the
grub menu screen.  (If you boot past to the kernel on an individual
disk then it will dirty the array and require a sync again to make the
mirror clean again.  Booting to the grub menu is usually sufficient to
test that each disk can individually boot.)

I have done this above technique for real many times and the rescue
media works very well for it.

Bob

Attachment: signature.asc
Description: Digital signature


Reply to: