Need help fixing up Grub 2 on SD card with Win/Ubuntu on different drive.
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Need help fixing up Grub 2 on SD card with Win/Ubuntu on different drive.
I need some help getting Grub setup correctly on an admittedly peculiar setup.
I have a HP ML110 G7 which has some quirks. It has two sata contollers, the main one which is fixed to a 4 port HD cradle and a second that has 2 ports for other devices. In AHCI mode, only the first controller can be set as the boot device.
The server also has an internal USB socket and an Internal SD Card. The bios can be set to boot from USB, but then you must fix whether it's the SD Card, internal USB or external USB. This can't be selected at boot time.
My setup is a 1TB conventional HD on the first sata controller and a 128GB SSD on the second. I have Windows 10 and Ubuntu 15.04.
Because the BIOS won't boot from the second sata controller, and I want to keep the 1TB as removable data only, the only solution that I could come up with after many, may trials was to sacrifice an old 256 MB SD card as a boot device with grub installed manually which then boots the OS of choice from the SSD card. This way if the 1TB is missing or broken, then the system will still boot fine. Not the most elegant solution, but it works fine and boots quickly as the SD card does not contain any of the OS files.
This worked fine until the first time there was an update to the linux kernel and thus an update to grub, on the next boot Ubuntu would no longer boot. Windows boots fine.
I did manage to boot into linux by using the grub-recovery and using the find command to locate the vmlinuz and kernel files and then executing the boot manually, but this was not persistent and I couldn't seem to fix it permanently.
I'm quite certain that I've got it setup incorrectly as I have transferred the vmlinuz files to the SD card, and this does not seem to be the fastest or most reliable setup. I tried symlinking the /grub folder from the ssd to the /boot on the SD card, but this just ended up nesting grub as /boot/boot/grub.
What I'd like to achieve, is the SD card as the boot device, with all the necessary files outside of the config on the SSD. I especially want a setup that will update on Windows and Ubuntu which will not kill the grub boot. I'd also like to avoid a chain-loading of grubs in order to boot into linux (ie grub on sd to grub on ssd) unless it's a simple quick handover.
I'm sure there is an easy simple solution, but I'm stuck.
I can't access the computer at the moment, however I did have the grub ls entries written down:
hd0,msdos1 = SD card
hd1,msdos1 = Windows Data HDD
hd1,msdos2 = Linux Data HDD
hd2,msdos1 = SSD Persistent Boot
hd2,msdos2 = SSD Windows
hd2,msdos3 = SSD Linux
I'll get the rest as soon as I can access the system.
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
set have_grubenv=true
load_env
fi
if [ "${next_entry}" ] ; then
set default="${next_entry}"
set next_entry=
save_env next_entry
set boot_once=true
else
set default="0"
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 recordfail {
set recordfail=1
if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; 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_msdos
insmod ext2
set root='hd2,msdos3'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd2,msdos3 --hint-efi=hd2,msdos3 --hint-baremetal=ahci2,msdos3 bbd209f9-085b-4ffa-b928-b6919221f847
else
search --no-floppy --fs-uuid --set=root bbd209f9-085b-4ffa-b928-b6919221f847
fi
font="/usr/share/grub/unicode.pf2"
fi
if loadfont $font ; then
set gfxmode=auto
load_video
insmod gfxterm
set locale_dir=$prefix/locale
set lang=en_AU
insmod gettext
fi
terminal_output gfxterm
if [ "${recordfail}" = 1 ] ; then
set timeout=30
else
if [ x$feature_timeout_style = xy ] ; then
set timeout_style=hidden
set timeout=0
# Fallback hidden-timeout code in case the timeout_style feature is
# unavailable.
elif sleep --interruptible 0 ; then
set timeout=0
fi
fi
### END /etc/grub.d/00_header ###
### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
if background_color 44,0,30,0; then
clear
fi
### END /etc/grub.d/05_debian_theme ###
### BEGIN /etc/grub.d/10_linux ###
function gfxmode {
set gfxpayload="${1}"
if [ "${1}" = "keep" ]; then
set vt_handoff=vt.handoff=7
else
set vt_handoff=
fi
}
if [ "${recordfail}" != 1 ]; then
if [ -e ${prefix}/gfxblacklist.txt ]; then
if hwmatch ${prefix}/gfxblacklist.txt 3; then
if [ ${match} = 0 ]; then
set linux_gfx_mode=keep
else
set linux_gfx_mode=text
fi
else
set linux_gfx_mode=text
fi
else
set linux_gfx_mode=keep
fi
else
set linux_gfx_mode=text
fi
export linux_gfx_mode
menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-bbd209f9-085b-4ffa-b928-b6919221f847' {
recordfail
load_video
gfxmode $linux_gfx_mode
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_msdos
insmod ext2
set root='hd2,msdos3'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd2,msdos3 --hint-efi=hd2,msdos3 --hint-baremetal=ahci2,msdos3 bbd209f9-085b-4ffa-b928-b6919221f847
else
search --no-floppy --fs-uuid --set=root bbd209f9-085b-4ffa-b928-b6919221f847
fi
linux /boot/vmlinuz-3.19.0-23-generic root=UUID=bbd209f9-085b-4ffa-b928-b6919221f847 ro quiet splash $vt_handoff
initrd /boot/initrd.img-3.19.0-23-generic
}
submenu 'Advanced options for Ubuntu' $menuentry_id_option 'gnulinux-advanced-bbd209f9-085b-4ffa-b928-b6919221f847' {
menuentry 'Ubuntu, with Linux 3.19.0-23-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.0-23-generic-advanced-bbd209f9-085b-4ffa-b928-b6919221f847' {
recordfail
load_video
gfxmode $linux_gfx_mode
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_msdos
insmod ext2
set root='hd2,msdos3'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd2,msdos3 --hint-efi=hd2,msdos3 --hint-baremetal=ahci2,msdos3 bbd209f9-085b-4ffa-b928-b6919221f847
else
search --no-floppy --fs-uuid --set=root bbd209f9-085b-4ffa-b928-b6919221f847
fi
echo 'Loading Linux 3.19.0-23-generic ...'
linux /boot/vmlinuz-3.19.0-23-generic root=UUID=bbd209f9-085b-4ffa-b928-b6919221f847 ro quiet splash $vt_handoff
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-3.19.0-23-generic
}
menuentry 'Ubuntu, with Linux 3.19.0-23-generic (upstart)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.0-23-generic-init-upstart-bbd209f9-085b-4ffa-b928-b6919221f847' {
recordfail
load_video
gfxmode $linux_gfx_mode
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_msdos
insmod ext2
set root='hd2,msdos3'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd2,msdos3 --hint-efi=hd2,msdos3 --hint-baremetal=ahci2,msdos3 bbd209f9-085b-4ffa-b928-b6919221f847
else
search --no-floppy --fs-uuid --set=root bbd209f9-085b-4ffa-b928-b6919221f847
fi
echo 'Loading Linux 3.19.0-23-generic ...'
linux /boot/vmlinuz-3.19.0-23-generic root=UUID=bbd209f9-085b-4ffa-b928-b6919221f847 ro quiet splash $vt_handoff init=/sbin/upstart
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-3.19.0-23-generic
}
menuentry 'Ubuntu, with Linux 3.19.0-23-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.0-23-generic-recovery-bbd209f9-085b-4ffa-b928-b6919221f847' {
recordfail
load_video
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_msdos
insmod ext2
set root='hd2,msdos3'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd2,msdos3 --hint-efi=hd2,msdos3 --hint-baremetal=ahci2,msdos3 bbd209f9-085b-4ffa-b928-b6919221f847
else
search --no-floppy --fs-uuid --set=root bbd209f9-085b-4ffa-b928-b6919221f847
fi
echo 'Loading Linux 3.19.0-23-generic ...'
linux /boot/vmlinuz-3.19.0-23-generic root=UUID=bbd209f9-085b-4ffa-b928-b6919221f847 ro recovery nomodeset
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-3.19.0-23-generic
}
menuentry 'Ubuntu, with Linux 3.19.0-20-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.0-20-generic-advanced-bbd209f9-085b-4ffa-b928-b6919221f847' {
recordfail
load_video
gfxmode $linux_gfx_mode
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_msdos
insmod ext2
set root='hd2,msdos3'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd2,msdos3 --hint-efi=hd2,msdos3 --hint-baremetal=ahci2,msdos3 bbd209f9-085b-4ffa-b928-b6919221f847
else
search --no-floppy --fs-uuid --set=root bbd209f9-085b-4ffa-b928-b6919221f847
fi
echo 'Loading Linux 3.19.0-20-generic ...'
linux /boot/vmlinuz-3.19.0-20-generic root=UUID=bbd209f9-085b-4ffa-b928-b6919221f847 ro quiet splash $vt_handoff
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-3.19.0-20-generic
}
menuentry 'Ubuntu, with Linux 3.19.0-20-generic (upstart)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.0-20-generic-init-upstart-bbd209f9-085b-4ffa-b928-b6919221f847' {
recordfail
load_video
gfxmode $linux_gfx_mode
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_msdos
insmod ext2
set root='hd2,msdos3'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd2,msdos3 --hint-efi=hd2,msdos3 --hint-baremetal=ahci2,msdos3 bbd209f9-085b-4ffa-b928-b6919221f847
else
search --no-floppy --fs-uuid --set=root bbd209f9-085b-4ffa-b928-b6919221f847
fi
echo 'Loading Linux 3.19.0-20-generic ...'
linux /boot/vmlinuz-3.19.0-20-generic root=UUID=bbd209f9-085b-4ffa-b928-b6919221f847 ro quiet splash $vt_handoff init=/sbin/upstart
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-3.19.0-20-generic
}
menuentry 'Ubuntu, with Linux 3.19.0-20-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.19.0-20-generic-recovery-bbd209f9-085b-4ffa-b928-b6919221f847' {
recordfail
load_video
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_msdos
insmod ext2
set root='hd2,msdos3'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd2,msdos3 --hint-efi=hd2,msdos3 --hint-baremetal=ahci2,msdos3 bbd209f9-085b-4ffa-b928-b6919221f847
else
search --no-floppy --fs-uuid --set=root bbd209f9-085b-4ffa-b928-b6919221f847
fi
echo 'Loading Linux 3.19.0-20-generic ...'
linux /boot/vmlinuz-3.19.0-20-generic root=UUID=bbd209f9-085b-4ffa-b928-b6919221f847 ro recovery nomodeset
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-3.19.0-20-generic
}
}
### 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+ ###
menuentry 'Memory test (memtest86+)' {
insmod part_msdos
insmod ext2
set root='hd2,msdos3'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd2,msdos3 --hint-efi=hd2,msdos3 --hint-baremetal=ahci2,msdos3 bbd209f9-085b-4ffa-b928-b6919221f847
else
search --no-floppy --fs-uuid --set=root bbd209f9-085b-4ffa-b928-b6919221f847
fi
knetbsd /boot/memtest86+.elf
}
menuentry 'Memory test (memtest86+, serial console 115200)' {
insmod part_msdos
insmod ext2
set root='hd2,msdos3'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd2,msdos3 --hint-efi=hd2,msdos3 --hint-baremetal=ahci2,msdos3 bbd209f9-085b-4ffa-b928-b6919221f847
else
search --no-floppy --fs-uuid --set=root bbd209f9-085b-4ffa-b928-b6919221f847
fi
linux16 /boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###
### BEGIN /etc/grub.d/30_os-prober ###
menuentry 'Windows Recovery Environment (loader) (on /dev/sdc1)' --class windows --class os $menuentry_id_option 'osprober-chain-46CA4022CA40111B' {
insmod part_msdos
insmod ntfs
set root='hd2,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd2,msdos1 --hint-efi=hd2,msdos1 --hint-baremetal=ahci2,msdos1 46CA4022CA40111B
else
search --no-floppy --fs-uuid --set=root 46CA4022CA40111B
fi
parttool ${root} hidden-
drivemap -s (hd0) ${root}
chainloader +1
}
set timeout_style=menu
if [ "${timeout}" = 0 ]; then
set timeout=10
fi
### 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 ###
I updated the system and re-ran update-grub, then copied the grub.cfg to /boot/grub/ on /dev/sdb1, which is the SD Card. I know this is not a solution, but it does allow me to boot without having to use the grub command line.
Perhaps the best solution would be to simply have the SD boot and immediately pass it off to grub on the SSD. This way if I move the SSD to a new system it will still be viable and boot into linux. Given that the SD card is only a work around for this hardware this seems logical. I would like to avoid a double grub menu if possible.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.