rhboot / efibootmgr

efibootmgr development tree
GNU General Public License v2.0
519 stars 99 forks source link

Unable to create new boot entry: `Could not prepare boot variable: Invalid argument` #3

Closed paulepanter closed 10 years ago

paulepanter commented 10 years ago

On the Asus U38N I am unable to create a boot entry.

(gdb) b make_boot_var
Breakpoint 1 at 0x8049682: file src/efibootmgr/efibootmgr.c, line 224.
(gdb) run  -v -c -d /dev/sda -p 2 -w -L "Debian GNU/Linux (GRUB)" -l "\EFI\debian\grubx64.efi"
Starting program: /home/paul/src/efibootmgr/src/efibootmgr/efibootmgr -v -c -d /dev/sda -p 2 -w -L "Debian GNU/Linux (GRUB)" -l "\EFI\debian\grubx64.efi"
warning: Could not load shared library symbols for linux-gate.so.1.
Do you need "set solib-search-path" or "set sysroot"?

Breakpoint 1, make_boot_var (boot_list=0x8056120 <boot_entry_list>) at src/efibootmgr/efibootmgr.c:224
224     efi_variable_t *boot = NULL;
(gdb) l
219 }
220 
221 static efi_variable_t *
222 make_boot_var(list_t *boot_list)
223 {
224     efi_variable_t *boot = NULL;
225     int free_number;
226     list_t *pos;
227     int rc;
228 
(gdb) n
229     if (opts.bootnum == -1)
(gdb) n
230         free_number = find_free_boot_var(boot_list);
(gdb) n
243     if (free_number == -1)
(gdb) p free_number
$1 = 0
(gdb) n
250     boot = calloc(1, sizeof(*boot));
(gdb) n
251     if (!boot)
(gdb) p boot
$2 = (efi_variable_t *) 0x8057018
(gdb) p* boot
$3 = {name = 0x0, guid = {a = 0, b = 0, c = 0, d = 0, e = "\000\000\000\000\000"}, data = 0x0, data_size = 0, attributes = 0, num = 0, list = {next = 0x0, prev = 0x0}}
(gdb) n
253     if (make_linux_load_option(&boot->data, &boot->data_size) < 0)
(gdb) n
255     if (append_extra_args(&boot->data, &boot->data_size) < 0)
(gdb) n
258     boot->num = free_number;
(gdb) n
259     boot->guid = EFI_GLOBAL_VARIABLE;
(gdb) n
260     rc = asprintf(&boot->name, "Boot%04X", free_number);
(gdb) n
261     if (rc < 0)
(gdb) p rc
$4 = 8
(gdb) n
263     boot->attributes = EFI_VARIABLE_NON_VOLATILE |
(gdb) n
266     rc = efi_set_variable(boot->guid, boot->name, boot->data,
(gdb) n
268     if (rc < 0)
(gdb) p rc
$5 = -1
(gdb) p* boot
$6 = {name = 0x8057008 "Boot0000", guid = {a = 2347032417, b = 37834, c = 4562, d = 3498, e = "\000\340\230\003+\214"}, data = 0x8057100 "\001", data_size = 100, attributes = 7, num = 0, list = {next = 0x0, 
    prev = 0x0}}
(gdb) n
269         goto err_boot_entry;
(gdb) c
Continuing.

Could not prepare boot variable: Invalid argument

[Inferior 1 (process 14853) exited with code 01]
paulepanter commented 10 years ago

efivars: Malformed variable content is printed by Linux when running the above command.

orumin commented 10 years ago

I have a same problem and It will libefivar's bug

vathpela commented 10 years ago

Does this work better with recent libefivar?

orumin commented 10 years ago

I tested on libefivar 0.8 and it runs correctly. thank you