xref: /freebsd/tools/tools/sysbuild/README (revision 05248206f720394d95c2a7475429311df670a2e9)
168d566e6SPoul-Henning Kamp
268d566e6SPoul-Henning KampAbout sysbuild.sh
368d566e6SPoul-Henning Kamp=================
468d566e6SPoul-Henning Kamp
568d566e6SPoul-Henning KampI have been running -current on my laptop since before FreeBSD 2.0 was
668d566e6SPoul-Henning Kampreleased and along the way developed this little trick to making the
768d566e6SPoul-Henning Kamptask easier.
868d566e6SPoul-Henning Kamp
968d566e6SPoul-Henning Kampsysbuild.sh is a way to build a new FreeBSD system on a computer from
1068d566e6SPoul-Henning Kampa specification, while leaving the current installation intact.
1168d566e6SPoul-Henning Kamp
1268d566e6SPoul-Henning Kampsysbuild.sh assume you have two partitions that can hold your rootfs
1368d566e6SPoul-Henning Kampand can be booted, and roughly speaking, all it does is build a new
1468d566e6SPoul-Henning Kampsystem into the one you don't use, from the one you do use.
1568d566e6SPoul-Henning Kamp
1668d566e6SPoul-Henning KampA partition named /freebsd is assumed to be part of your layout, and
1768d566e6SPoul-Henning Kampthat is where the sources and ports will be found.
1868d566e6SPoul-Henning Kamp
1968d566e6SPoul-Henning KampIf you know how nanobsd works, you will find a lot of similarity.
2068d566e6SPoul-Henning Kamp
2168d566e6SPoul-Henning KampHOWTO
2268d566e6SPoul-Henning Kamp=====
2368d566e6SPoul-Henning Kamp
248ce070c1SUlrich SpörleinIn all likelihood, it is easier if we imagine you start with a blank
2568d566e6SPoul-Henning Kampcomputer.
2668d566e6SPoul-Henning Kamp
2768d566e6SPoul-Henning KampGrab a FreeBSD install ISO and boot it.
2868d566e6SPoul-Henning Kamp
2968d566e6SPoul-Henning KampCreate four disk slices:
3068d566e6SPoul-Henning Kamp
3168d566e6SPoul-Henning Kamp	ad0s1 = 5GB
3268d566e6SPoul-Henning Kamp	ad0s2 = 5GB
3368d566e6SPoul-Henning Kamp	ad0s3 = 5GB
3468d566e6SPoul-Henning Kamp	ad0s4 = the rest
3568d566e6SPoul-Henning Kamp
3668d566e6SPoul-Henning KampCreate a root filesystem in s1a filling the entire ad0s1 slice.
3768d566e6SPoul-Henning Kamp
3868d566e6SPoul-Henning KampCreate a swap partition, if you want one, in ad0s4b.
3968d566e6SPoul-Henning Kamp
4068d566e6SPoul-Henning KampInstall the boot0 bootmanager.
4168d566e6SPoul-Henning Kamp
4268d566e6SPoul-Henning KampInstall the "Minimal" FreeBSD system into ad0s1a.
4368d566e6SPoul-Henning Kamp
4468d566e6SPoul-Henning KampReboot from the newly installed system.
4568d566e6SPoul-Henning Kamp
4668d566e6SPoul-Henning KampRun these commands to set up the other partitions sysbuild.sh cares about:
4768d566e6SPoul-Henning Kamp
4868d566e6SPoul-Henning Kamp	# /freebsd filesystem
4968d566e6SPoul-Henning Kamp	newfs -b 4096 -f 512 -O2 -U /dev/ad0s3
5068d566e6SPoul-Henning Kamp	echo "/dev/ad0s3 /freebsd ufs rw 2 2" >> /etc/fstab
5168d566e6SPoul-Henning Kamp	mkdir /freebsd
5268d566e6SPoul-Henning Kamp	mount /freebsd
5368d566e6SPoul-Henning Kamp
5468d566e6SPoul-Henning Kamp	# deputy rootfilesystem
5568d566e6SPoul-Henning Kamp	bsdlabel -B -w /dev/ad0s2
5668d566e6SPoul-Henning Kamp	newfs -O2 -U /dev/ad0s2a
5768d566e6SPoul-Henning Kamp
5868d566e6SPoul-Henning KampNext, install ports and sources:
5968d566e6SPoul-Henning Kamp
6068d566e6SPoul-Henning Kamp	cd /usr
6168d566e6SPoul-Henning Kamp	rm -rf ports src
6268d566e6SPoul-Henning Kamp	ln -s /freebsd/src
6368d566e6SPoul-Henning Kamp	ln -s /freebsd/ports
6468d566e6SPoul-Henning Kamp	cd /freebsd
6568d566e6SPoul-Henning Kamp	mkdir ports src packages
6668d566e6SPoul-Henning Kamp
67*b1522355SGavin Atkinson	svn co https://svn0.us-east.FreeBSD.org/base/stable/10 src
68*b1522355SGavin Atkinson	svn co https://svn0.us-east.FreeBSD.org/ports/head ports
6968d566e6SPoul-Henning Kamp
7068d566e6SPoul-Henning KampAnd we should be ready to try a shot:
7168d566e6SPoul-Henning Kamp
7268d566e6SPoul-Henning Kamp	cd /root
73bfe3989eSPoul-Henning Kamp	cp /usr/src/tools/tools/sysbuild/sysbuild.sh .
7468d566e6SPoul-Henning Kamp	sh sysbuild.sh |& tee _.sb
7568d566e6SPoul-Henning Kamp
7668d566e6SPoul-Henning KampIf it succeeds, you should be able to:
7768d566e6SPoul-Henning Kamp
7868d566e6SPoul-Henning Kamp	boot0cfg -s 2 -v /dev/ad0
7968d566e6SPoul-Henning Kamp	reboot
8068d566e6SPoul-Henning Kamp
8168d566e6SPoul-Henning KampAnd come up with your newly built system.
8268d566e6SPoul-Henning Kamp
8368d566e6SPoul-Henning Kamp	Next time you want a new system, you just run sysbuild.sh again
8468d566e6SPoul-Henning Kamp	and boot slice 1 when it's done.
8568d566e6SPoul-Henning Kamp
8668d566e6SPoul-Henning KampTWEAKS
8768d566e6SPoul-Henning Kamp======
8868d566e6SPoul-Henning Kamp
8968d566e6SPoul-Henning KampThe sysbuild.sh script takes various parameters:
9068d566e6SPoul-Henning Kamp
9168d566e6SPoul-Henning Kamp	-c specfile	# configure stuff, see below.
9268d566e6SPoul-Henning Kamp	-w		# skip buildworld, assume it was done earlier.
9368d566e6SPoul-Henning Kamp	-k		# skip buildkernel, ---//---
9468d566e6SPoul-Henning Kamp	-b		# skip both buildworld & buildkernel
9568d566e6SPoul-Henning Kamp	-p		# install cached packacges if found.
9668d566e6SPoul-Henning Kamp
9768d566e6SPoul-Henning KampThe specfile is a shellscript where you can override or set a number of
9868d566e6SPoul-Henning Kampshell variables and functions.
9968d566e6SPoul-Henning Kamp
10068d566e6SPoul-Henning KampA partial example:
10168d566e6SPoul-Henning Kamp
10268d566e6SPoul-Henning Kamp	# use a kernel different from GENERIC
10368d566e6SPoul-Henning Kamp	KERNCONF=SMP
10468d566e6SPoul-Henning Kamp
10568d566e6SPoul-Henning Kamp	# Cache built packages, so we can use -p
10668d566e6SPoul-Henning Kamp	PKG_DIR=/freebsd/packages
10768d566e6SPoul-Henning Kamp
10868d566e6SPoul-Henning Kamp	# Mount ports distfiles from another machine
10968d566e6SPoul-Henning Kamp	REMOTEDISTFILES=fs:/rdonly/distfiles
11068d566e6SPoul-Henning Kamp
11168d566e6SPoul-Henning Kamp	# Fetch distfiles through a proxy
11268d566e6SPoul-Henning Kamp	FTP_PROXY=http://127.0.0.1:3128/
11368d566e6SPoul-Henning Kamp	HTTP_PROXY=http://127.0.0.1:3128/
11468d566e6SPoul-Henning Kamp	export FTP_PROXY HTTP_PROXY
11568d566e6SPoul-Henning Kamp
11668d566e6SPoul-Henning Kamp	# We want these ports
11768d566e6SPoul-Henning Kamp	PORTS_WE_WANT='
11868d566e6SPoul-Henning Kamp		/usr/ports/archivers/unzip
11968d566e6SPoul-Henning Kamp		/usr/ports/archivers/zip
12068d566e6SPoul-Henning Kamp		/usr/ports/cad/linux-eagle
12168d566e6SPoul-Henning Kamp		/usr/ports/comms/lrzsz
12268d566e6SPoul-Henning Kamp		/usr/ports/databases/rrdtool
12368d566e6SPoul-Henning Kamp		/usr/ports/devel/subversion-freebsd
12468d566e6SPoul-Henning Kamp	'
12568d566e6SPoul-Henning Kamp
12668d566e6SPoul-Henning Kamp	# Files to move over
12768d566e6SPoul-Henning Kamp	CONFIGFILES='
12868d566e6SPoul-Henning Kamp		/root/.ssh
12968d566e6SPoul-Henning Kamp		/etc/X11/xorg.conf
13068d566e6SPoul-Henning Kamp		/etc/ssh/ssh_host*
13168d566e6SPoul-Henning Kamp		/etc/rc.conf
13268d566e6SPoul-Henning Kamp		/etc/rc.local
13368d566e6SPoul-Henning Kamp	'
13468d566e6SPoul-Henning Kamp
13568d566e6SPoul-Henning Kamp	# Shell functions to tweak things
13668d566e6SPoul-Henning Kamp	# (This makes commits to /etc mostly painless)
13768d566e6SPoul-Henning Kamp	final_chroot() (
13868d566e6SPoul-Henning Kamp		chpass -p "\$1\$IgMjWs2L\$Nu12OCsjfiwHHj0I7TmUN1" root
13968d566e6SPoul-Henning Kamp
14068d566e6SPoul-Henning Kamp		pw useradd phk -u 488 -d /home/phk -c "Poul-Henning Kamp" \
14168d566e6SPoul-Henning Kamp		    -G "wheel,operator,dialer" -s /bin/csh -w none
14268d566e6SPoul-Henning Kamp
14368d566e6SPoul-Henning Kamp		chpass -p "\$1\$VcM.9Ow8\$IcXHs0h9jsk27b8N64lOm/" phk
14468d566e6SPoul-Henning Kamp
14568d566e6SPoul-Henning Kamp		sed -i "" -e 's/^DS/DSorigo.freebsd.dk/' /etc/mail/sendmail.cf
14668d566e6SPoul-Henning Kamp		sed -i "" -e '/console/s/^/#/' /etc/syslog.conf
14768d566e6SPoul-Henning Kamp		echo "beastie_disable=YES" >> /boot/loader.conf
14868d566e6SPoul-Henning Kamp		touch /root/.hushlogin
14968d566e6SPoul-Henning Kamp	)
15068d566e6SPoul-Henning Kamp
15168d566e6SPoul-Henning Kamp
152