# I have a ECS that cannot be restarted to enter the system every time I upgrade



## Alucn (Mar 24, 2022)

Many upgrades failed, so I had to ：boot /boot/kernel.old/kernel
Stuck in the boot interface, I don't know why?
Upgrade version P4 > Upgrade version P8


----------



## covacat (Mar 24, 2022)

boot kernel.old and investingate the size and hash of /boot/kernel/kernel


----------



## Alucn (Mar 25, 2022)

covacat said:


> boot kernel.old and investingate the size and hash of /boot/kernel/kernel



Upgrade failed MD5 that cannot be started
root@freebsd:~ # md5 /boot/kernel/kernel
MD5 (/boot/kernel/kernel) = 18f43409f035127acd05985fda18d46c
Another successfully upgraded server kernel MD5
root@bsd:~ # md5 /boot/kernel/kernel
MD5 (/boot/kernel/kernel) = 18f43409f035127acd05985fda18d46c

Compared with another ECS that has been upgraded successfully, the MD5 value is the same. I don't know it's the problem of finding the inside.


----------



## covacat (Mar 25, 2022)

looks like a bios/efi disk read error


----------



## Alucn (Mar 25, 2022)

covacat said:


> looks like a bios/efi disk read error


Using the old kernel can start the system normally, and updating to the new kernel fails.


----------



## covacat (Mar 25, 2022)

the error most likely comes from here /usr/src/stand/common/misc.c

```
if ((size_t)archsw.arch_readin(fd, dest, len) != len) {
#ifdef DEBUG
                printf("\nreadin failed\n");
#endif
                return (-1);
        }
```
which is invoked from  /usr/src/stand/common/load_elf.c

```
if (phdr[i].p_filesz > fpcopy) {
                        if (kern_pread(VECTX_HANDLE(ef),
                            phdr[i].p_vaddr + off + fpcopy,
                            phdr[i].p_filesz - fpcopy,
                            phdr[i].p_offset + fpcopy) != 0) {
                                printf("\nelf" __XSTRING(__ELF_WORD_SIZE)
                                    "_loadimage: read failed\n");
                                goto out;
                        }
                }
```
which indicates a short read caused either by the underlying disk driver or bad elf header data (wrong length passed to read function)
it is hard to tell which one without some printfs added to the loader code


----------



## Alucn (Mar 25, 2022)

covacat said:


> the error most likely comes from here /usr/src/stand/common/misc.c
> 
> ```
> if ((size_t)archsw.arch_readin(fd, dest, len) != len) {
> ...


Thank you for your reply!
/usr/src/ Under the directory is an empty folder


----------



## covacat (Mar 25, 2022)

https://download.freebsd.org/ftp/releases/amd64/13.0-RELEASE/src.txz


----------



## SirDice (Mar 25, 2022)

If you just want to read the code, use the cgit browser: https://cgit.freebsd.org/src/tree/?h=releng/13.0 (assuming you were talking about a 13.0-RELEASE)

Or github if you're more comfortable with that: https://github.com/freebsd/freebsd-src/tree/releng/13.0


----------

