使用LVM和RAID预置Ubuntu partman配方

我试图预装Ubuntu 12.04服务器安装,并创build了一个配方,在2个驱动器上创buildRAID 1,然后使用LVM对其进行分区。 不幸的是,partman在创buildLVM卷时抱怨说在配方中没有可以与LVM一起使用的分区(在控制台中它抱怨不可用的配方)。

我之后的布局是sdb和sdc上的RAID 1(从U盘安装,因此需要sda),然后使用LVM创build引导,根和交换。

奇怪的是,如果我将boot_lv的挂载点更改为home,那么配方工作正常(除了安装在错误的地方),但是当挂载在/ boot时,它会失败

我知道我可以使用单独的/启动主分区,但任何人都可以告诉我为什么失败。 下面的配方和相关的选项。

## Partitioning using RAID di partman-auto/disk string /dev/sdb /dev/sdc di partman-auto/method string raid di partman-lvm/device_remove_lvm boolean true di partman-md/device_remove_md boolean true #di partman-lvm/confirm boolean true di partman-auto-lvm/new_vg_name string main_vg di partman-auto/expert_recipe string \ multiraid :: \ 100 512 -1 raid \ $lvmignore{ } \ $primary{ } \ method{ raid } \ . \ 256 512 256 ext3 \ $defaultignore{ } \ $lvmok{ } \ method{ format } \ format{ } \ use_filesystem{ } \ filesystem{ ext3 } \ mountpoint{ /boot } \ lv_name{ boot_lv } \ . \ 2000 5000 -1 ext4 \ $defaultignore{ } \ $lvmok{ } \ method{ format } \ format{ } \ use_filesystem{ } \ filesystem{ ext4 } \ mountpoint{ / } \ lv_name{ root_lv } \ . \ 64 512 300% linux-swap \ $defaultignore{ } \ $lvmok{ } \ method{ swap } \ format{ } \ lv_name{ swap_lv } \ . di partman-auto-raid/recipe string \ 1 2 0 lvm - \ /dev/sdb1#/dev/sdc1 \ . di mdadm/boot_degraded boolean true #di partman-md/confirm boolean true #di partman-partitioning/confirm_write_new_label boolean true #di partman/choose_partition select Finish partitioning and write changes to disk #di partman/confirm boolean true #di partman-md/confirm_nooverwrite boolean true #di partman/confirm_nooverwrite boolean true 

经过一些试验和错误,我已经到达了下面的配方和设置,我用它来成功地预装我们的服务器。 就目前而言,它会在没有确认的情况下覆盖磁盘,然后在实际testing之前调整选项。

 ## Partitioning using RAID # The method should be set to "raid". di partman-auto/method string raid # Specify the disks to be partitioned. They will all get the same layout, # so this will only work if the disks are the same size. di partman-auto/disk string /dev/sda /dev/sdb di partman-lvm/device_remove_lvm boolean true di partman-md/device_remove_md boolean true di partman-lvm/confirm boolean true di partman-auto-lvm/new_vg_name string main_vg # Next you need to specify the physical partitions that will be used. di partman-auto/expert_recipe string \ multiraid :: \ 256 512 256 raid \ $lvmignore{ } \ $primary{ } \ method{ raid } \ raidid{ 1 } \ . \ 4000 5000 -1 raid \ $lvmignore{ } \ method{ raid } \ raidid{ 2 } \ . \ 2000 5000 -1 ext4 \ $defaultignore{ } \ $lvmok{ } \ method{ format } \ format{ } \ use_filesystem{ } \ filesystem{ ext4 } \ mountpoint{ / } \ lv_name{ root_lv } \ . \ 512 512 300% linux-swap \ $defaultignore{ } \ $lvmok{ } \ method{ swap } \ format{ } \ lv_name{ swap_lv } \ . # Last you need to specify how the previously defined partitions will be # used in the RAID setup. Remember to use the correct partition numbers # for logical partitions. RAID levels 0, 1, 5, 6 and 10 are supported; # devices are separated using "#". # Parameters are: # <raidtype> <devcount> <sparecount> <fstype> <mountpoint> \ # <devices> <sparedevices> di partman-auto-raid/recipe string \ 1 2 0 ext3 /boot \ raidid=1 \ . \ 1 2 0 lvm - \ raidid=2 \ . di mdadm/boot_degraded boolean true di partman-md/confirm boolean true di partman-partitioning/confirm_write_new_label boolean true di partman/choose_partition select Finish partitioning and write changes to disk di partman/confirm boolean true di partman-md/confirm_nooverwrite boolean true di partman/confirm_nooverwrite boolean true 

在googlesearch了一下之后,我发现在partman-auto-lvm下面的代码片段中,似乎如果lvm配方在LVM上检测到/ boot分区,它将会退出,尽pipe在LVM上启动/启动是完全可能的。 根据我的研究,在GRUB 2之前,您无法从LVM启动,因此您需要单独的主启动分区。

 # Make sure a boot partition isn't marked as lvmok if echo "$scheme" | grep lvmok | grep -q "[[:space:]]/boot[[:space:]]"; then bail_out unusable_recipe fi 

解决方法是指定没有安装点,并从设置屏幕手动执行,这在一定程度上破坏了无人值守安装的目的。