All these years sysinstall(8) was helping us to install FreeBSD with most options we needed, today with new filesystems/features like GJournal/ZFS/Geli/GMirror/GStripe its no longer up to the task, because it only supports creating installation on UFS filesystem with SoftUpdates turned ON or OFF.
In this guide you will learn how to setup FreeBSD installation in simple yet flexible setup based on read-only UFS (without SoftUpdates) for 'base system' [1], some SWAP space, /tmp mounted on SWAP and all the other filesystems (/var /usr ...) mounted on ZFS. It will not require rebuilding anything, just simple setup on plain MBR partitions. I should also mention that we would be using AHCI mode for disks.
Here is the layout of the DISK:
FreeBSD core, the 'base system' [1] should remain almost unchanged/untouched on daily basis while you can mess all other filesystems, this ensures that when things go wrong, you will be able to fix anything still having working 'base system' [1].
You will need *-dvd-* disk or *-memstick-* image for this installation, *-disk1-* will not do since it does not contain livefs system.
Here is the procedude, described as simple as possible.
1.0. I assume that our disk for the installation would be /dev/ad0
1.1. Boot *-dvd-* from DVD disk or *-memstick-* image from pendrive
1.2. Create your temporary working environment
1.3. Load needed modules
1.4. Create/mount needed filesystems
1.5. Actually install needed FreeBSD system sets
1.6. Provide basic configuration needed to boot new system
1.7. Unmount filesystems and reboot
Now lets talk things you will need to do after reboot.
2.0. If you will be dropped into 'single user mode'
2.1. Set root password
2.2. Set hostname
2.3. Set timezone and date
2.4. Tune ZFS filesystem (only for i386)
2.5. Mount /tmp on swap
2.6. Move termcap into /etc (instead of useless link on crash)
2.7. Add latest security patches
2.8. Make all changes to configuration in /etc, then set / to be mounted read-only in /etc/fstab
2.9. Reboot and enjoy modern install of FreeBSD system
To summarise, this setup provides us these things:
CHANGELOG
1.0 / 2010-01-14 / initial version
1.1 / 2010-01-15 / simplified PATH
MIRROR THREAD: http://daemonforums.org/showthread.php?t=4200
POLISH VERSION: http://bsdguru.org/dyskusja/viewtopic.php?t=19392
In this guide you will learn how to setup FreeBSD installation in simple yet flexible setup based on read-only UFS (without SoftUpdates) for 'base system' [1], some SWAP space, /tmp mounted on SWAP and all the other filesystems (/var /usr ...) mounted on ZFS. It will not require rebuilding anything, just simple setup on plain MBR partitions. I should also mention that we would be using AHCI mode for disks.
Here is the layout of the DISK:
Code:
+ / 512 MB --> UFS/read-only
MBR SLICE 1 + [SWAP] 2 GB
+ /tmp 1 GB --> mounted on SWAP with[B] mdmfs(8)[/B]
-----------------------------------------------------------------
+ /usr - --> ZFS
MBR SLICE 2 + /var - --> ZFS
+ ... - --> ZFS
FreeBSD core, the 'base system' [1] should remain almost unchanged/untouched on daily basis while you can mess all other filesystems, this ensures that when things go wrong, you will be able to fix anything still having working 'base system' [1].
You will need *-dvd-* disk or *-memstick-* image for this installation, *-disk1-* will not do since it does not contain livefs system.
Here is the procedude, described as simple as possible.
1.0. I assume that our disk for the installation would be /dev/ad0
1.1. Boot *-dvd-* from DVD disk or *-memstick-* image from pendrive
Code:
Country Selection --> United States
Fixit --> CDROM/DVD ([file]*-dvd-*[/file]) or USB ([file]*-memstick-*[/file])
1.2. Create your temporary working environment
Code:
fixit# [color="Blue"]/mnt2/bin/csh[/color]
fixit# [color="blue"]setenv PATH /mnt2/rescue:/mnt2/usr/bin[/color]
fixit# [color="blue"]set filec[/color]
fixit# [color="blue"]set autolist[/color]
fixit# [color="blue"]set nobeep[/color]
1.3. Load needed modules
Code:
fixit# [color="#0000ff"]kldload /mnt2/boot/kernel/geom_mbr.ko[/color]
fixit# [color="blue"]kldload /mnt2/boot/kernel/opensolaris.ko[/color]
fixit# [color="blue"]kldload /mnt2/boot/kernel/zfs.ko[/color]
1.4. Create/mount needed filesystems
Code:
fixit# [color="blue"]cat > part << __EOF__
p 1 165 63 2560M
p 2 165 * *
p 3 0 0 0
p 4 0 0 0
a 1
__EOF__[/color]
fixit# [color="blue"]fdisk -f part ad0[/color]
fixit# [color="blue"]bsdlabel -B -w ad0s1[/color]
fixit# [color="blue"]cat > label << __EOF__
# /dev/ad0s1:
8 partitions:
a: 512m 0 4.2BSD
b: * * swap
__EOF__[/color]
fixit# [color="blue"]bsdlabel ad0s1 | tail -1 >> label[/color]
fixit# [color="blue"]bsdlabel -R ad0s1 label[/color]
fixit# [color="Blue"]glabel label rootfs ad0s1a[/color]
fixit# [color="blue"]glabel label swap ad0s1b[/color]
fixit# [color="blue"]newfs /dev/label/rootfs[/color]
fixit# [color="blue"]zpool create basefs ad0s2[/color]
fixit# [color="blue"]zfs create basefs/usr[/color]
fixit# [color="blue"]zfs create basefs/var[/color]
fixit# [color="blue"]mkdir /NEWROOT[/color]
fixit# [color="blue"]mount /dev/label/rootfs /NEWROOT[/color]
fixit# [color="blue"]zfs set mountpoint=/NEWROOT/usr basefs/usr[/color]
fixit# [color="blue"]zfs set mountpoint=/NEWROOT/var basefs/var[/color]
1.5. Actually install needed FreeBSD system sets
Code:
fixit# [color="blue"]setenv DESTDIR /NEWROOT[/color]
fixit# [color="blue"]cd /dist/8.0-RELEASE[/color]
fixit# [color="blue"]cd base[/color]
fixit# [color="blue"]./install.sh [/color]# answer [I]'y'[/I] here
fixit# [color="blue"]cd ..[/color]
fixit# [color="blue"]cd manpages[/color]
fixit# [color="blue"]./install.sh[/color]
fixit# [color="blue"]cd ..[/color]
fixit# [color="Blue"]cd kernels[/color]
fixit# [color="blue"]./install.sh generic[/color]
fixit# [color="Blue"]cd ..[/color]
fixit# [color="Blue"]cd /NEWROOT/boot[/color]
fixit# [color="Blue"]rm -r kernel[/color]
fixit# [color="Blue"]mv GENERIC kernel[/color]
1.6. Provide basic configuration needed to boot new system
Code:
fixit# [color="Blue"]cat > /NEWROOT/etc/fstab << __EOF__
#dev #mount #fs #opts #dump #pass
/dev/label/rootfs / ufs rw 2 2
/dev/label/swap none swap sw 0 0
basefs/var /var zfs rw 0 0
basefs/usr /usr zfs rw 0 0
__EOF__[/color]
fixit# [color="Blue"]cat > /NEWROOT/boot/loader.conf << __EOF__
zfs_load="YES"
ahci_load="YES"
__EOF__
[/color]
fixit# [color="Blue"]zfs set mountpoint=/usr basefs/usr[/color]
fixit# [color="Blue"]zfs set mountpoint=/var basefs/var[/color]
1.7. Unmount filesystems and reboot
Code:
fixit# [color="Blue"]umount /NEWROOT/var[/color]
fixit# [color="Blue"]umount /NEWROOT/usr[/color]
fixit# [color="Blue"]umount /NEWROOT[/color]
fixit# [color="Blue"]reboot[/color]
Now lets talk things you will need to do after reboot.
2.0. If you will be dropped into 'single user mode'
Use these commands to import and mount your basefs zpool:
Code:
newsystem# [color="Green"]zpool import -f basefs[/color]
2.1. Set root password
Code:
newsystem# [color="Green"]passwd[/color]
2.2. Set hostname
Code:
newsystem# [color="Green"]echo hostname=\"HOSTNAME\" >> /etc/rc.conf[/color]
2.3. Set timezone and date
Code:
menu# [color="Green"]tzsetup[/color]
manual# [color="Green"]cat /usr/share/zoneinfo/Europe/Warsaw > /etc/localtime[/color]
time# [color="Green"]date 201001142240[/color]
2.4. Tune ZFS filesystem (only for i386)
Code:
newsystem# [color="Green"]cat > /boot/loader.conf << __EOF__
vfs.zfs.prefetch_disable=0 # enable prefetch
vfs.zfs.arc_max=134217728 # 128 MB
vm.kmem_size=536870912 # 512 MB
vm.kmem_size_max=536870912 # 512 MB
vfs.zfs.vdev.cache.size=8388608 # 8 MB
__EOF__[/color]
2.5. Mount /tmp on swap
Code:
newsystem# [color="Green"]cat >> /etc/rc.conf << __EOF__
tmpmfs="YES"
tmpsize="1024m"
tmpmfs_flags="-m 0 -o async,noatime -S -p 1777"
__EOF__[/color]
2.6. Move termcap into /etc (instead of useless link on crash)
Code:
newsystem# [color="Green"]rm /etc/termcap[/color]
newsystem# [color="Green"]mv /usr/share/misc/termcap /etc[/color]
newsystem# [color="Green"]ln -s /etc/termcap /usr/share/misc/termcap[/color]
2.7. Add latest security patches
Code:
newsystem# [color="Green"]freebsd-update fetch[/color]
newsystem# [color="Green"]freebsd-update install[/color]
2.8. Make all changes to configuration in /etc, then set / to be mounted read-only in /etc/fstab
Code:
#dev #mount #fs #opts #dump #pass
[color="Green"]+/dev/label/rootfs / ufs ro 2 2[/color]
[color="Red"]-/dev/label/rootfs / ufs rw 2 2[/color]
/dev/label/swap none swap sw 0 0
2.9. Reboot and enjoy modern install of FreeBSD system
Code:
newsystem# [color="Green"]shutdown -r now[/color]
To summarise, this setup provides us these things:
-- bulletproof 'base system' [1] on UFS (w/o SU) mounted read-only
-- /tmp filesystem mounted on SWAP
-- usage of new AHCI mode in FreeBSD
-- flexibility for all other filesystems on ZFS
-- fully working environment on crash (/etc/termcap)
-- disks/filesystems mounted by label, possible device name changes are harmless
[1] base system is / and /usr while this setup, in context of this setup I name 'base system'
the most important core of FreeBSD, the / filesystem and its binaries/libraries/configuration
(thanks to phoenix for reminding me what REAL base system is/means)
-- /tmp filesystem mounted on SWAP
-- usage of new AHCI mode in FreeBSD
-- flexibility for all other filesystems on ZFS
-- fully working environment on crash (/etc/termcap)
-- disks/filesystems mounted by label, possible device name changes are harmless
[1] base system is / and /usr while this setup, in context of this setup I name 'base system'
the most important core of FreeBSD, the / filesystem and its binaries/libraries/configuration
(thanks to phoenix for reminding me what REAL base system is/means)
CHANGELOG
1.0 / 2010-01-14 / initial version
1.1 / 2010-01-15 / simplified PATH
+fixit# setenv PATH /mnt2/rescue:/mnt2/usr/bin
-fixit# setenv PATH /mnt2/bin:/mnt2/sbin:/mnt2/usr/bin:/mnt2/usr/sbin
1.2 / 2010-01-15 / added link for termcap (instead of duplicate on /etc and /usr) [2.6.]-fixit# setenv PATH /mnt2/bin:/mnt2/sbin:/mnt2/usr/bin:/mnt2/usr/sbin
.newsystem# rm /etc/termcap
+newsystem# mv /usr/share/misc/termcap /etc
+newsystem# ln -s /etc/termcap /usr/share/misc/termcap
-newsystem# cp /usr/share/misc/termcap /etc
1.3 / 2010-01-21 / removed unneeded mount commands [2.0.]+newsystem# mv /usr/share/misc/termcap /etc
+newsystem# ln -s /etc/termcap /usr/share/misc/termcap
-newsystem# cp /usr/share/misc/termcap /etc
-newsystem# zfs mount basefs/var
-newsystem# zfs mount basefs/usr
-newsystem# zfs mount basefs/usr
MIRROR THREAD: http://daemonforums.org/showthread.php?t=4200
POLISH VERSION: http://bsdguru.org/dyskusja/viewtopic.php?t=19392