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