Problem with EFI partitions trying to dual boot Win11

I’m trying to dual boot with Windows. I’m replacing a partition on which I previously had NixOs installed and then deleted that partition, and creating a new efi partition. But installation fails apparently when trying to create the new efi partition with this output :
https://termbin.com/2wth

Outputs for lsblk

[liveuser@eos-2025.03.19 ~]$ lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop0         7:0    0   2.6G  1 loop /run/archiso/airootfs
sda           8:0    1  28.6G  0 disk 
└─sda1        8:1    1  28.6G  0 part /run/archiso/bootmnt
nvme0n1     259:0    0 476.9G  0 disk 
├─nvme0n1p1 259:5    0   260M  0 part 
├─nvme0n1p2 259:6    0    16M  0 part 
├─nvme0n1p3 259:7    0 377.7G  0 part 
├─nvme0n1p4 259:8    0     1G  0 part 
└─nvme0n1p5 259:9    0    98G  0 part 

lsblk -f

[liveuser@eos-2025.03.19 ~]$ lsblk -f
NAME        FSTYPE   FSVER LABEL       UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
loop0       squashfs 4.0                                                          0   100% /run/archiso/airootfs
sda                                                                                        
└─sda1      vfat     FAT32 EOS_202503  8272-8205                              25.7G    10% /run/archiso/bootmnt
nvme0n1                                                                                    
├─nvme0n1p1 vfat     FAT32 ESP         3C40-FD55                                           
├─nvme0n1p2                                                                                
├─nvme0n1p3 ntfs           ACER        D060428460427170                                    
├─nvme0n1p4 ntfs           Recovery    6A7443EB7443B899                                    
└─nvme0n1p5 ext4     1.0   endeavouros e5fc38ac-bd3b-483c-ba7b-2aeaa40d6394 

So this one?
No other disks in play?
Ok.. there is an existing ESP at /dev/nvme0n1p1.
It is also populated with windoze stuff.

And its having trouble accessing it as it is read-only.
Considering you are trying to create a new ESP (at ~nvme0n1p6) I dont know why its even touching the existing one. But it does seem to be the cause of the issue.

Use Manual partitioning (instead of “Replace a partition”) and point the installer to the new ESP (2 GB FAT32) and the new EXT4 partitions you have created for EndeavourOS.

If you want to use Grub, you need to mount ESP at /boot/efi and flag it boot.

If you want to use systemd-boot you need to mount the ESP at /efi and flag it boot.

Edited to add that for your EXT4 partition you choose the mountpoint /. No flag is needed.

Yeah that’s what really confused me too

OK I’ll try to do a manual partition and see how it goes

You seem to have already pre-partitioned your disk (or am I wrong?)

Just choose the Manual partition mode and instruct the installer to use those partitions as described above.

Tried manual partitioning, here’s what it looks like


Everything seemed good until about 80% installation after which i get this error
https://termbin.com/ics9 which looks like a calamares issue now

What bootloader did you chose?

systemd

1 Like
2025-05-04 - 14:35:23 [1]:     ERROR: Error while running: FileNotFoundError: [Errno 2] No such file or directory: '/tmp/calamares-root-p2p24hmm/efi/loader/loader.conf'

At:
  /usr/lib/calamares/modules/bootloader/main.py(268): create_loader
  /usr/lib/calamares/modules/bootloader/main.py(565): install_systemd_boot
  /usr/lib/calamares/modules/bootloader/main.py(900): prepare_bootloader
  /usr/lib/calamares/modules/bootloader/main.py(936): run
2025-05-04 - 14:35:23 [1]:     ERROR: Installation failed: "Bad main script file" 
2025-05-04 - 14:35:23 [6]:     .. - message: "Bad main script file" 
2025-05-04 - 14:35:23 [6]:     .. - details: Main script file /usr/lib/calamares/modules/bootloader/main.py for python job bootloader raised an exception.

Looks like it is failing at the bootloader installation stage. I don’t know why it happens and how to troubleshoot this one.

Perhaps someone else or one of the devs (@joekamprad or @dalto ?) can have a look.

Yeah I figured so too, thank you for the help anyways. Unless the devs can help me out here this probably means the end of my little Endeavour adventure

The fact that the solution to this is beyond my current knowledge doesn’t mean that there is none.

I am pretty sure that there is one. Please be patient a bit considering that it is Sunday and people are taking some time off, even from the forum.

1 Like

This is what i found concerning the error message.

