# FreeBSD and linux emulator problem



## mrowcp (Jan 12, 2010)

Hello,
I use FreeBSD 7.2 and have some problems with Linux emulator instalation.I can't load it via kldload:


```
caph# kldload linux
kldload: can't load linux: No such file or directory
```

Also I try with:


```
sysctl compat.linux.osrelease=2.6.16

Add:

compat.linux.osrelease=2.6.16 to /etc/sysctl.conf
```

and


```
caph# pkg_add -r linux_base-f9
Fetching [url]ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-7.2-release/Latest/linux_base-f9.tbz[/url]... Done.
sysctl: unknown oid 'compat.linux.osrelease'
linuxulator is not (kld)loaded, exiting
pkg_add: install script returned error status
```

but... nothing.
If I run it via /ports/


```
===>  linux_base-f10-10_2 linuxulator is not (kld)loaded.
*** Error code 1

Stop in /usr/ports/emulators/linux_base-f10.
```

Thanks


----------



## SirDice (Jan 12, 2010)

Have a look in /boot/kernel/ the module should exist there.

Did you set any options in /etc/make.conf?

How do you update, source or freebsd-update?


----------



## mrowcp (Jan 12, 2010)

1st sorry for the wrong section 
2nd:


```
caph# pwd
/boot/kernel
caph# ls lin*
linker.hints
caph# cat /etc/make.conf
# added by use.perl 2010-01-08 00:23:55
PERL_VERSION=5.8.9
```

Sorry but Im new in FreeBSD and... I thing that I update ports, when smokeping was installed:


```
# cvsup -L 2 /root/ports-supfile
# portsdb -Uu
```

and than:


```
# portversion -l "<"
# portupgrade -arR
# pkgdb -F
```

but Im not 100% sure what this cmd do


----------



## SIFE (Jan 13, 2010)

installing linux module ,you have to be have already kernel source or install linux emulatio from sysinstall from command line .

```
cd /usr/src/sys/modules/linux
make install clean
```
add to rc.conf :

```
linux_enable="YES"
```
load linux module :

```
kldload linux
```
install linux emulation :
	
	



```
/usr/ports/emulators/linux_base-f9
make install clean
```
i did not try to install f10 in FreeBSD 7.1 only f9 or f8 .
add to /etc/fstab this line :

```
linproc                 /usr/compat/linux/proc  linprocfs       rw              0       0
```
finally mount linproc and start linux emulation :

```
mount linproc
/etc/rc.d/abi start
/etc/rc.d/sysctl restart
```


----------



## mrowcp (Jan 13, 2010)

thx bro but:


```
caph# cd /usr/src/sys/modules/linux
caph# make install clean
install -o root -g wheel -m 555   linux.ko /boot/kernel
install: linux.ko: No such file or directory
*** Error code 71

Stop in /usr/src/sys/modules/linux
```
.

google didnt find any solution 

From sysinstall I have some error like:


```
sysctl: unknown oid 'compat.linux.osrelease'
linuxulator is not (kld)loaded, exiting
```

and:


```
caph# cd /usr/ports/emulators/linux_base-f9
caph# make install clean
===>  linux_base-f9-9_1,1 linuxulator is not (kld)loaded.
*** Error code 1

Stop in /usr/ports/emulators/linux_base-f9.
caph# cd ..
caph# cd /usr/ports/emulators/linux_base-f8
caph# make install clean
===>  linux_base-f8-8_12 linuxulator is not (kld)loaded.
*** Error code 1

Stop in /usr/ports/emulators/linux_base-f8.
```

I thing that may be something missing, but...


----------



## mrowcp (Jan 13, 2010)

sry cant find how to edit post, so I will write it in new replay:


```
caph# locate linux.ko
/boot/kernel/3dfx_linux.ko
/boot/kernel/3dfx_linux.ko.symbols
/boot/kernel/aac_linux.ko
/boot/kernel/aac_linux.ko.symbols
/boot/kernel/amr_linux.ko
/boot/kernel/amr_linux.ko.symbols
caph# whereis linux.ko
linux.ko:
```


----------



## mrowcp (Jan 13, 2010)

ah and again 


