Fileserver mit FreeBSD und ZFS

Sunday, December 6. 2009

Hardware:

  • Intel D945GCLF2

  • 2 x Samsung HM320JI 320GB 2.5" HDD


Installation von der FreeBSD 8.0 DVD
Ressourcen:
[1] http://www.chruetertee.ch/blog/archive/2009/07/29/freebsd-nur-auf-zfs-installieren.html
[2] http://rhyous.com/2009/12/01/how-to-install-freebsd-8-0-using-only-zfs-partitions/

Ein erster Versuch nach der Anleitung von [1] schlug leider fehl. Nach eingehender Nachforschung bin ich auf den Hinweis gestossen, dass das BIOS auf dem verwendeten Motherboard offenbar nicht von Festplatten mit GPT booten kann. Im zweiten Anlauf hab ich daher eine MBR-Partitionstabelle verwendet.
Booten von der FreeBSD DVD und danach in den 'Fixit'-Modus wechseln.

Die ganzen Festplatten für FreeBSD verwenden:


Fixit# gpart create -s mbr ad4
ad4 created
Fixit# gpart create -s mbr ad6
ad6 created
Fixit# gpart show ad4
=>       63  625142385  ad4  MBR  (298G)
         63  625142385       - free -  (298G)

Fixit# gpart show ad6
=>       63  625142385  ad6  MBR  (298G)
         63  625142385       - free -  (298G)
 


Auf den Festplatten je ein Slice erstellen, welches die ganze Festplatte benützt


Fixit# gpart add -b 63 -s 625142385 -t freebsd ad4
ad4s1 added
Fixit# gpart add -b 63 -s 625142385 -t freebsd ad6
ad6s1 added
Fixit# gpart create -s BSD ad4s1
ad4s1 created
Fixit# gpart create -s BSD ad6s1
ad6s1 created
 


Den Slice als aktiv markieren


Fixit# gpart set -a active -i 1 ad4
ad4s1 has active set
Fixit# gpart set -a active -i 1 ad6
ad6s1 has active set
Fixit# gpart show ad4s1
=>        0  625142385  ad4s1  BSD  (298G)
          0  625142385         - free -  (298G)

Fixit# gpart show ad6s1
=>        0  625142385  ad6s1  BSD  (298G)
          0  625142385         - free -  (298G)
 


Eine /-Partition erstellen


Fixit# gpart add -i 1 -b 0 -s 625142385 -t freebsd-zfs ad4s1
ad4s1a added
Fixit# gpart add -i 1 -b 0 -s 625142385 -t freebsd-zfs ad6s1
ad6s1a added
 


ZFS Kernel Module laden


kldload /mnt2/boot/kernel/opensolaris.ko
kldload /mnt2/boot/kernel/zfs.ko
 


ZFS pool mit mirroring erstellen ('rpool' ist bloss der Name des pools, welcher frei gewählt werden kann)


Fixit# zpool create rpool mirror /dev/ad4s1a /dev/ad6s1a
Fixit# zpool set bootfs=rpool rpool
 


Bootloader installieren


Fixit# gpart bootcode -b /mnt2/boot/boot0 ad4
ad4 has bootcode
Fixit# gpart bootcode -b /mnt2/boot/boot0 ad6
ad6 has bootcode
 


zpool.cache Datei erstellen (wird später benötigt)


Fixit# mkdir /boot/zfs
Fixit# zpool export rpool
 


ZFS boot installieren


Fixit# dd if=/mnt2/boot/zfsboot of=/dev/ad4s1 count=1
1+0 records in
1+0 records out
512 bytes transferred in 0.000285 secs (1797057 bytes/sec)
Fixit# ddiif=/mnt2/boot/zfsboot of=/dev/ad6s1 count=1
1+0 records in
1+0 records out
512 bytes transferred in 0.000281 secs (1821445 bytes/sec)
Fixit# dd if=/mnt2/boot/zfsboot of=/dev/ad6s1a skip=1 seek=1024
64+0 records in
64+0 records out
32768 bytes transferred in 0.486839 secs (67308 bytes/sec)
Fixit# dd if=/mnt2/boot/zfsboot of=/dev/ad4s1a skip=1 seek=10244
64+0 records in
64+0 records out
32768 bytes transferred in 0.011327 secs (2892904 bytes/sec)
 


ZFS pool wieder importieren und Dateisystem erstellen


Fixit# zpool import rpool
Fixit# zfs create rpool/tmp
Fixit# zfs create rpool/var
Fixit# zfs create rpool/usr
 


Swap partition auf ZFS erstellen


Fixit# zfs create -V 2gb rpool/swap
Fixit# zfs set org.freebsd:swap=on rpool/swap
Fixit# zfs set checksum=off rpool/swap
 


FreeBSD installieren


Fixit# cd /dist/8.0-RELEASE
Fixit# export DESTDIR=/rpool
Fixit# for dir in base catpages dict doc games info lib32 manpages ports; \
> do (cd $dir; ./install.sh); done
Fixit# cd src
Fixit# ./install.sh all
Fixit# cd ../kernels
Fixit# ./install.sh generic
Fixit# cd /rpool/boot
Fixit# cp -Rlp GENERIC/* kernel/
Fixit# chroot /rpool
Fixit# echo 'zfs_enable="YES"' > /etc/rc.conf
Fixit# echo 'hostname="mydomain.com"' >> /etc/rc.confg
Fixit# echo 'ifconfig_re0="DHCP"' >> /etc/rc.conf
Fixit# echo 'zfs_load="YES"' > /boot/loader.conf
Fixit# echo 'vfs.root.mountfrom="zfs:rpool"' >> /boot/loader.conf
Fixit# echo 'LOADER_ZFS_SUPPORT="YES"' > /etc/src.conf
Fixit# mount -t devfs devfs /dev
Fixit# unset DESTDIR=
Fixit# cd /usr/src/sys/boot
Fixit# make obj && make depend && make
Fixit# cd i386/loader
Fixit# make install
Fixit# passwd
Fixit# tzsetup
Fixit# cd /etc/mail
Fixit# make aliases
Fixit# umount /dev
Fixit# exit
 


zpool.cache kopieren


Fixit# cp /boot/zfs/zpool.cache /rpool/boot/zfs/
Fixit# touch /rpool/etc/fstab
Fixit# export LD_LIBRARY_PATH=/mnt2/lib
Fixit# cd /
Fixit# zfs umount -a
 


Mountpoints setzen


Fixit# zfs set mountpoint=legacy rpool
Fixit# zfs set mountpoint=/tmp rpool/tmp
Fixit# zfs set mountpoint=/var rpool/var
Fixit# zfs set mountpoint=/usr rpool/usr
Fixit# exit
 

Trackbacks


Trackback specific URI for this entry
    No Trackbacks

Comments


    No comments

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
You can use [geshi lang=lang_name [,ln={y|n}]][/geshi] tags to embed source code snippets.
Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

BBCode format allowed