降级软件 raid 启动

降级软件 raid 启动

我在新服务器中安装了 Ubuntu 12.04.1,并设置了 4 个硬盘驱动器和 3 个 RAID 1 设备,配置是前两个驱动器具有 md0(交换空间)和 md1 (/),第三个和第四个驱动器具有 md0(交换空间)和 md1 (/)具有 md2 (/var) 的驱动器。

我一直在测试驱动器故障下的操作,发现如果删除磁盘 2,系统可以正常启动,但如果删除磁盘 1,系统就会进入 grub,然后重新启动。我很困惑为什么 grub 似乎可以从磁盘 2 正确加载,但启动失败。

我尝试将 MBR 从磁盘 1 复制到磁盘 2:

dd if=/dev/sda of=/dev/sdb bs=512 count=1

但这并没有什么区别。

grub配置文件

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
  set have_grubenv=true
  load_env
fi
set default="0"
if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function recordfail {
  set recordfail=1
  if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; fi
}

function load_video {
  insmod vbe
  insmod vga
  insmod video_bochs
  insmod video_cirrus
}

insmod raid
insmod mdraid1x
insmod part_msdos
insmod part_msdos
insmod ext2
set root='(mduuid/bec69e6b53a222d6726d1f6a11d27043)'
search --no-floppy --fs-uuid --set=root c3a8948c-4ca8-4d3b-acbe-64baa0f7a181
if loadfont /usr/share/grub/unicode.pf2 ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
  insmod raid
  insmod mdraid1x
  insmod part_msdos
  insmod part_msdos
  insmod ext2
  set root='(mduuid/bec69e6b53a222d6726d1f6a11d27043)'
  search --no-floppy --fs-uuid --set=root c3a8948c-4ca8-4d3b-acbe-64baa0f7a181
  set locale_dir=($root)/boot/grub/locale
  set lang=en_GB
  insmod gettext
fi
terminal_output gfxterm
if [ "${recordfail}" = 1 ]; then
  set timeout=-1
else
  set timeout=2
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
function gfxmode {
    set gfxpayload="${1}"
    if [ "${1}" = "keep" ]; then
        set vt_handoff=vt.handoff=7
    else
        set vt_handoff=
    fi
}
if [ "${recordfail}" != 1 ]; then
  if [ -e ${prefix}/gfxblacklist.txt ]; then
    if hwmatch ${prefix}/gfxblacklist.txt 3; then
      if [ ${match} = 0 ]; then
        set linux_gfx_mode=keep
      else
        set linux_gfx_mode=text
      fi
    else
      set linux_gfx_mode=text
    fi
  else
    set linux_gfx_mode=keep
  fi
else
  set linux_gfx_mode=text
fi
export linux_gfx_mode
if [ "${linux_gfx_mode}" != "text" ]; then load_video; fi
menuentry 'Ubuntu, with Linux 3.2.0-29-generic' --class ubuntu --class gnu-linux --class gnu --class os {
    recordfail
    gfxmode $linux_gfx_mode
    insmod gzio
    insmod raid
    insmod mdraid1x
    insmod part_msdos
    insmod part_msdos
    insmod ext2
    set root='(mduuid/bec69e6b53a222d6726d1f6a11d27043)'
    search --no-floppy --fs-uuid --set=root c3a8948c-4ca8-4d3b-acbe-64baa0f7a181
    linux   /boot/vmlinuz-3.2.0-29-generic root=UUID=c3a8948c-4ca8-4d3b-acbe-64baa0f7a181 ro   
    initrd  /boot/initrd.img-3.2.0-29-generic
}
menuentry 'Ubuntu, with Linux 3.2.0-29-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
    recordfail
    insmod gzio
    insmod raid
    insmod mdraid1x
    insmod part_msdos
    insmod part_msdos
    insmod ext2
    set root='(mduuid/bec69e6b53a222d6726d1f6a11d27043)'
    search --no-floppy --fs-uuid --set=root c3a8948c-4ca8-4d3b-acbe-64baa0f7a181
    echo    'Loading Linux 3.2.0-29-generic ...'
    linux   /boot/vmlinuz-3.2.0-29-generic root=UUID=c3a8948c-4ca8-4d3b-acbe-64baa0f7a181 ro recovery nomodeset 
    echo    'Loading initial ramdisk ...'
    initrd  /boot/initrd.img-3.2.0-29-generic
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
    insmod raid
    insmod mdraid1x
    insmod part_msdos
    insmod part_msdos
    insmod ext2
    set root='(mduuid/bec69e6b53a222d6726d1f6a11d27043)'
    search --no-floppy --fs-uuid --set=root c3a8948c-4ca8-4d3b-acbe-64baa0f7a181
    linux16 /boot/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
    insmod raid
    insmod mdraid1x
    insmod part_msdos
    insmod part_msdos
    insmod ext2
    set root='(mduuid/bec69e6b53a222d6726d1f6a11d27043)'
    search --no-floppy --fs-uuid --set=root c3a8948c-4ca8-4d3b-acbe-64baa0f7a181
    linux16 /boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###