```
caph# find / -name linux.ko
/boot/kernel/linux.ko
```

file is there, wtf?!?
I try to edit Makefile ( /usr/src/sys/modules/linux ), but cant find where linux.ko is... !?!


----------



## SIFE (Jan 13, 2010)

try this :

```
cd /usr/src/sys/modules/linux
make
make install
make clean
```
then install linux emulation .
to edit your post ,under your reply you will see a red button named EDIT .


----------



## SirDice (Jan 13, 2010)

SIFE said:
			
		

> to edit your post ,under your reply you will see a red button named EDIT .


You can edit posts after 10 posts and 10 days.


----------



## DutchDaemon (Jan 13, 2010)

Though nothing will prevent you from using the correct posting tags straight away.


----------



## mrowcp (Jan 13, 2010)

SIFE said:
			
		

> try this :
> 
> ```
> cd /usr/src/sys/modules/linux
> ...



Nothing again 


```
caph# make 
...........
...........
 -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -Wundef 
-Wno-pointer-sign -fformat-extensions -c /usr/src/sys/modules/linux/../../i386/linux/imgact_linux.c
ld  -d -warn-common -r -d -o linux.kld linux_locore.o linux_support.o linux_dummy.o linux_emul.o linux_file.o linux_futex.o linux_getcwd.o 
linux_ioctl.o linux_ipc.o linux_machdep.o linux_mib.o linux_misc.o linux_signal.o linux_socket.o linux_stats.o linux_sysctl.o linux_sysent.o 
linux_sysvec.o linux_uid16.o linux_util.o linux_time.o assym.o linux_ptrace.o imgact_linux.o
echo  linux_emul_path linux_get_osname linux_get_osrelease linux_ifname linux_ioctl_register_handler linux_ioctl_unregister_handler > 
export_syms
awk -f /usr/src/sys/modules/linux/../../conf/kmod_syms.awk linux.kld  export_syms | xargs -J% objcopy % linux.kld
ld -Bshareable  -d -warn-common -o linux.ko linux.kld
objcopy --strip-debug linux.ko

caph# make install
install -o root -g wheel -m 555   linux.ko /boot/kernel
install: /boot/kernel/linux.ko: Input/output error
*** Error code 71

Stop in /usr/src/sys/modules/linux.
caph#
```

Thx for the edit info


----------



## SIFE (Jan 13, 2010)

try to update your /usr/src using cvsup ,and then install the module .


----------



## mrowcp (Jan 13, 2010)

SIFE said:
			
		

> try to update your /usr/src using cvsup ,and then install the module .



can you help me to create a supfile? 
Is this correct:


```
caph# cat supfile

*default tag=.
*default host=cvsu.FreeBSD.org
*default prefix=/usr
*default base=/var/db
*default release=cvs delete use-rel-suffix compress

src-all

caph# cvsup supfile
```


----------



## DutchDaemon (Jan 13, 2010)

/usr/share/examples/cvsup/


----------



## SirDice (Jan 13, 2010)

Skip the installation of net/cvsup. Since 6.4 the base OS includes csup. It's similar in features and use.


----------



## mrowcp (Jan 13, 2010)

This is my cvs-supfile:


```
*default host=cvsup.FreeBSD.org
*default base=/var/db
*default prefix=/usr
*default release=cvs
*default delete use-rel-suffix

*default compress

src-all

#ports-base

doc-all
www
projects-all
cvsroot-all
```


```
caph# cvsup cvs-supfile
...............
...............
```

when I came home ( after 1h ) and run:


```
caph# make
......
......
echo  linux_emul_path linux_get_osname linux_get_osrelease linux_ifname linux_ioctl_register_handler linux_ioctl_unregister_handler > export_syms
awk -f /usr/src/sys/modules/linux/../../conf/kmod_syms.awk linux.kld  export_syms | xargs -J% objcopy % linux.kld
ld -Bshareable  -d -warn-common -o linux.ko linux.kld
objcopy --strip-debug linux.ko
caph# make install
install -o root -g wheel -m 555   linux.ko /boot/kernel
install: /boot/kernel/linux.ko: Input/output error
*** Error code 71

Stop in /usr/src/sys/modules/linux.
```

Is my cvs-supfile wrong ?!?

P.S. after 5h+ I close putty ( I was at work so I use putty ) from the X button.Is this interrupt the compilation?Here is ps aux before my last make->make install


----------



## SIFE (Jan 14, 2010)

try to remove first /usr/src/*

```
cd /usr/src
rm -R *
cd /usr/obj
rm -R *
```
then cvsup :

```
*default host=cvsup7.de.FreeBSD.org
*default base=/var/db
*default prefix=/usr
*default release=cvs tag=RELENG_7_1
*default delete use-rel-suffix
*default compress
```
are you have custom kernel or generic kernel .


----------



## mrowcp (Jan 14, 2010)

SIFE said:
			
		

> try to remove first /usr/src/*
> 
> ```
> cd /usr/src
> ...



Thanks,I use - generic FreeBSD 7.2 


```
*default release=cvs tag=RELENG_7_2
```

?


----------



## SIFE (Jan 14, 2010)

now what happend .


----------



## mrowcp (Jan 15, 2010)

SIFE said:
			
		

> now what happend .



box was down for a while 
Now seems all is OK.I have some success:


```
caph# make install
install -o root -g wheel -m 555   linux.ko /boot/kernel
kldxref /boot/kernel
```


than I run, make clean and:


```
caph# cd linux_base-f10
caph# make install clean
===>  linux_base-f10-10_2 compat.linux.osrelease: 2.4.2 is not supported, please use 2.6.16.
*** Error code 1

Stop in /usr/ports/emulators/linux_base-f10.
caph# pwd
/usr/ports/emulators/linux_base-f10
caph# cd ..
caph# cd linux_base-f9
caph# make install clean
===>  linux_base-f9-9_1,1 compat.linux.osrelease: 2.4.2 is not supported, please use 2.6.16.
*** Error code 1

Stop in /usr/ports/emulators/linux_base-f9.
```

Now I must run:

```
caph# sysctl compat.linux.osrelease=2.6.16
```

?


----------



## SIFE (Jan 15, 2010)

```
echo compat.linux.osrelease=2.6.16 >> /etc/sysctl.conf
```
this will take effect next boot and ,ake your life easy .


----------



## mrowcp (Jan 15, 2010)

SIFE said:
			
		

> ```
> echo compat.linux.osrelease=2.6.16 >> /etc/sysctl.conf
> ```
> this will take effect next boot and ,ake your life easy .




```
===>   Registering installation for linux_base-f10-10_2
===> SECURITY REPORT:
      This port has installed the following files which may act as network
      servers and may therefore pose a remote security risk to the system.
/compat/linux/lib/libdb-4.7.so
/compat/linux/usr/lib/libgssrpc.so.4.0
/compat/linux/lib/libselinux.so.1
/compat/linux/lib/libresolv-2.9.so

      If there are vulnerabilities in these programs there may be a security
      risk to the system. FreeBSD makes no guarantee about the security of
      ports included in the Ports Collection. Please type 'make deinstall'
      to deinstall the port if this is a concern.
===>  Cleaning for rpm-3.0.6_14
===>  Cleaning for automake-1.4.6_5
===>  Cleaning for autoconf-2.13.000227_6
===>  Cleaning for linux_base-f10-10_2
```

Thank you ppl :beergrin
All is done now :e


----------



## hexabit (Feb 17, 2010)

Sometimes you just don't want to reboot the machine so you can do the following:


```
sysctl compat.linux.osrelease=2.6.16
```

and then install linux_base-f10 from ports.


----------



## lme@ (Feb 19, 2010)

hexabit said:
			
		

> Sometimes you just don't want to reboot the machine so you can do the following:
> 
> 
> ```
> ...



Be sure to end every process that uses linuxolator, first.


----------



## JornZ (Apr 15, 2011)

Hi,

Sorry for reviving this old thread. I had the same problem as the OP. I managed to fix the issue with linux.ko by doing this:


```
cd /boot/kernel
install -o root -g wheel -m 555 linux.ko .
```


----------



## valuequest (Jul 13, 2011)

SIFE said:
			
		

> try this :
> 
> ```
> cd /usr/src/sys/modules/linux
> ...


