我有一个远程 CentOS 6.4 服务器(具有 KVM 访问权限),当我收到该服务器时,它正在单个磁盘(sda)上使用 LVM 运行
我设法删除了 LVM 并在 sda 和 sdb 磁盘中安装了 raid 1
镜像工作正常,我现在唯一的问题是每次我重新启动服务器时,我都会得到 grub 命令行,并且我必须使用命令手动启动
grub> 配置文件 (hd1,0)/grub/grub.conf
或者
grub> 配置文件 (hd0,0)/grub/grub.conf
那么它将正常启动,不会出现任何错误。
知道如何让它自动启动吗?
注意:每个磁盘(sda 和 sdb)大小均为 2TB,这可能是问题所在吗?
我的设置
Filesystem Size Used Avail Use% Mounted on
/dev/md2 1.8T 1.1G 1.7T 1% /
tmpfs 16G 0 16G 0% /dev/shm
/dev/md0 1.9G 69M 1.8G 4% /boot
# cat /proc/mdstat
Personalities : [raid1]
md2 : active raid1 sda3[2] sdb3[0]
1940882240 blocks super 1.2 [2/2] [UU]
md1 : active raid1 sdb2[0] sda2[2]
10482176 blocks super 1.2 [2/2] [UU]
md0 : active raid1 sdb1[0] sda1[1]
2008000 blocks [2/2] [UU]
unused devices: <none>
# fdisk -l /dev/sda
Disk /dev/sda: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000b0530
Device Boot Start End Blocks Id System
/dev/sda1 * 1 250 2008093+ 83 Linux
/dev/sda2 251 1556 10490445 82 Linux swap / Solaris
/dev/sda3 1557 243201 1941013462+ fd Linux raid autodetect
# fdisk -l /dev/sdb
Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xadb3bd62
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 250 2008093+ fd Linux raid autodetect
/dev/sdb2 251 1556 10490445 82 Linux swap / Solaris
/dev/sdb3 1557 243201 1941013462+ fd Linux raid autodetect
# cat grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/mapper/vg_srv6953-lv_root
# initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd1,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-358.18.1.el6.x86_64)
root (hd1,0)
kernel /vmlinuz-2.6.32-358.18.1.el6.x86_64 ro root=/dev/md2 KEYBOARDTYPE=pc KEYTABLE=us LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 crashkernel=auto rhgb quiet rd_retry=20
initrd /initramfs-2.6.32-358.18.1.el6.x86_64.img
title CentOS (2.6.32-358.el6.x86_64)
root (hd1,0)
kernel /vmlinuz-2.6.32-358.el6.x86_64 ro root=/dev/md2 KEYBOARDTYPE=pc KEYTABLE=us LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 crashkernel=auto rhgb quiet
initrd /initramfs-2.6.32-358.el6.x86_64.img
# grub
Probing devices to guess BIOS drives. This may take a long time.
GNU GRUB version 0.97 (640K lower / 3072K upper memory)
[ Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists the possible
completions of a device/filename.]
grub> root (hd0,0)
root (hd0,0)
Filesystem type is ext2fs, partition type 0xfd
grub> setup (hd0)
setup (hd0)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 27 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 (hd0) (hd0)1+27 p (hd0,0)/boot/grub/stage2 /boot/grub/grub.conf"... succeeded
Done.
答案1
您需要在服务器硬盘设备上重新安装 grub。要了解设备地址,请在终端中输入
sudo fdisk -l
这将在列表中列出磁盘及其卷。记下您需要安装 grub 的设备。设备的大小会给您提示。如果 /dev/sda 是需要安装 grub 的设备,请转到终端并输入
sudo grub-install /dev/sda
重新启动服务器并检查问题是否解决。
答案2
好的
我做了以下事情:
- 从 raid 中移除 sda(使用 mdadm)
- 运行 dd(dd if=/dev/zero of=/dev/sda bs=512 count=1000)
- 复制当前磁盘分区表(sfdisk -d /dev/sdb | sfdisk /dev/sda)
- 将磁盘添加到 raid(使用 mdadm)
- 重新安装 grub(使用 grub 命令)
- 运行 grub-install /dev/sda
- 重启
现在它可以工作了:)
我之前做过上述所有步骤,除了第 2 步,似乎我需要用 dd 清除磁盘