general/other I made a small script that adds Linuxulator FSTAB entries

Linux binary compatabilty allows running Linux binaries on FreeBSD8+, and with the "debbootstrap" program (and please read the entire documentation) you can run binaries that are binary compatible with distributions such as Ubuntu and Debian, and I think theres recent versions of CentOS, as documented in chapter 12.3.3 in the Linux Binary Emulation section in the documentation

Had a rough night, but I can share the script

Basically, you can read the documentation on setting up Linux Binary Compatibility and when needed, this script will take the checked first argument the script, and add all entries *noted on the documentation, which includes a mount of the home directory on $LINUX_DIR's variable*

*if you do rm -rf $LINUX_DIR/home it will in fact erase your entire home directory, not the users home directory, the entire /home folder on the root partition*

*PLEASE READ THIS SCRIPT FIRST BEFORE USING, stuff like awk (like if awk { print $0 } == $LINUX_DIR/devfs then echo "entries found"*

you can add it but im on my way to bed

Here's the script, I tried to add as many conditions where it checks data before writing to disk, but you're free to use it for your needs


#!/bin/sh

echo ""
echo "PLEASE READ THE SCRIPT SOURCE"
echo "MODIFY FSTAB_FILE TO FSTAB FILE"
echo "MODIFY LINUX_NAME AND LINUX_DIR"
echo ""

echo "PLEASE ONLY RUN ONCE WHEN CONFIGURED"
echo "OR YOU WILL HAVE TO CLEAN UP YOUR FSTAB_FILE"
echo ""
echo "FOR INSTRUCTIONS ON SETTING UP LINUX BINARY COMPATABILITY"
echo "--> https://docs.freebsd.org/en/books/handbook/linuxemu/"
echo ""

FSTAB_FILE=/root/temp
LINUX_NAME=$1
LINUX_DIR=/linux/$LINUX_NAME
# outputs first argument of the bash script and sets another variable
# to the directory of the emu

if [ "$LINUX_NAME" != "" ]; then
if [ -d "$LINUX_DIR" ]; then
echo "directory found"
echo "devfs $LINUX_DIR/dev devfs" >> $FSTAB_FILE
echo "tmpfs $LINUX_DIR/dev/shm tmpfs" >> $FSTAB_FILE
echo "fdescfs $LINUX_DIR/dev/fd fdescfs" >> $FSTAB_FILE
echo "linprocfs $LINUX_DIR/proc linprocfs" >> $FSTAB_FILE
echo "linsysfs $LINUX_DIR/sys linsysfs" >> $FSTAB_FILE
echo "/tmp $LINUX_DIR/tmp nullfs" >> $FSTAB_FILE
echo "/home $LINUX_DIR/home nullfs" >> $FSTAB_FILE
echo ""


echo "WARNING : $LINUX_DIR/home IS LINKED TO THE *ACTUAL* "
echo "HOME DIRECTORY THAT IS ON THE ROOT PARTITION"

else


echo "directory not found"

fi

else

echo "directory does not exist"
echo "please update LINUX_NAME and LINUX DIR"
fi

#echo "todo"
#echo "use awk/sed to parse FSTAB_FILE to check if entries are there"

This is useful for multiple versions of Linux and they should reside in the /linux directory !!
 
They're automatically mounted with linux_enable="YES" (linux_mounts_enable defaults to "YES"), see /etc/rc.d/linux:
Code:
        if checkyesno linux_mounts_enable; then
                linux_mount linprocfs "${_emul_path}/proc" -o nocover
                linux_mount linsysfs "${_emul_path}/sys" -o nocover
                linux_mount devfs "${_emul_path}/dev" -o nocover
                linux_mount fdescfs "${_emul_path}/dev/fd" -o nocover,linrdlnk
                linux_mount tmpfs "${_emul_path}/dev/shm" -o nocover,mode=1777
        fi
 
Back
Top