Out of technical curiosity why do the make commands need to be executed one at a time in this case?


----------



## valuequest (Jul 14, 2011)

Okay... after having followed SIFE's very excellent instructions above I am pretty sure that I have now managed to get linux_dist-gentoo-stage3 correctly installed on my now-freshly-updated-to-8-STABLE installation.

I'm a bit confused about how to use linprocfs and linsysfs though.  The man pages say that these should be mounted at /compat/linux. Attempting to mount either filesystem there though results in the following:

```
mount: /usr/compat/linux: No such file or directory
```

Upon closer inspection the port appears to have created the following: 
> /compat -symbolic link-> /usr/compat which is empty
> /usr/local/gentoo-stage3 which appears to contain most of a root filesystem including a /sys but not a /proc

With respect to the information in the "Linux file/directory tricks" section of http://www.leidinger.net/blog/category/freebsd/linuxolator/ -- do I need to figure out how to mount linproc and linsys at /compat/linux as all documentation suggests? Or should I mount linproc and linsys at /usr/local/gentoo-stage3?


----------



## wblock@ (Jul 14, 2011)

Earlier parts of this thread are pretty old, so beware.  Is there a reason you're using linux_dist-gentoo-stage3 instead of the standard emulators/linux_base-f10?  The pkg-message for emulators/linux_dist-gentoo-stage3 says to see linprocfs(5) and linsysfs(5), which are standard.


----------



## valuequest (Jul 15, 2011)

I decided to utilize linux_dist-gentoo-stage3 after I read the "Constraints regarding chroot into /compat/linux" section of http://www.leidinger.net/blog/2010/09/28/the-freebsd-linuxulator-explained-for-users/ and determined that I actually need to chroot into the linux environment for what I need to do with it.

Yes I read linprocfs() and linsysfs() which are what lead me to try to mount in /compat/linux... I described the result in the previous post.  The way that linux_dist-gentoo-stage3 installed its files in /usr/local/gentoo-stage3 as I described in previous post causes me to wonder if the man pages have fallen behind the design of the port.


----------



## wblock@ (Jul 15, 2011)

/usr/compat/linux should already exist.  Did you do a minimal install?


----------



## valuequest (Jul 15, 2011)

I'm not quite sure what a minimal install is wblock but I installed this system from 8.2 RELEASE.  A couple of days ago I updated sources to 8-STABLE and installed a new world with the sequence described in http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html (still shocked that actually worked on the first attempt).

I have made no changes to /usr/compat which (as I described in the previous post) is empty.

The key question that I have here is where linproc and linsys need to be mounted in order for linux_dist-gentoo-stage3 to work as designed.


----------



## wblock@ (Jul 15, 2011)

A minimal install is one of the options in the installer.  It leaves a lot of stuff out.

The SYNOPSIS line in linprocfs(5) and linsysfs(5) shows where to mount them.  At least that works with emulators/linux_base-f10.


----------



## valuequest (Jul 15, 2011)

Okay the author of the http://www.leidinger.net/blog/2010/09/28/the-freebsd-linuxulator-explained-for-users/ article was nice enough to respond to my question.


> I don't have a login there, so here's the info via mail. Please add it to the thread in the forum.
> 
> The linux-dist ports are not designed to be a replacement for the linux_base ports. So if the intend is to use it like this: the user experience will be not as expected (linking from /compat/linux to /usr/local/gentoo-stage3 is not enough, the linux_base ports make some modifications to the linux-bits to have a better "integrated into FreeBSD"-experience).
> 
> ...


Thanks Alexander!


----------



## valuequest (Jul 18, 2011)

I also had trouble with the linux_dist-gentoo-stage3 environment's lack of a /dev.

Thanks again to Alexander for the following tip:

```
mount -t devfs /nonexistent /usr/local/gentoo-stage3/dev
```


----------



## rusma (Sep 20, 2011)

Hey, nice thread. I think /proc is becoming obsolete, though; or maybe it is considered obsolete already. Now, in Linux, everything happens in /sys, AFAIK from experience in ArchLinux (it uses fairly new kernels).


----------

