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