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. I also provided two versions, for system with one harddisk and with three of them for redundant setup.
Here is the layout of the system with 1 harddisk:
... and here layout for single disk for system with 3 disks:
Redundancy planning for system with 3 disks:
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 (/dev/ad0 /dev/ad1 /dev/ad2 for system with 3 disks)
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 sets
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. I also provided two versions, for system with one harddisk and with three of them for redundant setup.
Here is the layout of the system with 1 harddisk:
Code:
MBR SLICE 1 | / | 512 MB | UFS/read-only
| SWAP | 2 GB |
| /tmp | 512 MB | mounted on SWAP with[B] mdmfs(8)[/B]
------------+------+---------------------------------------
MBR SLICE 2 | /usr | REST | ZFS dataset
| /var | REST | ZFS dataset
... and here layout for single disk for system with 3 disks:
Code:
MBR SLICE 1 | / | 512 MB | UFS/read-only
------------+------+--------+------------------------------
MBR SLICE 2 | SWAP | 1 GB |
| /tmp | 512 MB | mounted on SWAP with [B]mdmfs(8)[/B]
------------+------+--------+------------------------------
MBR SLICE 3 | /usr | REST | ZFS dataset
| /var | REST | ZFS dataset
Redundancy planning for system with 3 disks:
Code:
[ [B]DISK0[/B] ] [ [B]DISK1[/B] ] [ [B]DISK2[/B] ]
[ / ] [color="Silver"]< RAID1 >[/color] [ / ] [color="Silver"]< RAID1 >[/color] [ / ]
[ SWAP0 ] [ SWAP1 ] [ SWAP2 ]
[ Z ] [color="Silver"]< RAID5 >[/color] [ F ] [color="Silver"]< RAID5 >[/color] [ S ]
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 (/dev/ad0 /dev/ad1 /dev/ad2 for system with 3 disks)
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]
# [color="blue"]setenv PATH /mnt2/rescue:/mnt2/usr/bin:/mnt2/sbin[/color]
# [color="blue"]set filec[/color]
# [color="blue"]set autolist[/color]
# [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:
[B]DISKS: 3[/B] | [B]DISKS: 1[/B]
# [color="Blue"]cat > part << __EOF__[/color] | # [color="Red"]cat > part << __EOF__[/color]
[color="Blue"]p 1 165 63 512M[/color] | [color="Red"]p 1 165 63 2560M[/color]
[color="Blue"]p 2 165 * 1024M[/color] | [color="Red"]p 2 159 * *[/color]
[color="Blue"]p 3 159 * *[/color] | [color="Red"]p 3 0 0 0[/color]
[color="Blue"]p 4 0 0 0[/color] | [color="Red"]p 4 0 0 0[/color]
[color="Blue"]a 1[/color] | [color="Red"]a 1[/color]
[color="Blue"]__EOF__[/color] | [color="Red"]__EOF__[/color]
|
# [color="Blue"]fdisk -f part ad0[/color] | # [color="Red"]fdisk -f part ad0[/color]
# [color="Blue"]fdisk -f part ad1[/color] |
# [color="Blue"]fdisk -f part ad2[/color] |
|
# [color="Blue"]kldload /mnt2/boot/kernel/geom_mirror.ko[/color] |
# [color="Blue"]gmirror label rootfs ad0s1[/color] |
# [color="Blue"]gmirror insert rootfs ad1s1[/color] |
# [color="Blue"]gmirror insert rootfs ad2s1[/color] |
|
# [color="Blue"]bsdlabel -B -w /dev/mirror/rootfs[/color] | # [color="Red"]cat > label << __EOF__[/color]
| [color="Red"]# /dev/ad0s1:[/color]
| [color="Red"]8 partitions:[/color]
| [color="Red"] a: 512m 0 4.2BSD[/color]
| [color="Red"] b: * * swap[/color]
| [color="Red"]__EOF__[/color]
|
| # [color="Red"]bsdlabel -B -w ad0s1[/color]
| # [color="Red"]bsdlabel ad0s1 | tail -1 >> label[/color]
| # [color="Red"]bsdlabel -R ad0s1 label[/color]
|
# [color="Blue"]glabel label swap0 ad0s2[/color] | # [color="Red"]glabel label rootfs ad0s1a[/color]
# [color="Blue"]glabel label swap1 ad1s2[/color] | # [color="Red"]glabel label swap ad0s1b[/color]
# [color="Blue"]glabel label swap2 ad2s2[/color] |
|
# [color="Blue"]newfs /dev/mirror/rootfsa[/color] | # [color="Red"]newfs /dev/label/rootfs[/color]
# [color="Blue"]zpool create basefs raidz ad0s3 ad1s3 ad2s3[/color] | # [color="Red"]zpool create basefs ad0s2[/color]
# [color="Blue"]zfs create basefs/usr[/color] | # [color="Red"]zfs create basefs/usr[/color]
# [color="Blue"]zfs create basefs/var[/color] | # [color="Red"]zfs create basefs/var[/color]
# [color="Blue"]mkdir /NEWROOT[/color] | # [color="Red"]mkdir /NEWROOT[/color]
# [color="Blue"]mount /dev/mirror/rootfsa /NEWROOT[/color] | # [color="Red"]mount /dev/label/rootfs /NEWROOT[/color]
# [color="Blue"]zfs set mountpoint=/NEWROOT/usr basefs/usr[/color] | # [color="Red"]zfs set mountpoint=/NEWROOT/usr basefs/usr[/color]
# [color="Blue"]zfs set mountpoint=/NEWROOT/var basefs/var[/color] | # [color="Red"]zfs set mountpoint=/NEWROOT/var basefs/var[/color]
1.5. Actually install needed FreeBSD sets
Code:
# [color="blue"]setenv DESTDIR /NEWROOT[/color]
# [color="blue"]cd /dist/8.0-RELEASE[/color]
# [color="blue"]cd base[/color]
# [color="blue"]./install.sh[/color] (answer [I]'y'[/I] here)
# [color="blue"]cd ..[/color]
# [color="blue"]cd manpages[/color]
# [color="blue"]./install.sh[/color]
# [color="blue"]cd ..[/color]
# [color="Blue"]cd kernels[/color]
# [color="blue"]./install.sh generic[/color]
# [color="Blue"]cd ..[/color]
# [color="Blue"]cd /NEWROOT/boot[/color]
# [color="Blue"]rm -r kernel[/color]
# [color="Blue"]mv GENERIC kernel[/color]