Booting Ubuntu with GRUB2: how to add boot entry to GRUB2?
I would use the posted tutorial, procedure number 2 there. Before issuing the commands make sure that /dev/sdd
is the intended 1TB drive.
sudo mount /dev/sdd3 /mnt
sudo grub-install --root-directory=/mnt/ /dev/sdd
This will install the Grub loader to the beginning of the drive and to the /boot
directory on sdd3
.
You don't need to run the update-grub
section there. Then go to BIOS and mark the sdd
drive as the primary boot device.
David Elner
Updated on September 18, 2022Comments
-
David Elner over 1 year
Last night, I decided to take the plunge, and install Ubuntu as complimentary part to my dual boot system (with Windows 7). Unfortunately, the entire process has been a struggle uphill, namely with getting the bootloader configured properly.
A short historical synopsis, for the full context of the situation:
Generated and installed Ubuntu 11.04 x64 off of a USB drive setup on a Windows 7 machine. I had trouble getting the installer to even boot, until I learned I couldn't use my USB3.0 port. Switched to the USB2.0 port, continued with the install.
I have a 1TB HDD that I split in half for the purpose of dual booting: 500GB partition for Windows 7, and a 500GB for Ubuntu (excluding the boot/swap file partitions). The Ubuntu partition was installed with the ext4 filesystem, and installation completed without any apparent problems, and was prompted to reboot.
Upon rebooting, I got dumped into the old Windows boot loader, which immediately fired up Windows. I played around with a utility called EasyBCD to attempt to add a Linux entry to my newly installed partition, to no avail.
Then, I booted Ubuntu straight off the USB drive, and installed GRUB2 onto the boot partition following the steps outlined here. I also ran the step ("update-grub") to generate a new 'grub.cfg' file, which added an entry to my old 'Windows 7' bootloader, but not one for my new Ubuntu partition! When I rebooted, the GRUB2 bootloader started successfully, but my Ubuntu was still unable to be found/booted under the list of available operating systems.
Anyone have any ideas how I should change/update this configuration such that it'll point to my new Ubuntu installation properly?
Some useful information...
"fdisk -l":
Disk /dev/sdd: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb209a592
Device Boot Start End Blocks Id System /dev/sdd1 * 1 13 102400 7 HPFS/NTFS Partition 1 does not end on cylinder boundary. /dev/sdd2 13 60555 486297600 7 HPFS/NTFS /dev/sdd3 60555 120143 478642176 83 Linux /dev/sdd4 120143 121602 11717633 5 Extended /dev/sdd5 120143 121602 11717632 82 Linux swap / Solaris
"grub.cfg" entries:
### BEGIN /etc/grub.d/30_os-prober ### menuentry "Windows 7 (loader) (on /dev/sdd1)" --class windows --class os { insmod part_msdos insmod ntfs set root='(/dev/sdd,msdos1)' search --no-floppy --fs-uuid --set=root 08BAB5B0BAB59B20 chainloader +1 } ### END /etc/grub.d/30_os-prober ### ### 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 ###
"boot_info_script output:
Boot Info Script 0.60 from 17 May 2011 ============================= Boot Info Summary: =============================== => Windows is installed in the MBR of /dev/sda. => Windows is installed in the MBR of /dev/sdb. => Windows is installed in the MBR of /dev/sdc. => Grub2 (v1.99) is installed in the MBR of /dev/sdd and looks at sector 1 of the same hard drive for core.img. core.img is at this location and looks for (,msdos1)/grub on this drive. => Syslinux MBR (4.04 and higher) is installed in the MBR of /dev/sde. sda1: __________________________________________________________________________ File system: ntfs Boot sector type: Windows XP Boot sector info: No errors found in the Boot Parameter Block. Operating System: Boot files: sdb1: __________________________________________________________________________ File system: ntfs Boot sector type: Windows Vista/7 Boot sector info: No errors found in the Boot Parameter Block. Operating System: Boot files: /bootmgr /Boot/BCD sdb2: __________________________________________________________________________ File system: ntfs Boot sector type: Windows Vista/7 Boot sector info: No errors found in the Boot Parameter Block. Operating System: Windows 7 Boot files: /Windows/System32/winload.exe sdc1: __________________________________________________________________________ File system: ntfs Boot sector type: Windows XP Boot sector info: No errors found in the Boot Parameter Block. Operating System: Boot files: sdd1: __________________________________________________________________________ File system: ntfs Boot sector type: Windows Vista/7 Boot sector info: No errors found in the Boot Parameter Block. Operating System: Boot files: /grub/grub.cfg /bootmgr /Boot/BCD /grub/core.img sdd2: __________________________________________________________________________ File system: ntfs Boot sector type: Windows Vista/7 Boot sector info: No errors found in the Boot Parameter Block. Operating System: Windows 7 Boot files: /Windows/System32/winload.exe sdd3: __________________________________________________________________________ File system: ext4 Boot sector type: - Boot sector info: Operating System: Ubuntu 11.04 Boot files: /boot/grub/grub.cfg /etc/fstab sdd4: __________________________________________________________________________ File system: Extended Partition Boot sector type: - Boot sector info: sdd5: __________________________________________________________________________ File system: swap Boot sector type: - Boot sector info: sde1: __________________________________________________________________________ File system: vfat Boot sector type: SYSLINUX 4.04 2011-04-18 Boot sector info: Syslinux looks at sector 8448 of /dev/sde1 for its second stage. SYSLINUX is installed in the directory. The integrity check of the ADV area failed. No errors found in the Boot Parameter Block. Operating System: Boot files: /boot/grub/grub.cfg /syslinux/syslinux.cfg /ldlinux.sys ============================ Drive/Partition Info: ============================= Drive: sda _____________________________________________________________________ Disk /dev/sda: 1000.2 GB, 1000204886016 bytes 255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes Partition Boot Start Sector End Sector # of Sectors Id System /dev/sda1 63 1,953,520,064 1,953,520,002 7 NTFS / exFAT / HPFS Drive: sdb _____________________________________________________________________ Disk /dev/sdb: 250.1 GB, 250059350016 bytes 255 heads, 63 sectors/track, 30401 cylinders, total 488397168 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes Partition Boot Start Sector End Sector # of Sectors Id System /dev/sdb1 2,048 206,847 204,800 7 NTFS / exFAT / HPFS /dev/sdb2 * 206,848 488,394,751 488,187,904 7 NTFS / exFAT / HPFS Drive: sdc _____________________________________________________________________ Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes 255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes Partition Boot Start Sector End Sector # of Sectors Id System /dev/sdc1 63 1,953,520,064 1,953,520,002 7 NTFS / exFAT / HPFS Drive: sdd _____________________________________________________________________ Disk /dev/sdd: 1000.2 GB, 1000204886016 bytes 255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes Partition Boot Start Sector End Sector # of Sectors Id System /dev/sdd1 * 2,048 206,847 204,800 7 NTFS / exFAT / HPFS /dev/sdd2 206,848 972,802,047 972,595,200 7 NTFS / exFAT / HPFS /dev/sdd3 972,802,048 1,930,086,399 957,284,352 83 Linux /dev/sdd4 1,930,088,446 1,953,523,711 23,435,266 5 Extended /dev/sdd5 1,930,088,448 1,953,523,711 23,435,264 82 Linux swap / Solaris Drive: sde _____________________________________________________________________ Disk /dev/sde: 3926 MB, 3926949888 bytes 16 heads, 16 sectors/track, 29960 cylinders, total 7669824 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes Partition Boot Start Sector End Sector # of Sectors Id System /dev/sde1 * 8,064 7,669,823 7,661,760 c W95 FAT32 (LBA) "blkid" output: ________________________________________________________________ Device UUID TYPE LABEL /dev/loop0 squashfs /dev/sda1 36BA3C8CBA3C4A9F ntfs Data Storage (Backup) /dev/sdb1 90A09285A0927188 ntfs System Reserved /dev/sdb2 88E09C67E09C5D6E ntfs Old OS HDD /dev/sdc1 1CEE7227EE71F8FA ntfs Data Storage /dev/sdd1 08BAB5B0BAB59B20 ntfs System Reserved /dev/sdd2 30EEC43AEEC3F65E ntfs Operating System /dev/sdd3 fb62baf1-e6a7-4e0d-ada2-2efb52ab12fa ext4 /dev/sdd5 086c0085-650b-495f-b9e8-e7e637fac705 swap /dev/sde1 FC8F-97FE vfat PENDRIVE ================================ Mount points: ================================= Device Mount_Point Type Options /dev/loop0 /rofs squashfs (ro,noatime) /dev/sde1 /cdrom vfat (ro,noatime,fmask=0022,dmask=0022,codepage=cp437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro) ============================= sdd1/grub/grub.cfg: ============================== -------------------------------------------------------------------------------- # # 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 set default="0" 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 { insmod vbe insmod vga insmod video_bochs insmod video_cirrus } insmod part_msdos insmod ext2 set root='(/dev/sdd,msdos5)' search --no-floppy --fs-uuid --set=root 43000377-e88b-4373-975e-66146de829ce if loadfont /usr/share/grub/unicode.pf2 ; then set gfxmode=auto load_video insmod gfxterm fi terminal_output gfxterm insmod part_msdos insmod ntfs set root='(/dev/sdd,msdos1)' search --no-floppy --fs-uuid --set=root 08BAB5B0BAB59B20 set locale_dir=($root)/grub/locale set lang=en_US insmod gettext if [ "${recordfail}" = 1 ]; then set timeout=-1 else set timeout=10 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; then clear fi ### END /etc/grub.d/05_debian_theme ### ### BEGIN /etc/grub.d/10_linux ### 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 if [ "$linux_gfx_mode" != "text" ]; then load_video; fi ### 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/30_os-prober ### # menuentry "Windows 7 (loader) (on /dev/sdb1)" --class windows --class os { # insmod part_msdos # insmod ntfs # set root='(/dev/sdb,msdos1)' # search --no-floppy --fs-uuid --set=root 90A09285A0927188 # chainloader +1 # } menuentry "Windows 7 (loader) (on /dev/sdd1)" --class windows --class os { insmod part_msdos insmod ntfs set root='(/dev/sdd,msdos1)' search --no-floppy --fs-uuid --set=root 08BAB5B0BAB59B20 chainloader +1 } ### END /etc/grub.d/30_os-prober ### ### 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 $prefix/custom.cfg ]; then source $prefix/custom.cfg; fi ### END /etc/grub.d/41_custom ### -------------------------------------------------------------------------------- =================== sdd1: Location of files loaded by Grub: ==================== GiB - GB File Fragment(s) ?? = ?? grub/core.img 1 ?? = ?? grub/grub.cfg 1 =========================== sdd3/boot/grub/grub.cfg: =========================== -------------------------------------------------------------------------------- # # 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 set default="0" 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 { insmod efi_gop insmod efi_uga insmod video_bochs insmod video_cirrus } insmod part_msdos insmod ext2 set root='(/dev/sdd,msdos3)' search --no-floppy --fs-uuid --set=root fb62baf1-e6a7-4e0d-ada2-2efb52ab12fa if loadfont /usr/share/grub/unicode.pf2 ; then set gfxmode=auto load_video insmod gfxterm fi terminal_output gfxterm insmod part_msdos insmod ext2 set root='(/dev/sdd,msdos3)' search --no-floppy --fs-uuid --set=root fb62baf1-e6a7-4e0d-ada2-2efb52ab12fa set locale_dir=($root)/boot/grub/locale set lang=en_US insmod gettext if [ "${recordfail}" = 1 ]; then set timeout=-1 else set timeout=10 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; then clear fi ### END /etc/grub.d/05_debian_theme ### ### BEGIN /etc/grub.d/10_linux ### 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 if [ "$linux_gfx_mode" != "text" ]; then load_video; fi menuentry 'Ubuntu, with Linux 2.6.38-8-generic' --class ubuntu --class gnu-linux --class gnu --class os { recordfail set gfxpayload=$linux_gfx_mode insmod part_msdos insmod ext2 set root='(/dev/sdd,msdos3)' search --no-floppy --fs-uuid --set=root fb62baf1-e6a7-4e0d-ada2-2efb52ab12fa linux /boot/vmlinuz-2.6.38-8-generic root=UUID=fb62baf1-e6a7-4e0d-ada2-2efb52ab12fa ro quiet splash vt.handoff=7 initrd /boot/initrd.img-2.6.38-8-generic } menuentry 'Ubuntu, with Linux 2.6.38-8-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os { recordfail set gfxpayload=$linux_gfx_mode insmod part_msdos insmod ext2 set root='(/dev/sdd,msdos3)' search --no-floppy --fs-uuid --set=root fb62baf1-e6a7-4e0d-ada2-2efb52ab12fa echo 'Loading Linux 2.6.38-8-generic ...' linux /boot/vmlinuz-2.6.38-8-generic root=UUID=fb62baf1-e6a7-4e0d-ada2-2efb52ab12fa ro single echo 'Loading initial ramdisk ...' initrd /boot/initrd.img-2.6.38-8-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='(/dev/sdd,msdos3)' search --no-floppy --fs-uuid --set=root fb62baf1-e6a7-4e0d-ada2-2efb52ab12fa linux16 /boot/memtest86+.bin } menuentry "Memory test (memtest86+, serial console 115200)" { insmod part_msdos insmod ext2 set root='(/dev/sdd,msdos3)' search --no-floppy --fs-uuid --set=root fb62baf1-e6a7-4e0d-ada2-2efb52ab12fa linux16 /boot/memtest86+.bin console=ttyS0,115200n8 } ### END /etc/grub.d/20_memtest86+ ### ### BEGIN /etc/grub.d/30_os-prober ### menuentry "Windows 7 (loader) (on /dev/sdb1)" --class windows --class os { insmod part_msdos insmod ntfs set root='(/dev/sdb,msdos1)' search --no-floppy --fs-uuid --set=root 90A09285A0927188 chainloader +1 } menuentry "Windows 7 (loader) (on /dev/sdd1)" --class windows --class os { insmod part_msdos insmod ntfs set root='(/dev/sdd,msdos1)' search --no-floppy --fs-uuid --set=root 08BAB5B0BAB59B20 chainloader +1 } ### END /etc/grub.d/30_os-prober ### ### 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 $prefix/custom.cfg ]; then source $prefix/custom.cfg; fi ### END /etc/grub.d/41_custom ### -------------------------------------------------------------------------------- =============================== sdd3/etc/fstab: ================================ -------------------------------------------------------------------------------- # /etc/fstab: static file system information. # # Use 'blkid -o value -s UUID' to print the universally unique identifier # for a device; this may be used with UUID= as a more robust way to name # devices that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc nodev,noexec,nosuid 0 0 # / was on /dev/sdd3 during installation UUID=fb62baf1-e6a7-4e0d-ada2-2efb52ab12fa / ext4 errors=remount-ro 0 1 # swap was on /dev/sdd5 during installation UUID=086c0085-650b-495f-b9e8-e7e637fac705 none swap sw 0 0 -------------------------------------------------------------------------------- =================== sdd3: Location of files loaded by Grub: ==================== GiB - GB File Fragment(s) 476.025924683 = 511.128944640 boot/grub/grub.cfg 1 465.547851562 = 499.878199296 boot/initrd.img-2.6.38-8-generic 2 686.000980377 = 736.587943936 boot/vmlinuz-2.6.38-8-generic 1 465.547851562 = 499.878199296 initrd.img 2 686.000980377 = 736.587943936 vmlinuz 1 =========================== sde1/boot/grub/grub.cfg: =========================== -------------------------------------------------------------------------------- if loadfont /boot/grub/font.pf2 ; then set gfxmode=auto insmod efi_gop insmod efi_uga insmod gfxterm terminal_output gfxterm fi set menu_color_normal=white/black set menu_color_highlight=black/light-gray menuentry "Try Ubuntu without installing" { set gfxpayload=keep linux /casper/vmlinuz file=/cdrom/preseed/ubuntu.seed boot=casper quiet splash -- initrd /casper/initrd.lz } menuentry "Install Ubuntu" { set gfxpayload=keep linux /casper/vmlinuz file=/cdrom/preseed/ubuntu.seed boot=casper only-ubiquity quiet splash -- initrd /casper/initrd.lz } menuentry "Check disc for defects" { set gfxpayload=keep linux /casper/vmlinuz boot=casper integrity-check quiet splash -- initrd /casper/initrd.lz } -------------------------------------------------------------------------------- ========================= sde1/syslinux/syslinux.cfg: ========================== -------------------------------------------------------------------------------- # D-I config version 2.0 include menu.cfg default vesamenu.c32 prompt 0 timeout 50 # If you would like to use the new menu and be presented with the option to install or run from USB at startup, remove # from the following line. This line was commented out (by request of many) to allow the old menu to be presented and to enable booting straight into the Live Environment! # ui gfxboot bootlogo -------------------------------------------------------------------------------- =================== sde1: Location of files loaded by Grub: ==================== GiB - GB File Fragment(s) ?? = ?? boot/grub/grub.cfg 1 ================= sde1: Location of files loaded by Syslinux: ================== GiB - GB File Fragment(s) ?? = ?? ldlinux.sys 1 ?? = ?? syslinux/gfxboot.c32 1 ?? = ?? syslinux/syslinux.cfg 1 ?? = ?? syslinux/vesamenu.c32 1 ============== sde1: Version of COM32(R) files used by Syslinux: =============== syslinux/gfxboot.c32 : COM32R module (v4.xx) syslinux/vesamenu.c32 : COM32R module (v4.xx) =============================== StdErr Messages: =============================== unlzma: Decoder error /home/ubuntu/Desktop/boot_info_script.sh: line 1579: [: 2.73495e+09: integer expression expected
-
samme4life over 12 yearsThe provided info is OK, but could you please post the output of boot_info_script too? bootinfoscript.sourceforge.net
-
David Elner over 12 yearsAdded the output to the original post: please excuse the formatting... it was a copy/paste job.
-
David Elner over 12 yearsAlso, some explanation of what you're seeing: sda = NTFS formatted data drive sdb = OLD Windows 7 HDD (no longer in use) sdc = NTFS formatted data drive sdd = Windows 7 & Ubuntu drive (this is the one I want to boot from) sde = USB Drive (where Im currently loading Ubuntu from)