LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > *BSD
User Name
Password
*BSD This forum is for the discussion of all BSD variants.
FreeBSD, OpenBSD, NetBSD, etc.

Notices

Reply
 
Search this Thread
Old 01-21-2010, 03:05 PM   #1
vermaden
Member
 
Registered: Jan 2006
Location: pl_PL.lodz
Distribution: FreeBSD
Posts: 395

Rep: Reputation: 80
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.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  rw    1     1     | +/dev/label/rootfs /      ufs  rw    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
MIRROR THREAD: http://daemonforums.org/showthread.php?t=4200
MIRROR THREAD: http://forums.freebsd.org/showthread.php?t=10334
POLISH VERSION: http://bsdguru.org/dyskusja/viewtopic.php?t=19392

Last edited by vermaden; 06-23-2010 at 01:45 PM.
 
Old 01-25-2010, 02:19 PM   #2
Jeebizz
Senior Member
 
Registered: May 2004
Distribution: Slackware 14.1 64-bit with multilib
Posts: 2,074

Rep: Reputation: 199Reputation: 199
This is actually really cool! Nice work and maybe this should be stickied. I also wondered how would you install FreeBSD with ZFS, when the standard installer only had the option for UFS/UFS+. Kinda disappointed that version 8 didn't even give you that option. Maybe in 8.1 this might be addressed, but if not your method can be used.
 
Old 01-26-2010, 09:47 AM   #3
rndm_luser
LQ Newbie
 
Registered: Jan 2009
Posts: 8

Rep: Reputation: 1
Thank you for sharing. I am relatively new to FreeBSD and didn't know about freebsd-update. It looks like it will be useful for patching production systems that you want to keep on a release candidate rather than going through the process of updating from CVS sources.
 
Old 03-08-2010, 07:54 AM   #4
vermaden
Member
 
Registered: Jan 2006
Location: pl_PL.lodz
Distribution: FreeBSD
Posts: 395

Original Poster
Rep: Reputation: 80
@Jeebizz | @rndm_luser

Thanks, I have added a section on how to create redundant setup with 3 disks and improved/simplified overall process.
 
Old 06-12-2010, 09:46 AM   #5
blood_omen
Member
 
Registered: Apr 2004
Location: Canada
Distribution: OpenBSD 3.6, Slackware 10.1
Posts: 134

Rep: Reputation: 15
Greetings:

I'm following the instructions, but when I get to section 2.0 and issue /rescue/zpool import -D I get an error: no pools available to import.

I have to mention that for some reason FreeBSD recognizes my ONLY drive as ad4 instead ad ad0, I follow all the steps using ad4 and I get no errors except when issuing /rescue/zpool import -D

Any help is appreciated.
 
Old 06-23-2010, 01:47 PM   #6
vermaden
Member
 
Registered: Jan 2006
Location: pl_PL.lodz
Distribution: FreeBSD
Posts: 395

Original Poster
Rep: Reputation: 80
@blood_omen

Try /rescue/zpool import -f basefs instead of /rescue/zpool import -D then.

If Your chipset does not support AHCI, then You will have ad0/ad1/ad2/... disks, they do not always start from ad0 (STATIC NUMBERING is enabled by default on the kernel config), but that is not important since You will be using LABELS instead.
 
Old 06-24-2010, 12:13 AM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,971
Blog Entries: 11

Rep: Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876
Hi,

I've stickied your thread, really good work; I'd recommend a closure,
though, as it may quickly become very cluttered. What are your/others
thoughts on a closure?



Cheers,
Tink
 
Old 06-24-2010, 10:26 AM   #8
vermaden
Member
 
Registered: Jan 2006
Location: pl_PL.lodz
Distribution: FreeBSD
Posts: 395

Original Poster
Rep: Reputation: 80
@Tinkster

Hi and thanks.

I would not close it personally, there are always some questions and problems with such big/complicated howtos, as for the 'growing problem', I have also put that howto on other forums, some grew up to 4-5 pages, and sometimes even still grow (I even got late questions about this guide if it works on FreeBSD/SPARC, and the funny thing is it even works there), but I do not see that as a problem, 1st post will remain the howto with all the rest as discussion/comments. I also got several very helpful responds just after posting the howto, which showed several errors in the process, there still may be some smaller ones, as I cannot try every possible configuration out there.

So to make my idea short, IMHO we should not close it.

Regards mate.
 
Old 06-24-2010, 02:47 PM   #9
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,971
Blog Entries: 11

Rep: Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876Reputation: 876
Your call ... my concern was (is) that it will end up as a
catch-all thread for any random questions popping up.



Cheers,
Tink
 
Old 07-25-2010, 01:48 PM   #10
vermaden
Member
 
Registered: Jan 2006
Location: pl_PL.lodz
Distribution: FreeBSD
Posts: 395

Original Poster
Rep: Reputation: 80
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.
 
1 members found this post helpful.
Old 12-04-2010, 02:03 AM   #11
c0mputerking
LQ Newbie
 
Registered: Jul 2007
Posts: 18

Rep: Reputation: 0
Great tutorial thanks, but......

why did u use raid 5 for the zfs partition instead of zraid? I think zraid is superior to even raid5. Just curious why you would setup zfs, and not use its best feature zraid! am i missing something. I am debating weather to use this tutorial, or the automagic mfsroot installer which broke for me after updates something about expecting version 14 got version 15

I might try just the update section of these posts maybe it will fix my mfsroot errors, however i have to agree with you about root being on raid 1, root on zfs (zraid) makes me kind of nervous what if something goes wrong? but then again software raid 1 can be a b!tch too when things go wrong
 
Old 12-04-2010, 08:04 PM   #12
vermaden
Member
 
Registered: Jan 2006
Location: pl_PL.lodz
Distribution: FreeBSD
Posts: 395

Original Poster
Rep: Reputation: 80
Quote:
Originally Posted by c0mputerking View Post
Great tutorial thanks, but......

why did u use raid 5 for the zfs partition instead of zraid?
Have You checked 1.4 section?
Code:
# zpool create basefs raidz ad0s3 ad1s3 ad2s3
I USE raidz, but its equivalent of RAID5, same for raidz2 as RAID6
 
1 members found this post helpful.
Old 11-21-2012, 12:52 PM   #13
charlie_lab
Member
 
Registered: Nov 2006
Posts: 255

Rep: Reputation: 30
Hello,

Maybe a stupid question but can this also be working on a disk where freebsd is on the second partition.
On the first 200G is Win7 installed and on the last 100G FreeBSD can be installed.
If so, what are the names of the disk then ?

Roelof
 
Old 11-21-2012, 02:37 PM   #14
vermaden
Member
 
Registered: Jan 2006
Location: pl_PL.lodz
Distribution: FreeBSD
Posts: 395

Original Poster
Rep: Reputation: 80
ada0 - disk
ada0s1 - 1st MBR partition (Windows)
ada0s2 - 2nd MBR partition (FreeBSD)
ada0s2a - 1st BSDLABEL partition of 2nd MBR partition

I haven't setup FreeBSD boot alongside Windows 7, so You will have to google that out.

Just make sure that both Windows and FreeBSD MBR partitions are PRIMARY partitions.
 
Old 11-21-2012, 02:45 PM   #15
charlie_lab
Member
 
Registered: Nov 2006
Posts: 255

Rep: Reputation: 30
Thanks

So ad0 for me is ad0s1 ??
And can I better follow this one or better the newer tutorial which can be found here : http://www.linuxquestions.org/questi...sd-4175412036/

Roelof
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Modern Warfare 2 dive Linux - Games 14 01-31-2010 08:01 AM
FreeBSD VMail Howto hosler *BSD 2 10-08-2006 08:23 PM
freebsd 4.7 howto upgrate stable kernelvn *BSD 0 06-20-2005 10:32 AM
howto update KDE by freeBSD 5.2.1 without errors ? cccc *BSD 16 10-04-2004 11:27 AM
howto install shockwave plugin on freeBSD ? cccc *BSD 4 08-25-2004 03:58 AM


All times are GMT -5. The time now is 04:34 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration