# How to resolve   ld-elf.so.1: /bin/sh: Undefined symbol "stat@FBSD_1.5"



## redscience (Oct 11, 2019)

In this topic i have a problem about update freebsd 11 to 12








						How to resolve Upgrading linux base-c7 from 7.4 to 7.7 kernel missing 64-bit Linux support
					

I would like to upgrade my FreeBD from 11 to 12 but I got this error message How can I resolve that?  Proceed with this action? [y/N]: y [1/266] Upgrading linux_base-c7 from 7.4.1708_6 to 7.7.1908... Cannot install package: kernel missing 64-bit Linux support pkg: PRE-INSTALL script failed




					forums.freebsd.org
				




but now i got a new error message
and when i want to reboot my server i see this error message
ld-elf.so.1: /bin/sh: Undefined symbol "stat@FBSD_1.5"
enter full pathname of shell or return for /bin/sh:





how can i resolve this problem?
Enter and fsck not work


----------



## Phishfry (Oct 11, 2019)

Are you absolutely sure you ran `freebsd-update` until it was finished?

freebsd-update needs to run three times on a major version upgrade with a few reboots.

You need to follow the instructions it shows onscreen exactly.
There is one ambiguous part where it says you must upgrade all the ports on your system.
This also applied to packages. You must reinstall all packages. (pkg-static upgrade -f )

Rerun the `freebsd-update` command if you can. There might be more steps needed.


----------



## Phishfry (Oct 11, 2019)

I have read the related post you had made and can only say one thing.
Sometimes it is easiest to just start over.
You could possibly do a source based upgrade to FreeBSD 12 to remedy this.
This might take some gynmastics seeing how you cannot boot your installation.


----------



## redscience (Oct 11, 2019)

Phishfry said:


> .
> .
> .


I cannot go to my panel *Phishfry*
first , I should go to my shell area, my freebsd os cannot go up and when i want to use any command to to anything i see this error message
cannot execute COMMAND for single user: no such file or directory
Of course, I started my FreeBSD with multiple user mode, but this message appears when I want to use Enter key for any written command


----------



## Phishfry (Oct 11, 2019)

Do you remember if you installed the FreeBSD source code when you installed FreeBSD?
That might be your only approach.

`freebsd-update` does have a -rollback feature but I don't see how you could use it with your machine in this state.


----------



## Phishfry (Oct 11, 2019)

Can you enter 'Single User' mode from the Loader prompt?
This is the screen with Beastie on it that waits 10 seconds.
That might be your only saving grace.
Single User mode does not require a working shell.


----------



## yuripv (Oct 11, 2019)

Or, specify /rescue/sh as a shell, it's a statically linked binary (consisting of many programs).


----------



## redscience (Oct 11, 2019)

Phishfry said:


> Do you remember if you installed the FreeBSD source code when you installed FreeBSD?
> That might be your only approach.
> 
> `freebsd-update` does have a -rollback feature but I don't see how you could use it with your machine in this state.


I used         freebsd-update install
and it was done
next, i used         /usr/sbin/freebsd-update fetch
and In the next step again i used freebsd-update install
after that, for any command I saw

```
ld-elf.so.1: /bin/sh: Undefined symbol "stat@FBSD_1.5"
```
and after that i rebooted my server and now error message is

```
ld-elf.so.1: /bin/sh: Undefined symbol "stat@FBSD_1.5"
enter full pathname of shell or return for /bin/sh:
```
and my server cannot run up


----------



## redscience (Oct 11, 2019)

I synced my iso file to my server, how can i go to my live panel when boot comes again and downgrade my files to resolve this problem? ( I can update OS again when every thing came to first status )


----------



## Phishfry (Oct 11, 2019)

yuripv brings up a great point.
At the point FreeBSD is hanging at type /rescue/sh

rescue(4) might need a remount for the filesystem as noted in the manual.


----------



## redscience (Oct 11, 2019)

i FOUND my commands
I would like show you what was occurred

```
(~)> freebsd-update install

.....

The process will require 414 MiB more space.

Proceed with this action? [y/N]: y

[1/381] Upgrading linux_base-c7 from 7.4.1708_6 to 7.7.1908...

Cannot install package: kernel missing 64-bit Linux support

pkg: PRE-INSTALL script failed

(root@Host)-(04:54P)-(10/11)-(3)
```


```
(~)> freebsd-update install

Installing updates...rmdir: ///var/db/etcupdate/current/usr/share/openssl/man/en.ISO8859-1: Directory not empty

rmdir: ///var/db/etcupdate/current/usr/share/openssl/man: Directory not empty

rmdir: ///var/db/etcupdate/current/usr/share/openssl: Directory not empty

rmdir: ///var/db/etcupdate/current/usr/share/man/en.UTF-8: Directory not empty

rmdir: ///var/db/etcupdate/current/usr/share/man/en.ISO8859-1: Directory not empty

rmdir: ///var/db/etcupdate/current/usr/share/man: Directory not empty

 done.

(root@Host)-(04:56P)-(10/11)-(3)
```


```
(~)> freebsd-update install

No updates are available to install.

Run '/usr/sbin/freebsd-update fetch' first.

(root@Host)-(05:02P)-(10/11)-(3)
```



```
(~)> /usr/sbin/freebsd-update fetch

Looking up update.FreeBSD.org mirrors... 3 mirrors found.

Fetching metadata signature for 11.2-RELEASE from update1.freebsd.org... done.

Fetching metadata index... done.

Inspecting system... done.

Preparing to download files... done.

The following files will be updated as part of updating to 11.2-RELEASE-p14:

/bin/freebsd-version

/boot/check-password.4th

/boot/kernel/aac.ko

/boot/kernel/aacraid.ko

/boot/kernel/aesni.ko

/boot/kernel/alq.ko

/boot/kernel/arcmsr.ko

/boot/kernel/autofs.ko

/boot/kernel/cam.ko

/boot/kernel/cd9660.ko

/boot/kernel/cloudabi32.ko

/boot/kernel/cloudabi64.ko

/boot/kernel/coretemp.ko

/boot/kernel/cpuctl.ko

/boot/kernel/cpufreq.ko

/boot/kernel/ctl.ko

/boot/kernel/cuse.ko

/boot/kernel/cxgbei.ko

/boot/kernel/drm.ko

/boot/kernel/drm2.ko

-- MOST: *stdin*                                                                                                                        (1,1) 0%   

(root@Host)-(05:04P)-(10/11)-(3)
```

*NOW PLEASE SEE THIS LINE*

```
(~)> freebsd-update install

Installing updates...ld-elf.so.1: /bin/rm: Undefined symbol "lstat@FBSD_1.5"

ld-elf.so.1: /usr/bin/gunzip: Undefined symbol "fstat@FBSD_1.5"

ld-elf.so.1: /usr/bin/install: Undefined symbol "stat@FBSD_1.5"

ld-elf.so.1: /bin/rm: Undefined symbol "lstat@FBSD_1.5"

ld-elf.so.1: /usr/bin/gunzip: Undefined symbol "fstat@FBSD_1.5"

ld-elf.so.1: /usr/bin/install: Undefined symbol "stat@FBSD_1.5"

ld-elf.so.1: /bin/rm: Undefined symbol "lstat@FBSD_1.5"

ld-elf.so.1: /usr/bin/gunzip: Undefined symbol "fstat@FBSD_1.5"

ld-elf.so.1: /usr/bin/install: Undefined symbol "stat@FBSD_1.5"

ld-elf.so.1: /bin/rm: Undefined symbol "lstat@FBSD_1.5"

ld-elf.so.1: /usr/bin/gunzip: Undefined symbol "fstat@FBSD_1.5"

ld-elf.so.1: /usr/bin/install: Undefined symbol "stat@FBSD_1.5"

ld-elf.so.1: /bin/rm: Undefined symbol "lstat@FBSD_1.5"

ld-elf.so.1: /usr/bin/gunzip: Undefined symbol "fstat@FBSD_1.5"

ld-elf.so.1: /usr/bin/install: Undefined symbol "stat@FBSD_1.5"

ld-elf.so.1: /bin/rm: Undefined symbol "lstat@FBSD_1.5"

ld-elf.so.1: /usr/bin/gunzip: Undefined symbol "fstat@FBSD_1.5"

ld-elf.so.1: /usr/bin/install: Undefined symbol "stat@FBSD_1.5"

ld-elf.so.1: /bin/rm: Undefined symbol "lstat@FBSD_1.5"

ld-elf.so.1: /usr/bin/gunzip: Undefined symbol "fstat@FBSD_1.5"

ld-elf.so.1: /usr/bin/install: Undefined symbol "stat@FBSD_1.5"

ld-elf.so.1: /bin/rm: Undefined symbol "lstat@FBSD_1.5"

ld-elf.so.1: /bin/chflags: Undefined symbol "fts_open@FBSD_1.5"

ld-elf.so.1: /bin/chflags: Undefined symbol "fts_open@FBSD_1.5"

ld-elf.so.1: /bin/chflags: Undefined symbol "fts_open@FBSD_1.5"

ld-elf.so.1: /bin/chflags: Undefined symbol "fts_open@FBSD_1.5"

ld-elf.so.1: /bin/chflags: Undefined symbol "fts_open@FBSD_1.5"

ld-elf.so.1: /bin/chflags: Undefined symbol "fts_open@FBSD_1.5"

ld-elf.so.1: /bin/chflags: Undefined symbol "fts_open@FBSD_1.5"

ld-elf.so.1: /bin/chflags: Undefined symbol "fts_open@FBSD_1.5"

(root@Host)-(05:05P)-(10/11)-(3)
```

(~)> freebsd-update install
ld-elf.so.1: /bin/sh: Undefined symbol "stat@FBSD_1.5"
(root@Host)-(05:05P)-(10/11)-(3)
(~)> freebsd-update install
ld-elf.so.1: /bin/sh: Undefined symbol "stat@FBSD_1.5"
(root@Host)-(05:05P)-(10/11)-(3)
(~)> freebsd-update install
ld-elf.so.1: /bin/sh: Undefined symbol "stat@FBSD_1.5"
(root@Host)-(05:05P)-(10/11)-(3)
(~)>  pkg update
ld-elf.so.1: /lib/libelf.so.2: Undefined symbol "fstat@FBSD_1.5"
(root@Host)-(05:05P)-(10/11)-(3)
(~)> freebsd-update install
ld-elf.so.1: /bin/sh: Undefined symbol "stat@FBSD_1.5"
(root@Host)-(05:05P)-(10/11)-(3)
(~)> /usr/sbin/freebsd-update fetch
ld-elf.so.1: /bin/sh: Undefined symbol "stat@FBSD_1.5"
(root@Host)-(05:06P)-(10/11)-(3)
(~)>  pkg upgrade
ld-elf.so.1: /lib/libelf.so.2: Undefined symbol "fstat@FBSD_1.5"

(root@Host)-(05:39P)-(10/11)-(3)
(~)> reboot


----------



## redscience (Oct 11, 2019)

GOT IT
with this command
*/rescue/sh*


----------



## T-Daemon (Oct 12, 2019)

yuripv said:


> Or, specify /rescue/sh as a shell, it's a statically linked binary (consisting of many programs).





redscience said:


> GOT IT
> with this command
> */rescue/sh*


Have you checked the contents of /bin, /sbin, and /usr/lib as rescue(8) suggests, eventually copying those from a installation image over to the damaged system?

On the other hand, at this point, a new system installation with FreeBSD 12.0-RELEASE would be the best solution.



redscience said:


> I synced my iso file to my server, how can i go to my live panel when boot comes again and downgrade my files to resolve this problem?


Are we talking about a remote FreeBSD installation, at a data center, or a local home server?


----------



## redscience (Oct 12, 2019)

T-Daemon said:


> Have you checked the contents of /bin, /sbin, and /usr/lib as rescue(8) suggests, eventually copying those from a installation image over to the damaged system?
> 
> On the other hand, at this point, a new system installation with FreeBSD 12.0-RELEASE would be the best solution.
> 
> ...


unfortunately, this is in data center server and my server is now down

I cannot check anything and contents of /bin, /sbin, and /usr/lib
because I get error

pkg upgrade OUTPUT:
ld-elf.so.1: /lib/libelf.so.2: Undefined symbol "fstat@FBSD_1.5"
*ls OUTPUT*
ld-elf.so.1: /bin/ls: Undefined symbol "fts_open@FBSD_1.5"

and etc

I used this command        /rescue/mount -uw /
and now I dont know what can I do, My ISO file is on the server and I dont know can I remove and replace default files or not, and How can I do this? because I cannot go to my panel or work with my files


----------



## acheron (Oct 12, 2019)

Upgrade your libc.


----------



## redscience (Oct 12, 2019)

acheron said:


> Upgrade your libc.


upgrade command not work


----------



## acheron (Oct 12, 2019)

You did something really wrong when updating to 12.0, the correct way is:

```
/usr/sbin/freebsd-update -r 12.0-RELEASE upgrade
/usr/sbin/freebsd-update install
shutdown -r now
/usr/sbin/freebsd-update install
```
What ISO file do you have? Is it the 12.0-RELEASE? Then you can do the following:

```
/rescue/mdconfig /path/to/FreeBSD-12.0-RELEASE-amd64-disc1.iso
/rescue/mount_cd9660 /dev/md0 /mnt
/rescue/chflags noschg /lib/libc.so.7
/rescue/cp /mnt/lib/libc.so.7 /lib/libc.so.7
```


----------



## redscience (Oct 12, 2019)

acheron said:


> You did something really wrong when updating to 12.0, the correct way is:
> 
> ```
> /usr/sbin/freebsd-update -r 12.0-RELEASE upgrade
> ...




```
/usr/sbin/freebsd-update -r 12.0-RELEASE upgrade
/usr/sbin/freebsd-update install
shutdown -r now
/usr/sbin/freebsd-update install
```
All of these commands give me back this OUTPUT
*ld-elf.so.1: /bin/sh: Undefined symbol "stat@FBSD_1.5"*
First, I should find a way to resolve this error message
I googled this problem but i cannot find a way to resolve that


----------



## acheron (Oct 12, 2019)

redscience said:


> ```
> /usr/sbin/freebsd-update -r 12.0-RELEASE upgrade
> /usr/sbin/freebsd-update install
> shutdown -r now
> ...


You definitely don't know what you are doing then. This is what you should have done to upgrade your system, it's useless now, you can't recover your system with these commands.
I posted a way to recover your system with the rescue bin but you probably didn't read it.


----------



## redscience (Oct 12, 2019)

acheron said:


> You definitely don't know what you are doing then. This is what you should have done to upgrade your system, it's useless now, you can't recover your system with these commands.
> I posted a way to recover your system with the rescue bin but you probably didn't read it.


I know what you say, much appreciated for your answers
but my access is limited
please tell me how can I find exact path of my ISO file?
I have to give my iso path in vmware ? ( because here I cannot run and get a result when i enter a command )
I dont have any problem like this in debian centos slackware or gentoo and this error message occurred for first time and i dont have any experience about resolve that, for example we can find mounted driver with lsblk in kali-debian-ubuntu
or for example we can find path in /media/iso with > mount | awk '/\/media\/iso/ { print $1}'
but here i cannot find pathes
because i get this error message
ld-elf.so.1: /bin/sh: Undefined symbol "stat@FBSD_1.5"


----------



## acheron (Oct 12, 2019)

Not sure I understand you. You said earlier:


> My ISO file is on the server


, why are you mentioning vmware?
You just have to give the full path to /rescue/mount_cd9660.


----------



## acheron (Oct 12, 2019)

redscience said:


> because here I cannot run and get a result when i enter a command


It's normal, your libc is still from the 11.x era. The only command you can execute is the one located in /rescue


----------



## acheron (Oct 12, 2019)

I don't know vwmare at all. Can you attach a cdrom device to your machine and put an ISO in it?
You'll be able to mount it with `/rescue/mount_cd9660 /dev/cd0 /mnt`


----------



## redscience (Oct 12, 2019)

acheron said:


> It's normal, your libc is still from the 11.x era. The only command you can execute is the one located in /rescue


