Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: Remove legacy grub, switch to UEFI (with grub or refind)

  1. #1

    Default Remove legacy grub, switch to UEFI (with grub or refind)

    Here is my problem in short: after two days of fight, despite seemingly doing everything as recommended in different forums, I cannot remove legacy GRUB2 and force my machine to load EFI GRUB2 (or refind) boot manager.

    Now, the long description.

    I have an ASUS r556L laptop, in which I had installed linux OpenSuse Leap 42.1 and windows 10. Linux grub2 was installed in legacy mode, as for windows - I am not sure, but my grub2 manager loaded Windows boot manager (i vaguely remember i called the relevant entry "boot windows mbr manager") and everything was just fine. My family was using windows, while I was working on linux.

    Two days ago someone from my family have upgraded Windows 10. After the upgrade, obviously the machine could not load neither linux nor windows.

    After two hours of googling I find out what happened, burned my old install iso on dvd and I was able to get back the linux system. Now, grub2 was in legacy mode, and after much brooding I decided that maybe the reason I can't load Windows is that maybe windows was in EFI mode, and, besides, I should use grub2 in EFI mode on EFI machine, right?

    So here is what I did
    Boot from DVD
    (1) /sys/firmware/efi exists; efibootmgr gives the proper entries, so definetely I have booted in EFI mode
    (2) /dev/sda2 is EFI; /dev/sda8 is my linux partition.
    (3) I had /dev/sda6 as grub_bios. I have made a backup copy using dd, then I have destroyed the partition and just to be sure, before that i have filled it with zeroes using dd if=/dev/zero of=/dev/sda6 count=XXXX

    (4) I have removed /dev/sda2; then I have recreated it again using gdisk, setting is as EFI partition (ef00), and
    formatted using mkfs.vfat /dev/sda2

    # mount /dev/sda8 /mnt
    # mount /dev/sda2 /mnt/boot/efi
    # for i in /dev/ /dev/pts /proc /sys; do mount $i /mnt/$i -B; done
    # modprobe efivars # just to be sure
    # chroot /mnt
    # efibootmgr
    BootCurrent: 0004
    Timeout: 1 seconds
    BootOrder: 0004,0001,0002,0003
    Boot0001* CD/DVD Drive
    Boot0002* Hard Drive
    Boot0003* Network Card
    Boot0004* UEFI: HL-DT-ST DVDRAM GUC0N
    # grub2-install --target x86_64-efi /dev/sda
    Installing for x86_64-efi platform.
    Installation finished. No error reported.

    # grub2-mkconfig -o /boot/grub2/grub.cfg
    # efibootmgr -b 0002 -B # removing non-uefi hard drive option, just to be sure
    # efibootmgr -o 0003,0001 # setting opensuse, then efi dvd
    Just to be sure, efibootmgr now sees everything just fine: that efi opensuse should be loaded first.
    # efibootmgr -v
    BootCurrent: 0004
    Timeout: 1 seconds
    BootOrder: 0000,0004,0001,0003
    Boot0000* opensuse HD(2,e1800,32000,aab2a73b-d4b9-4dce-bbfd-f00e41d393c9)File(\EFI\opensuse\grubx64.efi)
    Boot0001* CD/DVD Drive BIOS(3,0,00)..GO..NO........o.H.L.-.D.T.-.S.T. .D.V.D.R.A.M. .G.U.C.0.N............^?........A......................^?.....>..Gd-.;.A..MQ..L.W.K.F.5.A.4.2.9.1.0. .6. . . . . . . . ...^?.....BO
    Boot0003* Network Card BIOS(6,0,00)..GO..NO........k.R.e.a.l.t.e.k. .P.X.E. .B.0.2. .D.0.0............^?.............rN.D+..,.\......^?.....<..Gd-.;.A..MQ..L.R.e.a.l.t.e.k. .P.X.E. .B.0.2. .D.0.0...^?.....BO
    Boot0004* UEFI: HL-DT-ST DVDRAM GUC0N ACPI(a0341d0,0)PCI(1f,2)03120a000100ffff0000CD-ROM(1,3b1,229c60)..BO

    gdisk -l /dev/sda

    GPT fdisk (gdisk) version 0.8.8

    Partition table scan:
    MBR: protective
    BSD: not present
    APM: not present
    GPT: present

    Found valid GPT with protective MBR; using GPT.
    Disk /dev/sda: 1953525168 sectors, 931.5 GiB
    Logical sector size: 512 bytes
    Disk identifier (GUID): EB75204E-7462-4BA9-A901-83746823FA22
    Partition table holds up to 128 entries
    First usable sector is 34, last usable sector is 1953525134
    Partitions will be aligned on 2048-sector boundaries
    Total free space is 234025 sectors (114.3 MiB)

    Number Start (sector) End (sector) Size Code Name
    1 2048 923647 450.0 MiB 2700 Basic data partition
    2 923648 1128447 100.0 MiB EF00 EFI System
    3 1128448 1161215 16.0 MiB 0C01 Microsoft reserved part
    4 1161216 1542056771 734.8 GiB 0700 Basic data partition
    5 1542057984 1543921663 910.0 MiB 2700
    7 1543942144 1547943935 1.9 GiB 0700 primary
    8 1548152832 1953523711 193.3 GiB 0700 primary

    According to everything I have read this should be enough and everything should work.

    REBOOT

    (1) What appears is just "GRUB" and nothing else (computer hangs; no grub prompt or anything)
    (2) Before I have removed /dev/sda6, it seems it had been loading legacy grub instead of efi (because after choosing
    menu entries it was complaining about initrdefi and linuxefi commands)
    (3) In BIOS, in boot section only non-EFI options appeared + EFI DVD
    (4) after rebooting into rescue mode using EFI DVD, efibootmgr does not see opensuse (which I have set previously). Everything looks as before I had done.

    Now, in BIOS I have no "enable EFI" option. I have option "Launch CSM", which I have enabled; without this option NOTHING could be booted, with this option EFI DVD is booted just fine (it looks like in this image I have googled:
    https://www.google.pl/search?q=asus+...4OVpmargw_qgM:)

    In BIOS, the same options as before are available for boot: non-EFI DVD and HDD, and EFI DVD.

    I tried downloading refind and using both automatic and manual installation, and the result was all the same (i.e. seems like legacy GRUB boot manager is still chosen, presenting me with "GRUB" and then hangs).

    I don't want to remove all the partitions and reinstall everything. This is basically out of option. I can fall back to legacy grub, which would mean I would have access to linux, but no access to windoze.

    here is output of parted -l:

    Model: ATA ST1000LM024 HN-M (scsi)
    Disk /dev/sda: 1000GB
    Sector size (logical/physical): 512B/4096B
    Partition Table: gpt
    Disk Flags: pmbr_boot

    Number Start End Size File system Name Flags
    1 1049kB 473MB 472MB ntfs Basic data partition hidden, diag
    2 473MB 578MB 105MB fat16 EFI System boot
    3 578MB 595MB 16.8MB Microsoft reserved partition msftres
    4 595MB 790GB 789GB ntfs Basic data partition
    5 790GB 790GB 954MB ntfs hidden, diag
    7 790GB 793GB 2049MB linux-swap(v1) primary
    8 793GB 1000GB 208GB xfs primary

  2. #2
    Join Date
    Jun 2015
    Location
    Toulouse
    Posts
    133

    Default Re: Remove legacy grub, switch to UEFI (with grub or refind)

    Le 02/11/2017 à 10:26, szopen76 a écrit :
    > and, besides, I should use grub2 in EFI mode on EFI machine, right?


    wrong

    as far as I know you can't change simply a legacy install for an efi one
    (neither in Windows than Linux).

    I don't say it can't be done, but not by changing grub.

    EFI boot needs an EFI partition. Windows needs also a GPT disk. Opensuse
    accommodate what you have

    so apart if you did a full windows reinstall, with disk reformatting,
    it's very unlikely that the boot system was changed

    jdd

  3. #3

    Default Re: Remove legacy grub, switch to UEFI (with grub or refind)

    What do you mean by that? I have /dev/sda2 EFI System partition; do you mean that I should remove /dev/sda8 (currently containing ext4 filesystem) and create new, 200GB partition with type of EFI?!? DOes that mean that data partitions (containing linux system) differ in type depending on whether you chose booting by EFI or legacy?!

    If really data partitions created by non-EFI installation cannot be booted from EFI bootloader, then I guess I would have to go back to legacy grub; however, how can I then boot windows 10? With legacy grub all I got was "invalid signature" (secure boot is disabled in BIOS and in grub).

  4. #4
    Join Date
    Jun 2015
    Location
    Toulouse
    Posts
    133

    Default Re: Remove legacy grub, switch to UEFI (with grub or refind)

    Le 02/11/2017 à 11:06, szopen76 a écrit :
    >
    > What do you mean by that? I have /dev/sda2 EFI System partition;


    what do you see in /boot/EFI ? do you see windows (or microsoft)

    do you
    > mean that I should remove /dev/sda8 (currently containing ext4
    > filesystem) and create new, 200GB partition with type of EFI?!? DOes
    > that mean that data partitions (containing linux system) differ in type
    > depending on whether you chose booting by EFI or legacy?!


    no

    >
    > If really data partitions created by non-EFI installation cannot be
    > booted from EFI bootloader, then I guess I would have to go back to
    > legacy grub; however, how can I then boot windows 10? With legacy grub
    > all I got was "invalid signature" (secure boot is disabled in BIOS and
    > in grub).
    >
    >

    if YaST installed legacy grub it's most certainly because the install
    was done in legacy mode. Linux can manage any variation of EFI/legacy +
    MSDOS/GPT partition, but Windows can't and if so openSUSE can't boot
    windows.

    I have this on one of my computers, I can boot legacy openSUSE fro an
    other EFI install (on other disk), but not Windows. I could manage the
    problem with the EFI boot manager, asking to boot the legacy first disk
    with Windows.

    A copy of sudo fdisk -l could be a good clue (http://susepaste.org/ or
    in the post)

    you *can* have an EFI partition and a legacy install, but not an EFI
    install without EFI partition

    jdd


  5. #5

    Default Re: Remove legacy grub, switch to UEFI (with grub or refind)

    I have efi partition. I see the usual /boot/efi/EFI with Boot, Microsoft and opensuse. In opensuse I have removed all the previous files and right now I have only grubx64.efi.

    But at this point I would like just to boot Linux in EFI mode.

    AS for fdisk -l:
    Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    Disklabel type: gpt
    Disk identifier: EB75204E-7462-4BA9-A901-83746823FA22

    Device Start End Sectors Size Type
    /dev/sda1 2048 923647 921600 450M Windows recovery environment
    /dev/sda2 923648 1128447 204800 100M EFI System
    /dev/sda3 1128448 1161215 32768 16M Microsoft reserved
    /dev/sda4 1161216 1542056771 1540895556 734.8G Microsoft basic data
    /dev/sda5 1542057984 1543921663 1863680 910M Windows recovery environment
    /dev/sda7 1543942144 1547943935 4001792 1.9G Microsoft basic data
    /dev/sda8 1548152832 1953523711 405370880 193.3G Microsoft basic data


    Here are the contents of /boot/efi/EFI:

    total 0
    drwxr-xr-x 2 root root 25 Dec 2 08:42 Boot
    drwxr-xr-x 4 root root 34 Dec 2 08:42 Microsoft
    drwxr-xr-x 2 root root 25 Dec 2 08:42 opensuse

    sda8/backup_EFI/EFI/Boot:
    total 120
    -rwxr-xr-x 1 root root 122368 Dec 2 08:42 bootx64.efi

    sda8/backup_EFI/EFI/Microsoft:
    total 4
    drwxr-xr-x 42 root root 4096 Dec 2 08:42 Boot
    drwxr-xr-x 2 root root 64 Dec 2 08:42 Recovery

    sda8/backup_EFI/EFI/Microsoft/Boot:
    total 4776
    -rwxr-xr-x 1 root root 49152 Dec 2 08:42 BCD
    -rwxr-xr-x 1 root root 65536 Dec 2 08:42 BCD.LOG
    -rwxr-xr-x 1 root root 0 Dec 2 08:42 BCD.LOG1
    -rwxr-xr-x 1 root root 0 Dec 2 08:42 BCD.LOG2
    -rwxr-xr-x 1 root root 65536 Dec 2 08:42 BOOTSTAT.DAT
    drwxr-xr-x 2 root root 4096 Dec 2 08:42 Fonts
    drwxr-xr-x 3 root root 38 Dec 2 08:42 Resources
    drwxr-xr-x 2 root root 53 Dec 2 08:42 bg-BG
    -rwxr-xr-x 1 root root 4669 Dec 2 08:42 boot.stl
    -rwxr-xr-x 1 root root 1224600 Dec 2 08:42 bootmgfw.efi
    -rwxr-xr-x 1 root root 1209760 Dec 2 08:42 bootmgr.efi
    -rwxr-xr-x 1 root root 115616 Dec 2 08:42 bootspaces.dll
    [CUT the rest, as there are several dozen files there]

    Currently I tried to remove all the files in /boot/efi/ and went with the all the procedure again, until there is only /boot/efi/EFI/opensuse/grubx64.efi, and it has not changed anything.

    I don't know why it keeps loading old grub. Also, I presume I should see EFI entries in BIOS, but I keep seeing there only "EFI DVD" and two non-efi options (non-efi dvd and hard drive). Moreover, why after every reboot all the changes i have done using efibootmgr are gone?

  6. #6
    Join Date
    Jun 2015
    Location
    Toulouse
    Posts
    133

    Default Re: Remove legacy grub, switch to UEFI (with grub or refind)

    Le 02/11/2017 à 11:36, szopen76 a écrit :
    >
    > I have efi partition. I see the usual /boot/efi/EFI with Boot, Microsoft
    > and opensuse. In opensuse I have removed all the previous files and
    > right now I have only grubx64.efi.


    seems good

    >
    > But at this point I would like just to boot Linux in EFI mode.


    should be done through Firmware/BIOS or boot menu

    > Disklabel type: gpt


    so combination UEFI/GPT, good

    > /dev/sda2 923648 1128447 204800 100M EFI System


    good

    > /dev/sda7 1543942144 1547943935 4001792 1.9G Microsoft basic data
    > /dev/sda8 1548152832 1953523711 405370880 193.3G Microsoft basic data


    I guess these last two are your linux swap and /. Could be better with
    linux partition type, but I don't think it's really important

    > Currently I tried to remove all the files in /boot/efi/ and went with
    > the all the procedure again, until there is only
    > /boot/efi/EFI/opensuse/grubx64.efi,


    not a good idea, may prevent Windows booting

    and it has not changed anything.

    the data may be saved in nvram
    >
    > I don't know why it keeps loading old grub.


    may be there are several successive installs, one previous in efi mode
    and the last in legacy mode?? just a wild guess :-(

    Also, I presume I should see
    > EFI entries in BIOS, but I keep seeing there only "EFI DVD" and two
    > non-efi options (non-efi dvd and hard drive). Moreover, why after every
    > reboot all the changes i have done using efibootmgr are gone?
    >
    >

    arch wiki is known to be good for efi

    https://wiki.archlinux.fr/EFI_Boot_Stub

    but efibootmgr is tricky, I always managed to make the boot config with Yast

    jdd

  7. #7

    Default Re: Remove legacy grub, switch to UEFI (with grub or refind)

    Thank, jdd. Even if it does not help, I appreciate that you have committed your time trying to find a solution.

    Right now I gave up and installed legacy grub. At least I can boot linux, even if windows is unavailable.

    Maybe someone else will know what to do. The key questions are:
    (1) Why even after installing grub-efi (grub2-install --target x86_64-efi, with no errors) the systems starts legacy grub ?
    (2) Why, despite everything being seemingly ok (efibootmgr showing right thing, gdisk showing the right thing, no errors) after a reboot EFI is not seen in BIOS and all the changes seem to disappear (i.e. after reboot efibootmgr sees no previous changes).

  8. #8
    Join Date
    Jun 2015
    Location
    Toulouse
    Posts
    133

    Default Re: Remove legacy grub, switch to UEFI (with grub or refind)

    Le 02/11/2017 à 13:36, szopen76 a écrit :
    >
    > Thank, jdd. Even if it does not help, I appreciate that you have
    > committed your time trying to find a solution.
    >
    > Right now I gave up and installed legacy grub. At least I can boot
    > linux, even if windows is unavailable.


    did you try yast? (for boot manager)

    jdd


  9. #9

    Default Re: Remove legacy grub, switch to UEFI (with grub or refind)

    yes, I did. The first thing I tried, actually; I have moved to more manual methods once yast failed.

  10. #10
    Join Date
    Jun 2015
    Location
    Toulouse
    Posts
    133

    Default Re: Remove legacy grub, switch to UEFI (with grub or refind)

    Le 02/11/2017 à 15:16, szopen76 a écrit :
    >
    > yes, I did. The first thing I tried, actually; I have moved to more
    > manual methods once yast failed.
    >
    >

    :-)

    I will have to test moving from grub2 to grub2-efi and vice-versa. When
    I find time :-(

    fact is uefi firmware is so buggy that it's difficult to port experience
    from a computer to an other

    jdd

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •