<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>59632</bug_id>
          
          <creation_ts>2026-06-24 00:11:45 +0300</creation_ts>
          <short_desc>grub-efi-install: installing Secure Boot binaries to ESP mv: cannot overwrite &apos;/boot/efi/EFI/BOOT/BOOTX64.EFI&apos;: Файл существует</short_desc>
          <delta_ts>2026-09-16 09:41:08 +0300</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Branch p11</product>
          <component>grub-efi</component>
          <version>unspecified</version>
          <rep_platform>x86_64</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>ASSIGNED</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P5</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Vyacheslav Bocharov">vebocharov</reporter>
          <assigned_to name="Egor Ignatov">egori</assigned_to>
          <cc>egori</cc>
    
    <cc>glinkinvd</cc>
    
    <cc>me</cc>
    
    <cc>vebocharov</cc>
          
          <qa_contact name="qa-p11@altlinux.org">qa-p11</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>290055</commentid>
    <comment_count>0</comment_count>
    <who name="Vyacheslav Bocharov">vebocharov</who>
    <bug_when>2026-06-24 00:11:45 +0300</bug_when>
    <thetext>После выполнения sudo apt-get dist-upgrade получил:

Found ESP at /boot/efi
Probing ALT Linux EFI binaries on ESP
  /boot/efi/EFI/altlinux/shimx64.efi: ALT shim
  /boot/efi/EFI/altlinux/grubx64.efi: ALT grub
  /boot/efi/EFI/BOOT/grubx64.efi: ALT grub
Detected: Secure Boot (non-removable)
Updating grub in /boot/efi
grub-efi-install: mode=SECURE_BOOT, bootloader_id=altlinux, efi_directory=/boot/efi
grub-efi-install: running grub-install --target=x86_64-efi --boot-directory=/boot --boot-directory-only 
Выполняется установка для платформы x86_64-efi.
grub-efi-install: installing Secure Boot binaries to ESP
mv: cannot overwrite &apos;/boot/efi/EFI/BOOT/BOOTX64.EFI&apos;: Файл существует

========================================================
WARNING: grub-efi-autoupdate failed!
The EFI bootloader was NOT updated. Next boot may fail.

What to do:
  1. Run &apos;grub-efi-autoupdate&apos; manually to see the full error
  2. If it fails again, try &apos;grub-efi-install &amp;&amp; grub-efi-autoupdate&apos;
  3. If your system lacks NVRAM, try &apos;grub-efi-install --removable&apos;
  4. Make sure you have recovery bootable media available
========================================================
Генерируется файл настройки grub …
[...]
завершено
EFI boot, skipping grub-pc autoupdate (no problem)
egrep: warning: egrep is obsolescent; using grep -E
Завершено.
rebuilding database /var/lib/rpm started
rebuilding database /var/lib/rpm finished

$ sudo ls -la /boot/efi/EFI/BOOT/ 
итого 4562
drwxrwxrwx 2 root root    1024 июн 23 23:38 .
drwxrwxrwx 6 root root    1024 сен 26  2023 ..
-rw-rw-rw- 1 root root  951408 янв  2 10:01 bootx64.efi
-rw-rw-rw- 1 root root  951408 июн 23 23:38 BOOTX64.EFI.new
-rw-rw-rw- 1 root root   90768 янв  2 10:01 fbx64.efi
-rw-rw-rw- 1 root root     143 янв  2 10:01 grub.cfg
-rw-rw-rw- 1 root root 1820904 янв  2 10:01 grubx64.efi
-rw-rw-rw- 1 root root  850008 янв  2 10:01 mmx64.efi

$ sudo cmp /boot/efi/EFI/BOOT/bootx64.efi /boot/efi/EFI/BOOT/BOOTX64.EFI.new
$ sudo rm /boot/efi/EFI/BOOT/bootx64.efi
$ sudo mv /boot/efi/EFI/BOOT/BOOTX64.EFI.new /boot/efi/EFI/BOOT/BOOTX64.EFI
$ sudo grub-efi-autoupdate
Found ESP at /boot/efi
Probing ALT Linux EFI binaries on ESP
  /boot/efi/EFI/altlinux/shimx64.efi: ALT shim
  /boot/efi/EFI/altlinux/grubx64.efi: ALT grub
  /boot/efi/EFI/BOOT/BOOTX64.EFI: ALT shim
  /boot/efi/EFI/BOOT/grubx64.efi: ALT grub
Detected: Secure Boot (non-removable)
Updating grub in /boot/efi
grub-efi-install: mode=SECURE_BOOT, bootloader_id=altlinux, efi_directory=/boot/efi
grub-efi-install: running grub-install --target=x86_64-efi --boot-directory=/boot --boot-directory-only 
Выполняется установка для платформы x86_64-efi.
grub-efi-install: installing Secure Boot binaries to ESP
grub-efi-install: NVRAM entry registered: &apos;ALT Linux&apos; \EFI\altlinux\shimx64.efi
grub-efi-install: installation finished successfully

grub-efi-2.14-alt7.x86_64</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>290067</commentid>
    <comment_count>1</comment_count>
    <who name="Egor Ignatov">egori</who>
    <bug_when>2026-06-24 09:06:09 +0300</bug_when>
    <thetext>Добрый день. Спасибо за репорт!

Подскажите еще, пожалуйста, опции с которыми смонтирован /boot/efi:
```
sudo mount | grep /boot/efi
sudo grep &apos;/boot/efi&apos; /etc/fstab
```
И версию ядра на момент возникновения ошибки.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>290103</commentid>
    <comment_count>2</comment_count>
    <who name="Vyacheslav Bocharov">vebocharov</who>
    <bug_when>2026-06-25 03:34:52 +0300</bug_when>
    <thetext>Здравствуйте.

$ sudo mount | grep /boot/efi
/dev/nvme0n1p1 on /boot/efi type vfat (rw,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=866,iocharset=utf8,shortname=mixed,quiet,showexec,utf8,errors=remount-ro)

journalctl -b -3 -k --grep &quot;Linux version&quot; | head -1
июн 12 00:59:03 &lt;hostname&gt; kernel: Linux version 6.12.74-6.12-alt1 (builder@localhost.localdomain) (gcc-13 (GCC) 13.2.1 20240128 (ALT Sisyphus 13.2.1-alt3), GNU ld (GNU Binutils) 2.41.0.20230826) #1 SMP PREEMPT_DYNAMIC Fri Mar  6 13:49:54 UTC 2026</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>290104</commentid>
    <comment_count>3</comment_count>
    <who name="Vyacheslav Bocharov">vebocharov</who>
    <bug_when>2026-06-25 03:43:50 +0300</bug_when>
    <thetext>$ sudo grep &apos;/boot/efi&apos; /etc/fstab
UUID=4201-1CF6	/boot/efi	vfat	umask=0,quiet,showexec,iocharset=utf8,codepage=866	1	2</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>290112</commentid>
    <comment_count>4</comment_count>
    <who name="Vladislav Glinkin">glinkinvd</who>
    <bug_when>2026-06-25 11:27:53 +0300</bug_when>
    <thetext>На MSI-B850-GAMING-PLUS-WIFI столкнулся с такой же проблемой при обновлении:
```
[root@MSI-B850-GAMING-PLUS-WIFI ~]# journalctl | grep &quot;grub-efi&quot;
июн 24 18:04:24 host-189 apt-get[4056]: grub-efi-2.14-alt7 p11+411845.254.13.1 1781794123 installed
июн 24 18:04:35 host-189 apt-get[4056]: grub-efi-2.12-alt14 p11+387320.100.1.1 1750090330 removed
```

Как следствие, загрузка с включенным Secure Boot невозможна.
```
[root@MSI-B850-GAMING-PLUS-WIFI ~]# pesign -i /boot/efi/EFI/altlinux/shimx64.efi -S
---------------------------------------------
certificate address is 0x7f7c4bcb8f00
Content was not encrypted.
Content is detached; signature cannot be verified.
The signer&apos;s common name is Microsoft Windows UEFI Driver Publisher
No signer email address.
No signing time included.
There were certs or crls included.
---------------------------------------------
[root@MSI-B850-GAMING-PLUS-WIFI ~]# pesign -i /boot/efi/EFI/altlinux/grubx64.efi -S
No signatures found.
```

Выполнение grub-efi-autoupdate помогло.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>293077</commentid>
    <comment_count>5</comment_count>
      <attachid>22070</attachid>
    <who name="Жора Змейкин">me</who>
    <bug_when>2026-08-23 01:20:29 +0300</bug_when>
    <thetext>Created attachment 22070
Исправление guile-evms

Нашёл решение данной проблемы. Она идёт с Сизифа и связана с пакетом guile-evms.

Проблема в том, что ESP монтируется с iocharset=utf8, при котором VFAT некорректно сопоставляет имена, отличающиеся только регистром.

Файл bootx64.efi, созданный Windows, хранится как короткая 8.3-запись BOOTX64.EFI со специальными lowercase-флагами. Linux ядро показывает его как bootx64.efi, но при iocharset=utf8 запрос к BOOTX64.EFI не находит существующий файл.

В результате grub-efi-install создаёт BOOTX64.EFI.new, после чего выполняет:
&gt; mv BOOTX64.EFI.new BOOTX64.EFI

VFAT сначала считает, что целевой файл отсутствует, а при попытке создать запись обнаруживает и возвращает EEXIST.


Для воспроизведения ошибки, в Linux подобный bootx64.efi файл можно получить, создав файл на VFAT при shortname=winnt, а затем перемонтировав раздел с shortname=mixed,iocharset=utf8


