FreeBSD: i386 inside a jail in amd64

The key point: make a symlink of jailed /libexec/ to /libexec/ Of course, your kernel should have COMPAT_IA32 option compiled.

# cd /usr/src && make TARGET_ARCH=i386 TARGET=i386 buildworld
# mkdir -p /home/jails/i386 && make TARGET_ARCH=i386 TARGET=i386 DESTDIR=/home/jails/i386 installworld
# make TARGET_ARCH=i386 TARGET=i386 DESTDIR=/home/jails/i386 distribution
# ln -s /home/jails/i386/libexec/ /home/jails/i386/libexec/

Then, edit rc.conf in jail to run sshd and start jails. Some utilities, like w/ps/top can not run because they retrieve data from FreeBSD kernel, and the kernel returns 64-bit structures, not 32-bit.

4:37AM  up 12 days,  8:40, 1 user, load averages: 0.03, 0.18, 0.20
USER             TTY      FROM              LOGIN@  IDLE WHAT
w: kinfo_proc size mismatch (expected 768, got 1088): No such file or directory

I am doing further test to make sure there aren’t any mines :)

5 Responses to “FreeBSD: i386 inside a jail in amd64”

  • that is a great idea. i’m still trying to get it to work though, my freebsd cd install had no i386 libraries by default

  • i think it should be

    ln -s /libexec/ /home/jails/i386/libexec/

  • Thanks for the tips! I’m running this under 7.1-RELEASE now. But a symlink in /libexec was unneccessary. What I had to do instead was mount the host’s /usr/lib32 over the jail’s /usr/lib. Also, added ARCH=i386 to the jail’s /etc/make.conf. Everything seems to build and run fine except for ps, top, pkill, killall, and oddly, “screen”. However, I got a working ps by copying the statically linked binary from the host’s /rescue/ps.

  • “cd /usr/src/usr.bin/killall && make NO_SHARED=true depend all && cp killall /usr/local/jail/” on host amd64 environment produces static killall for jail. you can make these command with any utility of FreeBSDs’ world.

  • If the jail kernel is copied instead of symlinked, all of the system utilities such as w, ps and top work ok. I have published a detailed recipe for this, inspired by yours, but I am not allowed to post a link in a comment. Just search for 32bit on mye site

Leave a Reply