You are not logged in.

#1 2017-11-13 17:11:13

UGF3ZcWC
Member
Registered: 2017-11-13
Posts: 3

Installing rEFInd again after reinstalling Windows in dual-boot

Hi,

Here is my disk setup:

sda                                                                      
├─sda1                                                                   
├─sda2  ntfs          /mnt/WINDOWS
├─sda3  vfat          /boot/efi
└─sda4  ntfs          /mnt/DATA

sdb                                                                      
├─sdb1  swap          [SWAP]
├─sdb2  vfat          /boot
├─sdb3  ext4          /
├─sdb4  ext4          /home
└─sdb5  crypto_LUKS

I want to wipe out all the data on sda and do a clean Windows 10 install. As far as I know, it would render my Arch system on sdb unbootable. The most obvious thing to do in that case would be, I assume, running Arch from USB stick, chrooting into my system and installing rEFInd again:

mount /dev/sdb3 /mnt
mount /dev/sdb2 /mnt/boot
mount /dev/sda3 /mnt/boot/efi
arch-chroot /mnt
refind-install

But then, the Wiki says:

When refind-install is run in chroot (e.g. in live system when installing Arch Linux) /boot/refind-linux.conf is populated with kernel options from the live system not the one on which it is installed. You need to adjust kernel options in /boot/refind-linux.conf manually.

It doesn't elaborate any more on that, and I'm not quite sure what it means exactly. Would my system not boot until I change entries in this file manually? Currently it only contains the following lines:

"Boot with standard options"  "root=UUID=9d0eb3fb-1ef6-457f-85a7-df56f103d4c2 rw quiet resume=UUID=7326bcf8-67bd-4ff2-9eb3-b2a716d5acf4"
"Boot to single-user mode"    "root=UUID=9d0eb3fb-1ef6-457f-85a7-df56f103d4c2 rw quiet resume=UUID=7326bcf8-67bd-4ff2-9eb3-b2a716d5acf4 single"
"Boot with minimal options"   "ro root=UUID=9d0eb3fb-1ef6-457f-85a7-df56f103d4c2"

I only started using rEFInd recently, and I'm not yet familiar with it. I installed it on top of GRUB, and choosing Arch from rEFInd boot menu sends me first to the standard GRUB menu. But GRUB would also be missing after formatting the ESP, so I'm not sure if the previous config would still be adequate.

I'll be grateful for explanation on how to solve this matter properly.

Last edited by UGF3ZcWC (2017-11-13 17:18:40)

Offline

#2 2017-11-13 21:16:37

Blasphemist
Member
From: Colorado
Registered: 2013-01-17
Posts: 150

Re: Installing rEFInd again after reinstalling Windows in dual-boot

Some confusion here so lets clear that up first. Your commands above for mounting partitions are wrong so be sure not to do that. You also mention a poor process of going through refind to grub. That means you skip using the built-in UEFI boot manager, use the refind boot manager to bring up the grub boot loader to launch the arch linux kernel. You don't have to do all that on a UEFI system.

I don't know of any UEFI implementations that don't include a built-in boot manager. You press an F key at boot, it brings up a list of devices with valid boot options, select a device, then select the desired OS on that device to boot. I don't see the point in using some other boot manager like refind when you have that already. Do ask if it is confusing to you what the differences are between boot managers and boot loaders but I won't assume you don't know the differences..

I think it might help to discuss the most simple and efficient boot configuration for arch and windows on a UEFI system. UEFI has variables it stores in NVRAM that it reads at boot to know what EFI file to launch when the hardware initialization is finished. The windows installation will put a windows boot loader efi file on the ESP and entries in the UEFI variables that point to it. UEFI will read those variables and launch that loader if windows is the only or first boot entry or if you choose it from the built in boot manager.

The simplest and fastest boot option for Arch is to use /boot as the mount point for the ESP and take advantage of the default EFISTUB capability enabled in the Arch kernel. You won't have to install any boot manager or boot loader. That is in the wiki and the efibootmgr utility is used to put the boot entry in the UEFI boot entries. You can look up the efibootmgr command I've used here in the past or I can post it later but I have to run right now.


