0

I need to find out how I can get grub2/opensuse boot process to ignore raid partitions on non-primary disks. I have system with /dev/sda and /dev/sdb which are primary disks which boot UEFI from grub2 and a series of secondary disks. They look like this:

NAME              MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda                 8:0    0 465.8G  0 disk  
├─sda1              8:1    0     2G  0 part  /boot/efi
└─sda2              8:2    0 463.8G  0 part  
  └─md0             9:0    0 463.8G  0 raid1 
    ├─system-root 254:0    0 455.8G  0 lvm   /
    └─system-swap 254:1    0     8G  0 lvm   [SWAP]
sdb                 8:16   0 465.8G  0 disk  
├─sdb1              8:17   0     2G  0 part  
└─sdb2              8:18   0 463.8G  0 part  
  └─md0             9:0    0 463.8G  0 raid1 
    ├─system-root 254:0    0 455.8G  0 lvm   /
    └─system-swap 254:1    0     8G  0 lvm   [SWAP]
sdc                 8:32   0   1.8T  0 disk  
├─sdc1              8:33   0   399M  0 part  
└─sdc2              8:34   0   1.8T  0 part  
sdd                 8:48   0   1.8T  0 disk  
├─sdd1              8:49   0   399M  0 part  
└─sdd2              8:50   0   1.8T  0 part  
sde                 8:64   0   1.8T  0 disk  
sdf                 8:80   0   1.8T  0 disk  

The disks /dev/sdc - /dev/sdf are disks that are used by virtual hosts run on the outer host. Reason being outer hosts functions as router and inner hosts are encrypted root servers that can be started remotely by ssh'ing into outer host. Outr host does not have root encryption, but obviously does not host any critical data.

Problem is that disks /dev/sdc - /dev/sdf have raid partitions (encryption + lvm, etc..) and when outer system boots it attempts to construct raid arrays, decrypt etc.. These raid arrays have to be deconstructed before virtual hosts can be booted. Furthermore boot fails when the volumes on these raid arrays cannot be unencrypted.

Question: how can grub2 boot process be set to ignore partitions on disks /dev/sdc - /dev/sdf and only set up system based on primary disks /dev/sda and /dev/sdb. Objective is automatic boot that looks like above structure.

Here is /boot/grub2/grub.cfg

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -f ${config_directory}/grubenv ]; then
  load_env -f ${config_directory}/grubenv
elif [ -s $prefix/grubenv ]; then
  load_env
fi

if [ "${env_block}" ] ; then
  load_env -f "${env_block}"
fi

if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   if [ "${env_block}" ] ; then
     save_env -f "${env_block}" next_entry
   fi
   set boot_once=true
else
   set default="${saved_entry}"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

if [ x$feature_default_font_path = xy ] ; then
   font=unicode
else
insmod part_gpt
insmod part_gpt
insmod diskfilter
insmod mdraid1x
insmod lvm
insmod ext2
set root='lvmid/36Ndwy-2YD2-onbC-3fKp-BdXl-Kmra-aELGxs/Pt4neo-JhAd-I4G4-02S8-X8eb-5xeY-wRpDWz'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint='lvmid/36Ndwy-2YD2-onbC-3fKp-BdXl-Kmra-aELGxs/Pt4neo-JhAd-I4G4-02S8-X8eb-5xeY-wRpDWz'  95092080-6e02-43c0-8e97-730fd53cb61f
else
  search --no-floppy --fs-uuid --set=root 95092080-6e02-43c0-8e97-730fd53cb61f
fi
    font="/usr/share/grub2/unicode.pf2"
fi

if loadfont $font ; then
echo "Please press t to show the boot menu on this console"
  set gfxmode=auto
  load_video
  insmod gfxterm
  set locale_dir=$prefix/locale
  set lang=POSIX
  insmod gettext
fi
terminal_output gfxterm
insmod part_gpt
insmod part_gpt
insmod diskfilter
insmod mdraid1x
insmod lvm
insmod ext2
set root='lvmid/36Ndwy-2YD2-onbC-3fKp-BdXl-Kmra-aELGxs/Pt4neo-JhAd-I4G4-02S8-X8eb-5xeY-wRpDWz'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint='lvmid/36Ndwy-2YD2-onbC-3fKp-BdXl-Kmra-aELGxs/Pt4neo-JhAd-I4G4-02S8-X8eb-5xeY-wRpDWz'  95092080-6e02-43c0-8e97-730fd53cb61f
else
  search --no-floppy --fs-uuid --set=root 95092080-6e02-43c0-8e97-730fd53cb61f
fi
insmod gfxmenu
loadfont ($root)/boot/grub2/themes/openSUSE/DejaVuSans-Bold14.pf2
loadfont ($root)/boot/grub2/themes/openSUSE/DejaVuSans10.pf2
loadfont ($root)/boot/grub2/themes/openSUSE/DejaVuSans12.pf2
loadfont ($root)/boot/grub2/themes/openSUSE/ascii.pf2
insmod png
set theme=($root)/boot/grub2/themes/openSUSE/theme.txt
export theme
if [ x${boot_once} = xtrue ]; then
  set timeout=0
