1#!/bin/sh - 2# 3# Copyright (c) 1992, 1993 4# The Regents of the University of California. All rights reserved. 5# 6# %sccs.include.redist.sh% 7# 8# @(#)get 8.2 (Berkeley) 11/30/93 9# 10 11# Shell script to build a mini-root file system in preparation for building 12# a distribution tape. The file system created here is image copied onto 13# tape, then image copied onto disk as the "first" step in a cold boot of 14# 4.3BSD systems. 15# 16DISTROOT= 17# 18if [ `pwd` = '/' ] 19then 20 echo You just '(almost)' destroyed the root 21 exit 22fi 23 24# copy in kernel 25cp $DISTROOT/sys/compile/GENERIC.pmax/vmunix . 26 27# create necessary directories 28DIRLIST="bin dev etc a tmp stand sbin usr usr/mdec" 29rm -rf $DIRLIST 30mkdir $DIRLIST 31 32ETC="disktab services" 33for i in $ETC; do 34 cp $DISTROOT/etc/$i etc/$i 35done 36 37SBIN="disklabel fsck ifconfig init mknod mount newfs restore umount" 38USBIN="pwd_mkdb" 39for i in $SBIN; do 40 cp $DISTROOT/sbin/$i sbin/$i 41done 42for i in $USBIN; do 43 cp $DISTROOT/usr/sbin/$i sbin/$i 44done 45ln sbin/restore sbin/rrestore 46 47BIN="[ cat cp dd echo ed expr ls mkdir mv pax rcp rm sh stty sync" 48UBIN="awk mt" 49for i in $BIN; do 50 cp $DISTROOT/bin/$i bin/$i 51done 52for i in $UBIN; do 53 cp $DISTROOT/usr/bin/$i bin/$i 54done 55ln bin/[ bin/test 56 57MDEC="rzboot bootrz" 58for i in $MDEC; do 59 cp $DISTROOT/usr/mdec/$i usr/mdec/$i 60done 61 62DOT=".profile" 63for i in $DOT; do 64 cp $DISTROOT/$i $i 65done 66 67# initialize /dev 68cp $DISTROOT/dev/MAKEDEV dev/MAKEDEV 69chmod +x dev/MAKEDEV 70cp /dev/null dev/MAKEDEV.local 71(cd dev; ./MAKEDEV std dc0 scc0 rz0 rz1 rz2 rz3 rz4 tz0 tz1 \ 72 pm0 cfb0 xcfb0 mfb0 pty0) 73 74# initialize /etc/passwd 75cat >etc/passwd <<EOF 76root::0:0::/:/bin/sh 77daemon:*:1:1::/: 78EOF 79cat >etc/master.passwd <<EOF 80root::0:0::0:0::/:/bin/sh 81daemon:*:1:1::0:0::/root: 82EOF 83 84# initialize /etc/group 85cat >etc/group <<EOF 86system:*:0: 87daemon:*:1: 88uucp:*:2: 89kmem:*:3: 90bin:*:4: 91news:*:8: 92staff:*:10: 93operator:*:28: 94EOF 95 96# initialize /etc/fstab 97cat >etc/fstab <<EOF 98/dev/rz0a / ufs rw 1 1 99/dev/rz0g /usr ufs xx 1 2 100EOF 101 102# create xtr script 103cat >xtr <<'EOF' 104#!/bin/sh -e 105: ${disk?'Usage: disk=xx0 tape=yy0 [type=zz] xtr'} 106: ${tape?'Usage: disk=xx0 tape=yy0 [type=zz] xtr'} 107echo 'Build root file system' 108disklabel -W /dev/r${disk}c ${type} 109disklabel -w -r -B /dev/r${disk}c ${type} 110newfs /dev/r${disk}a ${type} 111sync 112mount -u / 113echo 'Check the file system' 114fsck /dev/r${disk}a 115mount /dev/${disk}a /a 116cd /a 117echo 'Rewind tape' 118mt -f /dev/${tape} rew 119echo 'Restore the dump image of the root' 120restore rsf 2 /dev/${tape} 121cd / 122sync 123umount /a 124sync 125fsck /dev/r${disk}a 126echo 'Root filesystem extracted' 127EOF 128 129# make xtr script executable 130chmod +x xtr 131 132sync 133