xref: /freebsd/tools/tools/sysbuild/README (revision f39bffc62c1395bde25d152c7f68fdf7cbaab414)
1$FreeBSD$
2
3About sysbuild.sh
4=================
5
6I have been running -current on my laptop since before FreeBSD 2.0 was
7released and along the way developed this little trick to making the
8task easier.
9
10sysbuild.sh is a way to build a new FreeBSD system on a computer from
11a specification, while leaving the current installation intact.
12
13sysbuild.sh assume you have two partitions that can hold your rootfs
14and can be booted, and roughly speaking, all it does is build a new
15system into the one you don't use, from the one you do use.
16
17A partition named /freebsd is assumed to be part of your layout, and
18that is where the sources and ports will be found.
19
20If you know how nanobsd works, you will find a lot of similarity.
21
22HOWTO
23=====
24
25In all likelihood, it is easier if we imagine you start with a blank
26computer.
27
28Grab a FreeBSD install ISO and boot it.
29
30Create four disk slices:
31
32	ad0s1 = 5GB
33	ad0s2 = 5GB
34	ad0s3 = 5GB
35	ad0s4 = the rest
36
37Create a root filesystem in s1a filling the entire ad0s1 slice.
38
39Create a swap partition, if you want one, in ad0s4b.
40
41Install the boot0 bootmanager.
42
43Install the "Minimal" FreeBSD system into ad0s1a.
44
45Reboot from the newly installed system.
46
47Run these commands to set up the other partitions sysbuild.sh cares about:
48
49	# /freebsd filesystem
50	newfs -b 4096 -f 512 -O2 -U /dev/ad0s3
51	echo "/dev/ad0s3 /freebsd ufs rw 2 2" >> /etc/fstab
52	mkdir /freebsd
53	mount /freebsd
54
55	# deputy rootfilesystem
56	bsdlabel -B -w /dev/ad0s2
57	newfs -O2 -U /dev/ad0s2a
58
59Next, install ports and sources:
60
61	cd /usr
62	rm -rf ports src
63	ln -s /freebsd/src
64	ln -s /freebsd/ports
65	cd /freebsd
66	mkdir ports src packages
67
68	svn co https://svn0.us-east.FreeBSD.org/base/stable/10 src
69	svn co https://svn0.us-east.FreeBSD.org/ports/head ports
70
71And we should be ready to try a shot:
72
73	cd /root
74	cp /usr/src/tools/tools/sysbuild/sysbuild.sh .
75	sh sysbuild.sh |& tee _.sb
76
77If it succeeds, you should be able to:
78
79	boot0cfg -s 2 -v /dev/ad0
80	reboot
81
82And come up with your newly built system.
83
84	Next time you want a new system, you just run sysbuild.sh again
85	and boot slice 1 when it's done.
86
87TWEAKS
88======
89
90The sysbuild.sh script takes various parameters:
91
92	-c specfile	# configure stuff, see below.
93	-w		# skip buildworld, assume it was done earlier.
94	-k		# skip buildkernel, ---//---
95	-b		# skip both buildworld & buildkernel
96	-p		# install cached packacges if found.
97
98The specfile is a shellscript where you can override or set a number of
99shell variables and functions.
100
101A partial example:
102
103	# use a kernel different from GENERIC
104	KERNCONF=SMP
105
106	# Cache built packages, so we can use -p
107	PKG_DIR=/freebsd/packages
108
109	# Mount ports distfiles from another machine
110	REMOTEDISTFILES=fs:/rdonly/distfiles
111
112	# Fetch distfiles through a proxy
113	FTP_PROXY=http://127.0.0.1:3128/
114	HTTP_PROXY=http://127.0.0.1:3128/
115	export FTP_PROXY HTTP_PROXY
116
117	# We want these ports
118	PORTS_WE_WANT='
119		/usr/ports/archivers/unzip
120		/usr/ports/archivers/zip
121		/usr/ports/cad/linux-eagle
122		/usr/ports/comms/lrzsz
123		/usr/ports/databases/rrdtool
124		/usr/ports/devel/subversion-freebsd
125	'
126
127	# Files to move over
128	CONFIGFILES='
129		/root/.ssh
130		/etc/X11/xorg.conf
131		/etc/ssh/ssh_host*
132		/etc/rc.conf
133		/etc/rc.local
134	'
135
136	# Shell functions to tweak things
137	# (This makes commits to /etc mostly painless)
138	final_chroot() (
139		chpass -p "\$1\$IgMjWs2L\$Nu12OCsjfiwHHj0I7TmUN1" root
140
141		pw useradd phk -u 488 -d /home/phk -c "Poul-Henning Kamp" \
142		    -G "wheel,operator,dialer" -s /bin/csh -w none
143
144		chpass -p "\$1\$VcM.9Ow8\$IcXHs0h9jsk27b8N64lOm/" phk
145
146		sed -i "" -e 's/^DS/DSorigo.freebsd.dk/' /etc/mail/sendmail.cf
147		sed -i "" -e '/console/s/^/#/' /etc/syslog.conf
148		echo "beastie_disable=YES" >> /boot/loader.conf
149		touch /root/.hushlogin
150	)
151
152
153