You are not logged in.

#1 2019-04-03 13:49:22

regid
Member
Registered: 2016-06-06
Posts: 201

UEFI boot manager entries for poweroff and reboot

Am I right that:

  1. Most UEFI boot managers don't suggest distinct menu entries (almost) out of the box for poweroff and reboot, even though these are usable entries.

  2. Two distinct source code, one that can add a poweroff, the other that can add a reboot, menu entries to most, possibly any, UEFI boot managers will be surprisingly short.

  3. Neither the AUR, nor the binary archives, have packages that offer that functionality.

?


powerofforreboot.efi (AUR): Utilities to be used from within a UEFI boot manager or shell.

Offline

#2 2019-04-03 14:14:00

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 1,975
Website

Re: UEFI boot manager entries for poweroff and reboot

1) What do you mean by "UEFI boot manager"? Do you mean a bootloader?
2) I don't understand the sentence at all.
3) Why should one package such a useless feature?
If the system is not bootet, You can power it off directly py pressing the power button.
And you can reboot it by pressing

[Ctrl]+[Alt]+[Del]

If you want an EFI loader entry, which I consider useless, you can add a boot entry with

systemd.unit=reboot.target

or

systemd.unit=poweroff.target

respectively.

Last edited by schard (2019-04-03 14:21:04)


macro_rules! yolo { { $($tokens:tt)* } => { unsafe { $($tokens)* } }; }

Offline

#3 2019-04-03 14:19:17

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,544

Re: UEFI boot manager entries for poweroff and reboot

schard: systemd-boot, refind, the firmware's menu, etc are all boot managers, NOT bootloaders.

Online

#4 2019-04-03 16:59:28

regid
Member
Registered: 2016-06-06
Posts: 201

Re: UEFI boot manager entries for poweroff and reboot

Suppose I want the boot menu to look like

  • archlinux

  • archlinux fallback

  • UEFI shell

  • reboot

  • poweroff

As far as I remember, the reboot and poweroff is quite customary. Syslinux has a poweroff module. Persumably because the machine might be under the desk, so pressing the power button might not be convenient.

A reboot entry might help users that are not familiar with ctrl+alt+del, or are not sure when ctrl+alt+del is safe, or must have something that supposedly looks more professional.

systemd targets are not shown in the boot menu, do they?

schard wrote:

1) What do you mean by "UEFI boot manager"? Do you mean a bootloader?

Stroked text by schard. I assume it was answered.

schard wrote:

2) I don't understand the sentence at all.

I was trying to say that just like the archlinux and archlinux-fallback menu entries, I think there are two main issues.

  1. How to get that entry into the menu?

  2. What exactly the boot loader manager should do with poweroff/reboot entries, once they are there?

The answer to putting the entries in the menu is that it is boot loader manager specific, and similar to any other entry the menu has.

The answer to what the boot loader manager would do with the poweroff/reboot entries is surprisingly short programs. Or that is what I think. These programs can be built from source with a new PKGBUILD. No need to modify the source code of the boot loader manager. No need to modify the boot loader manager PKGBUILD. Any user that doesn't want these entries can simply not install that poweroff/reboot PKGBUILD. And even if he built the package, he can not install it or not add the poweroff/reboot entries to his UEFI menu.

schard wrote:

3) Why should one package such a useless feature?
If the system is not bootet, You can power it off directly py pressing the power button.
And you can reboot it by pressing

[Ctrl]+[Alt]+[Del]

If you want an EFI loader entry, which I consider useless, you can add a boot entry with

systemd.unit=reboot.target

or

systemd.unit=poweroff.target

respectively.

I tried to answer a few line above, at the beginning of this message.

Last edited by regid (2019-04-03 17:23:58)


powerofforreboot.efi (AUR): Utilities to be used from within a UEFI boot manager or shell.

Offline

#5 2019-04-03 22:53:00

loqs
Member
Registered: 2014-03-06
Posts: 17,321

Re: UEFI boot manager entries for poweroff and reboot

Do you plan on using the EFI runtime services API for poweroff / reboot?

Offline

#6 2019-04-04 07:50:01

d_fajardo
Member
Registered: 2017-07-28
Posts: 1,568

Re: UEFI boot manager entries for poweroff and reboot

Why not just use a boot manager? I use rEFInd and I have the options to boot to Arch, to a UEFI Shell, to the system BIOS, to do a MemTest, shutdown and reboot all on my rEFInd greeter.

Offline

#7 2019-04-04 11:21:05

regid
Member
Registered: 2016-06-06
Posts: 201

Re: UEFI boot manager entries for poweroff and reboot

loqs wrote:

