1# $NetBSD: evbmips.conf,v 1.1 2020/07/17 15:16:34 jmcneill Exp $ 2# evbmips shared config 3# 4image=$HOME/${board}.img 5 6MACHINE=evbmips 7 8extra=48 # spare space 9init=32 10boot=$((192 - ${init})) 11ffsoffset=$(( (${init} + ${boot}) / 2 ))m 12 13size=0 # autocompute 14msdosid=12 15 16if $gpt; then 17 partition_type="gpt" 18else 19 partition_type="disklabel" 20fi 21 22mkdir -p ${mnt}/boot 23 24make_label_evbmips() { 25 # compute all sizes in terms of sectors 26 local totalsize=$(( ${newsize} * 1024 * 2 / 512 )) 27 28 local bootsize=$(( ${boot} * 1024 )) 29 30 local bootoffset=$(( ${init} * 1024 )) 31 32 local asize=$(( ${totalsize} - ${bootsize} - ${bootoffset} )) 33 local aoffset=$(( ${bootoffset} + ${bootsize} )) 34 35 local bps=512 36 local spt=32 37 local tpc=64 38 local spc=2048 39 local cylinders=$(( ${totalsize} / ${spc} )) 40 41 cat << EOF 42type: SCSI 43disk: STORAGE DEVICE 44label: fictitious 45flags: removable 46bytes/sector: ${bps} 47sectors/track: ${spt} 48tracks/cylinder: ${tpc} 49sectors/cylinder: ${spc} 50cylinders: ${cylinders} 51total sectors: ${totalsize} 52rpm: 3600 53interleave: 1 54trackskew: 0 55cylinderskew: 0 56headswitch: 0 # microseconds 57track-to-track seek: 0 # microseconds 58drivedata: 0 59 608 partitions: 61# size offset fstype [fsize bsize cpg/sgs] 62 a: ${asize} ${aoffset} 4.2BSD ${fsize} ${bsize} 0 # 63 c: ${totalsize} 0 unused 0 0 # 64 e: ${bootsize} ${bootoffset} MSDOS # 65EOF 66} 67 68make_fstab_evbmips_gpt() { 69 cat > ${mnt}/etc/fstab << EOF 70# NetBSD /etc/fstab 71# See /usr/share/examples/fstab/ for more examples. 72NAME=${gpt_label_ffs:-netbsd-root} / ffs rw,noatime 1 1 73NAME=${gpt_label_boot:-boot} /boot msdos rw 1 1 74kernfs /kern kernfs rw 75ptyfs /dev/pts ptyfs rw 76procfs /proc procfs rw 77tmpfs /var/shm tmpfs rw,-m1777,-sram%25 78EOF 79} 80 81make_fstab_evbmips_normal() { 82 cat > ${mnt}/etc/fstab << EOF 83# NetBSD /etc/fstab 84# See /usr/share/examples/fstab/ for more examples. 85ROOT.a / ffs rw,noatime 1 1 86ROOT.e /boot msdos rw 1 1 87kernfs /kern kernfs rw 88ptyfs /dev/pts ptyfs rw 89procfs /proc procfs rw 90tmpfs /var/shm tmpfs rw,-m1777,-sram%25 91EOF 92} 93 94# From Richard Neswold's: 95# http://rich-tbp.blogspot.com/2013/03/netbsd-on-rpi-minimizing-disk-writes.html 96# Also for the postfix stuff below 97make_fstab_evbmips_minwrites() { 98 cat > ${mnt}/etc/fstab << EOF 99# NetBSD /etc/fstab 100# See /usr/share/examples/fstab/ for more examples. 101ROOT.a / ffs rw,log,noatime,nodevmtime 1 1 102ROOT.e /boot msdos rw 1 1 103kernfs /kern kernfs rw 104ptyfs /dev/pts ptyfs rw 105procfs /proc procfs rw 106tmpfs /tmp tmpfs rw,-s32M 107tmpfs /var/log tmpfs rw,union,-s32M 108tmpfs /var/run tmpfs rw,union,-s1M 109tmpfs /var/mail tmpfs rw,union,-s10M 110tmpfs /var/spool/postfix tmpfs rw,union,-s20M 111tmpfs /var/db/postfix tmpfs rw,union,-s1M 112tmpfs /var/chroot tmpfs rw,union,-s10M 113tmpfs /var/shm tmpfs rw,-m1777,-sram%25 114EOF 115} 116 117make_fstab_evbmips() { 118 if $gpt; then 119 make_fstab_evbmips_gpt 120 elif $minwrites; then 121 make_fstab_evbmips_minwrites 122 else 123 make_fstab_evbmips_normal 124 fi 125 echo "./etc/fstab type=file uname=root gname=wheel mode=0644" \ 126 >> "$tmp/selected_sets" 127 128 # Missing mount points from fstab 129 echo "./proc type=dir uname=root gname=wheel mode=0755" \ 130 >> "$tmp/selected_sets" 131 echo "./kern type=dir uname=root gname=wheel mode=0755" \ 132 >> "$tmp/selected_sets" 133} 134 135customize_evbmips() { 136 if $minwrites; then 137 mkdir ${mnt}/etc/postfix 138 (umask 022 139 sed -e 's/fifo/unix/' < ${release}/etc/postfix/master.cf > \ 140 ${mnt}/etc/postfix/master.cf) 141 fi 142 143 cp ${release}/etc/rc.conf ${mnt}/etc/rc.conf 144 cat >> ${mnt}/etc/rc.conf << EOF 145dev_exists() { 146 if /sbin/drvctl -l \$1 >/dev/null 2>&1 ; then 147 printf YES 148 else 149 printf NO 150 fi 151} 152 153rc_configured=YES 154hostname=${hostname:-${board}} 155no_swap=YES 156savecore=NO 157sshd=YES 158dhcpcd=YES 159ntpd=YES 160ntpd_flags="-g" 161creds_msdos=YES 162creds_msdos_partition=/boot 163EOF 164 165 if $resize; then 166 cat >> ${mnt}/etc/rc.conf << EOF 167resize_${partition_type}=YES 168resize_root=YES 169resize_root_flags="-p" 170resize_root_postcmd="/sbin/reboot -n" 171EOF 172 fi 173 174 echo "./etc/rc.conf type=file uname=root gname=wheel mode=0644" \ 175 >> "$tmp/selected_sets" 176 177 mkdir ${mnt}/etc/rc.d 178 for _f in resize_${partition_type} creds_msdos; do 179 cp ${DIR}/files/${_f} ${mnt}/etc/rc.d/${_f} 180 echo "./etc/rc.d/${_f} type=file uname=root gname=wheel mode=0555" \ 181 >> "$tmp/selected_sets" 182 done 183 184 if [ ! -f ${release}/dev/MAKEDEV ]; then 185 echo ${PROG}: Missing ${release}/dev/MAKEDEV 1>&2 186 exit 1 187 fi 188 echo "${bar} running MAKEDEV ${bar}" 189 ${HOST_SH} ${release}/dev/MAKEDEV -s all | sed -e 's:^\./:\./dev/:' \ 190 >> "$tmp/selected_sets" 191 192 echo "${bar} fixing up permissions" 193 echo "./boot type=dir uname=root gname=wheel mode=0755" \ 194 >> "$tmp/selected_sets" 195} 196