]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tools/tools/sysbuild/README
OpenZFS: MFV 2.0-rc3-gfc5966
[FreeBSD/FreeBSD.git] / tools / tools / sysbuild / README
1 $FreeBSD$
2
3 About sysbuild.sh
4 =================
5
6 I have been running -current on my laptop since before FreeBSD 2.0 was
7 released and along the way developed this little trick to making the
8 task easier.
9
10 sysbuild.sh is a way to build a new FreeBSD system on a computer from
11 a specification, while leaving the current installation intact.
12
13 sysbuild.sh assume you have two partitions that can hold your rootfs
14 and can be booted, and roughly speaking, all it does is build a new
15 system into the one you don't use, from the one you do use.
16
17 A partition named /freebsd is assumed to be part of your layout, and
18 that is where the sources and ports will be found.
19
20 If you know how nanobsd works, you will find a lot of similarity.
21
22 HOWTO
23 =====
24
25 In all likelihood, it is easier if we imagine you start with a blank
26 computer.
27
28 Grab a FreeBSD install ISO and boot it.
29
30 Create four disk slices:
31
32         ad0s1 = 5GB
33         ad0s2 = 5GB
34         ad0s3 = 5GB
35         ad0s4 = the rest
36
37 Create a root filesystem in s1a filling the entire ad0s1 slice.
38
39 Create a swap partition, if you want one, in ad0s4b.
40
41 Install the boot0 bootmanager.
42
43 Install the "Minimal" FreeBSD system into ad0s1a.
44
45 Reboot from the newly installed system.
46
47 Run 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
59 Next, 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
71 And 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
77 If it succeeds, you should be able to:
78
79         boot0cfg -s 2 -v /dev/ad0
80         reboot
81
82 And 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
87 TWEAKS
88 ======
89
90 The 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
98 The specfile is a shellscript where you can override or set a number of
99 shell variables and functions.
100
101 A 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