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