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