/
postinstall.sh
191 lines (144 loc) · 4.27 KB
/
postinstall.sh
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
181
182
183
184
185
186
187
188
189
190
191
date > /etc/vagrant_box_build_time
#http://www.freebsd.org/doc/en_US.ISO8859-1/articles/remote-install/installation.html
dd if=/dev/zero of=/dev/ad4 count=2
#bsdlabel -w -B /dev/ad4
sysctl kern.geom.debugflags=16
#http://forum.nginx.org/read.php?23,146311,146451
# Init the disk with an MBR
gpart create -s mbr ad4
# Create a BSD container
gpart add -t freebsd ad4
# Init with a BSD scheme
gpart create -s bsd ad4s1
# 1GB for /
gpart add -t freebsd-ufs -s 1G ad4s1
gpart add -t freebsd-swap -s 2G ad4s1
# 2GB for swap
gpart add -t freebsd-ufs -s 2G ad4s1
# 2GB for /var
gpart add -t freebsd-ufs ad4s1
# all rest for /usr
#install bootcode
gpart bootcode -p /boot/boot -i 1 ad4s1
gpart set -a active -i ad4
cat <<EOF >/install.cfg
# This is the installation configuration file for our rackmounted FreeBSD
# cluster machines
# Turn on extra debugging.
debug=yes
#releaseName 8.0-RELEASE
################################
# My host specific data
#hostname=dragonfly
#domainname=cs.duke.edu
#nameserver=152.3.145.240
#defaultrouter=152.3.145.240
#ipaddr=152.3.145.64
#netmask=255.255.255.0
################################
tryDHCP=NO
################################
# Which installation device to use
# ftp://ftp.smr.ru/pub/0/FreeBSD/current/src/release/sysinstall/sysinstall.h
_ftpPath=ftp://ftp2.freebsd.org/pub/FreeBSD/
#_httpPath=ftp://ftp2.freebsd.org/pub/FreeBSD/
#httpProxy=192.168.2.10:800
netDev=em0
mediaSetFTP
#mediaSetHTTP
################################
################################
# Select which distributions we want.
#dists= bin doc games manpages catpages proflibs dict info des compat1x compat20 compat21 X331bin X331cfg X331doc X331html X331lib X331lkit X331man X331prog X331ps X331set X331VG16 X331nest X331vfb X331fnts X331f100 X331fcyr X331fscl X331fnon sinclude
#distSetCustom
distSetMinimum
################################
################################
# Now set the parameters for the partition editor on ad4.
disk=ad4
partition=all
#http://www.mail-archive.com/freebsd-questions@freebsd.org/msg212036.html
bootManager=standard
diskPartitionEditor
#diskPartitionWrite
################################
################################
# All sizes are expressed in 512 byte blocks!
#
# A 960MB root partition, followed by a 0.5G swap partition, followed by
# a 1G /var, and a /usr using all the remaining space on the disk
#
ad4s1-1=ufs 1966080 /mnt
ad4s1-2=swap 1048576 none
ad4s1-3=ufs 2097152 /mnt/var
ad4s1-4=ufs 0 /mnt/usr
# Let's do it!
diskLabelEditor
diskLabelCommit
#http://unix.derkeiler.com/Mailing-Lists/FreeBSD/questions/2010-11/msg00420.html
installRoot=/mnt
#
# OK, everything is set. Do it!
installCommit
# Install some packages at the end.
# package=LPRng-3.2.3
# packageAdd
# Install some packages at the end.
#
# this last package is special. It is used to configure the machine.
# it installs several files (like /root/.rhosts) an its installation
# script tweaks several options in /etc/rc.conf
#
#package=ari-0.0
#packageAdd
EOF
sysinstall configFile=/install.cfg loadConfig
#http://www.daemonforums.org/showthread.php?t=4389
cd /mnt/boot
cp -Rp GENERIC/* kernel/
#For some reason this is the disk layout the sysinstall creates
cat <<EOF > /mnt/etc/fstab
/dev/ad4s1b none swap sw 0 0
/dev/ad4s1d / ufs rw 0 0
/dev/ad4s1f /usr ufs rw 0 0
/dev/ad4s1e /var ufs rw 0 0
EOF
# boot0cfg -B ad4
#make the menu appear
# Booting mentions an error
# Invalid partition
# FAILS WITH: 0:ad(0,a)/boot/kernel/kernel
# WORKS WITH: 0:ad(4,d)/boot/loader
#http://www.mail-archive.com/freebsd-questions@freebsd.org/msg72530.html
cat <<EOF > /mnt/boot/loader.conf
#geom_label_load="YES"
#root_disk_unit="4"
#currdev="disk4s1d"
#rootdev="disk4s1d"
#vfs.root.mountfrom="ufs:/dev/ad4s1d"
EOF
#activate dhcp
cat <<EOF > /mnt/etc/rc.conf
ifconfig_DEFAULT="DHCP"
EOF
#The vi edit program needs a /var/tmp/vi.recover file.
mkdir -p /mnt/usr/local/etc/rc.d/
cd /mnt/usr/local/etc/rc.d/
cat <<EOF > mkvirecover
#!/bin/sh
# PROVIDE: mkvirecover
# REQUIRE: mountcritremote
# BEFORE: DAEMON virecover
. /etc/rc.subr
name="mkvirecover"
stop_cmd=":"
start_cmd="mkvirecover_start"
mkvirecover_start()
{
[ -d /var/tmp/vi.recover ] || mkdir -m 1777 /var/tmp/vi.recover
echo '.'
}
load_rc_config "\$name"
run_rc_command "\$1"
EOF
chmod 555 /mnt/usr/local/etc/rc.d/mkvirecover