Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] installing on UEFI system
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
Vieri
l33t
l33t


Joined: 18 Dec 2005
Posts: 872

PostPosted: Tue Feb 07, 2017 2:00 pm    Post subject: [SOLVED] installing on UEFI system Reply with quote

Hi,

I'm a bit confused on how to set up disk partitions when using UEFI.

I've looked at two places that aren't really saying the same:

https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Disks
https://wiki.gentoo.org/wiki/Quick_Installation_Checklist#Format_drive

I'll try to summarize it all here:

Code:
/dev/sda1    BIOS boot partition [handbook recommends 2MB, Checklist recommends 32MB?]
/dev/sda2    Boot partition [handbook and checklist recommend 128MB]
/dev/sda3    Swap partition
/dev/sda4    Root partition


Handbook suggests creating BIOS boot first, boot second.
Checklist suggest creating boot first, BIOS boot/UEFI second.
Is there a difference?

Let's suppose I follow what the Handbook says regarding the first 2 partitions only:
Code:
/dev/sda1 -> BIOS boot, size: 2 MB or 32 MB ?
/dev/sda2 -> boot, size: 128 MB


Code:
parted -a optimal /dev/sda
(parted) mklabel gpt
(parted) unit mib
(parted) mkpart primary 1 3
(parted) name 1 grub
(parted) set 1 bios_grub on
(parted) mkpart primary 3 131
(parted) name 2 boot
...
(parted) set 2 boot on


Are we sure it's "set 2 boot on" instead of "set 1 boot on"?
I'm asking because further down in the handbook, under the "fdisk alternative", in "Creating the BIOS boot partition", it says to "mark the partition [1] for UEFI purposes".
So it's referring to /dev/sda1, not /dev/sda2... Confusing.

The end result according to the handbook should be:

Code:
/dev/sda1             1         3      5198+  ef  EFI (FAT-12/16/32)
/dev/sda2   *         3        14    105808+  83  Linux


Finally, the handbook seems to be missing information on how to format and mount UEFI partitions.

If I take the info from the "Checklist" wiki and apply it to the handbook then I'm guessing that maybe I should do the following:

Code:
mkfs.vfat /dev/sda1
mkfs.ext2 -T small /dev/sda2


Code:
mkdir -p /mnt/gentoo
mount /dev/sda4 /mnt/gentoo
mkdir /mnt/gentoo/boot
mount /dev/sda2 /mnt/gentoo/boot
mkdir /mnt/gentoo/boot/efi
mount /dev/sda1 /mnt/gentoo/boot/efi


Is this correct?


Last edited by Vieri on Fri Feb 10, 2017 1:09 pm; edited 1 time in total
Back to top
View user's profile Send private message
Logicien
Veteran
Veteran


Joined: 16 Sep 2005
Posts: 1555
Location: Montréal

PostPosted: Tue Feb 07, 2017 2:14 pm    Post subject: Reply with quote

If you make an UEFI mode Gentoo installation, your better to use a GPT partitions table. You do not need a Bios Boot Partition. If you intend to make a Bios mode Gentoo installation, you can use the legacy DOS/MBR partitions table who is still alive again. You do not need a Bios Boot Partition.

This is the way I proceed with BIOS and UEFI modes. It's possible to convert a GPT to DOS/MBR partitions table and reverse if needed but, this is something I do not do.

When the Bios Boot Partition is the first partition on a drive it just beside the MBR bootloader sector. The EFI partition is generally mounted in /boot/efi. The EFI partition can have a double purpose, in EFI mode it can serve as a boot partition and as an efi partition at the same time, code EF00, EFI System formated in Fat 16 or 32. It is than mounted in /boot. It replace the boot partition who must not be use in this case.

You need to know how to manage this double use of the EFI partition with the EFI bootloader and the EFI menu entries.
_________________
Paul
Back to top
View user's profile Send private message
Vieri
l33t
l33t


Joined: 18 Dec 2005
Posts: 872

PostPosted: Tue Feb 07, 2017 4:58 pm    Post subject: Reply with quote

So, if my partitioning scheme is like in the handbook, I need to:

Code:
parted -a optimal /dev/sda
(parted) mklabel gpt
(parted) unit mib
(parted) mkpart primary 1 3
(parted) name 1 grub
(parted) set 1 bios_grub on
(parted) mkpart primary 3 131
(parted) name 2 boot
...
(parted) set 2 boot on

mkfs.fat -F 32 /dev/sda2
mount /dev/sda2 /mnt/gentoo/boot


Then within chroot:

Code:
grub-install --target=X86 64-efi --efi-directory=/boot
Back to top
View user's profile Send private message
Fitzcarraldo
Advocate
Advocate


Joined: 30 Aug 2008
Posts: 2034
Location: United Kingdom

PostPosted: Tue Feb 07, 2017 11:21 pm    Post subject: Reply with quote

Vieri,

The Gentoo Intstallation Guide is confusing in my opinion. If you want to use a GPT-formatted HDD with a UEFI machine, you don't need a BIOS boot partition. A BIOS boot partition (Code EF02) is intended for a GPT-formatted HDD with a BIOS machine. If you want to use UEFI, what you do need is an ESP (EFI System Partition) formatted as FAT32. (If you had wanted to use a GPT-formatted HDD with a BIOS machine, an ESP is not required/used at all.)

If you want UEFI + GPT then the following would suffice (I'm assuming you want to use GRUB and prefer /home on a separate partition):

1 MiB of unpartitioned space before /dev/sda1.
/dev/sda1 fat32 partition of e.g. 512 MiB, Code EF00, with the boot and esp flags set, which will contain /boot/efi/.
/dev/sda2 linuxswap partition, Code 8200.
/dev/sda3 ext4 partition, Code 8300, to contain / (root) (and /boot and /boot/grub/). No flags set.
/dev/sda4 ext4 partition, Code 8300, to contain /home.
1 MiB of unpartitioned space after /dev/sda4.

If you don't mind having / (root), /boot and /home all on the same partition, the above can be simplified to:

1 MiB of unpartitioned space before /dev/sda1.
/dev/sda1 fat32 partition of e.g. 512 MiB, Code EF00, with the boot and esp flags set, which will contain /boot/efi/.
/dev/sda2 linuxswap partition, Code 8200.
/dev/sda3 ext4 partition, Code 8300, to contain / (root) (and /boot, /boot/grub/ and /home). No flags set.
1 MiB of unpartitioned space after /dev/sda3.

If you prefer to have /boot (and /boot/grub/) on a separate partition from / (root) then the following scheme is an alternative to the above:

1 MiB of unpartitioned space before /dev/sda1.
/dev/sda1 fat32 partition of e.g. 512 MiB, Code EF00, with the boot and esp flags set, which will contain /boot/efi/.
/dev/sda2 linuxswap partition, Code 8200.
/dev/sda3 ext2 partition of e.g. 512 MiB, Code 8300, to contain /boot (and /boot/grub/). No flags set.
/dev/sda4 ext4 partition, Code 8300, to contain / (root).
/dev/sda5 ext4 partition, Code 8300, to contain /home.
1 MiB of unpartitioned space after /dev/sda5.

Below is an example of the above partitioning scheme in a virtual UEFI machine with virtual 64GiB HDD partitioned with GPT, onto which I installed a working Linux.

Code:
# gdisk -l /dev/sda
GPT fdisk (gdisk) version 1.0.1

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/sda: 134217728 sectors, 64.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 54B3C38F-1C55-4A19-9BAA-499C4D0D8DD0
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 134217694
Partitions will be aligned on 2048-sector boundaries
Total free space is 4029 sectors (2.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         1050623   512.0 MiB   EF00
   2         1050624         5244927   2.0 GiB     8200
   3         5244928         6293503   512.0 MiB   8300
   4         6293504        72353791   31.5 GiB    8300
   5        72353792       134215679   29.5 GiB    8300

# fdisk -l /dev/sda
Disk /dev/sda: 64 GiB, 68719476736 bytes, 134217728 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 54B3C38F-1C55-4A19-9BAA-499C4D0D8DD0

Device        Start       End  Sectors  Size Type
/dev/sda1      2048   1050623  1048576  512M EFI System
/dev/sda2   1050624   5244927  4194304    2G Linux swap
/dev/sda3   5244928   6293503  1048576  512M Linux filesystem
/dev/sda4   6293504  72353791 66060288 31.5G Linux filesystem
/dev/sda5  72353792 134215679 61861888 29.5G Linux filesystem

# parted -l
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 68.7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system     Name  Flags
 1      1049kB  538MB   537MB   fat32                 boot, esp
 2      538MB   2685MB  2147MB  linux-swap(v1)
 3      2685MB  3222MB  537MB   ext2
 4      3222MB  37.0GB  33.8GB  ext4
 5      37.0GB  68.7GB  31.7GB  ext4

# blkid
/dev/sda4: LABEL="ROOT" UUID="174ac3e8-f105-4606-bed1-7a1aa22c3631" TYPE="ext4" PARTUUID="01d9c139-fe70-415a-abc6-2351fad33384"
/dev/sda1: UUID="B4C1-7EA5" TYPE="vfat" PARTUUID="d941f728-c386-4f4c-b0c3-aa76f4290774"
/dev/sda2: LABEL="SWAP" UUID="e3ddf9b5-2ae3-4469-a121-0a1a78aa6702" TYPE="swap" PARTUUID="a4daec88-da44-4ae3-8119-01cc81325f03"
/dev/sda3: LABEL="BOOT" UUID="1e24ea9d-5358-4e9b-8667-d7a42e7b6ad7" TYPE="ext2" PARTUUID="b5369ce3-4b44-4d19-be6f-1d226dc71cb3"
/dev/sda5: LABEL="HOME" UUID="87f6a0af-dbed-4587-b810-efca8f269618" TYPE="ext4" PARTUUID="19fd7d00-2d89-4653-af03-e81618a3b70d"

# [ -d /sys/firmware/efi ] && echo "Machine booted with UEFI" || echo "Machine booted with BIOS"
Machine booted with UEFI

The 1MiB (2048 512B sectors) of unpartitioned space at the beginning of a GPT-partitioned HDD is to cater for:

The Protective MBR (512B). <--- Ignored by UEFI.
The Primary GPT Header (512B).
The Primary GPT entries for up to 128 partitions (up to 16KiB).

The 1MiB (2048 512B sectors) of unpartitioned space at the end of a GPT-partitioned HDD is to cater for:

The Secondary GPT entries for up to 128 partitions (up to 16KiB).
The Secondary GPT Header (512B).

So allowing 1 MiB of empty space before the first partition and after the last partition is more than enough. The Secondary GPT is a standard feature of GPT and is a backup for the Primary GPT.
_________________
Clevo W230SS: amd64, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC udev elogind & KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
Vieri
l33t
l33t


Joined: 18 Dec 2005
Posts: 872

PostPosted: Wed Feb 08, 2017 8:32 am    Post subject: Reply with quote

Thanks for the info.

I must agree that the Handbook is confusing regarding UEFI.

There are also typo mistakes such as the one found here:

https://wiki.gentoo.org/wiki/Handbook:AMD64/Full/Installation#Install
This is the code that is shown in the Handbook:

Code:
    root #grub-install --target=X86 64-efi --efi-directory=/boot


The "target" is wrong.

Anyway, does the UEFI partition have to be the first one?

If not, is this scheme OK?

Code:
1 MiB of unpartitioned space before /dev/sda1.
/dev/sda1 ext2 partition of e.g. 512 MiB, Code 8300, to contain /boot (and /boot/grub/). No flags set.
/dev/sda2 fat32 partition of e.g. 512 MiB, Code EF00, with the boot and esp flags set, which will contain /boot/efi/.
/dev/sda3 linuxswap partition, Code 8200.
/dev/sda4 ext4 partition, Code 8300, to contain / (root) (and /boot, /boot/grub/ and /home). No flags set.
1 MiB of unpartitioned space after /dev/sda4.


Is the mouting correct?
Code:
# mount /dev/sda4 /mnt/gentoo
# mkdir -p /mnt/gentoo/boot/efi
# mount /dev/sda2 /mnt/gentoo/boot/efi
# mount /dev/sda1 /mnt/gentoo/boot


I'm not sure which of the two below I need to run within chroot.

Code:
# grub-install --target=x86_64-efi --efi-directory=/boot /dev/sda


or

Code:
# grub-install --target=x86_64-efi --efi-directory=/boot/efi /dev/sda
Back to top
View user's profile Send private message
Fitzcarraldo
Advocate
Advocate


Joined: 30 Aug 2008
Posts: 2034
Location: United Kingdom

PostPosted: Wed Feb 08, 2017 2:59 pm    Post subject: Reply with quote

Well spotted regarding the mistaken command in the Gentoo Handbook; it should indeed contain '--target=x86_64-efi' rather than '--target=x86 64-efi'.

Also, you should use '--efi-directory=/boot/efi' rather than '--efi-directory=/boot' with the partitioning schemes I outlined above.

Your proposed scheme mentions '/boot' and '/boot/grub/' on /dev/sda1 and also on /dev/sda4. I assume what you meant to write was:

1 MiB of unpartitioned space before /dev/sda1.
/dev/sda1 ext2 partition of e.g. 512 MiB, Code 8300, to contain /boot (and /boot/grub/). No flags set.
/dev/sda2 fat32 partition of e.g. 512 MiB, Code EF00, with the boot and esp flags set, which will contain /boot/efi/.
/dev/sda3 linuxswap partition, Code 8200.
/dev/sda4 ext4 partition, Code 8300, to contain / (root) and /home. No flags set.
1 MiB of unpartitioned space after /dev/sda4.

That should work, but why do you want the HDD arm at boot to bypass sda1 and go to sda2 then back to sda1 then forward to sda4? I suggest you use the following scheme:

1 MiB of unpartitioned space before /dev/sda1.
/dev/sda1 fat32 partition of e.g. 512 MiB, Code EF00, with the boot and esp flags set, which will contain /boot/efi/.
/dev/sda2 ext2 partition of e.g. 512 MiB, Code 8300, to contain /boot (and /boot/grub/). No flags set.
/dev/sda3 linuxswap partition, Code 8200.
/dev/sda4 ext4 partition, Code 8300, to contain / (root) and /home. No flags set.
1 MiB of unpartitioned space after /dev/sda4.

Or, to put it aother way:

1 MiB of unpartitioned space before /dev/sda1.
/dev/sda1 fat32 partition of e.g. 512 MiB, Code EF00, with the boot and esp flags set. Mountpoint /boot/efi/.
/dev/sda2 ext2 partition of e.g. 512 MiB, Code 8300. Mountpoint /boot. No flags set.
/dev/sda3 linuxswap partition, Code 8200.
/dev/sda4 ext4 partition, Code 8300, Mountpoint / (root). No flags set.
1 MiB of unpartitioned space after /dev/sda4.

This is how you would mount the above partitions (you need to do it in the correct order):

Code:
# mkdir -p /mnt/gentoo/boot/efi
# mount /dev/sda4 /mnt/gentoo
# mount /dev/sda2 /mnt/gentoo/boot
# mount /dev/sda1 /mnt/gentoo/boot/efi


Just to prove this is the correct sequence to mount them, here is what happens when I use the Gentoo LiveDVD in a virtual UEFI machine to look at an existing Linux installation on a virtual GPT-formatted HDD (ignore /dev/sda5 below, as you indicated that you want /home to be on the same partition as / (root), i.e. on /dev/sda4):

Code:
livecd gentoo # parted /dev/sda print
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 68.7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system     Name       Flags
 1      2097kB  539MB   537MB   fat32                      boot, esp
 2      539MB   1076MB  537MB   ext2            /boot
 3      1076MB  3223MB  2147MB  linux-swap(v1)  linuxswap
 4      3223MB  37.6GB  34.4GB  ext4            /
 5      37.6GB  68.7GB  31.1GB  ext4            /home

livecd gentoo # gdisk -l /dev/sda
GPT fdisk (gdisk) version 1.0.1

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/sda: 134217728 sectors, 64.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 9807AF0F-8BD5-4727-A3CD-9995B2705732
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 134217694
Partitions will be aligned on 2048-sector boundaries
Total free space is 8125 sectors (4.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            4096         1052671   512.0 MiB   EF00 
   2         1052672         2101247   512.0 MiB   8300  /boot
   3         2101248         6295551   2.0 GiB     8200  linuxswap
   4         6295552        73404415   32.0 GiB    8300  /
   5        73404416       134213631   29.0 GiB    8300  /home
livecd gentoo #


Code:
livecd gentoo # mkdir -p /mnt/gentoo/boot/efi
livecd gentoo # ls /mnt/gentoo
boot
livecd gentoo # ls /mnt/gentoo/boot
efi
livecd gentoo # ls /mnt/gentoo/boot/efi
livecd gentoo # mount /dev/sda4 /mnt/gentoo
livecd gentoo # mount /dev/sda2 /mnt/gentoo/boot
livecd gentoo # mount /dev/sda1 /mnt/gentoo/boot/efi
livecd gentoo # ls /mnt/gentoo/boot/efi
EFI  startup.nsh
livecd gentoo # ls /mnt/gentoo/boot   
System.map-4.4.0-31-generic  config-4.4.0-62-generic      lost+found                vmlinuz-4.4.0-62-generic
System.map-4.4.0-62-generic  efi                          memtest86+.bin            vmlinuz-4.4.0-62-generic.efi.signed
abi-4.4.0-31-generic         grub                         memtest86+.elf
abi-4.4.0-62-generic         initrd.img-4.4.0-31-generic  memtest86+_multiboot.bin
config-4.4.0-31-generic      initrd.img-4.4.0-62-generic  vmlinuz-4.4.0-31-generic
livecd gentoo # ls /mnt/gentoo     
bin   cdrom  etc   initrd.img      lib    lost+found  mnt  proc  run   snap  sys  usr  vmlinuz
boot  dev    home  initrd.img.old  lib64  media       opt  root  sbin  srv   tmp  var
livecd gentoo #

_________________
Clevo W230SS: amd64, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC udev elogind & KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
Vieri
l33t
l33t


Joined: 18 Dec 2005
Posts: 872

PostPosted: Wed Feb 08, 2017 4:44 pm    Post subject: Reply with quote

I decided to put EFI on the first partition and /boot/grub on the second partition.

The only extra thing I tried was to build RAID1 sets.

I'm stuck in the RAID building process. :-(

I have 2 HDDs that I'm recycling. They previously had a partition layout and RAID sets. My goal was to clean those disks out and start wit a fresh install.

First problem: I can't seem to really clean the disks because I keep seeing devices such as /dev/md125 (see below).

Second problem: I can't get past building the RAID set, watching /proc/mdstat...

Here are the commands I ran:

Code:

modprobe raid1 dm-mod
umount -l /dev/md127
mdadm --stop /dev/md127
mdadm --remove /dev/md127
umount -l /dev/md126
mdadm --stop /dev/md126
mdadm --remove /dev/md126
umount -l /dev/md125
mdadm --stop /dev/md125
mdadm --remove /dev/md125
umount -l /dev/md124
mdadm --stop /dev/md124
mdadm --remove /dev/md124
umount -l /dev/md124
mdadm --stop /dev/md124
mdadm --remove /dev/md124
umount -l /dev/md125
mdadm --stop /dev/md125
mdadm --remove /dev/md125
umount -l /dev/md126
mdadm --stop /dev/md126
mdadm --remove /dev/md126
umount -l /dev/md127
mdadm --stop /dev/md127
mdadm --remove /dev/md127
mdadm --zero-superblock /dev/sda
mdadm --zero-superblock /dev/sdb
dd if=/dev/zero of=/dev/sda bs=1M
dd if=/dev/zero of=/dev/sdb bs=1M
hdparm -z /dev/sda
hdparm -z /dev/sdb
mdadm --examine /dev/sda
mdadm --examine /dev/sdb
partprobe
parted -a optimal -s /dev/sda mklabel gpt
parted -a optimal -s /dev/sda unit MiB mkpart primary 1MiB 513MiB
parted -a optimal -s /dev/sda set 1 raid on
parted -a optimal -s /dev/sda name 1 uefi
parted -a optimal -s /dev/sda set 1 boot on
parted -a optimal -s /dev/sda unit MiB mkpart primary 513MiB 1025MiB
parted -a optimal -s /dev/sda set 2 raid on
parted -a optimal -s /dev/sda name 2 boot
parted -a optimal -s /dev/sda unit MiB mkpart primary 1025MiB 37218MiB
parted -a optimal -s /dev/sda set 3 raid on
parted -a optimal -s /dev/sda name 3 swap
parted -a optimal -s -- /dev/sda unit MiB mkpart primary 37218MiB -101
parted -a optimal -s /dev/sda set 4 raid on
parted -a optimal -s /dev/sda name 4 rootfs
partprobe /dev/sda
parted -a optimal -s /dev/sdb mklabel gpt
parted -a optimal -s /dev/sdb unit MiB mkpart primary 1MiB 513MiB
parted -a optimal -s /dev/sdb set 1 raid on
parted -a optimal -s /dev/sdb name 1 uefi
parted -a optimal -s /dev/sdb set 1 boot on
parted -a optimal -s /dev/sdb unit MiB mkpart primary 513MiB 1025MiB
parted -a optimal -s /dev/sdb set 2 raid on
parted -a optimal -s /dev/sdb name 2 boot
parted -a optimal -s /dev/sdb unit MiB mkpart primary 1025MiB 37218MiB
parted -a optimal -s /dev/sdb set 3 raid on
parted -a optimal -s /dev/sdb name 3 swap
parted -a optimal -s -- /dev/sdb unit MiB mkpart primary 37218MiB -101
parted -a optimal -s /dev/sdb set 4 raid on
parted -a optimal -s /dev/sdb name 4 rootfs
partprobe /dev/sdb
mdadm --create --verbose /dev/md1 --name=BIOS --level=mirror --raid-devices=2 --metadata=0.90 /dev/sda1 /dev/sdb1
mdadm --create --verbose /dev/md2 --name=BOOT --level=mirror --raid-devices=2 --metadata=0.90 /dev/sda2 /dev/sdb2
mdadm --create --verbose /dev/md3 --name=SWAP --level=mirror --raid-devices=2 --metadata=0.90 /dev/sda3 /dev/sdb3
mdadm --create --verbose /dev/md4 --name=ROOT --level=mirror --raid-devices=2 --metadata=0.90 --assume-clean /dev/sda4 /dev/sdb4


And here are the results (output of my custom script from commands listed above):

Code:

INFO: Activating mdadm/kernel raid... (limiting to RAID1)
IINFO: md devices I see right now (they will be removed):
1_0
2_0
3_0
4_0
INFO: Unmounting RAID array /dev/md127
INFO: Stopping RAID array /dev/md127
INFO: Removing RAID array /dev/md127
INFO: Unmounting RAID array /dev/md126
INFO: Stopping RAID array /dev/md126
INFO: Removing RAID array /dev/md126
INFO: Unmounting RAID array /dev/md125
INFO: Stopping RAID array /dev/md125
INFO: Removing RAID array /dev/md125
INFO: Unmounting RAID array /dev/md124
INFO: Stopping RAID array /dev/md124
INFO: Removing RAID array /dev/md124
INFO: Unmounting RAID array /dev/md124
INFO: Stopping RAID array /dev/md124
INFO: Removing RAID array /dev/md124
INFO: Unmounting RAID array /dev/md125
INFO: Stopping RAID array /dev/md125
INFO: Removing RAID array /dev/md125
INFO: Unmounting RAID array /dev/md126
INFO: Stopping RAID array /dev/md126
INFO: Removing RAID array /dev/md126
INFO: Unmounting RAID array /dev/md127
INFO: Stopping RAID array /dev/md127
INFO: Removing RAID array /dev/md127
INFO: Zeroing out superblocks in /dev/sda and /dev/sdb
INFO: mdadm --zero-superblock /dev/sda
INFO: Deleting the whole disk
INFO: Started working on device /dev/sda...
INFO: Finished target device /dev/sda. Now working on /dev/sdb...
INFO: after full clean-up there should be NO md devices here:
/dev/md124
/dev/md125
/dev/md126
/dev/md127
/dev/mdev.seq
INFO: after partprobe (you should not see any md devices here):
/dev/md124
/dev/md125
/dev/md126
/dev/md127
/dev/mdev.seq
INFO: Partition table on both disks should now be empty:
Model: ATA OCZ-AGILITY3 (scsi)
Disk /dev/sda: 228937MiB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:
Model: ATA OCZ-AGILITY3 (scsi)
Disk /dev/sdb: 228937MiB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:
INFO: /dev/sda Detected device total size: 228937 mebibytes
INFO: Detected total RAM MiB space: 32097, suggested SWAP MiB space: 36193
INFO: Will create:
INFO: UEFI boot partition: 512 MiB
INFO: BOOT Grub2 partition: 512 MiB
INFO: SWAP partition: 36193 MiB
INFO: ROOT partition: rest of disk
INFO: Setting label
INFO: GPT MBR OK
INFO: UEFI boot partition...
INFO: Setting Linux RAID on UEFI partition
INFO: UEFI partition on /dev/sda (RAID) OK
INFO: UEFI partition RAID activation on /dev/sda OK
INFO: UEFI partition name on /dev/sda OK
INFO: UEFI partition boot on /dev/sda OK
INFO: BOOT partition...
INFO: Setting Linux RAID on BOOT partition
INFO: BOOT partition on /dev/sda (RAID) OK
INFO: BOOT partition RAID activation on /dev/sda OK
INFO: BOOT partition name on /dev/sda OK
INFO: SWAP partition...
INFO: Setting Linux RAID on SWAP partition
INFO: SWAP partition on /dev/sda (RAID) OK
INFO: SWAP partition RAID activation on /dev/sda OK
INFO: SWAP partition name on /dev/sda OK
INFO: > ROOT partition...
INFO: Setting Linux RAID on ROOT partition
INFO: ROOT partition on /dev/sda (RAID) OK
INFO: ROOT partition RAID activation on /dev/sda OK
INFO: ROOT partition name on /dev/sda OK
INFO: partprobe /dev/sda OK
INFO: Partition table is now:
Model: ATA OCZ-AGILITY3 (scsi)
Disk /dev/sda: 228937MiB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start     End        Size       File system  Name    Flags
 1      1.00MiB   513MiB     512MiB                  uefi    boot, esp
 2      513MiB    1025MiB    512MiB                  boot    raid
 3      1025MiB   37218MiB   36193MiB                swap    raid
 4      37218MiB  228836MiB  191618MiB               rootfs  raid

INFO: Partition table of /dev/sdb
Model: ATA OCZ-AGILITY3 (scsi)
Disk /dev/sdb: 228937MiB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:
INFO: Detected device total size: 228937 mebibytes
INFO: Detected total RAM MiB space: 32097, suggested SWAP MiB space: 36193
INFO: Will create:
INFO: UEFI boot partition: 512 MiB
INFO: BOOT Grub2 partition: 512 MiB
INFO: SWAP partition: 36193 MiB
INFO: ROOT partition: rest of disk
INFO: Setting label
INFO: GPT MBR OK
INFO: UEFI boot partition...
INFO: Setting Linux RAID on UEFI partition
INFO: UEFI partition on /dev/sdb (RAID) OK
INFO: UEFI partition RAID activation on /dev/sdb OK
INFO: UEFI partition name on /dev/sdb OK
INFO: UEFI partition boot on /dev/sdb OK
INFO: BOOT partition...
INFO: Setting Linux RAID on BOOT partition
INFO: BOOT partition on /dev/sdb (RAID) OK
INFO: BOOT partition RAID activation on /dev/sdb OK
INFO: BOOT partition name on /dev/sdb OK
INFO: SWAP partition...
INFO: Setting Linux RAID on SWAP partition
INFO: SWAP partition on /dev/sdb (RAID) OK
INFO: SWAP partition RAID activation on /dev/sdb OK
INFO: SWAP partition name on /dev/sdb OK
INFO: > ROOT partition...
INFO: Setting Linux RAID on ROOT partition
INFO: ROOT partition on /dev/sdb (RAID) OK
INFO: ROOT partition RAID activation on /dev/sdb OK
INFO: ROOT partition name on /dev/sdb OK
INFO: partprobe /dev/sdb OK
INFO: Partition table is now:
Model: ATA OCZ-AGILITY3 (scsi)
Disk /dev/sdb: 228937MiB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start     End        Size       File system  Name    Flags
 1      1.00MiB   513MiB     512MiB                  uefi    boot, esp
 2      513MiB    1025MiB    512MiB                  boot    raid
 3      1025MiB   37218MiB   36193MiB                swap    raid
 4      37218MiB  228836MiB  191618MiB               rootfs  raid

INFO: dev.raid.speed_limit_min = 50000
INFO: creating UEFI BOOT RAID set /dev/md1
INFO: creating BOOT RAID set /dev/md2
INFO: creating SWAP RAID set /dev/md3
INFO: creating ROOT RAID set /dev/md4
INFO: RAID set should be building now (ROOT is assumed clean).


However, I'm stuck here below:

Code:

# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4] [raid0] [raid1] [raid10] [linear] [multipath]
md1 : active raid1 sda1[0] sdb1[1]
      524224 blocks [2/2] [UU]
     
md2 : active raid1 sdb2[1]
      524224 blocks [2/1] [_U]
     
md4 : active (auto-read-only) raid1 sda4[0]
      196216320 blocks [2/1] [U_]
      bitmap: 0/2 pages [0KB], 65536KB chunk

md3 : active (auto-read-only) raid1 sda3[0]
      37061568 blocks [2/1] [U_]
         resync=PENDING
     
unused devices: <none>

# uname -a
Linux livecd 4.4.39-gentoo #1 SMP Thu Jan 26 07:23:09 UTC 2017 x86_64 AMD FX(tm)-8320 Eight-Core Processor AuthenticAMD GNU/Linux


Any ideas?
Back to top
View user's profile Send private message
Fitzcarraldo
Advocate
Advocate


Joined: 30 Aug 2008
Posts: 2034
Location: United Kingdom

PostPosted: Wed Feb 08, 2017 5:19 pm    Post subject: Reply with quote

A year ago I also had trouble wiping two large (3TB) GPT-formatted HDDs in order to create a RAID1 installation. To fix that, I created a new LivePenDrive with the latest version of SystemRescueCD, booted it and performed the zero-ing of the GPT labels of both the HDDs.

Code:
root@sysresccd /root % cat /sys/block/sda/size
5860533168

root@sysresccd /root % cat /sys/block/sdb/size
5860533168

root@sysresccd /root % fdisk -l

root@sysresccd /root % /bin/dd if=/dev/zero of=/dev/sda bs=512 count=34
34+0 records in
34+0 records out
17408 bytes (17 kB) copied, 0.011545 s, 1.5 MB/s

root@sysresccd /root % /bin/dd if=/dev/zero of=/dev/sdb bs=512 count=34
34+0 records in
34+0 records out
17408 bytes (17 kB) copied, 0.0214954 s, 810 kB/s

root@sysresccd /root % /bin/dd if=/dev/zero of=/dev/sda bs=512 count=34 skip=5860533134 <--- No. of sectors on /dev/sda minus 34
34+0 records in
34+0 records out
17408 bytes (17 kB) copied, 0.0196862 s, 884 kB/s

root@sysresccd /root % /bin/dd if=/dev/zero of=/dev/sdb bs=512 count=34 skip=5860533134 <--- No. of sectors on /dev/sdb minus 34
34+0 records in
34+0 records out
17408 bytes (17 kB) copied, 0.0109395 s, 1.6 MB/s

root@sysresccd /root % partprobe /dev/sda

root@sysresccd /root % partprobe /dev/sdb

root@sysresccd /root % fdisk -l


The 'fdisk -l' command after performing the operation should show that sda and sdb have no partitions.

Disclaimer: Do this at your own risk.
_________________
Clevo W230SS: amd64, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC udev elogind & KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
Fitzcarraldo
Advocate
Advocate


Joined: 30 Aug 2008
Posts: 2034
Location: United Kingdom

PostPosted: Wed Feb 08, 2017 6:14 pm    Post subject: Reply with quote

Regarding RAID in Gentoo, someone else will have to advise you as I don't use RAID in Gentoo, only in Ubuntu.

In Ubuntu I had a similar problem with /dev/md1 being renamed to /dev/md125, /dev/md126 or /dev/md127 on reboot. The following two Web pages explain how to solve this in the case of Ubuntu, which might give you some pointers:

Why is my RAID /dev/md1 showing up as /dev/md126? Is mdadm.conf being ignored?

How-to change the name of an MD device (mdadm)

Below is what I did to fix the problem in Ubuntu, which again may give you some pointers for Gentoo (although the commands to chroot, regenerate the initramfs image, install & configure GRUB are different in Gentoo):

Booted Ubuntu Desktop LiveDVD, then:
Code:
ubuntu@ubuntu:~$ sudo apt-get install mdadm
ubuntu@ubuntu:~$ sudo mdadm --assemble --scan
ubuntu@ubuntu:~$ sudo fdisk -l
ubuntu@ubuntu:~$ sudo blkid
ubuntu@ubuntu:~$ sudo mount /dev/md/1 /mnt
ubuntu@ubuntu:~$ sudo mount /dev/sdf1 /mnt/boot
ubuntu@ubuntu:~$ sudo mdadm --examine --scan
ubuntu@ubuntu:~$ cat /etc/mdadm/mdadm.conf | grep ARRAY


Then I chrooted into the Ubuntu HDD installation:
Code:
ubuntu@ubuntu:~$ for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
ubuntu@ubuntu:~$ sudo chroot /mnt
root@ubuntu:/# sudo grub-install --recheck /dev/sdf
root@ubuntu:/# sudo update-grub # Same as doing 'grub-mkconfig -o /boot/grub/grub.cfg'
root@ubuntu:/# sudo update-initramfs -u # Regenerate the initramfs image in order to update the mdadm table in it.
root@ubuntu:/# blkid


Then I exited from the chroot and rebooted:
Code:
root@ubuntu:/# ^D
ubuntu@ubuntu:~$ sudo reboot


Then I reinstalled GRUB and regenerated the initramfs image yet again (probably unnecessary as I already did both of these when chrooted):
Code:
fitzcarraldo@server:~$ sudo blkid # Find out which partition has /boot
fitzcarraldo@server:~$ sudo mount /dev/sdf1 /boot
fitzcarraldo@server:~$ sudo grub-install --recheck /dev/sdf
fitzcarraldo@server:~$ sudo update-grub # Same as doing 'grub-mkconfig -o /boot/grub/grub.cfg'
fitzcarraldo@server:~$ sudo update-initramfs -u
fitzcarraldo@server:~$ sudo umount /boot


/etc/fstab needs to use the md UUID returned by blkid, not the UUID returned by the 'mdadm -Es' command and used in mdadm.conf. The reason the UUIDs reported by blkid and mdadm are different is explained on the following Web page: Difference between UUID from blkid and mdadm?
_________________
Clevo W230SS: amd64, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC udev elogind & KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
Vieri
l33t
l33t


Joined: 18 Dec 2005
Posts: 872

PostPosted: Wed Feb 08, 2017 11:16 pm    Post subject: Reply with quote

Regarding the removal of RAID sets, I just spotted an interesting or awkward behavior.

If I run the following commands I won't always successfully remove the set. The commands' exit codes are 0, but the device is still there.

Code:
umount -l /dev/md125
mdadm --verbose --stop /dev/md125
mdadm --verbose --remove /dev/md125


However, I noticed that if I repeatedly run mdadm --stop on that device then it will eventually disappear.

Code:
# mdi=/dev/md124
counter=0
while [ -e $mdi ]; do
   echo -ne "Working on $mdi... ${counter} seconds elapsed.\r"
       mdadm --stop $mdi >/dev/null 2>&1 3>&1
   sleep 2
   counter=$(( counter + 2 ))
done


Odd.

In any case, I did that and now the newly created RAID sets are sync'ing according to /proc/mdstat.

I'm in the process of installing now and will see if the system can finally boot with UEFI.
Back to top
View user's profile Send private message
Vieri
l33t
l33t


Joined: 18 Dec 2005
Posts: 872

PostPosted: Thu Feb 09, 2017 10:35 am    Post subject: Reply with quote

I can't boot with UEFI because I can't install grub2.

Within jail root I have:

Code:
# ls /boot/grub/
fonts  grub.cfg  grubenv  locale  themes  x86_64-efi

# ls /boot/efi/EFI/gentoo/
grubx64.efi

# mount
/dev/md4 on / type ext4 (rw,relatime,data=ordered)
/dev/md2 on /boot type ext2 (rw,relatime,errors=continue,user_xattr,acl)
/dev/md1 on /boot/efi type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
[...]

# fdisk -l /dev/sda
Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: B67E7422-24B8-4DF2-9EF7-42C1071B9343

Device        Start       End   Sectors   Size Type
/dev/sda1      2048   1050623   1048576   512M EFI System
/dev/sda2   1050624   2099199   1048576   512M Linux RAID
/dev/sda3   2099200  76222463  74123264  35.4G Linux RAID
/dev/sda4  76222464 468655279 392432816 187.1G Linux RAID

# fdisk -l /dev/sdb
Disk /dev/sdb: 223.6 GiB, 240057409536 bytes, 468862128 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: C2BBA579-AAB6-4293-8109-34F5661B6197

Device        Start       End   Sectors   Size Type
/dev/sdb1      2048   1050623   1048576   512M EFI System
/dev/sdb2   1050624   2099199   1048576   512M Linux RAID
/dev/sdb3   2099200  76222463  74123264  35.4G Linux RAID
/dev/sdb4  76222464 468655279 392432816 187.1G Linux RAID


When I try to install grub with the command 'grub-install --target=x86_64-efi --efi-directory=/boot/efi /dev/sda', I get:

Code:
Installing for x86_64-efi platform.
EFI variables are not supported on this system.
efibootmgr: option requires an argument -- 'd'
efibootmgr version 14
usage: efibootmgr [options]
        -a | --active         sets bootnum active
        -A | --inactive       sets bootnum inactive
        -b | --bootnum XXXX   modify BootXXXX (hex)
        -B | --delete-bootnum delete bootnum
        -c | --create         create new variable bootnum and add to bootorder
        -C | --create-only      create new variable bootnum and do not add to bootorder
        -D | --remove-dups      remove duplicate values from BootOrder
        -d | --disk disk       (defaults to /dev/sda) containing loader
        -r | --driver         Operate on Driver variables, not Boot Variables.
        -e | --edd [1|3|-1]   force EDD 1.0 or 3.0 creation variables, or guess
        -E | --device num      EDD 1.0 device number (defaults to 0x80)
        -g | --gpt            force disk with invalid PMBR to be treated as GPT
        -i | --iface name     create a netboot entry for the named interface
        -l | --loader name     (defaults to \EFI\redhat\grub.efi)
        -L | --label label     Boot manager display label (defaults to "Linux")
        -m | --mirror-below-4G t|f mirror memory below 4GB
        -M | --mirror-above-4G X percentage memory to mirror above 4GB
        -n | --bootnext XXXX   set BootNext to XXXX (hex)
        -N | --delete-bootnext delete BootNext
        -o | --bootorder XXXX,YYYY,ZZZZ,...     explicitly set BootOrder (hex)
        -O | --delete-bootorder delete BootOrder
        -p | --part part        (defaults to 1) containing loader
        -q | --quiet            be quiet
        -t | --timeout seconds  set boot manager timeout waiting for user input.
        -T | --delete-timeout   delete Timeout.
        -u | --unicode | --UCS-2  pass extra args as UCS-2 (default is ASCII)
        -v | --verbose          print additional information
        -V | --version          return version and exit
        -w | --write-signature  write unique sig to MBR if needed
        -y | --sysprep          Operate on SysPrep variables, not Boot Variables.
        -@ | --append-binary-args file  append extra args from file (use "-" for stdin)
        -h | --help             show help/usage
Installation finished. No error reported.


Code:
sys-boot/grub-2.02_beta3-r1::gentoo was built with the following:
USE="fonts nls themes -debug -device-mapper -doc -efiemu (-libzfs) -mount -multislot -sdl -static -test -truetype" ABI_X86="64" GRUB_PLATFORMS="efi-64 pc -coreboot -efi-32 -emu -ieee1275 -loongson -multiboot -qemu -qemu-mips -uboot -xen -xen-32"
CFLAGS=""
LDFLAGS=""


Any ideas?

[EDIT] I also tried the following before chroot'ing but no luck.
Code:
livecd ~ # modprobe efivars
modprobe: ERROR: could not insert 'efivars': No such device
livecd ~ # modprobe efivarfs
modprobe: ERROR: could not insert 'efivarfs': No such device

Does this mean that the kernel in the current Gentoo minimal install ISO does not support EFI variables, thus making it impossible to run grub-install with efi variables?
Back to top
View user's profile Send private message
Fitzcarraldo
Advocate
Advocate


Joined: 30 Aug 2008
Posts: 2034
Location: United Kingdom

PostPosted: Thu Feb 09, 2017 3:27 pm    Post subject: Reply with quote

I don't know, as I normally use SystemRescueCd to install Gentoo, not the Minimal Installation CD. What EFI-related parameters are enabled in the kernel config of the Minimal Installation CD? For SystemRescueCd I can see:

Code:
root@sysresccd /root % zcat /proc/config.gz > config
root@sysresccd /root % grep EFI config | grep -v ^#
CONFIG_EFI_PARTITION=y
CONFIG_EFI=y
CONFIG_EFI_STUB=y
CONFIG_EFI_MIXED=y
CONFIG_EFI_SECURE_BOOT_SIG_ENFORCE=y
CONFIG_FB_EFI=y
CONFIG_XEN_EFI=y
CONFIG_DMI_SCAN_MACHINE_NON_EFI_FALLBACK=y
CONFIG_EFI_VARS=y
CONFIG_EFI_ESRT=y
CONFIG_EFI_VARS_PSTORE=y
CONFIG_EFI_VARS_PSTORE_DEFAULT_DISABLE=y
CONFIG_EFI_RUNTIME_MAP=y
CONFIG_EFI_RUNTIME_WRAPPERS=y
CONFIG_UEFI_CPER=y
CONFIG_CACHEFILES=m
CONFIG_EFIVAR_FS=y
CONFIG_EARLY_PRINTK_EFI=y
CONFIG_EFI_SIGNATURE_LIST_PARSER=y


On another note, do you have GRUB_PLATFORMS="efi-64" rather than GRUB_PLATFORMS="Efi-64" in /etc/portage/make.conf? There is a bug in the Gentoo Installation Guide (https://bugs.gentoo.org/show_bug.cgi?id=608544).
_________________
Clevo W230SS: amd64, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC udev elogind & KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
Vieri
l33t
l33t


Joined: 18 Dec 2005
Posts: 872

PostPosted: Thu Feb 09, 2017 4:10 pm    Post subject: Reply with quote

My GRUB_PLATFORM is OK I guess because I set it to
Code:
GRUB_PLATFORMS="efi-64 pc"

in make.conf.

The more I look at the UEFI instructions in the Handbook the more I'm disappointed,.
It doesn't say anywhere you can't install grub/UEFI with grub-install if you use the minimal install CD/ISO.

It's stunning to see however that there's a wiki page saying that if you want to use UEFI, either boot the liveDVD or SysRescCD:

https://wiki.gentoo.org/wiki/UEFI_Gentoo_Quick_Install_Guide

Still, if I inspect the minimal install ISO, I do see an efi image but of course, that doesn't mean all efi-related features are in the live kernel.

I'm wondering why the minimal image is lacking features of this sort.
I'll look at /proc/config.gz asap but it's funny that you and basically all the Funtoo users boot off SysRescCD...
I guess I'll have to do the same.

I must say though that I'm totally new to UEFI and I'm wondering if I'm not missing some basic concepts such as:

1) do I "require" to boot the live medium with UEFI in order to install grub+UEFI on a target HDD?

2) how do I make sure my machine can boot UEFI devices? I'm asking because I've read somewhere that if the boot menu that comes up when launching SysRescCD from, say, a live USB stick, has a black and white background, it means that it's been initialized through UEFI. If it's blue, it hasn't. I don't know if that's true but I'm always getting the blue background no matter how I fiddle with the BIOS settings. In fact, I noticed that if I set "UEFI only" boot options in the BIOS instead of "UEFI & Legacy" then the system does not detect any UEFI devices at all and doesn't boot. So before I mess with a Gentoo + UEFI installation I'd like to make sure my system can boot through UEFI. How can I easily test that?
Back to top
View user's profile Send private message
khayyam
Watchman
Watchman


Joined: 07 Jun 2012
Posts: 6227
Location: Room 101

PostPosted: Thu Feb 09, 2017 4:52 pm    Post subject: Reply with quote

Vieri wrote:
1) do I "require" to boot the live medium with UEFI in order to install grub+UEFI on a target HDD?

Vieri ... yes, to "install grub2" as it will attempt to write to efivars, however, you can set up the 'default' fallback, {ESP}/efi/boot/bootx64.efi, and this should be selected (so, without having to run 'efibootmgr' and write NVRAM/efivars).

Vieri wrote:
2) how do I make sure my machine can boot UEFI devices? I'm asking because I've read somewhere that if the boot menu that comes up when launching SysRescCD from, say, a live USB stick, has a black and white background, it means that it's been initialized through UEFI. If it's blue, it hasn't. I don't know if that's true but I'm always getting the blue background no matter how I fiddle with the BIOS settings. In fact, I noticed that if I set "UEFI only" boot options in the BIOS instead of "UEFI & Legacy" then the system does not detect any UEFI devices at all and doesn't boot. So before I mess with a Gentoo + UEFI installation I'd like to make sure my system can boot through UEFI. How can I easily test that?