elif [ x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=8
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=8
fi


### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/00_tuned ###
set tuned_params=""
### END /etc/grub.d/00_tuned ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'openSUSE LEAP 42.2'  --class opensuse --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-95092080-6e02-43c0-8e97-730fd53cb61f' {
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_gpt
        insmod part_gpt
        insmod diskfilter
        insmod mdraid1x
        insmod lvm
        insmod ext2
        set root='lvmid/36Ndwy-2YD2-onbC-3fKp-BdXl-Kmra-aELGxs/Pt4neo-JhAd-I4G4-02S8-X8eb-5xeY-wRpDWz'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint='lvmid/36Ndwy-2YD2-onbC-3fKp-BdXl-Kmra-aELGxs/Pt4neo-JhAd-I4G4-02S8-X8eb-5xeY-wRpDWz'  95092080-6e02-43c0-8e97-730fd53cb61f
        else
          search --no-floppy --fs-uuid --set=root 95092080-6e02-43c0-8e97-730fd53cb61f
        fi
        echo    'Loading Linux 4.4.27-2-default ...'
        linux   /boot/vmlinuz-4.4.27-2-default root=/dev/mapper/system-root  resume=/dev/system/swap splash=silent quiet showopts nomodeset
        echo    'Loading initial ramdisk ...'
        initrd  /boot/initrd-4.4.27-2-default
}
submenu 'Advanced options for openSUSE LEAP 42.2' --hotkey=1 $menuentry_id_option 'gnulinux-advanced-95092080-6e02-43c0-8e97-730fd53cb61f' {
        menuentry 'openSUSE LEAP 42.2, with Linux 4.4.27-2-default' --hotkey=2 --class opensuse --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.27-2-default-advanced-95092080-6e02-43c0-8e97-730fd53cb61f' {
                load_video
                set gfxpayload=keep
                insmod gzio
                insmod part_gpt
                insmod part_gpt
                insmod diskfilter
                insmod mdraid1x
                insmod lvm
                insmod ext2
                set root='lvmid/36Ndwy-2YD2-onbC-3fKp-BdXl-Kmra-aELGxs/Pt4neo-JhAd-I4G4-02S8-X8eb-5xeY-wRpDWz'
                if [ x$feature_platform_search_hint = xy ]; then
                  search --no-floppy --fs-uuid --set=root --hint='lvmid/36Ndwy-2YD2-onbC-3fKp-BdXl-Kmra-aELGxs/Pt4neo-JhAd-I4G4-02S8-X8eb-5xeY-wRpDWz'  95092080-6e02-43c0-8e97-730fd53cb61f
                else
                  search --no-floppy --fs-uuid --set=root 95092080-6e02-43c0-8e97-730fd53cb61f
                fi
                echo    'Loading Linux 4.4.27-2-default ...'
                linux   /boot/vmlinuz-4.4.27-2-default root=/dev/mapper/system-root  resume=/dev/system/swap splash=silent quiet showopts nomodeset
                echo    'Loading initial ramdisk ...'
                initrd  /boot/initrd-4.4.27-2-default
        }
}

### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###

### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/20_memtest86+ ###
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/50_bootcycle ###
# created for bootcycle detection
menuentry 'halt' {
        halt
}
### END /etc/grub.d/50_bootcycle ###

### BEGIN /etc/grub.d/80_suse_btrfs_snapshot ###
### END /etc/grub.d/80_suse_btrfs_snapshot ###

### BEGIN /etc/grub.d/90_persistent ###
### END /etc/grub.d/90_persistent ###

### BEGIN /etc/grub.d/95_textmode ###

    # On EFI systems we can only have graphics *or* serial, so allow the user
    # to switch between the two
    hiddenentry 'Text mode' --hotkey 't' {
        set textmode=true
        terminal_output console
    }
### END /etc/grub.d/95_textmode ###

Let me know what other info might be helpful to understand.

1 Answer 1

0
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

This is only partly true: The reason you shouldn't modify this is only because it gets overwritten by grub2-mkconfig. There's no other reason not to create it manually. You can reduce /boot/grub2/grub.cfg to only contain menuentries you need by writing your own configuration file.

grub-mkconfig does have some limitations. While adding extra custom menu entries to the end of the list can be done by editing /etc/grub.d/40_custom or creating /boot/grub/custom.cfg, changing the order of menu entries or changing their titles may require making complex changes to shell scripts stored in /etc/grub.d/. This may be improved in the future. In the meantime, those who feel that it would be easier to write grub.cfg directly are encouraged to do so (see Booting, and Shell-like scripting), and to disable any system provided by their distribution to automatically run grub-mkconfig.

The configuration created by grub-mkconfig tries to include everything from anywhere that could be detectable, like every kernel installed etc. However, your configuration seems to be more sophisticated, possibly needing comparably sophisticated, manually created grub.cfg.

1
  • I am fine to write my own configuration file and maintain it. What I do not know is how to cause grub2 not build raid arrrays or open lvm on drives other than the two primary drives. Any clue would be very welcome.
    – gatomulato
    May 23, 2017 at 10:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .