DaemonForums  

Go Back   DaemonForums > Miscellaneous > Guides

Guides All Guides and HOWTO's.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 14th January 2010
vermaden's Avatar
vermaden vermaden is offline
Administrator
 
Join Date: Apr 2008
Location: pl_PL.lodz
Posts: 1,051
Thanked 118 Times in 93 Posts
Post HOWTO: Modern FreeBSD Install (vermaden way)

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:
Code:
MBR SLICE 1 |    / | 512 MB | UFS/read-only 
            | SWAP |   2 GB |
            | /tmp | 512 MB | mounted on SWAP with mdmfs(8)
------------+------+---------------------------------------
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 mdmfs(8)
------------+------+--------+------------------------------
MBR SLICE 3 | /usr |   REST | ZFS dataset
            | /var |   REST | ZFS dataset
Redundancy planning for system with 3 disks:
Code:
 [ DISK0 ]           [ DISK1 ]           [ DISK2 ]
 [   /   ] < RAID1 > [   /   ] < RAID1 > [   /   ]
 [ SWAP0 ]           [ SWAP1 ]           [ SWAP2 ]
 [   Z   ] < RAID5 > [   F   ] < RAID5 > [   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 (*-dvd-*) or USB (*-memstick-*)
1.2. Create your temporary working environment
Code:
fixit# /mnt2/bin/csh
# setenv PATH /mnt2/rescue:/mnt2/usr/bin:/mnt2/sbin
# set filec
# set autolist
# set nobeep
1.3. Load needed modules
Code:
fixit# kldload /mnt2/boot/kernel/geom_mbr.ko
fixit# kldload /mnt2/boot/kernel/opensolaris.ko
fixit# kldload /mnt2/boot/kernel/zfs.ko
1.4. Create/mount needed filesystems
Code:
DISKS: 3                                               | DISKS: 1
# cat > part << __EOF__                                | # cat > part << __EOF__
p 1 165 63  512M                                       | p 1 165 63  2560M
p 2 165  * 1024M                                       | p 2 159  *     *
p 3 159  *     *                                       | p 3   0  0     0
p 4   0  0     0                                       | p 4   0  0     0
a 1                                                    | a 1
__EOF__                                                | __EOF__
                                                       |
# fdisk -f part ad0                                    | # fdisk -f part ad0
# fdisk -f part ad1                                    |
# fdisk -f part ad2                                    |
                                                       |
# kldload /mnt2/boot/kernel/geom_mirror.ko             |
# gmirror label  rootfs ad0s1                          |
# gmirror insert rootfs ad1s1                          |
# gmirror insert rootfs ad2s1                          |
                                                       |
# bsdlabel -B -w /dev/mirror/rootfs                    | # cat > label << __EOF__
                                                       | # /dev/ad0s1:
                                                       | 8 partitions:
                                                       |   a: 512m  0 4.2BSD
                                                       |   b: *     * swap
                                                       | __EOF__
                                                       |
                                                       | # bsdlabel -B -w ad0s1
                                                       | # bsdlabel       ad0s1 | tail -1 >> label
                                                       | # bsdlabel -R    ad0s1 label
                                                       |
# glabel label swap0 ad0s2                             | # glabel label rootfs ad0s1a
# glabel label swap1 ad1s2                             | # glabel label swap   ad0s1b
# glabel label swap2 ad2s2                             |
                                                       |
# newfs /dev/mirror/rootfsa                            | # newfs /dev/label/rootfs
# zpool create basefs raidz ad0s3 ad1s3 ad2s3          | # zpool create basefs ad0s2
# zfs create basefs/usr                                | # zfs create basefs/usr
# zfs create basefs/var                                | # zfs create basefs/var
# mkdir /NEWROOT                                       | # mkdir /NEWROOT
# mount /dev/mirror/rootfsa /NEWROOT                   | # mount /dev/label/rootfs /NEWROOT
# zfs set mountpoint=/NEWROOT/usr basefs/usr           | # zfs set mountpoint=/NEWROOT/usr basefs/usr
# zfs set mountpoint=/NEWROOT/var basefs/var           | # zfs set mountpoint=/NEWROOT/var basefs/var
1.5. Actually install needed FreeBSD sets
Code:
# setenv DESTDIR /NEWROOT
# cd /dist/8.0-RELEASE

# cd base
# ./install.sh (answer 'y' here)
# cd ..

# cd manpages
# ./install.sh
# cd ..

# cd kernels
# ./install.sh generic
# cd ..

# cd /NEWROOT/boot
# rm -r kernel
# mv GENERIC kernel
1.6. Provide basic configuration needed to boot new system
1.6.1.
Code:
DISKS: 3                                          | DISKS: 1
# cat > /NEWROOT/etc/fstab << __EOF__             | # cat > /NEWROOT/etc/fstab << __EOF__
#dev                #mount #fs  #opts #dump #pass | #dev              #mount #fs  #opts #dump #pass
/dev/mirror/rootfsa /      ufs  rw    1     1     | /dev/label/rootfs /      ufs  rw    1     1
/dev/label/swap0    none   swap sw    0     0     | /dev/label/swap   none   swap sw    0     0
/dev/label/swap1    none   swap sw    0     0     | __EOF__
/dev/label/swap2    none   swap sw    0     0     |
__EOF__                                           |
                                                  |
# cat > /NEWROOT/boot/loader.conf << __EOF__      | # cat > /NEWROOT/boot/loader.conf << __EOF__
zfs_load="YES"                                    | zfs_load="YES"
ahci_load="YES"                                   | ahci_load="YES"
geom_mirror_load="YES"                            | __EOF__
__EOF__                                           |
1.6.1.
Code:
# cat > /NEWROOT/etc/rc.conf << __EOF__
zfs_enable="YES"
__EOF__
1.7. Unmount filesystems and reboot
Code:
# cd /
# zfs umount -a
# umount /NEWROOT
# zfs set mountpoint=/usr basefs/usr
# zfs set mountpoint=/var basefs/var
# zpool export basefs
# reboot
Now lets talk things you will need to do after reboot.

2.0. At boot loader select boot into single user mode
4. Boot FreeBSD in single user mode

Code:
Enter full pathname of shell or RETURN for /bin/sh: /bin/csh
% /rescue/mount -w /
% /rescue/zpool import -D || /rescue/zpool import -f basefs
% exit
2.1. Login as root without password
Code:
login: root
password: (just hit ENTER)
2.2. Set root password
Code:
# passwd
2.3. Set hostname
Code:
# echo hostname=\"HOSTNAME\" >> /etc/rc.conf
2.4. Set timezone and date/time
Code:
# tzsetup
# date 201001142240
2.4.1 Generate the newaliases(8) database
Code:
# newaliases
2.5. Tune the ZFS filesystem (only for i386)
Code:
# 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__
2.6. Mount /tmp on SWAP
Code:
# cat >> /etc/rc.conf << __EOF__
tmpmfs="YES"
tmpsize="512m"
tmpmfs_flags="-m 0 -o async,noatime -S -p 1777"
__EOF__
2.7. Move termcap into /etc (instead of useless link on crash)
Code:
# rm /etc/termcap
# mv /usr/share/misc/termcap /etc
# ln -s /etc/termcap /usr/share/misc/termcap
2.8. Add latest security patches
Code:
# freebsd-update fetch
# freebsd-update install
2.9. Make all changes to configuration in /etc, then set / to be mounted read-only in /etc/fstab
Code:
DISKS: 3                                           | DISKS: 1
 #dev                #mount #fs  #opts #dump #pass |  #dev              #mount #fs  #opts #dump #pass
+/dev/mirror/rootfsa /      ufs  ro    1     1     | +/dev/label/rootfs /      ufs  ro    1     1
-/dev/mirror/rootfsa /      ufs  rw    1     1     | -/dev/label/rootfs /      ufs  rw    1     1
 /dev/label/swap0    none   swap sw    0     0     |  /dev/label/swap   none   swap sw    0     0
 /dev/label/swap1    none   swap sw    0     0     |
 /dev/label/swap2    none   swap sw    0     0     |
2.10. Reboot and enjoy modern install of FreeBSD system
Code:
# shutdown -r now
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
-- RAID1 for / and RAID5 for all other systems on setup with 3 disks

[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.]
.# rm /etc/termcap
+# mv /usr/share/misc/termcap /etc
+# ln -s /etc/termcap /usr/share/misc/termcap

-# cp /usr/share/misc/termcap /etc
1.3 / 2010-01-21 / removed unneeded mount commands [2.0.]
-# zfs mount basefs/var
-# zfs mount basefs/usr
1.4 / 2010-03-08 / added setup for 3 disks + cleanup
too much to fit here, we can as well call this new version RELOADED
1.5 / 2011-07-08 / added subsection: 2.4.1 Generate the newaliases(8) database





MIRROR THREAD: http://forums.freebsd.org/showthread.php?t=10334
POLISH VERSION: http://bsdguru.org/dyskusja/viewtopic.php?t=19392
__________________
religions, worst damnation of mankind
"If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds

Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”.
vermaden's: links resources deviantart spreadbsd

Last edited by vermaden; 8th July 2011 at 10:19 AM.
Reply With Quote
  #2   (View Single Post)  
Old 15th January 2010
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Thanked 112 Times in 104 Posts
Default

Personally Vermaden, I think I would call sysinstall a more the modern installation method. Unless you want to look at the 'Installing and Operating 4.4BSD UNIX' docs from the old System Managers Manual, and wonder what moron ever started to write sysinstall; no offence intended fwiw.


This thread reminds me of when one of my friends upgraded to FreeBSD 8 as a fresh install: he was annoyed to see how much work it was to set up a pure ZFS based system was compared to UFS, and sited ZFS as not "Production ready" on FreeBSD because of sysinstall. Then I reminded him that it's as production ready as FAT --> sysinstall uses the recommended defaults, if you don't like it, then it's YOUR problem to sort out the details, just like the rest of a real unix system.
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote
  #3   (View Single Post)  
Old 15th January 2010
bmk1st bmk1st is offline
Port Guard
 
Join Date: May 2008
Posts: 25
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by vermaden View Post
2.4. Tune ZFS filesystem (only for i386)
[code]newsystem# [COLOR="Green"]cat > /boot/laoder.conf << __EOF__
Found a typo

Good work and it's actually good timing for me. I'm planning to try FreeBSD 8 with ZFS on my i386 machine in a few days and I think I'll use your guide.

Thanks!
Reply With Quote
  #4   (View Single Post)  
Old 15th January 2010
vermaden's Avatar
vermaden vermaden is offline
Administrator
 
Join Date: Apr 2008
Location: pl_PL.lodz
Posts: 1,051
Thanked 118 Times in 93 Posts
Default

@bmk1st

Thanks, fixed.

Switching from Linux?
__________________
religions, worst damnation of mankind
"If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds

Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”.
vermaden's: links resources deviantart spreadbsd
Reply With Quote
  #5   (View Single Post)  
Old 15th January 2010
bmk1st bmk1st is offline
Port Guard
 
Join Date: May 2008
Posts: 25
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by vermaden View Post
@bmk1st

Thanks, fixed.

Switching from Linux?
No, I switched from Linux a long time ago. I'm an OpenBSD user since 3.4 and once in a while, I toyed with FreeBSD. FreeBSD was actually my first BSD (4.6 I think). I want to try it again because I'm interested in using ZFS. I have a 2.0 Ghz P4 machine sitting around and I've decided to put FreeBSD on it and use it as development & backup machine. All for fun.
Reply With Quote
  #6   (View Single Post)  
Old 8th March 2010
vermaden's Avatar
vermaden vermaden is offline
Administrator
 
Join Date: Apr 2008
Location: pl_PL.lodz
Posts: 1,051
Thanked 118 Times in 93 Posts
Default

I have added a section on how to create redundant setup with 3 disks and improved/simplified overall process.
__________________
religions, worst damnation of mankind
"If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds

Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”.
vermaden's: links resources deviantart spreadbsd
Reply With Quote
  #7   (View Single Post)  
Old 23rd March 2010
Broodjegehaktmetmayo Broodjegehaktmetmayo is offline
Shell Scout
 
Join Date: Sep 2008
Posts: 92
Thanked 0 Times in 0 Posts
Default

Complicated for me as a noob, but I am sure I will get it some day

Thanks for this tuto.
Reply With Quote
  #8   (View Single Post)  
Old 25th July 2010
vermaden's Avatar
vermaden vermaden is offline
Administrator
 
Join Date: Apr 2008
Location: pl_PL.lodz
Posts: 1,051
Thanked 118 Times in 93 Posts
Default

After FreeBSD 8.1-RELEASE has been released, we can now upgrade our ZPOOL(s) to newer (v13 --> v14) version, below You will find simple way to achieve that.

First check what is currently on You system:
Code:
# uname -m -r
8.1-RELEASE amd64

# zfs get version basefs
NAME    PROPERTY  VALUE    SOURCE
basefs  version   3        -

# zpool list -o version
VERSION
     13
Now lets proceed with the zpool/zfs upgrade procedure:
Code:
# zpool upgrade
This system is currently running ZFS pool version 14.

The following pools are out of date, and can be upgraded.  After being
upgraded, these pools will no longer be accessible by older software versions.

VER  POOL
---  ------------
13   basefs

Use 'zpool upgrade -v' for a list of available versions and their associated
features.

# zpool upgrade basefs
This system is currently running ZFS pool version 14.

Successfully upgraded 'basefs' from version 13 to version 14

# zfs upgrade
This system is currently running ZFS filesystem version 3.

All filesystems are formatted with the current version.
After the upgrade we can check again our ZPOOL(s) version:
Code:
# zpool list -o version
VERSION
     14
Your pool is now upgraded to newest 'release' zpool/zfs version.
__________________
religions, worst damnation of mankind
"If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds

Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”.
vermaden's: links resources deviantart spreadbsd
Reply With Quote
  #9   (View Single Post)  
Old 2nd August 2010
Crypt Crypt is offline
Port Guard
 
Join Date: Aug 2008
Location: Ajax, Ontario
Posts: 32
Thanked 0 Times in 0 Posts
Default

Man do I have a lot left to learn about BSD
Reply With Quote
Old 10th July 2011
sharris sharris is offline
Package Pilot
 
Join Date: Jun 2010
Posts: 146
Thanked 0 Times in 0 Posts
Default

I once was told that "a thread lives forever". I'm not into ZFS but your thread sent me on my way to learn how to do more things manually because technology is moving forward and if something throws me off I'll know how to handle it, manually. Wouldn't it not be great to re-find your thread one morning in the year 2020 and someone added advanced technology using your idea or simply wanted to say Thanks.

Thanks

July 10, 2011
Reply With Quote
Old 11th July 2011
vermaden's Avatar
vermaden vermaden is offline
Administrator
 
Join Date: Apr 2008
Location: pl_PL.lodz
Posts: 1,051
Thanked 118 Times in 93 Posts
Default

@sharris

Thank You mate, I appreciate it.

I should also mention that a lot of that credit should also go to corey_james and his thread (http://www.daemonforums.org/showthread.php?t=1538) which also helped me.

Pity corey_james hasn't been active on our forums for more then 2 years now
__________________
religions, worst damnation of mankind
"If 386BSD had been available when I started on Linux, Linux would probably never had happened." Linus Torvalds

Linux is not UNIX! Face it! It is not an insult. It is fact: GNU is a recursive acronym for “GNU's Not UNIX”.
vermaden's: links resources deviantart spreadbsd
Reply With Quote
Reply

Tags
ahci, gjournal, install, lodaer.conf, rc.conf, setup, swap, sysinstall, termcap, tmp, tmpmfs, zfs

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
HOWTO: Install and configure NVIDIA drivers on FreeBSD tangram Guides 2 29th March 2009 08:23 PM
HOWTO: Install and setup MLDonkey on FreeBSD tangram Guides 0 7th January 2009 05:13 PM
HOWTO: Always install an up-to-date port chris Guides 8 28th May 2008 11:53 AM


All times are GMT. The time now is 04:11 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick