xref: /freebsd/tools/tools/sysbuild/README (revision 39beb93c3f8bdbf72a61fda42300b5ebed7390c8)
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 likelyhood, 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	# Or use svn if you prefer
69	csup -h cvsup.???.freebsd.org /usr/share/examples/cvsup/ports-supfile
70	csup -h cvsup.???.freebsd.org /usr/share/examples/cvsup/stable-supfile
71
72And we should be ready to try a shot:
73
74	cd /root
75	cp /usr/src/tools/tools/sysbuild/sysbuild.sh .
76	sh sysbuild.sh |& tee _.sb
77
78If it succeeds, you should be able to:
79
80	boot0cfg -s 2 -v /dev/ad0
81	reboot
82
83And come up with your newly built system.
84
85	Next time you want a new system, you just run sysbuild.sh again
86	and boot slice 1 when it's done.
87
88TWEAKS
89======
90
91The sysbuild.sh script takes various parameters:
92
93	-c specfile	# configure stuff, see below.
94	-w		# skip buildworld, assume it was done earlier.
95	-k		# skip buildkernel, ---//---
96	-b		# skip both buildworld & buildkernel
97	-p		# install cached packacges if found.
98
99The specfile is a shellscript where you can override or set a number of
100shell variables and functions.
101
102A partial example:
103
104	# use a kernel different from GENERIC
105	KERNCONF=SMP
106
107	# Cache built packages, so we can use -p
108	PKG_DIR=/freebsd/packages
109
110	# Mount ports distfiles from another machine
111	REMOTEDISTFILES=fs:/rdonly/distfiles
112
113	# Fetch distfiles through a proxy
114	FTP_PROXY=http://127.0.0.1:3128/
115	HTTP_PROXY=http://127.0.0.1:3128/
116	export FTP_PROXY HTTP_PROXY
117
118	# We want these ports
119	PORTS_WE_WANT='
120		/usr/ports/archivers/unzip
121		/usr/ports/archivers/zip
122		/usr/ports/cad/linux-eagle
123		/usr/ports/comms/lrzsz
124		/usr/ports/databases/rrdtool
125		/usr/ports/devel/subversion-freebsd
126	'
127
128	# Files to move over
129	CONFIGFILES='
130		/root/.ssh
131		/etc/X11/xorg.conf
132		/etc/ssh/ssh_host*
133		/etc/rc.conf
134		/etc/rc.local
135	'
136
137	# Shell functions to tweak things
138	# (This makes commits to /etc mostly painless)
139	final_chroot() (
140		chpass -p "\$1\$IgMjWs2L\$Nu12OCsjfiwHHj0I7TmUN1" root
141
142		pw useradd phk -u 488 -d /home/phk -c "Poul-Henning Kamp" \
143		    -G "wheel,operator,dialer" -s /bin/csh -w none
144
145		chpass -p "\$1\$VcM.9Ow8\$IcXHs0h9jsk27b8N64lOm/" phk
146
147		sed -i "" -e 's/^DS/DSorigo.freebsd.dk/' /etc/mail/sendmail.cf
148		sed -i "" -e '/console/s/^/#/' /etc/syslog.conf
149		echo "beastie_disable=YES" >> /boot/loader.conf
150		touch /root/.hushlogin
151	)
152
153
154