Re: Re: (Thread restarted!) Debian installation using debootstrap and grub-install - no entry in ESC boot menu

2023-04-29 Thread Valentin Caracalla
Hello everyone,

I partly solved my problem and I would like to share my solution:

Until now, I thought that the EFI removable media path (\EFI\BOOT\BOOTX64.EFI) 
is really a fallback location, i.e. a location for putting the boot loader that 
just always works. Therefore I thought that I could forget about EFI variables 
altogether if I just put the boot loader there. My recipes don't bind-mount 
/sys/firmware/efi/efivars for that reason.

And when trying things out with the emulator, this assumption holds true, i.e. 
running "qemu-system-x86_64 -accel kvm -bios /usr/share/ovmf/OVMF.fd ..." will 
create a virtual machine that behaves like I expected.

However, my Asus UX31A does things differently and insists on EFI variables 
being used for the internal drive, i.e. it doesn't look at the fallback 
location (\EFI\BOOT\BOOTX64.EFI) of the internal drive.

That's the solution for the EFI boot interface, use EFI variables.

For the BIOS boot interface, I'm still clueless why it doesn't work. However, 
I'll leave it at that.

Thanks to everyone who helped!

Kind regards,
Valentin Caracalla



Re: (Thread restarted!) Debian installation using debootstrap and grub-install - no entry in ESC boot menu

2023-04-28 Thread David Wright
On Thu 27 Apr 2023 at 10:18:56 (+0700), Max Nikulin wrote:
> On 26/04/2023 22:57, Valentin Caracalla wrote:
> > the issue with the BIOS boot interface (see my original posting) is still 
> > unsolved
> 
> I had impression that there was no issue with booting in BIOS (legacy,
> compatibility, CSM) mode, of course when it is chosen in firmware/BIOS
> setup (requires disabling of secure boot).

Well, the OP wrote:

 "Previously, I've successfully installed Debian using official
  installation media on this machine (also using BIOS boot
  interface), so I know that it works in principle. But now I want to
  do it using command line utilities like debootstrap and grub-install."

But:

 "the problem is that the ESC boot menu doesn't show an entry for
  (the model name of) /dev/sda, so I can't boot into it."

My first question would be whether it makes a difference to use [F2]
and enter the BIOS/CMOS, rather than [ESC] to get just the boot list.

As you could read in another thread, I have been testing the d-i
installing on a BIOS machine, using a spare partition, in order to
see how it behaves with and without a BIOS Boot partition. However,
blanking the entire internal drive on a machine just for this
exercise is pushing things a bit too far, sorry.

And I'm not sure that results from one of /my/ machines would be
particularly useful either. They are either native BIOS booters, or
have a compatibility mode that just works, without requiring anything
out of the ordinary configured for a GPT disk in BIOS mode. That might
not be true for your Asus UX31A.

At this point, my action would be to install in BIOS mode using your
two methods, conventional d-i and debootstrap, and run bootinfoscript
(from package boot-info-script) on each, to look for differences.
I would avoid doing any UEFI booting between these runs.

Cheers,
David.



Re: (Thread restarted!) Debian installation using debootstrap and grub-install - no entry in ESC boot menu

2023-04-26 Thread Max Nikulin

On 26/04/2023 22:57, Valentin Caracalla wrote:

the issue with the BIOS boot interface (see my original posting) is still 
unsolved


I had impression that there was no issue with booting in BIOS (legacy, 
compatibility, CSM) mode, of course when it is chosen in firmware/BIOS 
setup (requires disabling of secure boot). Perhaps I confused it with 
qemu instead of bare metal.



I tried using the EFI removable media path (which should bypass any issues with 
EFI variables) without success.


This statement might be too strong. Internal drive is not a removable 
media. My impression is that you can boot from removable media (live 
CD), but not from internal drive.

- Is booting from that internal drive enabled in firmware setup?
- Is shim-signed package installed? Just shim is not enough when secure 
boot is enabled in firmware.



I want to install Debian on my Asus UX31A


UEFI implementation may have some peculiarities, likely you will find 
more pages:

https://wiki.osdev.org/Broken_UEFI_implementations
https://wiki.archlinux.org/title/Unified_Extensible_Firmware_Interface#Troubleshooting


