Grub 2: writing an /etc/grub.d/40_custom file.
by stf92 from LinuxQuestions.org on (#56WV6)
Hi: The following is from /boot/grub/grub.cfg.
Code:### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Slackware 14.2 x86_64 (post 14.2 -current) (on /dev/mmcblk0p2)' --class slackware --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-simple-70a70011-b918-40ff-8468-565327d809f2' {
insmod part_msdos
insmod ext2
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
else
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
fi
linux /boot/vmlinuz-generic root=/dev/mmcblk0p2 edd=off noapic i8042.nopnp
initrd /boot/initrd.gz
}
submenu 'Advanced options for Slackware 14.2 x86_64 (post 14.2 -current) (on /dev/mmcblk0p2)' $menuentry_id_option 'osprober-gnulinux-advanced-70a70011-b918-40ff-8468-565327d809f2' {
menuentry 'Slackware 14.2 x86_64 (post 14.2 -current) (on /dev/mmcblk0p2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz--70a70011-b918-40ff-8468-565327d809f2' {
insmod part_msdos
insmod ext2
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
else
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
fi
linux /boot/vmlinuz root=/dev/mmcblk0p2
initrd /boot/initrd.gz
}
menuentry 'Slackware 14.2 x86_64 (post 14.2 -current) (on /dev/mmcblk0p2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz--70a70011-b918-40ff-8468-565327d809f2' {
insmod part_msdos
insmod ext2
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
else
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
fi
linux /boot/vmlinuz root=/dev/mmcblk0p2
initrd /boot/initrd.gz.BAK
}
menuentry 'Slackware 14.2 x86_64 (post 14.2 -current) (on /dev/mmcblk0p2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz--70a70011-b918-40ff-8468-565327d809f2' {
insmod part_msdos
insmod ext2
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
else
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
fi
linux /boot/vmlinuz root=/dev/mmcblk0p2
initrd /boot/initrd.gz
}
menuentry 'Slackware 14.2 x86_64 (post 14.2 -current) (on /dev/mmcblk0p2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz--70a70011-b918-40ff-8468-565327d809f2' {
insmod part_msdos
insmod ext2
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
else
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
fi
linux /boot/vmlinuz root=/dev/mmcblk0p2
initrd /boot/initrd.gz.BAK
}
menuentry 'Slackware 14.2 x86_64 (post 14.2 -current) (on /dev/mmcblk0p2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-generic--70a70011-b918-40ff-8468-565327d809f2' {
insmod part_msdos
insmod ext2
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
else
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
fi
linux /boot/vmlinuz-generic root=/dev/mmcblk0p2
}
menuentry 'Slackware 14.2 x86_64 (post 14.2 -current) (on /dev/mmcblk0p2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-generic-5.4.50--70a70011-b918-40ff-8468-565327d809f2' {
insmod part_msdos
insmod ext2
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
else
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
fi
linux /boot/vmlinuz-generic-5.4.50 root=/dev/mmcblk0p2
}
menuentry 'Slackware 14.2 x86_64 (post 14.2 -current) (on /dev/mmcblk0p2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-huge--70a70011-b918-40ff-8468-565327d809f2' {
insmod part_msdos
insmod ext2
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
else
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
fi
linux /boot/vmlinuz-huge root=/dev/mmcblk0p2
}
menuentry 'Slackware 14.2 x86_64 (post 14.2 -current) (on /dev/mmcblk0p2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-huge-5.4.50--70a70011-b918-40ff-8468-565327d809f2' {
insmod part_msdos
insmod ext2
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
else
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
fi
linux /boot/vmlinuz-huge-5.4.50 root=/dev/mmcblk0p2
}
}
### END /etc/grub.d/30_os-prober ###
### BEGIN /etc/grub.d/30_uefi-firmware ###
### END /etc/grub.d/30_uefi-firmware ###
### 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/41_custom ###
if [ -f ${config_directory}/custom.cfg ]; then
source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###As you can see, in the section 30_os-prober, the first line beginning with 'linux' and the one following are these:Code:linux /boot/vmlinuz-generic root=/dev/mmcblk0p2 edd=off noapic i8042.nopnp
initrd /boot/initrd.gzIf I run update-grub then the string 'edd=off noapic i8042.nopnp' and the line following (initrd /boot/initrd.gz) disappear. So I need to write an /etc/grub.d/40_custom such that those two lines are preserved. What exactly would then be the contents of 40_custom?


Code:### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Slackware 14.2 x86_64 (post 14.2 -current) (on /dev/mmcblk0p2)' --class slackware --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-simple-70a70011-b918-40ff-8468-565327d809f2' {
insmod part_msdos
insmod ext2
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
else
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
fi
linux /boot/vmlinuz-generic root=/dev/mmcblk0p2 edd=off noapic i8042.nopnp
initrd /boot/initrd.gz
}
submenu 'Advanced options for Slackware 14.2 x86_64 (post 14.2 -current) (on /dev/mmcblk0p2)' $menuentry_id_option 'osprober-gnulinux-advanced-70a70011-b918-40ff-8468-565327d809f2' {
menuentry 'Slackware 14.2 x86_64 (post 14.2 -current) (on /dev/mmcblk0p2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz--70a70011-b918-40ff-8468-565327d809f2' {
insmod part_msdos
insmod ext2
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
else
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
fi
linux /boot/vmlinuz root=/dev/mmcblk0p2
initrd /boot/initrd.gz
}
menuentry 'Slackware 14.2 x86_64 (post 14.2 -current) (on /dev/mmcblk0p2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz--70a70011-b918-40ff-8468-565327d809f2' {
insmod part_msdos
insmod ext2
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
else
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
fi
linux /boot/vmlinuz root=/dev/mmcblk0p2
initrd /boot/initrd.gz.BAK
}
menuentry 'Slackware 14.2 x86_64 (post 14.2 -current) (on /dev/mmcblk0p2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz--70a70011-b918-40ff-8468-565327d809f2' {
insmod part_msdos
insmod ext2
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
else
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
fi
linux /boot/vmlinuz root=/dev/mmcblk0p2
initrd /boot/initrd.gz
}
menuentry 'Slackware 14.2 x86_64 (post 14.2 -current) (on /dev/mmcblk0p2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz--70a70011-b918-40ff-8468-565327d809f2' {
insmod part_msdos
insmod ext2
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
else
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
fi
linux /boot/vmlinuz root=/dev/mmcblk0p2
initrd /boot/initrd.gz.BAK
}
menuentry 'Slackware 14.2 x86_64 (post 14.2 -current) (on /dev/mmcblk0p2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-generic--70a70011-b918-40ff-8468-565327d809f2' {
insmod part_msdos
insmod ext2
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
else
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
fi
linux /boot/vmlinuz-generic root=/dev/mmcblk0p2
}
menuentry 'Slackware 14.2 x86_64 (post 14.2 -current) (on /dev/mmcblk0p2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-generic-5.4.50--70a70011-b918-40ff-8468-565327d809f2' {
insmod part_msdos
insmod ext2
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
else
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
fi
linux /boot/vmlinuz-generic-5.4.50 root=/dev/mmcblk0p2
}
menuentry 'Slackware 14.2 x86_64 (post 14.2 -current) (on /dev/mmcblk0p2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-huge--70a70011-b918-40ff-8468-565327d809f2' {
insmod part_msdos
insmod ext2
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
else
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
fi
linux /boot/vmlinuz-huge root=/dev/mmcblk0p2
}
menuentry 'Slackware 14.2 x86_64 (post 14.2 -current) (on /dev/mmcblk0p2)' --class gnu-linux --class gnu --class os $menuentry_id_option 'osprober-gnulinux-/boot/vmlinuz-huge-5.4.50--70a70011-b918-40ff-8468-565327d809f2' {
insmod part_msdos
insmod ext2
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
else
search --no-floppy --fs-uuid --set=root 70a70011-b918-40ff-8468-565327d809f2
fi
linux /boot/vmlinuz-huge-5.4.50 root=/dev/mmcblk0p2
}
}
### END /etc/grub.d/30_os-prober ###
### BEGIN /etc/grub.d/30_uefi-firmware ###
### END /etc/grub.d/30_uefi-firmware ###
### 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/41_custom ###
if [ -f ${config_directory}/custom.cfg ]; then
source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###As you can see, in the section 30_os-prober, the first line beginning with 'linux' and the one following are these:Code:linux /boot/vmlinuz-generic root=/dev/mmcblk0p2 edd=off noapic i8042.nopnp
initrd /boot/initrd.gzIf I run update-grub then the string 'edd=off noapic i8042.nopnp' and the line following (initrd /boot/initrd.gz) disappear. So I need to write an /etc/grub.d/40_custom such that those two lines are preserved. What exactly would then be the contents of 40_custom?