I'm not sure about your firmware but I think the background colour is a feature of the bootloader, at least such an indicator of MBR/UEFI is not a feature I've seen before. If your firmware is not booting efi capable boot disks then your only option is to use the 'fallback' when installing, and then do grub install on first boot. I've not heard of this happening before but firmware is provider specific, and so we can't have any expectations in that regard.

If you want to know if you're booted EFI then you can check for the presence of '/sys/firmware/efi/efivars'.

HTH & best ... khay
Back to top
View user's profile Send private message
Fitzcarraldo
Advocate
Advocate


Joined: 30 Aug 2008
Posts: 2034
Location: United Kingdom

PostPosted: Thu Feb 09, 2017 5:03 pm    Post subject: Reply with quote

1. Yes.

2. A UEFI-firmware machine booting a GPT-formatted HDD with ESP would have the directory /sys/firmware/efi. A BIOS-firmware machine booting either a GPT-formatted HDD or a MBR-formatted HDD would not have that directory.

When I boot SystemRescueCd on a machine with BIOS firmware, I see the SystemRescueCd boot menu on a light-blue background:

http://www.system-rescue-cd.org/images/sysresccd-003-640x480.png

When I boot SystemRescueCd on a machine with UEFI firmware, I see the standard GNU GRUB version 2.02~beta3 TUI menu (white box and text on black background).
_________________
Clevo W230SS: amd64, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC udev elogind & KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
Vieri
l33t
l33t


Joined: 18 Dec 2005
Posts: 872

PostPosted: Thu Feb 09, 2017 10:00 pm    Post subject: Reply with quote

I'm making progress. Thanks to all.

I grabbed hold of another machine with a UEFI BIOS and successfully booted off a live USB with SystemRescueCD. I saw the black&white grub menu and then confirmed the presence of /sys/firmware/efi.
I tried to do the same with a Gentoo minimal live USB but it wouldn't boot with UEFI. I'm certainly not going to use a 2GB liveDVD to install a system with UEFI so I'm forced to use SystemRescueCD. I don't like the idea because I always try to stick to what the official Gentoo Handbook has to say... However, I must admit the Handbook has a few errors and is very confusing regarding UEFI. It also does NOT mention that you can't use the minimal installation CD (which I believe is what most people use).

My next step is to see why I can't boot SysRescCD on the other UEFI system I'm installing to (OP).

By the way, if I wanted to install a system on a GPT-formatted HDD that I could boot to either with UEFI or Legacy BIOS, would the same partitioning scheme suffice or would I need to have a "BIOS boot" partition alongside the UEFI and grub boot partitions?
ie. would I need the following?

Code:
1MiB space
2MiB BIOS boot partition
512MiB UEFI partition
512MiB Grub boot partition
SWAP partition
ROOT partition
1MiB space
Back to top
View user's profile Send private message
Fitzcarraldo
Advocate
Advocate


Joined: 30 Aug 2008
Posts: 2034
Location: United Kingdom

PostPosted: Thu Feb 09, 2017 10:47 pm    Post subject: Reply with quote

SystemRescueCd is actually a Gentoo LiveCD with tools included for repairing and creating installations, and its developers release updates to it regularly, so you shouldn't dislike the idea of using it at all! It also has useful GUI utilities. To be honest, although I have used parted, fdisk and gdisk on the command line quite a few times, I like an easy life and I usually use GParted on SystemRescueCd to partition and format my HDDs for various Linux distributions (including Gentoo). It also has a Web browser, wireless drivers etc. and makes installation of Gentoo a less painful process.

Yes, you can add another partition on the HDD to be the BIOS Boot Partition (Code EF02) with flag bios_grub set. You don't even need to format it; just create an additional 1 MiB partition and set the bios_grub flag. The purpose of the BIOS Boot Partition is to hold GRUB's core.img (grub-install will write it there). At boot the BIOS will first access the MBR in Sector 0, which will then vector to core.img, which will then vector to the directory /boot/grub/ on another partition (either the /boot partition if you created one with mountpoint /boot, or the / (root) partition if you did not). Example 2 in the following diagram is a good illustration of this process:

https://upload.wikimedia.org/wikipedia/commons/4/45/GNU_GRUB_components.svg
_________________
Clevo W230SS: amd64, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC udev elogind & KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
Vieri
l33t
l33t