*acheron *this is not normal, because some of commands not work and output get this error message
ld-elf.so.1: /bin/sh: Undefined symbol "stat@FBSD_1.5"
here I cannot find path, because every thing get error,
I cannot use ls or find file and folders or any other command in my  /rescue/sh area
this is not normal,
this error was in my FreeBSD OS before reboot server
and I could not use commands
i cannot find path because all of commands give me this error message
ld-elf.so.1: /bin/sh: Undefined symbol "stat@FBSD_1.5"
I think one of resolving methods is deleting some paths and maybe this error message can be fixed and then I can go to my os area
these commands maybe resolve my problem but i cannot find my ISO path
 /rescue/mdconfig /path/to/FreeBSD-12.0-RELEASE-amd64-disc1.iso
/rescue/mount_cd9660 /dev/md0 /mnt
/rescue/chflags noschg /lib/libc.so.7
/rescue/cp /mnt/lib/libc.so.7 /lib/libc.so.7


----------



## acheron (Oct 12, 2019)

I start to think you're just a troll and you're wasting my time. I'll try to explain this one more time and hope you'll be more cooperative / less stubborn.



redscience said:


> *acheron *this is not normal, because some of commands not work and output get this error message
> ld-elf.so.1: /bin/sh: Undefined symbol "stat@FBSD_1.5"
> here I cannot find path, because every thing get error,
> I cannot use ls or find file and folders or any other command in my  /rescue/sh area
> ...


You're wrong, the error message is perfectly normal, you're trying to use some libc symbol that are not present in your libc. As I said in my very first post : you need to upgrade your libc.
Can you explain me what is a "path" for you? What do you mean by "cannot find path"? Can you tell me how you execute "ls", I hope it's with /rescue/ls or it just means you're a troll.


----------



## redscience (Oct 12, 2019)

you insult me, I am not a troll and I don't tell you to be here with force, you can go to other section of this forum,
all of my websites is down and now I am so sad and you tell me troll? you don't need to be here and waste your time, I don't have a good feeling with your sentences
by the way, this command give me error message
1.
/rescue/mdconfig /path/to/FreeBSD-12.0-RELEASE-amd64-disc1.iso
my ISO file is not in this path and i cannot find it
/path/to/FreeBSD-12.0-RELEASE-amd64-disc1.iso


----------



## acheron (Oct 12, 2019)

Ok, have you attached a cdrom on your machine? Have you put the ISO/cd in the cdrom?
if yes, you can mount it:

```
/rescue/mount_cd9660 /dev/cd0 /mnt
/rescue/chflags noschg /lib/libc.so.7
/rescue/cp /mnt/lib/libc.so.7 /lib/libc.so.7
```


----------



## redscience (Oct 12, 2019)

acheron said:


> Ok, have you attached a cdrom on your machine? Have you put the ISO/cd in the cdrom?
> if yes, you can mount it:
> 
> ```
> ...


thank you 
In the last row I got an error message ( file copied but tell us is Read-only file system )
cp:/lib/libc.so.7: Read-only file system




After that I used your commands In your first post
/usr/sbin/freebsd-update -r 12.0-RELEASE upgrade
/usr/sbin/freebsd-update install
shutdown -r now
/usr/sbin/freebsd-update install

but again I got this error message stat@FBSD_1.5




what is my wrong ? 
Of course, I think this error is natural because this command show me about update from source
( I have some of activities like sudo "sh /mnt" but I got an error again )
please tell me what can i do exactly


----------



## acheron (Oct 13, 2019)

I forgot that single user mode mount the filesystem read only, you'll need to remount it read / write. What is the name of your root partition (/dev/ada0xxx, /dev/da0xxx)? If you don't know, execute the following:

```
/rescue/mount
```
You should see something like: `/dev/ufs/rootfs on / (ufs, local, noatime)`
Then you can do (replace /dev/ufs/rootfs with the your root partition name): 
	
	



```
/rescue/mount -o rw /dev/ufs/rootfs /
```
You'll be able to execute the following after:

```
/rescue/chflags noschg /lib/libc.so.7
/rescue/cp /mnt/lib/libc.so.7 /lib/libc.so.7
```


----------



## acheron (Oct 13, 2019)

EDIT: before doing the following, make sure that you have 12.0-RELEASE in the output of `uname -a`

With the new libc in place you can drop to multi user (either reboot or type 'exit')
Since your base system is a mix of 11.2 and 12.0 binaries, you'll need to 'overwrite it' with a 12.0 system:

```
# backup /etc, just in case
mkdir -p /root/backup_etc
cp -R /etc /root/backup_etc

# remove protection of some binaries
chflags 0 /lib/libthr.so.3 /lib/libcrypt.so.5 /lib/libc.so.7 /libexec/ld-elf.so.1 /sbin/init /usr/bin/passwd /usr/bin/crontab /usr/bin/su /usr/bin/chpass /usr
/bin/login /usr/bin/opieinfo /usr/bin/opiepasswd /usr/lib/librt.so.1

# untar 12.0 world, the FreeBSD install ISO needs to be mounted in /mnt:
tar --exclude etc -xpf /mnt/usr/freebsd-dist/base.txz -C /
```


----------



## redscience (Oct 15, 2019)

acheron said:


> I forgot that single user mode mount the filesystem read only, you'll need to remount it read / write. What is the name of your root partition (/dev/ada0xxx, /dev/da0xxx)? If you don't know, execute the following:
> 
> ```
> /rescue/mount
> ...


I got this error message




uname -a





If I knew that update can gotten my time for a long time, never I didn't make it


----------



## acheron (Oct 15, 2019)

Use `/rescue/fsck`


----------



## redscience (Oct 15, 2019)

acheron said:


> Use `/rescue/fsck`


I do that
my last activity is:


----------



## acheron (Oct 15, 2019)

It's useless to execute a command if the previous one did not succeed. Your cdrom is not mounted.
There is another problem: you're still on a 11.2 kernel, updating libc will probably cause more trouble.
You should probably update your kernel first:

```
/rescue/mv /boot/kernel /boot/kernel.old
/rescue/tar xpf /mnt/usr/freebsd-dist/kernel.txz -C /
```
before rebooting make sure the commands suceeded.
You'll be able to update libc/base.txz after that.


----------



## redscience (Oct 15, 2019)

acheron said:


> It's useless to execute a command if the previous one did not succeed. Your cdrom is not mounted.
> There is another problem: you're still on a 11.2 kernel, updating libc will probably cause more trouble.
> You should probably update your kernel first:
> 
> ...


OUTPUT is:


----------



## acheron (Oct 16, 2019)

Why do you already have a kernel.old?


----------



## kevo-gt (Feb 11, 2020)

Hi all,
I had a similar situation when an upgrade from 11.2 to 12.0 broke and the system became corrupted. I managed to fix it using the instructions on this thread. I am just sharing what I did incase others have similar issues.



Power down the device (at this point I did not have a working shell). Once it gets to the single user prompt do the following:


```
/rescue/sh
uname -anr
```

It reported FreeBSD 12.0 amd64. I then downloaded this OS and mounted it (I was using VM Ware). Then:


```
/rescue/mount_cd9660 /dev/cd0 /mnt
/rescue/mount
/rescue/mount -o rw /dev/zroot/ROOT/default /
/rescue/chflags noschg /lib/libc.so.7
/rescue/cp /mnt/lib/libc.so.7 /lib/libc.so.7

exit
```

At this point I could login to my shell via console. I did "uname -anr" and saw that the system was reporting FreeBSD 12.0. So this was a broken update I was dealing with.

I then run the following steps:


```
/rescue/mount_cd9660 /dev/cd0 /mnt
/rescue/ldconfig /lib /usr/lib /usr/local/lib
/rescue/ldconfig -32 /usr/lib32 /usr/local/lib32/compat
cp /mnt/usr/lib/libbz2.so.4 /usr/lib/
```

I then installed rsync from ports and backed up my files (pkg asked to remove too many packages so went with ports instead). Of course tools like "tar" and "scp" are options but I prefer rsync for network copying. Then:


```
freebsd-update fetch
freebsd-update install
shutdown -r
```

The update worked and all my installed programs were running normally after reboot. I will have to update all packages later but at least the system is ok. For Mysql to work, I had to add this to /etc/rc.conf:


```
mysql_limits=""
```


----------