Do you plan on using the EFI runtime services API for poweroff / reboot?

Yes. I plan to use EFI runtime services. More specifically, ResetSystem().


powerofforreboot.efi (AUR): Utilities to be used from within a UEFI boot manager or shell.

Offline

#8 2019-04-04 11:25:40

regid
Member
Registered: 2016-06-06
Posts: 201

Re: UEFI boot manager entries for poweroff and reboot

d_fajardo wrote:

Why not just use a boot manager? I use rEFInd and I have the options to boot to Arch, to a UEFI Shell, to the system BIOS, to do a MemTest, shutdown and reboot all on my rEFInd greeter.

I am using systemd-boot. It doesn't have builtin shutdown and reboot. I didn't know that these are on rEFInd greeter. systemd-boot isn't graphical either. I think rEFInd is graphical.


powerofforreboot.efi (AUR): Utilities to be used from within a UEFI boot manager or shell.

Offline

#9 2019-04-04 12:38:29

d_fajardo
Member
Registered: 2017-07-28
Posts: 1,568

Re: UEFI boot manager entries for poweroff and reboot

Yes indeed rEFInd is graphical but that's what I personally like about it because the graphics is flexible enough to customise and so it is as how I want it to look. The options are not all there but can be added accordingly. You can also customise rEFInd to just print text if that's all you want.

Offline

#10 2019-04-07 21:00:21

regid
Member
Registered: 2016-06-06
Posts: 201

Re: UEFI boot manager entries for poweroff and reboot

The following works for me with systemd-boot. Hopefully it will work in many efi firmawres, and with other boot managers:

  • poweroff.c

#include <efi.h>
#include <efilib.h>

EFI_STATUS
EFIAPI
efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) {
    InitializeLib(ImageHandle, SystemTable);
    return uefi_call_wrapper(SystemTable->RuntimeServices->ResetSystem, 4, 
		             EfiResetShutdown, EFI_SUCCESS, sizeof(NULL), NULL);
}
  • reboot.c

#include <efi.h>
#include <efilib.h>

EFI_STATUS
EFIAPI
efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) {
    InitializeLib(ImageHandle, SystemTable);
    return uefi_call_wrapper(SystemTable->RuntimeServices->ResetSystem, 4, 
		             EfiResetCold, EFI_SUCCESS, sizeof(NULL), NULL);
}
  • Makefile

ARCH            = $(shell uname -m | sed s,i[3456789]86,ia32,)

EFIINC          = /usr/include/efi
EFIINCS         = -I$(EFIINC) -I$(EFIINC)/$(ARCH) -I$(EFIINC)/protocol
LIB             = /usr/lib
EFILIB          = /usr/lib
EFI_CRT_OBJS    = $(EFILIB)/crt0-efi-$(ARCH).o
EFI_LDS         = $(EFILIB)/elf_$(ARCH)_efi.lds

CFLAGS          = $(EFIINCS) -fno-stack-protector -fpic \
		  -fshort-wchar -mno-red-zone -Wall 
ifeq ($(ARCH),x86_64)
  CFLAGS += -DEFI_FUNCTION_WRAPPER
endif

LDFLAGS         = -nostdlib -znocombreloc -T $(EFI_LDS) -shared \
		  -Bsymbolic -L $(EFILIB) -L $(LIB) $(EFI_CRT_OBJS) 

all: poweroff.efi  reboot.efi

%.so: %.o
	ld $(LDFLAGS) $^ -o $@ -lefi -lgnuefi

%.efi: %.so
	objcopy -j .text -j .sdata -j .data -j .dynamic \
		-j .dynsym  -j .rel -j .rela -j .reloc \
		--target=efi-app-$(ARCH) $^ $@

When All 3 files are in the same directory

% make

Should build poweroff.efi and reboot.efi.
The dependencies, other then base-devel, is gnu-efi-libs.
poweroff.efi and reboot.efi should be copied to the ESP, and the boot manager should be configured to call them. They should also work from a UEFI shell.
If someone cares to upload it to the AUR, just drop a notice here. I don't have AUR upload privileges. I think these utilities should be there.

Last edited by regid (2019-04-09 00:57:00)


powerofforreboot.efi (AUR): Utilities to be used from within a UEFI boot manager or shell.

Offline

#11 2019-04-07 21:07:29

loqs
Member
Registered: 2014-03-06
Posts: 17,321

Re: UEFI boot manager entries for poweroff and reboot

AUR is for hosting PKGBUILDS not the projects themselves.
AUR registration is open once registered you should be able to upload the PKGBUILD yourself.

Offline

Board footer

Powered by FluxBB