Joined: 18 Dec 2005
Posts: 872

PostPosted: Fri Feb 10, 2017 1:09 pm    Post subject: Reply with quote

I can confirm that the Gentoo minimal installation image does not support EFI. /sys/firmare/efi is not found and I'm sure now that I'm booting my liveUSB device correctly.
SystemRescueCD on the other hand DOES boot with UEFI. I still don't like the idea of diverging from the Handbook but, oh well...

Now I'd like to create a PXE SysRescCD image to boot in my LAN. I can boot Legacy BIOS just fine via PXE but I'm having trouble with UEFI.

Anyway, that's a whole different ball game so I'm marking this topic as solved.

Thanks again!
Back to top
View user's profile Send private message
noci2
n00b
n00b


Joined: 14 Jan 2018
Posts: 10

PostPosted: Sat Jan 27, 2018 1:59 pm    Post subject: Reply with quote

In essence it can be done, run grub-install as before, there will be the error message from


(the EFI partitions have tag EF02, are in mdadm array /dev/md1, and have sda1, sdb1 as home disk)
grub-install COULD have done this...., by examining the given md-array (read from mount-table of /boot)....
determine the members & partitions and then run:
i use:
Disk: sda1, EFI Boot partition type, 300M; sda2, Linux Raid type, remainder of disk
sdb1, EFI Boot partition type, 300M; sdb2, Linux Raid type, remainder of disk