I want to install it to the internal drive /dev/sda, and I want to do so
by executing commands on an installer system, which is a system already
installed on the external drive /dev/sdb.


Does it mean that you have another linux installed and there is no issue 
with its booting? Is it debian?



For now, I only want to get a GRUB command line, because that appears to be the 
difficult part.


Then you do not need debian installer at all. To debug such issues it is 
enough to copy files to EFI/debian and to run a couple of efibootmgr 
commands. By the way, you have not posted "efibootmgr -v" or at least 
"efibootmgr" output. Running it from an existing install or a live media 
is OK.



For the BIOS boot interface:

sudo parted /dev/sda mklabel gpt
sudo parted /dev/sda mkpart root 512MiB 100%
sudo parted /dev/sda set 1 bios_grub on


Perhaps you may create both BIOS Boot and EFI System partitions on the 
same disk to support both modes.



For the EFI boot interface:

sudo parted /dev/sda mklabel gpt
sudo parted /dev/sda mkpart init 0% 512MiB
sudo parted /dev/sda set 1 boot on
sudo mkfs.vfat /dev/sda1


I do not remember if the "boot" flag sets proper GUID for ESP. I have 
heard that there may be issues if fat16 is used instead of fat32

https://www.rodsbooks.com/gdisk/booting.html

file --special /dev/sda1
parted /dev/sda print
sgdisk -p /dev/sda

(Some people may be more familiar with output of sgdisk than parted)


sudo mount --bind /sys /mnt/sys
sudo mount --bind /proc /mnt/proc
sudo mount --bind /dev /mnt/dev
sudo mount --bind /dev/pts /mnt/dev/pts
sudo mount --bind /run /mnt/run


I still do not see /sys/firmware/efi/efivars here. Check 
/mnt/sys/firmware/efi/efivars


Frankly speaking, I am confused by your description. I suspect it is a 
mix of
- What you are going to do in future (having working install, prepare a 
disk for another machine or install a fresh system for the same computer)

- What you are really doing
- Recipe which way others may try reproduce (boot from a live media and 
install to an internal drive)


Let's concentrate on UEFI. Unless you faced an Asus-specific issue, it 
should be possible to use qemu+OVMF.




(Thread restarted!) Debian installation using debootstrap and grub-install - no entry in ESC boot menu

2023-04-26 Thread Valentin Caracalla
Hello Max,

thanks a lot for your input! I do, however, believe that the problem has a 
different cause. I came to that conclusion, mainly because the issue with the 
BIOS boot interface (see my original posting) is still unsolved, but also 
because I tried using the EFI removable media path (which should bypass any 
issues with EFI variables) without success.

Therefore, and to make it easier for new people entering this thread, I restart 
the thread now by asking my original question again, in a single and well 
arranged posting. You can forget everything you read in the thread before if 
you just read this one post:

Hello everyone,

I want to install Debian on my Asus UX31A using command line utilities like 
debootstrap and grub-install.

I want to install it to the internal drive /dev/sda, and I want to do so by 
executing commands on an installer system, which is a system already installed 
on the external drive /dev/sdb. To reproduce the issue, you should use a 
current stable Debian Live-CD as the installer system. Just write the Live-CD 
image to the external drive /dev/sdb using dd.

For now, I only want to get a GRUB command line, because that appears to be the 
difficult part.

Here are the step-by-step instructions to reproduce the problem:

1.: On the installer system, type "sudo apt install ..." to install any 
dependencies required by the recipe (see below).

2.: On the installer system, exercise one of the following two recipes:

For the BIOS boot interface:

sudo parted /dev/sda mklabel gpt
sudo parted /dev/sda mkpart init 0% 512MiB
sudo parted /dev/sda mkpart root 512MiB 100%
sudo parted /dev/sda set 1 bios_grub on
sudo mkfs.ext4 /dev/sda2
sudo mount /dev/sda2 /mnt
sudo debootstrap stable /mnt
sudo mount --bind /sys /mnt/sys
sudo mount --bind /proc /mnt/proc
sudo mount --bind /dev /mnt/dev
sudo mount --bind /dev/pts /mnt/dev/pts
sudo mount --bind /run /mnt/run
sudo chroot /mnt apt install grub-pc
sudo chroot /mnt grub-install /dev/sda
sudo umount /mnt/run
sudo umount /mnt/dev/pts
sudo umount /mnt/dev
sudo umount /mnt/proc
sudo umount /mnt/sys
sudo umount /mnt

