大家好!
我花了一整天时间尝试在 Debian 8.5 上设置 LVM 类型 Raid1 卷,但服务器无法从它启动。
首先,这是我从 GRUB2 得到的错误:
这是我采取的步骤,首先我启动到 grml(Live-CD/Rescue-System):(全新 /dev/sda 和 /dev/sdb)
1.然后我在两个驱动器上创建分区:
- 512M 主 (Linux raid 自动检测)
- 20G 主 8e (Linux LVM)
2. 现在我为我的 /boot 创建 Raid 并将其格式化为 ext4
- mdadm --create /dev/md0 --level=1 --raid-disks=2 /dev/sda1 /dev/sdb1
- mkfs.ext4 /dev/md0
3. 是时候进行卷组了
pvcreate /dev/sda2 pvcreate /dev/sdb2 vgcreate vg0 /dev/sda2 /dev/sdb2
4.我们来到卷并格式化它们
lvcreate -n root -L 20G vg0 --type raid1 lvcreate -n swap -L 4G vg0 --type raid1
root@grml ~ # lvscan ACTIVE '/dev/vg0/root' [10,00 GiB] inherit ACTIVE '/dev/vg0/swap' [4,00 GiB] inherit
mkfs.ext4 /dev/vg0/root mkswap /dev/vg0/swap
5. 挂载卷
mount /dev/vg0/root /mnt cd /mnt mkdir boot mkdir proc mkdir dev mkdir sys mkdir home mount /dev/md0 boot/
- 创建 fstab
mkdir etc cd etc vi fstab
`proc /proc proc defaults 0 0
/dev/md0 /boot ext4 defaults 0 2
/dev/vg0/root / ext4 defaults 0 1
/dev/vg0/swap none swap defaults,pri=1 0 0`
7. debootstrap debian jessie
debootstrap --arch amd64 jessie /mnt ftp://ftp.de.debian.org/debian/
8. 安装一些必需品
mount -t proc none /mnt/proc mount -o bind /dev /mnt/dev mount -o bind /sys /mnt/sys
9. chroot 进入全新的 Debian
chroot /mnt /bin/bash
10.设置新的root密码
passwd
11. 将 contrib 和 non-free 添加到源列表
nano /etc/apt/sources.list
deb http://ftp.de.debian.org/debian jessie main contrib non-free
12.安装软件包
apt-get install mdadm openssh-server lvm2 locales ntp vim-nox firmware-realtek
13. 配置区域设置
dpkg-reconfigure locales tzdata
14.安装内核
apt-get install linux-image-amd64
15. grub2
apt-get install grub2
选择 sda 和 sdb 作为安装设备
grub-install --no-floppy /dev/sda grub-install --no-floppy /dev/sdb update-grub /dev/md0 update-initramfs -u
16.退出并重启
exit shutdown -r now
也许任何人都可以帮助我,我希望我只是忘记了一些事情。
答案1
根据红帽员工:
Grub 不支持 LVM RAID1(据我所知它仅支持 RAID 4/5/6 类型)。
Debian 8 有一些旧的内部结构,您可能会遇到同样的限制,我想找到一些关于 Grub 限制的官方信息,但不幸的是我失败了。
Re: [linux-lvm] GRUB boot problem with lvm mirror type raid1 From: Peter Rajnoha <prajnoha redhat com> To: gk180984 interia pl Cc: LVM general discussion and development <linux-lvm redhat com> Subject: Re: [linux-lvm] GRUB boot problem with lvm mirror type raid1 Date: Mon, 14 Apr 2014 11:40:36 +0200
On 04/14/2014 10:42 AM, gk180984 interia pl wrote: Hi I want to ask it is possible boot root file system (via GRUB) from LVM RAID1 volume? I can boot root file system (with /boot) from linera LVM volume and from mirror volume, but when I create raid1 mirror GRUB can't boot from it: lvconvert --type raid1 -m1 gsys/vsys LVM mirror is work: lvconvert -m1 gsys/vsys I have two disk and use only LVM, not other raid software. GRUB have lvm module.
Grub doesn't support LVM RAID1 (it supports only RAID 4/5/6 type IIRC). However, I don't recommend using /boot on LVM at the moment since grub support for LVM is limited and unofficial. There's a plan to add official and more robust support though - there are ongoing discussions between grub and LVM team...