rework lvm,raid grub2 support

This commit is contained in:
Tobias Powalowski 2012-04-22 20:06:54 +02:00
parent 6f6b31d359
commit 09ccc4fecf

View file

@ -4006,12 +4006,8 @@ EOF
dogrub2_common_before() { dogrub2_common_before() {
##### Check whether the below limitations still continue with ver 1.99~beta0 ##### Check whether the below limitations still continue with ver 1.99~beta0
### Grub2 restrictions: ### Grub2 restrictions:
# - dmraid doesn't work: # - Encryption is not recommended for grub2 /boot!
# https://bugs.launchpad.net/ubuntu/+source/ubuntu-meta/+bug/436340
# grub2 restriction due to messy dmraid mapping
# - Encryption is not supported by grub2 yet!
# - raid with no supperblock 0.90 is not supported by grub2 yet!
if [[ -f "${DESTDIR}/boot/grub/menu.lst" ]]; then if [[ -f "${DESTDIR}/boot/grub/menu.lst" ]]; then
DIALOG --msgbox "Found ${DESTDIR}/boot/grub/menu.lst, deinstalling grub now ..." 0 0 DIALOG --msgbox "Found ${DESTDIR}/boot/grub/menu.lst, deinstalling grub now ..." 0 0
${PACMAN} -R grub > ${LOG} ${PACMAN} -R grub > ${LOG}
@ -4365,11 +4361,11 @@ dogrub2_bios() {
# check if raid, raid partition, dmraid or device devicemapper is used # check if raid, raid partition, dmraid or device devicemapper is used
if [[ "$(echo ${bootdev} | grep /dev/md)" ]] || [[ "$(echo ${bootdev} | grep /dev/mapper)" ]]; then if [[ "$(echo ${bootdev} | grep /dev/md)" ]] || [[ "$(echo ${bootdev} | grep /dev/mapper)" ]]; then
# boot from lvm, raid and dmraid devices is supported # boot from lvm, raid, partitioned raid and dmraid devices is supported
FAIL_COMPLEX="0" FAIL_COMPLEX="0"
if [[ "$(echo ${bootdev} | grep /dev/md*p)" ]] || [[ "$(cryptsetup status ${bootdev})" ]]; then if [[ "$(cryptsetup status ${bootdev})" ]]; then
# partitionable raid and encryption devices are not supported # encryption devices are not supported
FAIL_COMPLEX="1" FAIL_COMPLEX="1"
fi fi
fi fi
@ -4377,31 +4373,6 @@ dogrub2_bios() {
if [[ "${FAIL_COMPLEX}" == "0" ]]; then if [[ "${FAIL_COMPLEX}" == "0" ]]; then
grubdev=$(basename ${bootdev}) grubdev=$(basename ${bootdev})
complexuuid=$(getfsuuid ${bootdev}) complexuuid=$(getfsuuid ${bootdev})
# check if mapper is used
if [[ "$(echo ${bootdev} | grep /dev/mapper)" ]]; then
RAID_ON_LVM="0"
#check if mapper contains a md device!
for devpath in $(pvs -o pv_name --noheading); do
if [[ "$(echo ${devpath} | grep -v /dev/md*p | grep /dev/md)" ]]; then
detectedvolumegroup="$(echo $(pvs -o vg_name --noheading ${devpath}))"
if [[ "$(echo /dev/mapper/${detectedvolumegroup}-* | grep ${bootdev})" ]]; then
# change bootdev to md device!
bootdev=$(pvs -o pv_name --noheading ${devpath})
RAID_ON_LVM="1"
break
fi
fi
done
fi
USE_RAID=""
if [[ "$(echo ${bootdev} | grep /dev/md)" ]]; then
USE_RAID="1"
fi
else else
# use normal device # use normal device
grubdev=$(mapdev ${bootdev}) grubdev=$(mapdev ${bootdev})
@ -4410,25 +4381,17 @@ dogrub2_bios() {
# A switch is needed if complex ${bootdev} is used! # A switch is needed if complex ${bootdev} is used!
# - It doesn't make sense to present device list, if raid or raid+lvm is used for ${bootdev}. # - LVM and RAID ${bootdev} needs the MBR of a device and cannot be used itself as ${bootdev}
# - LVM ${bootdev} needs the MBR of a device and cannot be used itself as ${bootdev}
if [[ "${FAIL_COMPLEX}" == "0" ]]; then if [[ "${FAIL_COMPLEX}" == "0" ]]; then
# use function below if no raid is detected! DEVS="$(findbootloaderdisks _)"
if [[ "${RAID_ON_LVM}" == "0" ]]; then
DEVS="$(findbootloaderdisks _)" if [[ "${DEVS}" == "" ]]; then
DIALOG --msgbox "No hard drives were found" 0 0
if [[ "${DEVS}" == "" ]]; then return 1
DIALOG --msgbox "No hard drives were found" 0 0
return 1
fi
DIALOG --menu "Select the boot device where the GRUB2 bootloader will be installed." 14 55 7 ${DEVS} 2>${ANSWER} || return 1
bootdev=$(cat ${ANSWER})
fi fi
if [[ "${USE_RAID}" == "1" ]]; then DIALOG --menu "Select the boot device where the GRUB2 bootloader will be installed." 14 55 7 ${DEVS} 2>${ANSWER} || return 1
DIALOG --yesno "Setup detected /boot on a raid setup.\n\nContinue installing GRUB2 on ${bootdev}?" 0 0 || return 1 bootdev=$(cat ${ANSWER})
fi
else else
DEVS="$(findbootloaderdisks _)" DEVS="$(findbootloaderdisks _)"
DEVS="${DEVS} $(findbootloaderpartitions _)" DEVS="${DEVS} $(findbootloaderpartitions _)"
@ -4455,7 +4418,7 @@ dogrub2_bios() {
fi fi
if [[ "${FAIL_COMPLEX}" == "1" ]]; then if [[ "${FAIL_COMPLEX}" == "1" ]]; then
DIALOG --msgbox "Error:\nGrub2 cannot boot from ${bootdev}, which contains /boot!\n\nPossible error sources:\n- raid partition device (/dev/md_dX) are not supported\n- encrypted devices are not supported" 0 0 DIALOG --msgbox "Error:\nGrub2 cannot boot from ${bootdev}, which contains /boot!\n\nPossible error sources:\n- encrypted devices are not supported" 0 0
return 1 return 1
fi fi
@ -4473,7 +4436,6 @@ dogrub2_bios() {
"${bootdev}" &>"/tmp/grub2_bios_install.log" "${bootdev}" &>"/tmp/grub2_bios_install.log"
chroot_umount chroot_umount
# cat /tmp/grub2.log > "${LOG}"
if [[ -e "${DESTDIR}/boot/grub/i386-pc/core.img" ]]; then if [[ -e "${DESTDIR}/boot/grub/i386-pc/core.img" ]]; then
DIALOG --msgbox "GRUB2 BIOS has been successfully installed." 0 0 DIALOG --msgbox "GRUB2 BIOS has been successfully installed." 0 0