However this topic is over a year old , and would mean that there is a longstanding bug in the main.py file of Calamares. Not sure the solution in the linked topic is stil working, or there is something else causing this error.

You rebooted after the failed first install?
you do set the boot flag on the EFI partition?

“job bootloader raised an exception.”

Must be something confused with the efi partition.
And the issue with the first try is basically something about fastboot not disabled and the EFI has a dirty bit caused by that.

/calamares/modules/networkcfg/main.p
is what the issue there at neon is about here we have an exception with bootloader module.

Rebooted only after second failed install, and boot flag was set each time. Also I made sure fastboot was disabled before trying installation so that seems weird if that were the issue

Try removing the esp/boot flag from the the first ESP (using partitionmanager or gparted).
You can set it back afterwards because Windows needs that for its updates/upgrades.

Then do as you did before in Manual mode. You could maybe try to let it reformat those partitions as well.

If it would be a general BUG we would know about, but the installer is not perfect and it will not work in cases.

It does mount the efi here:

Running QList("mount", "-t", "vfat", "-o", "fmask=0137,dmask=0027", "/dev/nvme0n1p5", "/tmp/calamares-root-p2p24hmm/efi")

but later there is a file missing that should has been written:
ERROR: Error while running: FileNotFoundError: [Errno 2] No such file or directory: '/tmp/calamares-root-p2p24hmm/efi/loader/loader.conf'

It also calls proper detection for bootloader and the path it will use:

2025-05-04 - 14:04:54 [6]:     The bootloader is  "systemd-boot" 
2025-05-04 - 14:04:54 [6]: virtual void PartitionViewStep::onActivate()
2025-05-04 - 14:04:54 [6]:     The efi location is  "/efi"
2025-05-04 - 14:35:23 [1]:     ERROR: Error while running: FileNotFoundError: [Errno 2] No such file or directory: '/tmp/calamares-root-p2p24hmm/efi/loader/loader.conf'

At:
  /usr/lib/calamares/modules/bootloader/main.py(268): create_loader
  /usr/lib/calamares/modules/bootloader/main.py(565): install_systemd_boot
  /usr/lib/calamares/modules/bootloader/main.py(900): prepare_bootloader
  /usr/lib/calamares/modules/bootloader/main.py(936): run
 2025-05-04 - 14:35:23 [1]:     ERROR: Installation failed: "Bad main script file" 
2025-05-04 - 14:35:23 [6]:     .. - message: "Bad main script file" 
2025-05-04 - 14:35:23 [6]:     .. - details: Main script file /usr/lib/calamares/modules/bootloader/main.py for python job bootloader raised an exception.

it points out 4 lines in the script what looks to me like it simply fails completely, it does say “Bad main script file” but this will get logged also if the script is fine and something outside is not working properl.

I mean, it could be the ISO has a corruption, aka not properly synced, or using a tool to create install media that changed something on the file. In cases we see users using ventoy and ISO is not fully synced to the usb it can cause strange issues.

May also check efibootmgr from the live session in terminal to see if it properly boots in efi mode.

1 Like

I used rufus to flash the drive, I could try flashing it again if other methods don’t work.
This is the output i get from efibootmgr

[liveuser@eos-2025.03.19 ~]$ efibootmgr
BootCurrent: 0000
Timeout: 0 seconds
BootOrder: 0002,0001,2001,2002,2003
Boot0000* EFI USB Device (SanDisk)      UsbWwid(781,558a,0,4C53000028032211234)/HD(1,MBR,0x27da2,0x800,0x39477e0)RC
Boot0001* Windows Boot Manager  HD(1,GPT,78ef2ccb-b7fc-4cc9-8085-a0e75f1a9a7b,0x800,0x82000)/\EFI\Microsoft\Boot\bootmgfw.efi57494e444f5753000100000088000000780000004200430044004f0042004a004500430054003d007b00390064006500610038003600320063002d0035006300640064002d0034006500370030002d0061006300630031002d006600330032006200330034003400640034003700390035007d00000026000100000010000000040000007fff0400
Boot0002  Linux Boot Manager    HD(1,GPT,78ef2ccb-b7fc-4cc9-8085-a0e75f1a9a7b,0x800,0x82000)/\EFI\systemd\systemd-bootx64.efi
Boot2001* EFI USB Device        RC
Boot2002* EFI DVD/CDROM RC
Boot2003* EFI Network   RC

I’ll try this out