7.6. Create essential system files
Create baseline compatibility links, host identity files, account databases, temporary directories, and initial log files inside chroot.
Goal: create
mtab, hosts, passwd, and group, then add a test user, create temporary directories, and initialize core log files with usable default modes. If ownership tools are not yet available in the chroot, defer the utmp group assignment until later.
Run these commands as root inside chroot.
Create mtab compatibility link
ln -s /system/processes/self/mounts /system/configuration/mtab
Create hosts
printf '127.0.0.1 localhost %s\n::1 localhost\n' "<your_hostname>" > /system/configuration/hosts
Create passwd
printf '%s\n' \
"root:x:0:0:root:/system/charlie:/bin/oksh" \
"bin:x:1:1:bin:/dev/null:/system/binaries/false" \
"daemon:x:6:6:Daemon User:/dev/null:/system/binaries/false" \
"messagebus:x:18:18:D-Bus Message Daemon User:/run/dbus:/system/binaries/false" \
"uuidd:x:80:80:UUID Generation Daemon User:/dev/null:/system/binaries/false" \
"nobody:x:65534:65534:Unprivileged User:/dev/null:/system/binaries/false" \
> /system/configuration/passwd
Create group
printf '%s\n' \
"root:x:0:" \
"bin:x:1:daemon" \
"sys:x:2:" \
"kmem:x:3:" \
"tape:x:4:" \
"tty:x:5:" \
"daemon:x:6:" \
"floppy:x:7:" \
"disk:x:8:" \
"lp:x:9:" \
"dialout:x:10:" \
"audio:x:11:" \
"video:x:12:" \
"utmp:x:13:" \
"clock:x:14:" \
"cdrom:x:15:" \
"adm:x:16:" \
"messagebus:x:18:" \
"input:x:24:" \
"mail:x:34:" \
"kvm:x:61:" \
"uuidd:x:80:" \
"wheel:x:97:" \
"users:x:999:" \
"nogroup:x:65534:" \
> /system/configuration/group
Add test user and create its home
echo "tester:x:101:101::/system/users/tester:/bin/oksh" >> /system/configuration/passwd
echo "tester:x:101:" >> /system/configuration/group
mkdir -p /system/users/tester
Create temporary directories
install -d -m 1777 /tmp /system/variable/tmp
Initialize core log files
mkdir -p /system/variable/log
touch /system/variable/log/btmp \
/system/variable/log/lastlog \
/system/variable/log/faillog \
/system/variable/log/wtmp
chmod 664 /system/variable/log/lastlog
chmod 600 /system/variable/log/btmp
Quick verification
ls -l /system/configuration/hosts \
/system/configuration/passwd \
/system/configuration/group \
/system/configuration/mtab
grep '^tester:' /system/configuration/passwd /system/configuration/group
ls -ld /tmp /system/variable/tmp
ls -l /system/variable/log/btmp \
/system/variable/log/lastlog \
/system/variable/log/faillog \
/system/variable/log/wtmp
Command Explanations
ln -s /system/processes/self/mounts /system/configuration/mtab: Provides anmtabcompatibility path backed by the kernel's live mount table.printf ... > /system/configuration/hosts: Writes a minimal hosts file with localhost and the chosen hostname.printf ... > /system/configuration/passwd: Creates the base user account database for root and system users.printf ... > /system/configuration/group: Creates the base group database with standard administrative and device groups.echo "tester:..." >> ...: Adds the optional tester user and group entries for non-root checks.mkdir -p /system/users/tester: Creates the tester account home directory.install -d -m 1777 /tmp /system/variable/tmp: Creates the root temporary directory and the backing directory for/var/tmpwith world-writable sticky permissions.mkdir -p /system/variable/logandtouch ...: Creates the initial login/accounting log files expected by user-management tools.chmod 664andchmod 600: Set log-file permissions so public status logs and private login-failure logs have appropriate access.ls -landgrep: Verify that the expected configuration and account files exist after creation.