1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
|
#!/bin/sh
set -x
:
: Controlled panic
:
sysctl -w ddb.onpanic=0
sysctl -w ddb.lines=0
:
: Make /tmp writable.
:
mount -t tmpfs tmpfs /tmp
touch /tmp/foo
:
: Initialize the disk creating a single DOS NetBSD partition.
:
dd count=2 if=/dev/zero of=/dev/ld0
fdisk -f -i ld0
fdisk -f -0 -a -s 169 -u ld0
fdisk ld0
:
: Now create the NetBSD partitions within that.
:
# By default NetBSD generates a label with everything in e:, switch it
# to a:. And use that as the root file system. Don't bother with
# swap.
disklabel ld0 > /tmp/ld0.label || echo disklabel barfed 2
sed -i -e "s/ e:/ a:/" /tmp/ld0.label
disklabel -R -r ld0 /tmp/ld0.label
newfs /dev/ld0a
:
: Enable booting of the first or zero partition.
:
# The MBR is installed into front of the disk; the NetBSD partition is
# made active; and finally install secondary boot and boot-blocks are
# installed into the just built root file system.
#
# Should (can) speed be changed, 9600 is so retro?
fdisk -f -0 -a ld0
fdisk -f -c /usr/mdec/mbr_com0 ld0
mount -o async /dev/ld0a /targetroot
cp /usr/mdec/boot /targetroot/boot # file: /boot not /boot/
umount /targetroot
dumpfs /dev/ld0a | grep format # expect FFSv1
installboot -v -o console=com0,timeout=5,speed=9600 /dev/rld0a /usr/mdec/bootxx_ffsv1
:
: Unpack the files into the root file system.
:
mount -o async /dev/ld0a /targetroot
touch /targetroot/.
sets=/mnt/$(uname -m)/binary/sets
case $(uname -m) in
i386 ) tgz=tgz ;;
* ) tgz=tar.xz ;;
esac
ls ${sets}
for f in ${sets}/[a-jl-z]*.${tgz} ${sets}/[a-jl-z]*.${tgz} ; do
if test -r "${f}" ; then
echo $f
( cd /targetroot && tar xpf ${f} )
fi
done
# Generating the ISO seems to, sometimes, corrupt the name.
for f in kern-GENERIC.${tgz} kern_generic.${tgz} ; do
k=${sets}/${f}
if test -r ${k} ; then
( cd /targetroot && tar xpvf ${k} )
break
fi
done
:
: Set up the mount points
:
mkdir /targetroot/kern /targetroot/proc /targetroot/pool /targetroot/bench
cat <<EOF | tee /targetroot/etc/fstab
ROOT.a / ffs rw,noatime 1 1
kernfs /kern kernfs rw
ptyfs /dev/pts ptyfs rw
procfs /proc procfs rw
tmpfs /var/shm tmpfs rw,-m1777,-sram%25
tmpfs /tmp tmpfs rw
@@GATEWAY@@:@@POOLDIR@@ /pool nfs rw
@@GATEWAY@@:@@BENCHDIR@@ /bench nfs rw
EOF
:
: run post install
:
# opensslcertsrehash needs /dev populated
( cd /targetroot/dev && ./MAKEDEV all )
# postinstall needs these
cp ${sets}/etc.${tgz} /targetroot/var/tmp
cp ${sets}/xetc.${tgz} /targetroot/var/tmp
# opensslcertsreahsh only works with /
chroot /targetroot postinstall -s /var/tmp/etc.${tgz} -s /var/tmp/xetc.${tgz} fix
# also blank out TOOR's password as backup?
# c("echo swan | pwhash |sed -e 's/[\$\/\\]/\\\$/g' | tee /tmp/pwd")
# sed -i -e "s/root:[^:]*:/root:$(cat /tmp/pwd):/" /etc/master.passwd
# sed -i -e "s/toor:[^:]*:/toor::/" /etc/master.passwd
:
: Setup the network to use DHCP on eth0
:
cat <<EOF | tee -a /targetroot/etc/rc.conf
. /etc/defaults/rc.conf
rc_configured=YES
no_swap=YES
savecore=NO
EOF
cat <<EOF | tee /targetroot/etc/ifconfig.vioif0
dhcp
EOF
cat <<EOF | tee /targetroot/etc/myname
netbsd
EOF
:
: Fix SHELL prompt
:
#
# Change the shell prompt to [USER@HOST PWD STATUS]# so it works with
# the make files.
#
cat <<EOF | tee /targetroot/root/.shrc
case "\$-" in
*i*)
if /bin/test -z "\${HOST}"; then
HOST=\$(hostname)
fi
set -E emacs
set -o tabcomplete
set -o promptcmds
PS1='['"\${USER}@\${HOST%%.*}"' \$(s=\$?;p=\${PWD##*/};echo \${p:-/} \${s#0})]# '
;;
esac
EOF
:
: tweak sysctl
:
echo ddb.lines=0 >> /targetroot/etc/sysctl.conf
:
: Cleanup and shutdown
:
umount /targetroot
umount /mnt
|