MD array /dev/md1 = (sda1, sdb1) /dev/md2 (sda2, sdb2)

LVM (/dev/md2): /boot 100M, / 50G etc.

mounted:
/ /dev/vg1/root ext4
/boot /dev/vg1/boot ext2
/boot/ESP /dev/md1 vfat

grub-install --target=x86_64-efi --efi-directory=/boot/ESP
copied the /boot/ESP/EFI/Gentoo/grubx64.efi -> /boot/ESP/EFI/Gentoo/grub.efi
efibootmgr -c -d /dev/sda -L "Gentoo sda" #added as 0000
efibootmgr -c -d /dev/sdb -L "Gentoo sdb" #added as 0001
efibootmgr -o 0001,0000,0003 #0003 = EFI Shell

in ESP disk it also needs \boot\grub or \boot\grub2 (depending on grub version and of grub1 & 2 are both installed) directory with the following content:
(ie. /boot/ESP/boot/grub(2)?...)
---8<---
set prefix=(lvm/vg1-boot)/grub
set root=(lvm/vg1-boot)
source ${prefix}/grub.cfg
---8<---
and the grubenv file from /boot/grub


The efibootmgr commands setup the EFI boot menu & order after grub-install fails.
Effectively this ONLY uses the EFI partition for storing the grub loader..., and as long as no one does anything with those partitions
(f.e. store data on them WITHOUT running the set mounted as mdadm array) this is stable.
In my case the only updates needed are grubx64.efi, in case an update of grub is needed and even then from linux

In case of repairs ANY partition being accessed wether EFI or other data "may become damaged"...... when handled without care outside of their intended use envelope.

PS.
The LIVE DVD can boot using EFI.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum