2024-01-21 # probably there already mkdir -pv /compat/linux (In my case I actually wanted the files stored elsewhere, and it worked fine to symlink: mkdir /compat mkdir /local/linux ln -s /local/linux /compat/linux then continue, still treating /compat/linux as though it were a simple directory .. it may sound obvious, but I wondered whether the linux service mounting proc,dev, et.c. would object .. which it didn't. Later, because I prefer /compat/linux rather than /local/linux in the paths made by annoying programs (matlab?) that like to resolve the symlinks manually or to call realpath, I did a bind mount instead of a symlink: mkdir /compat/linux mount -t nullfs /local/linux /compat/linux which also worked well. ) # copy the files from a working linux system that's able to run the # program we want, and the program itself; in this case we take them # from two different computers, and we don't have to change any # licensing setup in matlab because it uses a licence-server so its # config in the installation is just the licence-server name and port # cd /compat/linux ssh root@computerwithRHEL92 tar -c --one-file-system / | tar -xpf - ssh root@computerwithmatlab tar -c /opt/matlab/2023b | tar -xpf - # load kernel modules and mount special compat filesystems /etc/rc.d/linux start # modules include {linux,linux_comman,linux64,linsysfs,linprocfs}.ko # mounts are /compat/linux/{proc,sys,dev,dev/fs,dev/shm} # make the interpreter for matlab's startup script be the one from the # linux system (then, it seems, it will further use other commands from # there, avoiding incompatibility of command options etc between the # linux and freebsd, or confusion of matlab in determining the 'platform'; # presumably it's when a binary is run that the system notices it needs # to be using the linux emulation # line1: change '#!/bin/sh' to '#!/compat/linux/bin/sh' vi opt/matlab/2023b/bin/matlab # make sure the starting script can be seen in both systems by the # same path: it will be called from /opt/matlab/2023b/bin/matlab # but when the interpreter runs it will apparently see /compat/linux # as being its root directory ln -s /compat/linux/opt /opt # we're told it's nice to bind-mount /tmp , supposedly for X stuff, # although it seemed to be fine without this mount -t nullfs /tmp /compat/linux/tmp # if wanting our home to be seen directly despite the /compat/linux # looking like the root, then do a bind-type mount mkdir home/mydir mount -t nullfs /home/mydir /compat/linux/home/mydir # also, we should put an entry for our user-account into /compat/linux/etc/passwd # use of course the same login,uid,gid as in the system's (FreeBSD) /etc/passwd # this was found necessary in order to prevent a directory named '?' being created # in our pwd when running matlab, containing ?/.java/fonts # it was reasoned that ? was its (java/matlab/fontconfig) way of saying "I tried # looking up your homedir rather than simply trying $HOME, and I couldn't find it, # so I'm replacing $HOME with ? # with a suitable entry in the linux system's etc/passwd, it's always ~/.java/fonts # that gets the fontconfig files