Прикладываю патч, добавляющий iocharset=ascii, который обеспечивает корректное сравнение ASCII-регистра. Да, конечно можно обновить ещё утилиту обновления grub, чтобы она обнаруживала этот файл и что-то с ним делала. Но это дополнительное исправление.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>298999</commentid>
    <comment_count>6</comment_count>
    <who name="Egor Ignatov">egori</who>
    <bug_when>2026-09-16 09:41:08 +0300</bug_when>
    <thetext>Нашел решение данной проблемы, исправлю в ближайшем релизе.

Вот как это решили в debian [1]. По сути перед записью нужно узнать существует ли уже такой файл, и если есть, то использовать его точное имя учитывая регистр.

[1] https://salsa.debian.org/grub-team/grub/-/blob/master/debian/patches/grub-install-extra-removable.patch?ref_type=heads#L76


Примерная реализация на shell:
```
# esp_resolve_name DIR NAME
# Print the on-disk spelling of NAME in DIR: an exact match wins, then
# the first case-insensitive match (with a warning if there are
# several), then NAME itself (for a component that does not exist yet).
# Never fails.
esp_resolve_name() (
    dir=&quot;$1&quot; want=&quot;$2&quot;
    lower_want=&quot;$(printf &apos;%s&apos; &quot;$want&quot; | tr &apos;[:upper:]&apos; &apos;[:lower:]&apos;)&quot;
    found=
    nmatches=0
    for entry in &quot;$dir&quot;/*; do
        [ -e &quot;$entry&quot; ] || [ -L &quot;$entry&quot; ] || continue
        name=&quot;${entry##*/}&quot;
        if [ &quot;$name&quot; = &quot;$want&quot; ]; then
            printf &apos;%s\n&apos; &quot;$name&quot;
            return 0
        fi
        if [ &quot;$(printf &apos;%s&apos; &quot;$name&quot; | tr &apos;[:upper:]&apos; &apos;[:lower:]&apos;)&quot; = &quot;$lower_want&quot; ]; then
            [ -n &quot;$found&quot; ] || found=&quot;$name&quot;
            nmatches=$((nmatches + 1))
        fi
    done
    if [ -n &quot;$found&quot; ]; then
        if [ &quot;$nmatches&quot; -gt 1 ]; then
            echo &quot;${PROG:-grub-efi}: warning: $nmatches case-insensitive matches for &apos;$want&apos; in $dir; using &apos;$found&apos;&quot; &gt;&amp;2
        fi
        printf &apos;%s\n&apos; &quot;$found&quot;
        return 0
    fi
    printf &apos;%s\n&apos; &quot;$want&quot;
)
```</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>22070</attachid>
            <date>2026-08-23 01:20:29 +0300</date>
            <delta_ts>2026-08-23 01:20:29 +0300</delta_ts>
            <desc>Исправление guile-evms</desc>
            <filename>guile-evms-esp-vfat-casefold.patch</filename>
            <type>text/plain</type>
            <size>543</size>
            <attacher name="Жора Змейкин">me</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL2V2bXMuc2NtIGIvZXZtcy5zY20KaW5kZXggNDdlMzY5OC4uZTJiMGVlMyAx
MDA2NDQKLS0tIGEvZXZtcy5zY20KKysrIGIvZXZtcy5zY20KQEAgLTMwLDggKzMwLDggQEAKICAg
ICAoIi92YXIvd3d3IiAuICJub2RldixyZWxhdGltZSIpCiAgICAgKCIvdmFyL2NhY2hlL3NxdWlk
IiAuICJub2Rldixub2V4ZWMsbm9zdWlkLHJlbGF0aW1lIikKICAgICAoIi90bXAiIC4gIm5vc3Vp
ZCxyZWxhdGltZSIpCi0gICAgKCIvZWZpIiAuICJ1bWFzaz0wMDc3LG5vc3VpZCxub2Rldixub2V4
ZWMiKQotICAgICgiL2Jvb3QvZWZpIiAuICJ1bWFzaz0wMDc3LG5vc3VpZCxub2Rldixub2V4ZWMi
KSkpCisgICAgKCIvZWZpIiAuICJ1bWFzaz0wMDc3LG5vc3VpZCxub2Rldixub2V4ZWMsaW9jaGFy
c2V0PWFzY2lpLHV0Zjg9MSIpCisgICAgKCIvYm9vdC9lZmkiIC4gInVtYXNrPTAwNzcsbm9zdWlk
LG5vZGV2LG5vZXhlYyxpb2NoYXJzZXQ9YXNjaWksdXRmOD0xIikpKQogCiAoZGVmaW5lIGJhcmUt
bW91bnRwb2ludHMgJygiL2Jvb3QvZWZpIikpCiAK
</data>

          </attachment>
      

    </bug>

</bugzilla>