加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – 无法将grub安装到RAID1(md0)

发布时间:2020-12-13 16:53:31 所属栏目:Linux 来源:网络整理
导读:我的Ubuntu 12.04 LTS上有一个RAID1阵列,几天前我的/ sda硬盘已被更换.我用这个命令来代替: # go to superusersudo bash# see RAID statemdadm -Q -D /dev/md0# State should be "clean,degraded"# remove broken disk from RAIDmdadm /dev/md0 --fail /dev
我的Ubuntu 12.04 LTS上有一个RAID1阵列,几天前我的/ sda硬盘已被更换.我用这个命令来代替:
# go to superuser
sudo bash
# see RAID state
mdadm -Q -D /dev/md0
# State should be "clean,degraded"
# remove broken disk from RAID
mdadm /dev/md0 --fail /dev/sda1
mdadm /dev/md0 --remove /dev/sda1
# see partitions
fdisk -l
# shutdown computer
shutdown now
# physically replace old disk by new
# start system again
# see partitions
fdisk -l
# copy partitions from sdb to sda
sfdisk -d /dev/sdb | sfdisk /dev/sda
# recreate id for sda
sfdisk --change-id /dev/sda 1 fd
# add sda1 to RAID
mdadm /dev/md0 --add /dev/sda1
# see RAID state
mdadm -Q -D /dev/md0
# State should be "clean,degraded,recovering"
# to see status you can use
cat /proc/mdstat

这是同步后我的mdadm输出:

/dev/md0:
        Version : 0.90
  Creation Time : Wed Feb 17 16:18:25 2010
     Raid Level : raid1
     Array Size : 470455360 (448.66 GiB 481.75 GB)
  Used Dev Size : 470455360 (448.66 GiB 481.75 GB)
   Raid Devices : 2
  Total Devices : 2
Preferred Minor : 0
    Persistence : Superblock is persistent

    Update Time : Thu Nov  1 15:19:31 2012
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           UUID : 92e6ff4e:ed3ab4bf:fee5eb6c:d9b9cb11
         Events : 0.11049560

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

在构建完成后“fdisk -l”表示我没有有效的分区表/ dev / md0.
这是我的fdisk -l输出:

Disk /dev/sda: 500.1 GB,500107862016 bytes
255 heads,63 sectors/track,60801 cylinders,total 976773168 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: 0x00057d19

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63   940910984   470455461   fd  Linux raid autodetect
/dev/sda2       940910985   976768064    17928540    5  Extended
/dev/sda5       940911048   976768064    17928508+  82  Linux swap / Solaris

Disk /dev/sdb: 500.1 GB,total 976773168 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: 0x000667ca

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *          63   940910984   470455461   fd  Linux raid autodetect
/dev/sdb2       940910985   976768064    17928540    5  Extended
/dev/sdb5       940911048   976768064    17928508+  82  Linux swap / Solaris

Disk /dev/md0: 481.7 GB,481746288640 bytes
2 heads,4 sectors/track,117613840 cylinders,total 940910720 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

这是我的grub安装输出:

root@answe:~# grub-install /dev/sda
/usr/sbin/grub-setup: warn: Attempting to install GRUB to a disk with multiple partition labels or both partition label and filesystem.  This is not supported yet..
/usr/sbin/grub-setup: error: embedding is not possible,but this is required for cross-disk install.
root@answe:~# grub-install /dev/sdb
Installation finished. No error reported.

一些版本信息:

grub-install (GRUB) 1.99-21ubuntu3.4
3.2.0-32-generic #51-Ubuntu SMP Wed Sep 26 21:33:09 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

所以

1)“update-grub”只找到/ sda和/ sdb Linux,而不是/ md0

2)“dpkg-reconfigure grub-pc”说“GRUB无法安装以下设备/ dev / md0”

我无法加载我的系统,除了从/ sdb1(和手动,而不是自动),并在DEGRADED模式…

有人可以解决这个问题吗?我对此非常头疼.

更新:用零擦除新磁盘后,用sfdisk update-grub复制分区说:

root@answe:~# grub-install /dev/sda
error: found two disks with the index 2 for RAID md0.
error: found two disks with the index 2 for RAID md0.
error: found two disks with the index 2 for RAID md0.
error: found two disks with the index 2 for RAID md0.
error: found two disks with the index 2 for RAID md0.
Installation finished. No error reported.

现在update-grub生成相同的错误:

root@answe:~# update-grub
error: found two disks with the index 2 for RAID md0.
error: found two disks with the index 2 for RAID md0.
Generating grub.cfg ...
error: found two disks with the index 2 for RAID md0.
error: found two disks with the index 2 for RAID md0.
error: found two disks with the index 2 for RAID md0.
error: found two disks with the index 2 for RAID md0.
error: found two disks with the index 2 for RAID md0.
error: found two disks with the index 2 for RAID md0.
Found linux image: /boot/vmlinuz-3.2.0-32-generic
Found initrd image: /boot/initrd.img-3.2.0-32-generic
...
error: found two disks with the index 2 for RAID md0.
error: found two disks with the index 2 for RAID md0.
Found memtest86+ image: /boot/memtest86+.bin
No volume groups found
error: found two disks with the index 2 for RAID md0.
error: found two disks with the index 2 for RAID md0.
Found Ubuntu 12.04.1 LTS (12.04) on /dev/sda1
Found Ubuntu 12.04.1 LTS (12.04) on /dev/sdb1
error: found two disks with the index 2 for RAID md0.
error: found two disks with the index 2 for RAID md0.
error: found two disks with the index 2 for RAID md0.
error: found two disks with the index 2 for RAID md0.
done

解决方法

警告指出了根本原因.您用于替换的新磁盘可能曾经有过一个文件系统,grub-setup现在可能仍然存在于元数据中.

因此,只需将磁盘开头的所有内容清除到第一个分区即可.我从fdisk -l输出中取出了62号.它说63是第一个分区的开始,听起来像它之前有62个扇区你可以清理掉.

dd if=/dev/zero of=/dev/sda bs=512 count=62

然后重新创建分区表:

sfdisk -d /dev/sdb | sfdisk /dev/sda

sfdisk可能会抱怨“内核可能正在使用旧的分区表”,但您可以忽略该警告,因为您并未真正更改分区表.

然后你应该能够grub-install / dev / sda.

更新:

如果仍然出现错误,请尝试将磁盘从RAID中取出并从开头和结尾清零更多数据.或者只将整个磁盘归零(dd if = / dev / zero = = dev / sda).然后像以前一样将其添加回RAID,从sfdisk -d / dev / sdb |开始sfdisk / dev / sda.并考虑按照其他一些地方的建议切换到元数据格式1.0.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读