# basic kernel config for efivarfs mount

## DaggyStyle

Greetings,

in my workplace we have an usb image that allows us to boot our servers for some diagnostics.

I'm in charge of maintaining the kernel part of it (no one else has the guts to do that), one of the brainiac in the company has installed centos with efi support on.

now is computer is kinda broken and I need to be able to salvage some files from there. I need to add basic efivarfs support to the image, thing is I cannot get /sys/firmware/efi to exists, what is the minimal kernel config I need to be able to see /sys/firmware/efi and mount it?

Thanks.

----------

## eborg

I'm not sure if you're still looking, but here's what you need in the kernel.

Processor type and features  --->

    [*] EFI runtime service support 

    [*]   EFI stub support

----------

## DaggyStyle

 *eborg wrote:*   

> I'm not sure if you're still looking, but here's what you need in the kernel.
> 
> Processor type and features  --->
> 
>     [*] EFI runtime service support 
> ...

 

not sure that is correct, for example, centos's kernel doesn't jave EFI stub enabled but it does have /sys/firmware/efi

----------

## RazielFMX

I have /sys/firmware/efi, here are my EFI related kernel settings:

```

$ grep -i efi /usr/src/linux/.config

CONFIG_EFI_PARTITION=y

CONFIG_EFI=y

CONFIG_EFI_STUB=y

CONFIG_FB_EFI=y

CONFIG_DMI_SCAN_MACHINE_NON_EFI_FALLBACK=y

# EFI (Extensible Firmware Interface) Support

CONFIG_EFI_VARS=y

CONFIG_EFIVAR_FS=y

# CONFIG_EARLY_PRINTK_EFI is not set

```

My kernel info:

```

$ uname -a

Linux gentoobox 3.14.14-gentoo #1 SMP Thu Jul 31 11:36:36 EDT 2014 x86_64 Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz GenuineIntel GNU/Linux
```

----------

## VoidMage

CONFIG_EFI_STUB is for building a kernel, that can be run straight from EFI without a bootloader (though strong limitations here).

CONFIG_FB_EFI is for initial console before FRAMEBUFFER_CONSOLE/KMS kicks in.

----------

## DaggyStyle

question is, what I need to be able to read /sys/firmware/efi.

----------

## VoidMage

Well, menuconfig is your friend, but going by the names, most likely CONFIG_EFIVAR_FS.

Though IIRC, catch is the machine must be booted by UEFI, not BIOS - at least it was something like that when I was migrating grub to such setup.

----------

## DaggyStyle

 *VoidMage wrote:*   

> Well, menuconfig is your friend, but going by the names, most likely CONFIG_EFIVAR_FS.
> 
> Though IIRC, catch is the machine must be booted by UEFI, not BIOS - at least it was something like that when I was migrating grub to such setup.

 

you mean that the booting image must be efi right?

----------

## VoidMage

 *DaggyStyle wrote:*   

>  *VoidMage wrote:*   Well, menuconfig is your friend, but going by the names, most likely CONFIG_EFIVAR_FS.
> 
> Though IIRC, catch is the machine must be booted by UEFI, not BIOS - at least it was something like that when I was migrating grub to such setup. 
> 
> you mean that the booting image must be efi right?

 

...well, probably...

Not sure how it is right now, but back then if motherboard offered a choice between booting by BIOS and booting by UEFI, if you chose the former, sysfs efi entries wouldn't get populated.

----------

## eborg

 *DaggyStyle wrote:*   

> 
> 
> you mean that the booting image must be efi right?

 

For me that was the case. I went through SystemRescueCD, Fedora, then Ubuntu's EFI images (which all sort of worked ok), and then when I found Iron Penguin (Gentoo image), that was the final blow to getting me past my issues.

----------

## DaggyStyle

not sure I understood, bios is setup in efi, os was installed under efi, this means that the boot img is efi.

I have a usb image that I boot from, it isn't efi image, my question is, can I have /sys/firmware/efi in my usb image?

----------

## SlashBeast

the /sys is kernel interface, thus /sys/firmware/efi too. After a quick grep for '/sys/firmware/efi' on kernel sources I found:

 *drivers/firmware/efi/efi.c wrote:*   

> /*
> 
>  * efi.c - EFI subsystem
> 
>  *
> ...

 

And after quick glance on drivers/firmware/efi/Makefile

```
obj-$(CONFIG_EFI)           += efi.o vars.o
```

Which means you need to boot your kernel with CONFIG_EFI=y to have /sys/firmware/efi.

Srsly, don't be afraid to grep on kernel sources, they have tons of docs and comments in there.

----------

## VoidMage

I might not be good enough at explaining this, so just read these answers. Pay attention to the screenshot - one of the disks is listed both as BIOS and UEFI boot.

----------

## DaggyStyle

 *SlashBeast wrote:*   

> the /sys is kernel interface, thus /sys/firmware/efi too. After a quick grep for '/sys/firmware/efi' on kernel sources I found:
> 
>  *drivers/firmware/efi/efi.c wrote:*   /*
> 
>  * efi.c - EFI subsystem
> ...

 

I've booted my kernel with CONFIG_EFI, CONFIG_EFI_VARS and CONFIG_EFIVAR_FS. none of the combinations showed /sys/firmware/efi.

----------

## DaggyStyle

 *VoidMage wrote:*   

> I might not be good enough at explaining this, so just read these answers. Pay attention to the screenshot - one of the disks is listed both as BIOS and UEFI boot.

 

thanks, will take a look

----------