Simple and Open

Offline

#3 2017-11-13 23:08:50

UGF3ZcWC
Member
Registered: 2017-11-13
Posts: 3

Re: Installing rEFInd again after reinstalling Windows in dual-boot

Thank you for your feedback. I'll also begin with some clarification. My question was related specifically to rEFInd, which I chose mainly due to aesthetic reasons. I sometimes let other people use my PC, hence the Windows partition on it, and that's also the reason I want to keep this particular boot manager. It may sound funny, but the black, undecorated screen of GRUB seems to scare them a little. rEFInd looks more modern and thus, more user-friendly.

I wasn't aware of the difference between boot manager and boot loader. I've only been using Linux systems for the last two years and I always installed GRUB, which, if I understand correctly, combines both boot loader and boot manager, since it's possible to add entries for different OSes' boot loaders in it. I was aware of UEFI boot manager existence, but I always assumed it was a different kind of beast altogether, operating on a lower level.

So now that I know that rEFInd is a boot manager, not a boot loader (despite that the Arch Wiki lists it as such), I suppose I could just install GRUB through chroot and then add rEFInd on top of it later? I don't feel like booting my system with EFISTUB yet, since I've only just learned about its existence and I need to read more about it.

Besides, what exactly is wrong with my mount commands? I read that I need to mount the ESP for refind-install to work.

EDIT:
Okay, so I read about EFISTUB and an idea popped up in my mind. Would it work if I did the following steps:
1. copied all the files from sda3 (/boot/efi),
2. unmounted sda3 and removed its fstab entry,
3. moved all the files copied from sda3 to efi directory in sdb2 (/boot),
4. removed GRUB,
5. added EFISTUB entry with

efibootmgr --disk /dev/sdb --part 2 --create --gpt --label "Arch Linux" --loader /vmlinuz-linux --unicode "root=/dev/sdb3 rw initrd=/initramfs-linux.img"

6. formatted sda drive and installed Windows on it, with its boot loader on a different ESP partition (sda3),
7. booted Arch directly from built-in UEFI boot manager;
8. installed rEFInd and set it as default boot loader (manager)?

This way, if I got it right, I should have Windows boot loader on ESP on the first HDD (on sda3), Arch EFISTUB on the second (sdb2), and rEFInd with menu entries pointing to both of them, also on sdb2. That is, if it would work at all, because I'm not sure that my way of thinking here is correct.

Last edited by UGF3ZcWC (2017-11-14 00:12:18)

Offline

#4 2017-11-14 18:37:13

Blasphemist
Member
From: Colorado
Registered: 2013-01-17
Posts: 150

Re: Installing rEFInd again after reinstalling Windows in dual-boot

I just looked a bit at the definitions of boot loaders and boot managers and decided I shouldn't really make much distinction between them. Here is something from the creator of rEFInd. He does make a distinction but isn't really sure of it anymore.
http://www.rodsbooks.com/refind/
rEFInd does have a nice look and most other options can be made to look good as well, even grub. Most of the time there are a number of options that will work. There are some things to consider to determine which is better for your use case. I'll use your use case to start this explanation. You have a need to boot arch linux and windows. They happen to be good examples to describe what I call the difference between a loader and a manager.

Windows puts a boot loader on the ESP. It loads the windows kernel that resides on another partition. Arch puts kernel files on the ESP. No loader needs to launch them on another partition. This is the case when you use /boot as the mount point for the ESP. The Arch kernel is EFISTUB enabled and is installed to /boot. Since /boot is where the ESP is mounted, the kernel is on the ESP. UEFI can only launch files on the ESP so any EFISTUB enabled kernel or EFI boot manager/loader on the ESP can be launched.

UEFI knows what you want loaded from the ESP by what it sees in the UEFI variables, mainly bootnext, bootorder and boot entries. Let's say I have rEFInd, systemd boot, grub and maybe other boot options such as windows set up on the ESP and with corresponding boot entries in UEFI. I could set the bootnext variable to boot to any one of them on the next boot. Or I could change the boot order to boot any one of these by default. I can determine what I want at boot without installing, re-installing or re-configuring any software.

Most boot loader/managers do need to have the boot entries manually added. With grub the os-prober finds the existing valid boot options on the ESP when you run grub-mkconfig and I think it even finds kernels on other partitions. Both grub and rEFInd come equipped with their own drivers for accessing files on other partitions at boot but I think os-prober depends on what is available to the kernel you have loaded when you run it. rEFInd scans the system at the time of boot to determine what to show in its menu as available boot options.

When you install Arch you normally just need to mount the / (root) partition and the ESP. You mount / to /mnt and normally the ESP to /mnt/boot. This puts the ESP (the EFI system partition) in the file system as a sub-directory or root, /boot. You don't need to mount any other partition unless you have a separate home partition or specifically want logs or something on another partition. The directory /mnt/boot/efi does not need to be in any mount command. A use case where more than one instance of arch being installed on one system and therefor using the same ESP is when mounting the ESP to /boot/efi instead of /boot comes into play. This is done because both instances of Arch could have the same kernel file names and can lead to a conflict. Don't worry about all that for now, just don't be mounting anything at /boot/efi.

I have to run for a while but I'll come back to this in a bit. Let me know if this is helping, what makes sense now and what you still have questions about.


Simple and Open

Offline

#5 2017-11-14 19:43:44

Blasphemist
Member
From: Colorado
Registered: 2013-01-17
Posts: 150

Re: Installing rEFInd again after reinstalling Windows in dual-boot

I will add now that you don't need two ESP's. It looks like you are planning one on each drive. The one ESP should have the boot and ESP flags set and be formatted as VFAT. It can have boot loaders or managers that point to kernels on partitions on other drives.

I'd also not worry about copying files and folders around. Think of this, for the Arch kernel to load (using EFISTUB) nothing is actually needed but the kernel files and they are at /boot (the root of the ESP). Files needed by boot managers/loaders get put on the ESP during installation and configuration of that boot manager/loader. When you install a boot loader/manager you install the package, take steps to configure the boot loader/manager and create an entry in UEFI for that boot entry. I recommend doing this manually when possible but grub for example does the population of the ESP and configuration via script commonly.

Some boot loader/managers create weirdly named and nested directories on the ESP. Still you can browse those files and folders to look at and figure out some of how things are used. An ESP that is hosed up by some action can pretty easily be rebuilt and I'd caution you not to be copying files around on it because it can pretty easily make something already unnecessarily convoluted even more so.


Simple and Open

Offline

#6 2017-11-15 20:44:08

UGF3ZcWC
Member
Registered: 2017-11-13
Posts: 3

Re: Installing rEFInd again after reinstalling Windows in dual-boot

Thank you very much for your help! I did the above and it worked. Windows found the existing ESP during installation and added its boot loader to it - I didn't know before it could do that. I had to reinstall rEFInd though, because it didn't show up in UEFI boot manager after moving its files from one partition to another, but it works now.

There are two minor errors that didn't appear before, when I was booting Arch via GRUB. First is:

[Firmware Bug]: TSC_DEADLINE disabled due to Errata; please update microcode to version: 0x22 (or later)

I read about it in the Wiki, but I'm not sure what I need to do. I know how to add kernel parameters in GRUB, but it's not GRUB anymore, and I can't find how to append new options in the man entry for efibootmgr. Should I just delete current Arch UEFI entry and replace it with:

efibootmgr --disk /dev/sdb --part 2 --create --gpt --label "Arch Linux" --loader /vmlinuz-linux --unicode "root=/dev/sdb3 rw initrd=/intel-ucode.img initrd=/initramfs-linux.img"

The second error may not be related to the switching of boot loaders. Apparently, my root partition is not being properly unmounted during shutdown, so it needs to do fsck every time I boot into the system. I guess that's not normal, but I can't find any way to fix this on the internet.

Offline

#7 2017-11-16 18:45:10

Blasphemist
Member
From: Colorado
Registered: 2013-01-17
Posts: 150

Re: Installing rEFInd again after reinstalling Windows in dual-boot

Good progress! Add any kernel parameters that you need following what you already have for the --unicode option. I'll have to give the un-mounting issue some thought.


Simple and Open

Offline

#8 2017-11-17 01:34:52

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 5,993

Re: Installing rEFInd again after reinstalling Windows in dual-boot

Blasphemist wrote:

I don't know of any UEFI implementations that don't include a built-in boot manager.

Really? You've led a sheltered life.

Moreover, some UEFI implementations will not use the kernel's stub loader either directly or from refind, but will boot the kernel from GRUB. I am not now on such a system, but a couple of months ago, I was. That system always needed GRUB (or a similar EFI boot loader).

Breezy reassurances are all very well, but they do not reflect the extremely messy and buggy state of UEFI implementations. It is certainly worth pointing out possibly simpler configurations, but saying that there is no point in doing it any other way just because you've been fortunate in your experiences with UEFI is misleading in the extreme. I suppose you'll be suggesting next that 250M is sufficient for the EFI partition, because it works for you. Well, it works for most people, but it will nonetheless fail in cases where a larger ESP would work.

There are several advantages to having command line options in files as far as possible. For one thing, some UEFI routinely forget added entries. For another, some operations always wipe them (e.g. UEFI update). Obviously, this is a problem regardless, but it requires less messing around to restore things if complex configuration options are in a .conf file and not only in EFI.

Last edited by cfr (2017-11-17 01:38:26)


How To Ask Questions The Smart Way | Help Vampires

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Corporation Wireless 8265 / 8275 | US keyboard with Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#9 2017-11-17 17:35:04

Blasphemist
Member
From: Colorado
Registered: 2013-01-17
Posts: 150

Re: Installing rEFInd again after reinstalling Windows in dual-boot

cfr wrote:
Blasphemist wrote:

I don't know of any UEFI implementations that don't include a built-in boot manager.

Really? You've led a sheltered life.

Moreover, some UEFI implementations will not use the kernel's stub loader either directly or from refind, but will boot the kernel from GRUB. I am not now on such a system, but a couple of months ago, I was. That system always needed GRUB (or a similar EFI boot loader).

Breezy reassurances are all very well, but they do not reflect the extremely messy and buggy state of UEFI implementations. It is certainly worth pointing out possibly simpler configurations, but saying that there is no point in doing it any other way just because you've been fortunate in your experiences with UEFI is misleading in the extreme. I suppose you'll be suggesting next that 250M is sufficient for the EFI partition, because it works for you. Well, it works for most people, but it will nonetheless fail in cases where a larger ESP would work.

There are several advantages to having command line options in files as far as possible. For one thing, some UEFI routinely forget added entries. For another, some operations always wipe them (e.g. UEFI update). Obviously, this is a problem regardless, but it requires less messing around to restore things if complex configuration options are in a .conf file and not only in EFI.

Sorry to have offended you so. Actually, not so much.

By all means do school me up though. I certainly could be making this simpler than it is though that would be odd wouldn't it. I mean for the most part we do the opposite of that don't we? What exactly were you working with that didn't do what even the most basic of UEFI implementations have in my experience. What UEFI product and version? Seems it would be helpful to give me something I can learn from instead of just complaining about my well intention-ed help.


Simple and Open

Offline

#10 2017-11-17 18:22:10

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 5,993

Re: Installing rEFInd again after reinstalling Windows in dual-boot

Blasphemist wrote:

Sorry to have offended you so. Actually, not so much.

I'm not offended and I don't want, expect or need you to be sorry.

By all means do school me up though. I certainly could be making this simpler than it is though that would be odd wouldn't it. I mean for the most part we do the opposite of that don't we?

Not really. If it has always worked for you as it should, of course it will seem (relatively) simple. If you've dealt with buggy EFI implementations, it obviously will seem rather less straightforward. See refind's developer's pages on UEFI for further examples. I've only dealt with my own buggy UEFIs. He's dealt with a far greater variety of bugs.

What exactly were you working with that didn't do what even the most basic of UEFI implementations have in my experience. What UEFI product and version? Seems it would be helpful to give me something I can learn from instead of just complaining about my well intention-ed help.