mdadm配置

:~$ mdadm /dev/md0 
/dev/md0:
        Version : 1.2
  Creation Time : Wed Aug 29 10:28:02 2012
     Raid Level : raid1
     Array Size : 15615872 (14.89 GiB 15.99 GB)
  Used Dev Size : 15615872 (14.89 GiB 15.99 GB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent

    Update Time : Mon Sep  3 10:35:25 2012
          State : clean 
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           Name : norsewind-obs:0  (local to host norsewind-obs)
           UUID : b55552d2:1e554573:82671934:3831d058
         Events : 19

    Number   Major   Minor   RaidDevice State
       0       8        1        0      active sync   /dev/sda1
       1       8       17        1      active sync   /dev/sdb1


:~$ sudo mdadm -D /dev/md1
        Version : 1.2
  Creation Time : Wed Aug 29 10:28:11 2012
     Raid Level : raid1
     Array Size : 1937758016 (1847.99 GiB 1984.26 GB)
  Used Dev Size : 1937758016 (1847.99 GiB 1984.26 GB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent

    Update Time : Mon Sep  3 10:47:40 2012
          State : clean 
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           Name : norsewind-obs:1  (local to host norsewind-obs)
           UUID : bec69e6b:53a222d6:726d1f6a:11d27043
         Events : 263

    Number   Major   Minor   RaidDevice State
       0       8        2        0      active sync   /dev/sda2
       2       8       18        1      active sync   /dev/sdb2

磁盘驱动器

:~$ sudo fdisk -l

Disk /dev/sda: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000ccfa5

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048    31250431    15624192   fd  Linux RAID autodetect
/dev/sda2   *    31250432  3907028991  1937889280   fd  Linux RAID autodetect

Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000ccfa5

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    31250431    15624192   fd  Linux RAID autodetect
/dev/sdb2   *    31250432  3907028991  1937889280   fd  Linux RAID autodetect

Disk /dev/sdc: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c73aa

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048  3907028991  1953513472   fd  Linux RAID autodetect

Disk /dev/sdd: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00035b05

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1            2048  3907028991  1953513472   fd  Linux RAID autodetect

Disk /dev/md2: 2000.3 GB, 2000263380992 bytes
2 heads, 4 sectors/track, 488345552 cylinders, total 3906764416 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/md2 doesn't contain a valid partition table

Disk /dev/md0: 16.0 GB, 15990652928 bytes
2 heads, 4 sectors/track, 3903968 cylinders, total 31231744 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/md0 doesn't contain a valid partition table

Disk /dev/md1: 1984.3 GB, 1984264208384 bytes
2 heads, 4 sectors/track, 484439504 cylinders, total 3875516032 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/md1 doesn't contain a valid partition table

答案1

使用grub-install而不是dd将 grub 安装到 MBR 中。

例如(作为 root,或使用 sudo):

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

顺便说一句,除非您休眠到交换分区,否则交换设备上不需要 RAID。您最好销毁 md0 并分别使用 sda 和 sdb 上的交换分区。

相关内容