7.3. Create virtual filesystem link targets

Create target-side directories and top-level links for runtime virtual filesystems, then mount them before entering chroot.

Goal: create $LBI_ROOT/system/devices, $LBI_ROOT/system/processes, $LBI_ROOT/system/system, and $LBI_ROOT/system/run, link top-level paths to them, and mount the runtime virtual filesystems.

This step prepares mount targets for runtime virtual filesystems in the custom tree layout before entering chroot.

All commands in this section should be run as root.

Create the target directories

mkdir -p "$LBI_ROOT/system/devices"
mkdir -p "$LBI_ROOT/system/processes"
mkdir -p "$LBI_ROOT/system/system"
mkdir -p "$LBI_ROOT/system/run"

mkdir -p "$LBI_ROOT/system/devices/pts"
mkdir -p "$LBI_ROOT/system/devices/shm"

Create top-level compatibility links

rm -f "$LBI_ROOT/dev"
rm -f "$LBI_ROOT/proc"
rm -f "$LBI_ROOT/sys"
rm -f "$LBI_ROOT/run"

ln -sf system/devices "$LBI_ROOT/dev"
ln -sf system/processes "$LBI_ROOT/proc"
ln -sf system/system "$LBI_ROOT/sys"
ln -sf system/run "$LBI_ROOT/run"

Mount virtual filesystems

mount -o bind /dev "$LBI_ROOT/dev"
mount -t devpts devpts "$LBI_ROOT/dev/pts" -o gid=5,mode=0620
mount -t proc proc "$LBI_ROOT/proc"
mount -t sysfs sysfs "$LBI_ROOT/sys"
mount -t tmpfs tmpfs "$LBI_ROOT/run"

if [ -h "$LBI_ROOT/dev/shm" ]; then
    install -d -m 1777 "$LBI_ROOT/system/run/shm"
else
    mount -t tmpfs -o nosuid,nodev tmpfs "$LBI_ROOT/dev/shm"
fi

POSIX sh helper script

A ready-to-run helper script is provided here:

Run it as root with LBI_ROOT exported in your environment.

Quick verification

ls -ld "$LBI_ROOT/dev" "$LBI_ROOT/proc" "$LBI_ROOT/sys" "$LBI_ROOT/run"

Command Explanations