evbarm.conf revision 1.40 1 1.40 jmcneill # $NetBSD: evbarm.conf,v 1.40 2022/10/15 18:32:30 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.38 rin local totalsize=$(( ${size} / 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 ptyfs /dev/pts ptyfs rw
75 1.35 jmcneill procfs /proc procfs rw
76 1.35 jmcneill tmpfs /var/shm tmpfs rw,-m1777,-sram%25
77 1.35 jmcneill EOF
78 1.35 jmcneill }
79 1.35 jmcneill
80 1.11 christos make_fstab_evbarm_normal() {
81 1.5 christos cat > ${mnt}/etc/fstab << EOF
82 1.1 christos # NetBSD /etc/fstab
83 1.1 christos # See /usr/share/examples/fstab/ for more examples.
84 1.30 jmcneill ROOT.a / ffs rw,noatime 1 1
85 1.30 jmcneill ROOT.e /boot msdos rw 1 1
86 1.1 christos ptyfs /dev/pts ptyfs rw
87 1.1 christos procfs /proc procfs rw
88 1.19 jmcneill tmpfs /var/shm tmpfs rw,-m1777,-sram%25
89 1.1 christos EOF
90 1.1 christos }
91 1.1 christos
92 1.11 christos # From Richard Neswold's:
93 1.11 christos # http://rich-tbp.blogspot.com/2013/03/netbsd-on-rpi-minimizing-disk-writes.html
94 1.11 christos # Also for the postfix stuff below
95 1.11 christos make_fstab_evbarm_minwrites() {
96 1.11 christos cat > ${mnt}/etc/fstab << EOF
97 1.11 christos # NetBSD /etc/fstab
98 1.11 christos # See /usr/share/examples/fstab/ for more examples.
99 1.30 jmcneill ROOT.a / ffs rw,log,noatime,nodevmtime 1 1
100 1.30 jmcneill ROOT.e /boot msdos rw 1 1
101 1.11 christos ptyfs /dev/pts ptyfs rw
102 1.11 christos procfs /proc procfs rw
103 1.11 christos tmpfs /tmp tmpfs rw,-s32M
104 1.11 christos tmpfs /var/log tmpfs rw,union,-s32M
105 1.11 christos tmpfs /var/run tmpfs rw,union,-s1M
106 1.11 christos tmpfs /var/mail tmpfs rw,union,-s10M
107 1.11 christos tmpfs /var/spool/postfix tmpfs rw,union,-s20M
108 1.11 christos tmpfs /var/db/postfix tmpfs rw,union,-s1M
109 1.11 christos tmpfs /var/chroot tmpfs rw,union,-s10M
110 1.19 jmcneill tmpfs /var/shm tmpfs rw,-m1777,-sram%25
111 1.11 christos EOF
112 1.11 christos }
113 1.11 christos
114 1.11 christos make_fstab_evbarm() {
115 1.35 jmcneill if $gpt; then
116 1.35 jmcneill make_fstab_evbarm_gpt
117 1.35 jmcneill elif $minwrites; then
118 1.11 christos make_fstab_evbarm_minwrites
119 1.11 christos else
120 1.11 christos make_fstab_evbarm_normal
121 1.11 christos fi
122 1.18 skrll echo "./etc/fstab type=file uname=root gname=wheel mode=0644" \
123 1.18 skrll >> "$tmp/selected_sets"
124 1.20 skrll
125 1.20 skrll # Missing mount points from fstab
126 1.20 skrll echo "./proc type=dir uname=root gname=wheel mode=0755" \
127 1.20 skrll >> "$tmp/selected_sets"
128 1.11 christos }
129 1.11 christos
130 1.1 christos customize_evbarm() {
131 1.11 christos if $minwrites; then
132 1.11 christos mkdir ${mnt}/etc/postfix
133 1.11 christos (umask 022
134 1.11 christos sed -e 's/fifo/unix/' < ${release}/etc/postfix/master.cf > \
135 1.11 christos ${mnt}/etc/postfix/master.cf)
136 1.11 christos fi
137 1.27 hubertf
138 1.27 hubertf cp ${release}/etc/rc.conf ${mnt}/etc/rc.conf
139 1.5 christos cat >> ${mnt}/etc/rc.conf << EOF
140 1.31 jmcneill dev_exists() {
141 1.32 jmcneill if /sbin/drvctl -l \$1 >/dev/null 2>&1 ; then
142 1.31 jmcneill printf YES
143 1.31 jmcneill else
144 1.31 jmcneill printf NO
145 1.31 jmcneill fi
146 1.31 jmcneill }
147 1.31 jmcneill
148 1.40 jmcneill is_cloud() {
149 1.40 jmcneill ret=NO
150 1.40 jmcneill
151 1.40 jmcneill # AWS EC2
152 1.40 jmcneill if [ "\$(dev_exists ena0)" = "YES" ]; then
153 1.40 jmcneill ret=YES
154 1.40 jmcneill fi
155 1.40 jmcneill
156 1.40 jmcneill # Oracle OCI
157 1.40 jmcneill case "\$(/sbin/sysctl -n machdep.dmi.chassis-asset-tag)" in
158 1.40 jmcneill OracleCloud*)
159 1.40 jmcneill ret=YES
160 1.40 jmcneill ;;
161 1.40 jmcneill esac
162 1.40 jmcneill
163 1.40 jmcneill printf \$ret
164 1.40 jmcneill }
165 1.40 jmcneill
166 1.7 jmcneill rc_configured=YES
167 1.36 jmcneill hostname=${hostname:-${board}}
168 1.34 jmcneill no_swap=YES
169 1.34 jmcneill savecore=NO
170 1.1 christos sshd=YES
171 1.1 christos dhcpcd=YES
172 1.16 jmcneill ntpd=YES
173 1.16 jmcneill ntpd_flags="-g"
174 1.33 mrg creds_msdos=YES
175 1.33 mrg creds_msdos_partition=/boot
176 1.1 christos EOF
177 1.21 jmcneill
178 1.21 jmcneill if $resize; then
179 1.21 jmcneill cat >> ${mnt}/etc/rc.conf << EOF
180 1.35 jmcneill resize_${partition_type}=YES
181 1.21 jmcneill resize_root=YES
182 1.22 jmcneill resize_root_flags="-p"
183 1.21 jmcneill resize_root_postcmd="/sbin/reboot -n"
184 1.21 jmcneill EOF
185 1.21 jmcneill fi
186 1.21 jmcneill
187 1.20 skrll echo "./etc/rc.conf type=file uname=root gname=wheel mode=0644" \
188 1.20 skrll >> "$tmp/selected_sets"
189 1.20 skrll
190 1.21 jmcneill mkdir ${mnt}/etc/rc.d
191 1.35 jmcneill for _f in resize_${partition_type} creds_msdos; do
192 1.33 mrg cp ${DIR}/files/${_f} ${mnt}/etc/rc.d/${_f}
193 1.33 mrg echo "./etc/rc.d/${_f} type=file uname=root gname=wheel mode=0555" \
194 1.33 mrg >> "$tmp/selected_sets"
195 1.33 mrg done
196 1.21 jmcneill
197 1.5 christos if [ ! -f ${release}/dev/MAKEDEV ]; then
198 1.5 christos echo ${PROG}: Missing ${release}/dev/MAKEDEV 1>&2
199 1.1 christos exit 1
200 1.1 christos fi
201 1.1 christos echo "${bar} running MAKEDEV ${bar}"
202 1.13 skrll ${HOST_SH} ${release}/dev/MAKEDEV -s all | sed -e 's:^\./:\./dev/:' \
203 1.13 skrll >> "$tmp/selected_sets"
204 1.8 jmcneill
205 1.18 skrll echo "${bar} fixing up permissions"
206 1.18 skrll echo "./boot type=dir uname=root gname=wheel mode=0755" \
207 1.18 skrll >> "$tmp/selected_sets"
208 1.1 christos }
209