0

My question is related to Grub: boot with USB key, then continue booting from SD card? besides I am trying to create a grub iso file that I will later burn to a CD and this should be the way that I am booting into linux.

I am a bit newbie when it comes to grub and kernel and I am not sure that it would even be possible to boot an Ubuntu installed on SDCard from a CD.

What I tried so far was to install Ubuntu from a LiveUSB on my SDCard where partitions look like this:

Ubuntu partitions

Secondly, based on this thread: https://www.linuxquestions.org/questions/linux-general-1/creating-a-grub2-boot-cd-with-a-grub-cfg-menu-my-solution-754835/ I was able to create an grub iso file where I could burn it to CD via Brasero. I think the problem might be from here as I've just copied boot folder from /dev/sdb5 which is the root (/) partition from installed Ubuntu and then I ran the command:

grub-mkrescue --modules="linux ext2 fshelp ls boot pc" --output=grub2-boot.iso ~/Desktop/boot

However, after running the command above, I got:

grub-mkrescue: error: cannot open `/usr/lib/grub/i386-pc/pc.mod': No such file or directory.

I researched a bit for this problem and a fix for it might be running

sudo apt-get install grub-pc-bin

but it didn't create pc.mod so I removed that module from the command (again, I am not sure what exactly I am doing and what pc module should do).

Finally, when I restarted the system I found out that grub was booting from CD, but the problem is (at least one of them) that (hd1,msdos5) from my grub.cfg won't appear when executing "ls" in grub. The only filesystems available are (cd1) (cd1,msdos1) and I think that this might be related to the driver of the SDCard reader which isn't present at the booting stage. Somehow, the solution would integrate SDCard driver in the grub iso, but I'm not sure that this would be possible.

This is the full grub.cfg from boot folder of /dev/sdb5 which is mounted as /media/ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d (it's UUID I think):

#
# 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='hd1,msdos5'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos5 --hint-efi=hd1,msdos5 --hint-baremetal=ahci1,msdos5  ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d
else
  search --no-floppy --fs-uuid --set=root ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d
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_US
  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=1
    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-ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d' {
    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='hd1,msdos5'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos5 --hint-efi=hd1,msdos5 --hint-baremetal=ahci1,msdos5  ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d
    else
      search --no-floppy --fs-uuid --set=root ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d
    fi
        linux   /boot/vmlinuz-5.4.0-122-generic root=UUID=ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d ro  quiet splash $vt_handoff
    initrd  /boot/initrd.img-5.4.0-122-generic
}
submenu 'Advanced options for Ubuntu' $menuentry_id_option 'gnulinux-advanced-ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d' {
    menuentry 'Ubuntu, with Linux 5.4.0-122-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-122-generic-advanced-ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d' {
        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='hd1,msdos5'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos5 --hint-efi=hd1,msdos5 --hint-baremetal=ahci1,msdos5  ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d
        else
          search --no-floppy --fs-uuid --set=root ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d
        fi
        echo    'Loading Linux 5.4.0-122-generic ...'
            linux   /boot/vmlinuz-5.4.0-122-generic root=UUID=ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d ro  quiet splash $vt_handoff
        echo    'Loading initial ramdisk ...'
        initrd  /boot/initrd.img-5.4.0-122-generic
    }
    menuentry 'Ubuntu, with Linux 5.4.0-122-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-122-generic-recovery-ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d' {
        recordfail
        load_video
        insmod gzio
        if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
        insmod part_msdos
        insmod ext2
        set root='hd1,msdos5'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos5 --hint-efi=hd1,msdos5 --hint-baremetal=ahci1,msdos5  ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d
        else
          search --no-floppy --fs-uuid --set=root ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d
        fi
        echo    'Loading Linux 5.4.0-122-generic ...'
            linux   /boot/vmlinuz-5.4.0-122-generic root=UUID=ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d ro recovery nomodeset dis_ucode_ldr 
        echo    'Loading initial ramdisk ...'
        initrd  /boot/initrd.img-5.4.0-122-generic
    }
    menuentry 'Ubuntu, with Linux 5.4.0-42-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-42-generic-advanced-ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d' {
        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='hd1,msdos5'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos5 --hint-efi=hd1,msdos5 --hint-baremetal=ahci1,msdos5  ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d
        else
          search --no-floppy --fs-uuid --set=root ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d
        fi
        echo    'Loading Linux 5.4.0-42-generic ...'
            linux   /boot/vmlinuz-5.4.0-42-generic root=UUID=ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d ro  quiet splash $vt_handoff
        echo    'Loading initial ramdisk ...'
        initrd  /boot/initrd.img-5.4.0-42-generic
    }
    menuentry 'Ubuntu, with Linux 5.4.0-42-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-42-generic-recovery-ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d' {
        recordfail
        load_video
        insmod gzio
        if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
        insmod part_msdos
        insmod ext2
        set root='hd1,msdos5'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos5 --hint-efi=hd1,msdos5 --hint-baremetal=ahci1,msdos5  ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d
        else
          search --no-floppy --fs-uuid --set=root ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d
        fi
        echo    'Loading Linux 5.4.0-42-generic ...'
            linux   /boot/vmlinuz-5.4.0-42-generic root=UUID=ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d ro recovery nomodeset dis_ucode_ldr 
        echo    'Loading initial ramdisk ...'
        initrd  /boot/initrd.img-5.4.0-42-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='hd1,msdos5'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos5 --hint-efi=hd1,msdos5 --hint-baremetal=ahci1,msdos5  ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d
    else
      search --no-floppy --fs-uuid --set=root ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d
    fi
    knetbsd /boot/memtest86+.elf
}
menuentry 'Memory test (memtest86+, serial console 115200)' {
    insmod part_msdos
    insmod ext2
    set root='hd1,msdos5'
    if [ x$feature_platform_search_hint = xy ]; then
      search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos5 --hint-efi=hd1,msdos5 --hint-baremetal=ahci1,msdos5  ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d
    else
      search --no-floppy --fs-uuid --set=root ca8dc83c-7795-4dbd-8ee9-3e59ec526e6d
    fi
    linux16 /boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
### 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 ###

Thanks for your time!

2
  • try this ... run insmod part_msdos at grub prompt ... then run ls
    – jsotola
    Jul 17, 2022 at 3:14
  • AFAIK there's no way to make grub see block devices that the BIOS/UEFI cannot see. In other words, if you can't boot (e.g. grub) directly from one, grub (on another block device) will not be able to boot anything from it either.
    – Tom Yan
    Jul 17, 2022 at 4:14

1 Answer 1

0

I think I managed to solve my problem, seems that all the needed files from /boot were located in grub at

ls /

Now I am facing that each time I have to type in grub

linux /vmlinuz-5.4.0-122-generic root=/dev/sda5
initrd /initrd.img-5.4.0-122-generic
boot

in order to boot in Ubuntu. Is there any way that I can automatically make this step? Maybe adding these commands in grub.cfg and making a new iso?

2
  • Please do not use answers to ask questions. Instead you can edit your original question. Jul 31, 2022 at 7:47
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Jul 31, 2022 at 7:47

You must log in to answer this question.

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