For the EFI boot interface:

sudo parted /dev/sda mklabel gpt
sudo parted /dev/sda mkpart init 0% 512MiB
sudo parted /dev/sda mkpart root 512MiB 100%
sudo parted /dev/sda set 1 boot on
sudo mkfs.vfat /dev/sda1
sudo mkfs.ext4 /dev/sda2
sudo mount /dev/sda2 /mnt
sudo mkdir /mnt/boot
sudo mkdir /mnt/boot/efi
sudo mount /dev/sda1 /mnt/boot/efi
sudo debootstrap stable /mnt
sudo mount --bind /sys /mnt/sys
sudo mount --bind /proc /mnt/proc
sudo mount --bind /dev /mnt/dev
sudo mount --bind /dev/pts /mnt/dev/pts
sudo mount --bind /run /mnt/run
sudo chroot /mnt apt install grub-efi
sudo chroot /mnt grub-install --target=x86_64-efi /dev/sda
sudo chroot /mnt grub-install --target=x86_64-efi --removable /dev/sda
sudo umount /mnt/runsudo umount /mnt/dev/pts
sudo umount /mnt/dev
sudo umount /mnt/proc
sudo umount /mnt/sys
sudo umount /mnt/boot/efi
sudo umount /mnt
Please check every command's output before entering the next one.

3.: Shut down the installer system and disconnect the external drive /dev/sdb.

4.: Start the computer with the ESC key pressed. This will show a list of boot 
options (the ESC boot menu).

The expected behavior is that the list contains an entry for the installed 
system. Selecting that entry will give you a GRUB command line.

The actual behavior is that there is only the "Enter Setup" entry in the list, 
which is always there and does not do what we want (boot to GRUB command line).

That much for the step-by-step instructions.

Notice that the EFI variant of the recipe does set the "boot" and "esp" flags 
and the partition has the recommended size. Also notice that the EFI recipe 
will create the following directory structure on /dev/sda1:

drwxr-xr-x 3 root root   16384 Jan  1  1970 /mnt/boot/efi 
drwxr-xr-x 4 root root    8192 Apr 26 09:33 /mnt/boot/efi/EFI 
drwxr-xr-x 2 root root    8192 Apr 26 09:33 /mnt/boot/efi/EFI/BOOT 
-rwxr-xr-x 1 root root 108 Apr 26 09:33 /mnt/boot/efi/EFI/BOOT/BOOTX64.CSV 
-rwxr-xr-x 1 root root  934240 Apr 26 09:33 /mnt/boot/efi/EFI/BOOT/BOOTX64.EFI 
-rwxr-xr-x 1 root root   84648 Apr 26 09:33 /mnt/boot/efi/EFI/BOOT/fbx64.efi 
-rwxr-xr-x 1 root root 126 Apr 26 09:33 /mnt/boot/efi/EFI/BOOT/grub.cfg 
-rwxr-xr-x 1 root root 3827136 Apr 26 09:33 /mnt/boot/efi/EFI/BOOT/grubx64.efi 
-rwxr-xr-x 1 root root  845480 Apr 26 09:33 /mnt/boot/efi/EFI/BOOT/mmx64.efi 
drwxr-xr-x 2 root root    8192 Apr 26 09:33 /mnt/boot/efi/EFI/debian 
-rwxr-xr-x 1 root root 108 Apr 26 09:33 
/mnt/boot/efi/EFI/debian/BOOTX64.CSV 
-rwxr-xr-x 1 root root   84648 Apr 26 09:33 /mnt/boot/efi/EFI/debian/fbx64.efi 
-rwxr-xr-x 1 root root 126 Apr 26 09:33 /mnt/boot/efi/EFI/debian/grub.cfg 
-rwxr-xr-x 1 root root 4150720 Apr 26 09:33 
/mnt/boot/efi/EFI/debian/grubx64.efi 
-rwxr-xr-x 1 root root  845480 Apr 26 09:33 /mnt/boot/efi/EFI/debian/mmx64.efi 
-rwxr-xr-x 1 root root  934240 Apr 26 09:33