3

I have read several threads regarding this problem, but I can't solve mine.

Background

I wanted to upgrade my Lubuntu 20.04 to 22.04. My /boot/efi-partition's size was 150 MB and was working perfectly, but the Lubuntu 22.04 installer found an error: "/boot/efi partition has to be of at least 300 MB". So I went back, made my /swap partition 150 MB smaller, deleted the /boot/efi partition, and created it again but with a size of 300 MB. The installer accepted my manual partitioning and installed the OS.

Problem

My Lubuntu system works perfectly, but the "Windows Boot Manager" option on startup doesn't show up. The partition in which Windows 7 is installed remains untouched. The "Windows Boot Manager" option appeared yesterday and Windows 7 booted just fine.

Information

I did a lot of things, I can't really remember them all. I will leave you the information I believe is necessary after reading many threads and doing many things.

  1. Partition structure: I have an SSD in which I run my Lubuntu 22.04 (/dev/sda3), and in which I used to run my Windows 7 (/dev/sda6). The Lubuntu 20.04 (/dev/sdb7 I think) is an old backup Linux I have for emergencies.

    NAME    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
    loop0     7:0    0  74,2M  1 loop /snap/core22/1122
    loop1     7:1    0  74,2M  1 loop /snap/core22/1380
    loop2     7:2    0 262,5M  1 loop /snap/firefox/3779
    loop3     7:3    0     4K  1 loop /snap/bare/5
    loop4     7:4    0   497M  1 loop /snap/gnome-42-2204/141
    loop5     7:5    0  91,7M  1 loop /snap/gtk-common-themes/1535
    loop6     7:6    0  40,4M  1 loop /snap/snapd/20671
    loop7     7:7    0 139,7M  1 loop /snap/jdownloader2/20
    loop8     7:8    0  38,8M  1 loop /snap/snapd/21759
    sda       8:0    0 223,6G  0 disk 
    ├─sda1    8:1    0   301M  0 part /boot/efi
    ├─sda2    8:2    0   3,9G  0 part [SWAP]
    ├─sda3    8:3    0    40G  0 part /var/snap/firefox/common/host-hunspell
    │                                 /
    ├─sda4    8:4    0    60G  0 part /home
    ├─sda5    8:5    0    16M  0 part 
    └─sda6    8:6    0 119,4G  0 part 
    sdb       8:16   0 931,5G  0 disk 
    ├─sdb1    8:17   0    20G  0 part /home/el38/Descargas
    ├─sdb2    8:18   0    50G  0 part /home/el38/Documentos
    ├─sdb3    8:19   0   100G  0 part /home/el38/Imágenes
    ├─sdb4    8:20   0   100G  0 part /home/el38/Otros/misc
    ├─sdb5    8:21   0     1G  0 part 
    ├─sdb6    8:22   0     8G  0 part 
    ├─sdb7    8:23   0  43,6G  0 part 
    ├─sdb8    8:24   0  19,1G  0 part 
    ├─sdb9    8:25   0 377,1G  0 part /home/el38/Música
    └─sdb10   8:26   0   807M  0 part 
    
  2. sudo update-grub output

    Sourcing file `/etc/default/grub'
    Sourcing file `/etc/default/grub.d/init-select.cfg'
    Sourcing file `/etc/default/grub.d/lubuntu-grub-theme.cfg'
    Generating grub configuration file ...
    Found theme: /usr/share/grub/themes/lubuntu-grub-theme/theme.txt
    Found linux image: /boot/vmlinuz-6.5.0-41-generic
    Found initrd image: /boot/initrd.img-6.5.0-41-generic                                                                                                                   
    Found linux image: /boot/vmlinuz-6.5.0-18-generic                                                                                                                       
    Found initrd image: /boot/initrd.img-6.5.0-18-generic                                                                                                                   
    Memtest86+ needs a 16-bit boot, that is not available on EFI, exiting                                                                                                   
    Warning: os-prober will be executed to detect other bootable partitions.                                                                                                
    Its output will be used to detect bootable binaries on them and create new boot entries.                                                                                
    Found Ubuntu 20.04.3 LTS (20.04) on /dev/sdb7                                                                                                                           
    done
    
  3. sudo os-prober output:

    /dev/sdb7:Ubuntu 20.04.3 LTS (20.04):Ubuntu:linux
    
  4. /etc/fstab/ file. Note that for some reason there are two /boot/efi/ entries, with the same UUID, but one of them is commented. I did not do this manually, it is the original file that came with the install.

    # /etc/fstab: static file system information.
    #
    # Use 'blkid' 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>
    #UUID=F79B-717D                            /boot/efi      vfat    umask=0077 0 2
    UUID=9e06d6ca-c62d-46a3-9002-f46ead7d60b3 swap           swap    defaults,discard 0 0
    UUID=6f74b624-4306-4586-8913-d9328779bb27 /              ext4    defaults,discard 0 1
    UUID=78cd0971-1d29-4878-b3b3-f95499c7c141 /home          ext4    defaults,discard 0 2
    UUID=d72d820e-4479-4d9a-a742-c0cef3060ca9 /home/el38/Descargas ext4    defaults   0 2
    UUID=891ffb6e-ac93-4747-8d1e-e64661bd4805 /home/el38/Documentos ext4    defaults   0 2
    UUID=ddc43c37-870b-4d61-82dd-527bd6de118d /home/el38/Imágenes ext4    defaults   0 2
    UUID=af917f50-c22f-4fac-bb7b-9fdfeb65cae4 /home/el38/Otros/misc ext4    defaults   0 2
    UUID=54b294eb-c768-4061-9488-4e79f52104ae /home/el38/Música ext4    defaults   0 2
    /swapfile                                 swap           swap    defaults   0 0
    tmpfs                                     /tmp           tmpfs   defaults,noatime,mode=1777 0 0
    UUID=F79B-717D  /boot/efi       vfat    defaults      0       1
    
  5. I followed this guide and did what it said. I ran Boot-Repair in a live USB (the same I used to install my 22.04 new version in /dev/sda3). This is the Boot-Info diagnosis, and after running the recommended repair it said "Boot successfully repaired.", but the "Windows Boot Manager" option still does not appear and I can not boot Windows 7.

    This is the Recommended Repair report.

    I don't know if it's important, but after this recommended repair, Boot-Repair warned me about some "NVram locked". I searched this on the internet, and I read some people saying it is because of the Secure Boot option in the BIOS configuration. I made sure the Secure Boot was (and still is) disabled.

  6. (edit) sudo efibootmgr --verbose output

    Timeout: 1 seconds
    BootOrder: 000C,000D,000E,0004
    Boot0004  Hard Drive    BBS(HD,,0x0)..GO..NO........o.A.D.A.T.A.        .S.U.6.3.0....................A...........................>..Gd-.;.A..MQ..L.L.2.6.2.9.2.7.1.N.E.U.1. . . . . . . . ........BO..NO........o.S.T.1.0.0.0.L.M.0.2.4. .H.N.-.M.1.0.1.M.B.B....................A...........................>..Gd-.;.A..MQ..L.3.S.X.2.9.J.G.B.3.9.2.6.6.6. . . . . . ........BO
    Boot000C* ubuntu        HD(1,GPT,3860fedb-cbb4-1b4b-a151-c012fcf4afec,0x22,0x967de)/File(\EFI\UBUNTU\SHIMX64.EFI)
    
  7. (edit) My /dev/sda SSD partition table is of type GPT, in case this information is relevant. The /dev/sda6 partition (where Windows 7 is) has the boot-bios flag set.

  8. I got Boot Info Script and ran it. This is the result.

I would really appreciate your help and even more if it prevents me from reinstalling Windows 7, I do not even know how I got it working in the first place (until yesterday when I decided to update Lubuntu).

  1. I did as @talaat-etman suggested with great help from @kos too. My list volume output is

    Volume 0      G    NO_LABEL    FAT32   Partition   300 MB    Correct     Hidden
    ...
    Volume 2      K                NTFS    Partition   119 GB    Correct     Hidden
    ...
    Volume 4      E                NTFS    Partition   807 MB    Correct     Hidden
    Volume 5      D     W7X64ULT_E FAT32   Partition   14 GB     Correct     Hidden
    

    For clarity:

    • Volume 0 = /dev/sda1 = the /boot/efi partition

    • Volume 2 = /dev/sda6 = the Windows 7 C:/ partition (installed)

    • Volume 4 = /dev/sda5 = "Microsoft reserved partition" which is empty, unknown filesystem, msftres flag active

    • Volume 5 = /dev/sdc = Live USB stick from which I booted Win7 installer

I opened the "Advanced Options" menu, and opened CMD. I ran X:\sources>bcdboot X:\Windows /s G: /f ALL and also X:\sources>bcdboot X:\Windows /s K: /f ALL just in case, but both outputs were

   BFSVC Error: Failed to set element application device. Status = [c00000bb]
  1. After I followed the steps described in 11., the "Windows Boot Manager" option reappeared, so maybe I'm close. Trying to run it gives an error, though. I took photo of the screen: photo

  2. I booted the Boot-Repair CD from a live USB stick. I ran the program, and it said Windows legacy detected. The process continued and it said that the boot had been successfully repaired. It doesn't work though, since I rebooted and the option does not yet appear. It showed a warning before finishing asking if I wanted to continue (I said yes):

        EFI detected. You may want to retry after activating the [Separate /boot/efi partition:] option.
    

    When it finished, it gave this report and showed this message:

        You can now reboot your computer.
        Please do not forget to make your UEFI firmware boot on the Ubuntu 22.04.4 LTS entry (sda1/efi/ubuntu/grubx64.efi file)!
    

    So, I rebooted, added manually such entry in my BIOS configuration and made my PC boot using it. Still only showed my Lubuntu 22.04 on /dev/sda1 and the Lubuntu 20.04 on dev/sdb7.

19
  • 1
    The paste after the update-grub does not look like output from that command. Commented Jun 23 at 0:06
  • 1
    "EFI variables are not supported on this system" sounds bad. Did you install Lubuntu in compatability mode? Commented Jun 23 at 0:13
  • 1
    What is the output of sudo efibootmgr? (This doesn't do anything to your system, just lists the EFI boot info). Commented Jun 23 at 0:26
  • 2
    Windows restore media might replace the bootloaders, but they are just files, you can copy them (everything from the EFI/Microsoft... on down) from another Windows system to your system without them, then rerun sudo update-grub and hope they are picked up.
    – ubfan1
    Commented Jun 23 at 1:20
  • 1
    Note that BootInfoscript report is now part of Boot-Repair and is updated in Boot-Repair. I still run both as I can run BootInfoscript with a script where Boot-Repair needs a gui. But you can extract the two files from Boot-Repair that are the script and have a much updated bootinfoscript. Since UEFI and gpt drive, Windows fixes must be in UEFI boot mode. Boot Windows repair/recovery drive in UEFI mode. Early Windows 7 ISO did not have an UEFI mode, but later versions did.
    – oldfred
    Commented Jun 23 at 2:42

2 Answers 2

3

After rebooing by windows installation media, You can copy BCD files that support booting on either a UEFI-based or a BIOS-based computer from the C:\Windows folder to windows boot drive or to C drive by the following command:

bcdboot C:\Windows /s X: /f ALL     #replace X with windows drive

after then, reboot by lubuntu and update-grub

13
  • 2
    I think you meant "replace X with the EFI partition's letter". Also they should make sure the EFI partition is mounted, which IIRC isn't by default when booting from an installation media. CMD prompt, diskpart, list disk, check the target disk's index number (let's say 1), sel disk 1, list par, check the EFI partition's index number (let's say 2), sel par 2, assign letter x (which probably will be in use already and hosting the installation media's main partition, so maybe assign letter g or whatever) and then use the command replacing X with the correct letter.
    – kos
    Commented Jun 23 at 12:49
  • 3
    Final note: Windows isn't guaranteed to be mounted on C either, so checking from diskpart or running C: + dir perhaps is in order.
    – kos
    Commented Jun 23 at 12:53
  • 2
    @Santiago You should've chosen the letter where the installed Windows 7 was as the source letter, however you seemed to have (manually) copied the source files correctly (at least judging from what you said in your last edit to the question), but you didn't rebuild your BCD, which is an entirely different cat to skin. So you should manually remove all the files that you copied and follow the procedure correctly instead (the first command posted by Talaat in the comment above this one is correct, the other one is not), which also recreates the BCD in the right position.
    – kos
    Commented Jun 23 at 19:01
  • 2
    @Santiago Try again. Make sure the EFI partition is clean from all the files that you have moved into it during these attempts (the manual copy + the bcdboot way), boot the installation media again and, this time around, run diskpart and make sure that the letters match, you shouldn't be trying and randomly "changing letters"; the first argument to bcdboot must be the Windows installation folder (C, K or whatever else diskpart reports), the EFI partition must be mounted (you can mount it as I described in the previous comment) and its letter must be the argument to /s.
    – kos
    Commented Jun 24 at 1:10
  • 2
    @Santiago After that, at this point, I'd also boot into the BIOS and remove the Windows entry you previously added (most UEFIs will add a new entry automatically upon reboot)
    – kos
    Commented Jun 24 at 1:10
2

Ok, after quickly looking at boot repair log, i can see you have more than one grub, try loading the grub on sda, i can see it's already installed there, so all you need to do is mark sda1 partition with the boot flag, using gparted for example.

What happens is that the fixed grub containing windows section doesnot get booted.

Also beside boot repair, there is super grub disc too.

Is sdc your live usb stick?

Good luck ! and keep me posted...

4
  • Thanks for your suggestions. Yes, /dev/sdc is my USB stick. I think I understand what you are saying. I checked with GParted, and /dev/sda1 has "boot" and "esp" flags, /dev/sda3 (Lubuntu 22.04) has no flags, and /dev/sda6 (Win7) has boot_bios flag. With "fixed grub" you mean /dev/sda1? I'll try Super Grub2 Disk and get back to you.
    – Santiago
    Commented Jun 23 at 17:20
  • 1
    There is an app too called grub custimizer that custimizes grub within a working distro using a gui. Boot repair repairs only one grub, that's the fixed one. Try putting boot flag to /dev/sda3 too. Commented Jun 23 at 19:21
  • Added the point no. 11 with my walk through using the Boot-Repair CD which seems to be close to giving a solution. It shows that maybe I have 2 grubs like you suggested? Couldn't do Grub2 Disk work (the libe USB creator doesn't let me choose its .iso file).
    – Santiago
    Commented Jun 23 at 20:08
  • 1
    I strongly suggest that you do not use grub-customizer. Commented Jun 24 at 0:21

You must log in to answer this question.

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