I came here to say to say your comment helped me and it worked like a charm. Thanks
Yeah, it works, but it seems that subsequent HAOS updates are not working. So I reverted back to VM. Maybe that would (or already is) fixed, but not sure.
Oh wow, might have to require running the command all over again? What is the downside of running HA in VM? I have a fairly capable VM server
No downsides unless you want to use some hardware plugged into the box itself (e.g. zigbee usb stick).
But I have stick plugged into some router and just pass it over network using serial2lan to Zigbee2MQTT in the HA.
Or you can pass the stick directly into VM
The reason HA does not boot to the latest version after an update is because the OS writes to the /efi/boot/grubenv
file to update the environment, but the default location for load_env and save_env (used in the grub.cfg file) is /boot/grub/grubenv
. Setting default
to 1 in grub.cfg will work, however, it bypasses HA’s failover method. (HA always has two versions installed at a time, one in SLOT A and one in SLOT B. If one version fails to boot after 3 tries, it will attempt to boot the other version). To fix this while retaining the failover functionality, you can simply tell grub to use the same file by editing the /efi/boot/grub.cfg
file, changing the line that says
load_env
to
load_env --file (hd0,gpt1)/efi/boot/grubenv
and the line that says
save_env A_TRY A_OK B_TRY B_OK ORDER MACHINE_ID
to
save_env --file (hd0,gpt1)/efi/boot/grubenv A_TRY A_OK B_TRY B_OK ORDER MACHINE_ID
I followed the same steps that @carloshurtadom posted here and then changed those two lines in /efi/boot/grub.cfg
.
@trevormcclellan If your suggested solution removes the need to manually change the boot slot after each HAOS version update then that’s perfect and I will give it a try.
I’m hoping it will remove the need to manually change the boot slot after an update. That is still to be determined. I only started digging into the source code when 10.4 came out since I ran into the same issue, so I haven’t been able to test yet with a new update. I can confirm, however, that the failover functionality appears to be working. My OK counters increase immediately and if I shut the laptop off before it fully boots 3 times, it boots into the previous version. Previously, the OK counters were always 0 as you said. This is on an old BIOS-based Dell Latitude E6500.
@trevormcclellan You’re right and my interpretation about needing the UEFI was not correct. I tested your solution and the counters started working. Thanks!
As you said, it remains to be seen if this removes the need to manually change the boot slot but I’m quite sure it will.
I just updated to 10.5 and can now confirm that the boot slot does not need to be manually changed.
Thank you for the solution, Can you please explain how should I edit the .cfg file?
Should I use Debian Live?
Please be patient, I’m not an expert for sure!
Yeah, Debian Live should work, or any Live OS. I just used Ubuntu because I already had it on a flash drive. I’ll combine the instructions from others above that I used.
Edit the grub.cfg file
vi mnt/efi/boot/grub.cfg
(open in editor of your choice)- change
load env
toload_env --file (hd0,gpt1)/efi/boot/grubenv
- change
save_env A_TRY A_OK B_TRY B_OK ORDER MACHINE_ID
tosave_env --file (hd0,gpt1)/efi/boot/grubenv A_TRY A_OK B_TRY B_OK ORDER MACHINE_ID
- save and quit
This worked perfectly for me! Thanks so much for the detailed steps!
This. Worked. Perfectly.
However, I did go back and implement @blind-oracle 's implementation … but it worked like a charm. Thanks!
Hi, im a little new to linux, may i know what disk partitions did you create.
Thx
Why is it so hard to install HAOS? I mean… I can install ubuntu desktop with no issues and its all working, but installing a lightweight HAOS doesnt work? Someone have been sleeping in class when making this user frendly…
It’s not. It is actually pretty trivial assuming one uses a supported hardware platform.
Sure, that makes sense. Ubuntu is developed to run on a wide range of Desktop and Servers, as that is its target platform.
HAOS works great on the hardware it is designed for and tested on. It clearly states that a UEFI BIOS is required to install on x86 platforms. This thread is about users who are trying to install it on systems that do not support UEFI. Thus, the added complexity in trying to make it work.
I know this post is a little old. I’m new to HA and just now trying to get started. Using a PC without UEFI I was able to follow these instructions almost exactly except I used Ubuntu to get to a terminal window. I even opened a Mozilla window so I could copy and paste the code after I kept making typos. I can get HA running and it sees some devices already on my network. I will keep going to learn more.
My question now is this: With this method, I am unable to update HA to a newer version through the web interface. It says it is updating, but restarts with the same version. I tried loading 10.1 instead and tried to update to 10.5 with no luck. Will I just need to manually update by re-installing HA using this same method and restoring a backup database? Or am I missing something?
Thanks. Dale
Everything worked great until 11.2 update, don’t know what happend. I start the update, after rebooting the update notification is still on and no update has been installed. Any ideas?
@drhalleron and @fortunenick :
I had the same issue and had to quickly move the cursor at boot to use slot B in the grub menu to actually boot into the new version.
I found the changes to /mnt/EFI/BOOT/grub.cfg
were gone and I had to add “--file (hd0,gpt1)/efi/boot/grubenv
” again to load_env
and save_env
.
Maybe the file was overwritten by one of the updates.
Has someone found a more permanent solution?
So I just completed this task and thought I would share my experience in 2023 as the posts I got all seem outdated, mostly focussed on ver 9.3, the current version of HASSOS is 11.2.
Why I did this?
- I have an old laptop, Acer ONE Intel Atom N450, it was probably built somewhere in 2010 way before UEFI was mainstream. Unfortunately it is a core part of the HASSOS installation.
- I only have a 250GB drive, and the image file requires a 1TB drive (Disk application complains)
- I have been running a “supervised” installation for the last 3 years and have fallen behind on the maintenance (monthly updates of OS, and supervisor and core and add-ins) to the point that everything was becoming a mess. I highly recommend you DO NOT follow this path…
Assumptions:
You have already installed a version of linux on the machine which is bootable - you can find this process all over. (There are other shortcuts here like only installing a boot partition and GRUB, you only need GRUB to boot the machine, you dont really need a full linux install)
Step 1:
Boot into a linux distro with flash drive. Any distro, they are very much the same (for this task - please dont hate me). I used Linux Mint 20 XFCE, the GUI runs better on older hardware. On the official X86 installation they explain how to use Ubuntu.
Note: May have to change your BIOS setup to allow flash drive to boot before hard drive.
Step 2:
Download the latest version of the disk image. It is available as point 5 under METHOD 1 on official website: X86 installation.
Step 4:
Unzip (xz) the image with: xz -d -c img_file_name.img.xz
You will be left with a disk image file. Note: the zipped file is around 400MB but after unzipping, it is about 7GB.
Note: Flashdrives are notoriously slow, you could mount your hard drive and extract there. Google it, in short create a directory under your /mnt folder, call it whatever you want. I used my drive partition, so mkdir /mnt/sda7 then mount /dev/sda7 /mnt/sda7.
Step 5:
Mount the img file: losetup --find --partscan img_file_name.img
This will now (hopefully) mount 8 partitions. First is the “boot” partition, the next 4 are kernel and OS “pairs” (an A & B version for fallback). The next is a “Bootstate” and then an “overlay” for configs and a “data” for add-ons and other storage. Partitions are detailed here. PS: Mine only mounted 4 partitions: kernel, OS, overlay and data.
Note: In the link above they state that the alternate 2 “boot” partitions are empty on a first install. I manually mounted partition 1 to get access to the EFI boot partition.
Step 6:
You now have to create partitions on your local drive to mirror the above. Running: “df -h” is helpful to see the required sizes of the partitions. I used the “Disk” tool in Mint (also available in most distros) which is a nice GUI interface to disk partitioning. I then resized my existing Linux partitions to open up space for the new partitions I need. I created a 25MB partition for my kernel(FAT), and a 250MB partition for my OS(FAT), a 500MB partition for overlay (NB to label this correctly as HASSOS-OVERLAY), and a 15GB partition for my data (NB to label this correctly as HASSOS-DATA).
Note: You will notice I did not create the “A & B” setup, perhaps I will in future need to come update this post…this is what I needed to get up and running. Technically, you should be creating the additional 2 partitions which will probably be an issue when I upgrade.
Step 7:
Copying data to your partitions: I tried using dd command to write the partitions using the mounted volumes as input but that did not work well, and I had 2 corrupted drives (squashFS issues). I therefore just recursively copied (with permissions) the data from the mounted partitions (above) to the new partitions. using: cp -pdRx /media/mint/DISK/* /media/mint/KERNEL/. - just an example, my kernel drive (with the bzImage file was mounted as DISK, the OS was mounted as DISK1, overlay and data as per above by label mounted as HASOS-OVERLAY and HASSOS-DATA).
If you have gotten this far, you are well on your way
Step 8:
Configuring the boot file: Technically, you just need to hand the BIOS the kernel image, and the rest should just run. I opened the grub.cfg file from the HASSOS image mounted BOOT partition located in EFI/boot/grub/grub.cfg and copied everything after the first 2 lines (which were setting default and timeout) into my existing grub.cfg file located in /boot/grub/grub.cfg at the end of the file.
Step 9:
Making it boot: This was the most complex bit that took me time to figure out. The way drives are labelled and named depends on the architecture and bootloader version being used. The boot config in step 8 is pretty straight forward. There is an “A” and a “B” option, and then 2 “recovery” versions of same. The trick was in selecting the right drive and partition for the kernel (bzImage) and then identifying the root partition correctly so the kernel can handover to the OS. What worked in the end was to reboot, then hit “c” for command line when the GRUB menu came up. There I could run “ls” to see how my drives are being labelled. I had to change (HD0, GPT1) to (AHCI0,msdos7). The “root=” is defined by UUID (unique hardware reference to the partition) but this gave me a “Waiting on root” message and hanged for hours even after updating the UUID to the one matching the new partition. I replaced it with “root=/dev/hda7” (7th partition on the first hard drive), which worked!
Step 10 (extra):
If you had started like me with a previous basically unusable install, and had made backups using Google drive, you will find your backups on your Google drive. They are basically zipped files of the configs of apps and even the full homeassistant config. You can restore these files if you feel comfortable…I unzipped them and took out the files I needed to config my new installation as clean as possible.