HOWTO: Install FreeBSD 9.0 RELEASE (Root on UFS + ZFS, RAID1)

Would you like to share some of your solutions for certain problems? Tips or tricks? Post here. All new topics are automatically moderated.

HOWTO: Install FreeBSD 9.0 RELEASE (Root on UFS + ZFS, RAID1)

Postby vand777 » 21 Jan 2012, 21:03

I'll show how to install FreeBSD 9.0 RELEASE on the machine with 2 disks (RAID 1). I'll use the following logical layout:

Code: Select all
UFS 1G   /           ro
ZFS *    /home       rw
ZFS *    /tmp        rw
UFS *    /usr        ro | softupdates (mounted r/w only for packages updates)
ZFS *    /usr/obj    rw
ZFS *    /usr/ports  rw
ZFS *    /usr/src    rw
ZFS *    /var        rw
UFS 1G   /var/db/pkg ro | softupdates (mounted r/w only for packages updates)
vand777
Member
 
Posts: 292
Joined: 20 Jun 2010, 17:26
Location: London

Postby vand777 » 21 Jan 2012, 21:05

(1) Boot from a FreeBSD9 installation DVD or memstick and choose "Live CD".

(2) Load the necessary kernel modules.
Code: Select all
# kldload geom_mbr.ko
# kldload geom_mirror.ko
# kldload opensolaris.ko
# kldload zfs.ko


(3) Create the necessary partitions on the disks.
Code: Select all
# sh
# disk0=da0
# disk1=da1
# gpart create -s gpt $disk0
# gpart add -b 34 -s 94 -t freebsd-boot $disk0
# gpart add -s 1G -t freebsd-ufs $disk0
# gpart add -s 4G -t freebsd-swap $disk0
# gpart add -s 1G -t freebsd-ufs $disk0
# gpart add -s 8G -t freebsd-ufs $disk0
# gpart add -t freebsd-zfs $disk0
# gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 $disk0
# gpart backup $disk0 | gpart restore -F $disk1


(4) Create RAID1 for UFS and swap filesystems.
Code: Select all
# gmirror label  root  ${disk0}p2 ${disk1}p2
# gmirror label  swap  ${disk0}p3 ${disk1}p3
# gmirror label  pkg   ${disk0}p4 ${disk1}p4
# gmirror label  usr   ${disk0}p5 ${disk1}p5
vand777
Member
 
Posts: 292
Joined: 20 Jun 2010, 17:26
Location: London

Postby vand777 » 21 Jan 2012, 21:07

(5) Create filesystems and mount them.
Code: Select all
# newfs -m 1 /dev/mirror/root
# newfs -m 1 -U /dev/mirror/pkg
# newfs -m 1 -U /dev/mirror/usr
# mkdir /tmp/NEWROOT
# mount /dev/mirror/root /tmp/NEWROOT
# mkdir /tmp/NEWROOT/usr
# mount /dev/mirror/usr /tmp/NEWROOT/usr
# zpool create -m /tmp/NEWROOT/basefs basefs mirror ${disk0}p6 ${disk1}p6
# zfs create -o mountpoint=/tmp/NEWROOT/home basefs/home
# zfs create -o mountpoint=/tmp/NEWROOT/var basefs/var
# zfs create -o mountpoint=/tmp/NEWROOT/tmp basefs/tmp
# zfs create -o mountpoint=none basefs/usr
# zfs create -o mountpoint=/tmp/NEWROOT/usr/obj basefs/usr/obj
# zfs create -o mountpoint=/tmp/NEWROOT/usr/ports basefs/usr/ports
# zfs create -o mountpoint=/tmp/NEWROOT/usr/src basefs/usr/src


P.S. Feel free to play with ZFS filesystems options and create additional filesystems if you need/want.

(6) Install FreeBSD.
Code: Select all
# cd /usr/freebsd-dist
# export DESTDIR=/tmp/NEWROOT
# for file in base.txz lib32.txz kernel.txz;
# do (cat $file | tar --unlink -xpJf - -C ${DESTDIR:-/}); done
vand777
Member
 
Posts: 292
Joined: 20 Jun 2010, 17:26
Location: London

Postby vand777 » 21 Jan 2012, 21:09

(7) Provide basic configuration.
Code: Select all
# cat > /tmp/NEWROOT/etc/fstab << __EOF__             
#dev                #mount        #fs  #opts #dump #pass
/dev/mirror/root    /             ufs  rw    1     1     
/dev/mirror/swap    none          swap sw    0     0 
/dev/mirror/usr     /usr          ufs  rw    2     2 
basefs/var          /var          zfs  rw    0     0
/dev/mirror/pkg     /var/db/pkg   ufs  rw    2     2 

basefs              /basefs       zfs  rw    0     0
basefs/home         /home         zfs  rw    0     0
basefs/usr/obj      /usr/obj      zfs  rw    0     0
basefs/usr/ports    /usr/ports    zfs  rw    0     0
basefs/usr/src      /usr/src      zfs  rw    0     0
basefs/tmp          /tmp          zfs  rw    0     0
__EOF__   

# cat > /tmp/NEWROOT/boot/loader.conf << __EOF__     
zfs_load="YES"                                 
ahci_load="YES"                                 
geom_mirror_load="YES"                         
__EOF__ 

# cat > /tmp/NEWROOT/etc/rc.conf << __EOF__
zfs_enable="YES"
__EOF__


(8) Unmount filesystems and reboot.
Code: Select all
# cd /
# zfs umount -a
# umount /tmp/NEWROOT/usr
# umount /tmp/NEWROOT
# zfs set mountpoint=/home basefs/home
# zfs set mountpoint=/var basefs/var
# zfs set mountpoint=/tmp basefs/tmp
# zfs set mountpoint=/usr/obj basefs/usr/obj
# zfs set mountpoint=/usr/ports basefs/usr/ports
# zfs set mountpoint=/usr/src basefs/usr/src
# zpool export basefs
# reboot
vand777
Member
 
Posts: 292
Joined: 20 Jun 2010, 17:26
Location: London

Postby vand777 » 21 Jan 2012, 21:12

(9) Boot FreeBSD in single user mode.
Code: Select all
# mount -w /
# zpool import -f basefs
# reboot


(10) Set root password
Code: Select all
# passwd


(11) Set hostname
Code: Select all
# echo hostname=\"HOSTNAME\" >> /etc/rc.conf


(12) Set timezone
Code: Select all
# tzsetup


(13) Move termcap into [FILE]/etc[/FILE] (instead of useless link on crash)
Code: Select all
# rm /etc/termcap
# mv /usr/share/misc/termcap /etc
# ln -s /etc/termcap /usr/share/misc/termcap


(14) Setup networking and do any other necessary changes to [FILE]/etc[/FILE].

(15) Add latest security patches.
Code: Select all
# freebsd-update fetch
# freebsd-update install


(16) Set [FILE]/[/FILE] to be mounted read-only in [FILE]/etc/fstab[/FILE].
Code: Select all
[color="Green"]+/dev/mirror/root /      ufs  ro    1     1   [/color]
[color="Red"]-/dev/mirror/root /      ufs  rw    1     1[/color]   


(17) Reboot and enjoy.
Code: Select all
# reboot
vand777
Member
 
Posts: 292
Joined: 20 Jun 2010, 17:26
Location: London

Postby vand777 » 21 Jan 2012, 21:13

Reserved 1
vand777
Member
 
Posts: 292
Joined: 20 Jun 2010, 17:26
Location: London

Postby vand777 » 21 Jan 2012, 21:14

Reserved 2
vand777
Member
 
Posts: 292
Joined: 20 Jun 2010, 17:26
Location: London

Postby vand777 » 21 Jan 2012, 21:14

Reserved 3
vand777
Member
 
Posts: 292
Joined: 20 Jun 2010, 17:26
Location: London

Postby vand777 » 21 Jan 2012, 21:14

Reserved 4
vand777
Member
 
Posts: 292
Joined: 20 Jun 2010, 17:26
Location: London

Postby phoenix » 21 Jan 2012, 21:37

Just a quick note: if you have a separate /home, then you don't need the symlink.
Freddie

Help for FreeBSD: Handbook, FAQ, man pages, mailing lists.
User avatar
phoenix
MFC'd
 
Posts: 3349
Joined: 17 Nov 2008, 05:43
Location: Kamloops, BC, Canada

Postby vand777 » 21 Jan 2012, 22:21

phoenix wrote:Just a quick note: if you have a separate /home, then you don't need the symlink.


Thank you. Will remove it from the guide in a second.
vand777
Member
 
Posts: 292
Joined: 20 Jun 2010, 17:26
Location: London

Postby RusDyr » 24 Jan 2012, 09:12

I never can understand why do you need create such a numbers of [zfs] partitions like [FILE]/usr/ports[/FILE], [FILE]/usr/obj/[/FILE], [FILE]/usr/ports/distfiles[/FILE] and so on. It's excessive, doesn't neccesary for quick installation and obviusly can be done later.
This zfs partitioning way is in almost all howtos. Does anybody think the sense of it?
RusDyr
Junior Member
 
Posts: 83
Joined: 07 Nov 2011, 11:10
Location: St.Petersburg, Russia

Postby matoatlantis » 24 Jan 2012, 09:34

RusDyr wrote:I never can understand why do you need create such a numbers of [zfs] partitions like /usr/ports, /usr/obj/, /usr/ports/distfiles and so on. It's excessive, doesn't neccesary for quick installation and obviusly can be done later.
This zfs partitioning way is in the almost each howtos. Does anybody think the sense of it?


With [FILE]ZFS[/FILE], these tasks are much easier indeed; using UFS-only setup you have to do it beforehand. But I think it's _the_ perfect place to do it during installation. You're not on time trial when installing new BSD, are you? It only takes couple of seconds to do it right.
[color="Gray"]..when you do things right, people won't be sure you've done anything at all..[/color]
User avatar
matoatlantis
Member
 
Posts: 512
Joined: 26 Mar 2009, 21:07
Location: bratislava, slovakia

Postby RusDyr » 25 Jan 2012, 07:24

What's the point? There is no difference in [FILE]/usr/ports[/FILE], [FILE]/usr/obj[/FILE] and so on at least in current ZFS configuration.
RusDyr
Junior Member
 
Posts: 83
Joined: 07 Nov 2011, 11:10
Location: St.Petersburg, Russia

Postby gkontos » 25 Jan 2012, 10:02

RusDyr wrote:What's the point? There is no difference in [FILE]/usr/ports[/FILE], [FILE]/usr/obj[/FILE] and so on at least in current ZFS configuration.


There is a difference because if you want to set specific properties to those datasets, compression for example, you have to do it before they get populated.

[FILE]/usr/src[/FILE] is a good candidate for compression but if you set this after the installation then you pretty much don't have any.

[FILE]/usr/ports[/FILE] is another good candidate. But [FILE]/usr/ports/distfiles[/FILE] is not since it usually contains compressed files.

Of course all those are suggestions and anybody can improvise.

Regards
Powered by BareBSD
User avatar
gkontos
Senior Member
 
Posts: 1370
Joined: 09 Dec 2009, 08:36
Location: Polidendri, GR

Postby matoatlantis » 25 Jan 2012, 13:04

RusDyr wrote:What's the point? There is no difference in /usr/ports, /usr/obj and so on at least in current ZFS configuration.


For example, when you do a [FILE]/usr[/FILE] snapshot. I don't care about [FILE]/usr/ports/*[/FILE] , [FILE]/usr/src/*[/FILE] at all.
You don't need [FILE]/usr/ports[/FILE] for kernel debugging; [FILE]/usr/obj[/FILE] can be shared to others too (when possible). So it does make sense to separate it.


Reasons for separate FS?

* backup/restore (do I need to back it up?) - restore time
* mount options (performance and/or security)
* implications when FS gets full or corrupted (can it be restored online ?)
[color="Gray"]..when you do things right, people won't be sure you've done anything at all..[/color]
User avatar
matoatlantis
Member
 
Posts: 512
Joined: 26 Mar 2009, 21:07
Location: bratislava, slovakia

Postby bbzz » 25 Jan 2012, 14:27

All above and [FILE]zfs list[/FILE] show quickly how much space is taken in each fs :)
bbzz
Member
 
Posts: 858
Joined: 04 Nov 2010, 01:07
Location: random

Postby RusDyr » 26 Jan 2012, 08:55

Yeah, I thought about snapshots after I've wrote it.
Freeing space by compression or deduplication isn't valuable, especially on systems where are ZFS is (storage servers, isn't it?). ;)
RusDyr
Junior Member
 
Posts: 83
Joined: 07 Nov 2011, 11:10
Location: St.Petersburg, Russia

Postby gkontos » 26 Jan 2012, 14:14

RusDyr wrote:Yeah, I thought about snapshots after I've wrote it.
Freeing space by compression or deduplication isn't valuable, especially on systems where are ZFS is (storage servers, isn't it?). ;)


Your original question was why all guides create so many ZFS datasets during installation, instead of doing this afterwards.

This has nothing to do with snapshots whatsoever. The only reason why you might want to create a dataset before installing the OS, is because you want to assign certain properties such as, [FILE]compression[/FILE], [FILE]dedup[/FILE], [FILE]copies[/FILE], etc.

I hope this clarifies your question.
Powered by BareBSD
User avatar
gkontos
Senior Member
 
Posts: 1370
Joined: 09 Dec 2009, 08:36
Location: Polidendri, GR

Postby beesatmsu » 26 Jan 2012, 20:48

I am trying this now. First time I tried the
Code: Select all
# kldload geom_mbr.ko
It gave me a bunch of errors. however after I tried the second line, then went back to try it again, it says file aleady exists. So I hope it was loaded.

Now I am stuck at
Code: Select all
# gpart backup $disk0 | gpart restore -F $disk1
because it says
Code: Select all
gpart: geom 'ada1': Operation not permitted


[FILE]dmesg[/FILE] says I have [FILE]ada0[/FILE] and [FILE]ada1[/FILE], both 1TB drives. It appears [FILE]ada1[/FILE] is not writable.
beesatmsu
Member
 
Posts: 225
Joined: 07 Apr 2010, 14:11

Postby beesatmsu » 26 Jan 2012, 21:07

So I proceeded as if I had a single disk and ignored disk1. I had to omit 'mirror' and [FILE]${disk1}[/FILE] in the [FILE]zpool[/FILE] command.

But now I tried exactly:

Code: Select all
# cd /usr/freebsd-dist
# export DESTDIR=/tmp/NEWROOT
# for file in base.txz lib32.txz kernel.txz;
# do (cat $file | tar --unlink -xpJf - -C ${DESTDIR:-/}); done


and got:

Code: Select all
cat: lib32.txz: no such file or directory.


I am using a [color="Silver"][del]freebsd[/del][/color] FreeBSD 9.0 bootdisk (i386).
beesatmsu
Member
 
Posts: 225
Joined: 07 Apr 2010, 14:11

Postby beesatmsu » 26 Jan 2012, 21:13

indeed, ls gives:
Code: Select all
MANIFEST
doc.txz
kernel.txz
src.txz
base.txz
games.txz
ports.txz


but no lib32.txz.
beesatmsu
Member
 
Posts: 225
Joined: 07 Apr 2010, 14:11

Postby matoatlantis » 26 Jan 2012, 21:44

gkontos wrote:The only reason why you might want to create a dataset before installing the OS, is because you want to assign certain properties such as, [FILE]compression[/FILE], [FILE]dedup[/FILE], [FILE]copies[/FILE], etc.


Now that's quite some harsh statement (especially "the only" part).
[color="Gray"]..when you do things right, people won't be sure you've done anything at all..[/color]
User avatar
matoatlantis
Member
 
Posts: 512
Joined: 26 Mar 2009, 21:07
Location: bratislava, slovakia

Postby gkontos » 27 Jan 2012, 00:03

matoatlantis wrote:Now that's quite some harsh statement (especially "the only" part).


Ok, would like to elaborate?
Powered by BareBSD
User avatar
gkontos
Senior Member
 
Posts: 1370
Joined: 09 Dec 2009, 08:36
Location: Polidendri, GR

Postby beesatmsu » 27 Jan 2012, 03:35

Oops, just found out my boot disk was 9.0-RC3, not 9.0-release as I thought. Will try again tomorrow.
beesatmsu
Member
 
Posts: 225
Joined: 07 Apr 2010, 14:11

Next

Return to Howtos & FAQs (Moderated)

Who is online

Users browsing this forum: No registered users and 1 guest