Phoenis SecureCore Tiano in various versions. (Every version which became available for the x121e over four or five years.) https://bbs.archlinux.org/viewtopic.php?id=131149 for the original issue (which is actually caused by a too-small ESP, sized according to the recommendations at the time). The non-booting stub loader and the inability to launch any kind of EFI shell apply to the same hardware. There is a thread somewhere in the kernel developers' mailing archives in which various fixes are tried. However, I never got a kernel to boot with the stub loader - either directly or with refind. A boot loader such as grub worked like a charm. (Provided the ESP was formatted fat 16 or sufficiently large to officially support a fat 32 file system. Hence the wiki's current size recommendations.)


How To Ask Questions The Smart Way | Help Vampires

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Corporation Wireless 8265 / 8275 | US keyboard with Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#11 2017-11-18 16:29:24

Blasphemist
Member
From: Colorado
Registered: 2013-01-17
Posts: 150

Re: Installing rEFInd again after reinstalling Windows in dual-boot

The example you've given is getting near 10 years old. There has been much that has been learned and improved on it that time. 6 years ago when your thread was started was still in the early and very confused days of us using UEFI.

A change such as the switch to UEFI doesn't come easy to a user community. Most of us had to just learn as we went and the products themselves started with as little change from BIOS as possible and weren't always well tested. Add in that most of us didn't know how to use it or understand it and there was bound to be pain.

I knew I had to get a handle on it because all new systems would use it so I make a point to figure it out. I certainly don't know it all but do know how to make things simple and work through what I do run into. When I try to help others I try to have a positive and respectful attitude even if I don't always get that done. I try to be clear and explain my recommendations in some detail. I have had good experiences with UEFI once I got my head around it and I like to show that to others so that they don't think they can't solve their problem or think UEFI will never make sense to them.

I don't really know what lead to your complaint about my help here. I did try to explain the how's and why's of what I said. I tried to keep it simple and straightforward as possible while being clear and understandable. I don't have all the answers and there are always exceptions but if we get out of own way it usually helps a lot. I've always found that doing tech support it helps to keep me and the user out of the way to a solution. Do it simple, understand what and why, add as you need after that.


Simple and Open

Offline

#12 2017-11-19 02:20:55

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 5,993

Re: Installing rEFInd again after reinstalling Windows in dual-boot

Blasphemist wrote:

I don't really know what lead to your complaint about my help here.

I'm not complaining about the help you offered. But you said you 'didn't see the point' of using a more complex solution, as though the developers and users of refind and grub just don't understand they aren't needed. But that is misleading as it suggests that if the simple solution doesn't work for somebody, they have misconfigured or misunderstood something. I'm just pointing out that that is not true of the developers and not necessarily true of the users.

My thread was from 6 years ago, but that was my primary laptop 2 months ago. New hardware may get improved EFI, but manufacturers rarely push those changes out to existing users. Certainly Lenovo didn't. Plenty of people have few problems with UEFI; plenty of people do. Sometimes, that's the fault of the UEFI and not the user. And sometimes refind or grub or some other 'unnecessarily' complicated tool works where the stub loader does not.

There are certainly more recent threads which involve buggy UEFI. (Not to mention secure boot.)

There are, of course, other reasons to use refind or grub, but not being able to use the stub loader was the one while stood out.

That is, fine to suggest that there is probably a simpler approach - my objection was to the claim that any other lacked a point.

This machine boots the stub from refind without issue. Great - I can ditch grub! But I'm extremely grateful to the developers of grub for enabling me to boot for 6 years and for continuing to support UEFI boot on the older hardware. (I could not boot in legacy mode with a GPT partitioned disk and, although I didn't care about UEFI, I did care about using GPT.)

[NOTE: This is really no longer on topic and I'm not going to post here again, Probably, this part of the thread should not be here at all. (Not the thread, but this part of it is more 'bikeshed' and I'm certainly largely responsible to that. Apologies especially to the OP.]

Last edited by cfr (2017-11-19 02:24:43)


How To Ask Questions The Smart Way | Help Vampires

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Corporation Wireless 8265 / 8275 | US keyboard with Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

Board footer

Powered by FluxBB