Build a home server - part 7

Configure Flashcache
root@ohlala:~# cd /usr/src/
root@ohlala:/usr/src# git clone git://anonscm.debian.org/collab-maint/flashcache.git
Cloning into 'flashcache'...
root@ohlala:/usr/src# cd flashcache/
root@ohlala:/usr/src/flashcache# make
root@ohlala:/usr/src/flashcache# make clean
root@ohlala:/usr/src/flashcache# make install
root@ohlala:/usr/src/flashcache# make -f Makefile.dkms boot_conf

root@ohlala:/usr/src/flashcache# vi /etc/sysctl.conf


Add
#####################
# Flashcache settings
#####################
#
# Using Writethrough
#

# (All modes) Global caching mode to cache everything
dev.flashcache.md1+data-ftest.cache_all = 1

# (All modes) Change the reclaim policy to LRU from FIFO
dev.flashcache.md1+data-ftest.reclaim_policy = 1


Enable Flashcache (please check Robert Vojcik's blogg)
Edit /etc/default/flashcache:
#
# FlashCache Configuration#

# FlashCache configured ?
FLASH_CACHE_START=YES

# FlashCache binaries
FLASH_CACHE_BIN=/sbin

# New Flashcache device
FLASH_CACHE_DEV=fcache

# Original data device
DATA_DEV=/dev/mapper/data-ftest

# Cache device - Fast disk / SSD
CACHE_DEV=/dev/md1

# block size
BLOCK_SIZE=4k

# cache type (-p back|around|thru)
CACHE_TYPE=thru

Edit /etc/init/flashcache-init. Do not forget to chmod a+x /etc/init.d/flashcache-init.
#!/bin/bash
### BEGIN INIT INFO
# Provides:          flashcache-init
# Required-Start:
# Required-Stop:
# Default-Start:     S
# Default-Stop:      0 6
# Short-Description: Prepare flashcache device during boot time
# Description:       Create flashcache device during boot
### END INIT INFO
# debian lenny
# update-rc.d flashcache-init start 27 S . stop 45 0 6 .

# Load Configuration
. /etc/default/flashcache

export PATH=$PATH:$FLASH_CACHE_BIN:/usr/bin:/usr/sbin/

function do_start {

if ! [[ "$FLASH_CACHE_START" = "YES" ]] ; then

echo " --- Flashcache not configured or turned off"
exit 0

fi

echo " --- Starting FlashCache"
echo -n " --- Loading kernel module..."

if modprobe flashcache ; then
echo "OK"
else
echo "FAILED"
exit 1
fi

if [[ "$CACHE_TYPE" == "back" ]] ; then
echo " --- Trying to load FlashCache - $CACHE_TYPE"
if flashcache_load $CACHE_DEV; then

echo " --- Loading FlashCache OK - $CACHE_TYPE"

else

echo " --- ERROR: Problem during FlashCache loading"
exit 1

fi
fi

if [[ "$CACHE_TYPE" == "thru" ]] ; then
echo " --- Trying to initialize FlashCache, type: $CACHE_TYPE"
if flashcache_create -v -p $CACHE_TYPE -b $BLOCK_SIZE $FLASH_CACHE_DEV $
CACHE_DEV $DATA_DEV; then

echo " --- Initializing FlashCache OK, type: $CACHE_TYPE"

else

echo " --- ERROR: Problem during FlashCache initialization - typ
e: $CACHE_TYPE"
exit 1

fi
fi

if [[ "$CACHE_TYPE" = "around" ]] ; then
echo " --- Trying to initialize FlashCache, type: $CACHE_TYPE"
if flashcache_create -v -p $CACHE_TYPE -b $BLOCK_SIZE $FLASH_CACHE_DEV $
CACHE_DEV $DATA_DEV; then

echo " --- Initializing FlashCache OK, type: $CACHE_TYPE"

else

echo " --- ERROR: Problem during FlashCache initialization, type
: $CACHE_TYPE"
exit 1

fi
fi
}

function do_stop {

echo " --- Stopping FlashCache."
if dmsetup remove $FLASH_CACHE_DEV ; then
echo " --- Successfully removed."
exit
else
echo " --- ERROR: Some problems during remove."
exit 1
fi

}

case "$1" in
"start")
do_start
;;
"stop")
do_stop
;;
*)

cat  << EOF
Initialization script for FlashCache
Usage: $0 <start|stop>
EOF
exit 1

;;
esac


Edit /etc/rc.local:
#
# mount the cached file system
#
echo "\n *** Mounting cached filesystem /ftest (/etc/rc.local) ***"
mount -v -t ext4 -O user_xattr,nobarriers /dev/mapper/fcache /ftest


Edit /etc/fstab to make a note about your cached file system
/dev/mapper/fcache /ftest ext4    noauto,user_xattr,nobarrier    0       2

Done!

Part 8 - Configure LVM for snapshots.



Build a home server - part 6

Configure LVM
We need a physical device to tie to volume group:
root@ohlala:~# ls /dev/md*
/dev/md0  /dev/md1  /dev/md2

/dev/md:
0  1  2

root@ohlala:~# pvcreate /dev/md2
Physical volume "/dev/md2" successfully created


Create a Volume Group:
root@ohlala:~# vgcreate --verbose data /dev/md2
Wiping cache of LVM-capable devices
Wiping cache of LVM-capable devices
Adding physical volume '/dev/md2' to volume group 'data'
Creating directory "/etc/lvm/archive"
Archiving volume group "data" metadata (seqno 0).
Creating directory "/etc/lvm/backup"
Creating volume group backup "/etc/lvm/backup/data" (seqno 1).
Volume group "data" successfully created
root@ohlala:~#


Create a logical volume for testing Flashcache:
root@ohlala:~# lvcreate --verbose -L 100G --name ftest data
Setting logging type to disk
Finding volume group "data"
Archiving volume group "data" metadata (seqno 1).
Creating logical volume ftest
Creating volume group backup "/etc/lvm/backup/data" (seqno 2).
Found volume group "data"
Creating data-ftest
Loading data-ftest table (252:0)
Resuming data-ftest (252:0)
Clearing start of logical volume "ftest"
Creating volume group backup "/etc/lvm/backup/data" (seqno 2).
Logical volume "ftest" created


Format the Logical Volume:
root@ohlala:~# mkfs.ext4 -b 4096 -E stride=64,stripe-width=128 /dev/mapper/data-ftest

Part 7 - Configure Flashcache


Build a home server - part 5

Create a mirrored Flaschache device
root@ohlala:~# mdadm --verbose --create /dev/md1 --level=1 --raid-devices=2 /dev/sdb4 /dev/sdd4
mdadm: Note: this array has metadata at the start and
may not be suitable as a boot device.  If you plan to
store '/boot' on this device please ensure that
your boot-loader understands md/v1.x metadata, or use
--metadata=0.90
mdadm: size set to 40751284K
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md1 started.
root@ohlala:~#


Check the progress.
watch -d cat /proc/mdstat:
Every 2.0s: cat /proc/mdstat                            Sun Apr 29 09:35:03 2012

Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md1 : active raid1 sdd4[1] sdb4[0]
40751284 blocks super 1.2 [2/2] [UU]
[>....................]  resync =  0.8% (342656/40751284) finish=7.8min speed=85664K/sec

md0 : active raid1 sdd2[1] sdb2[0]
9764529 blocks super 1.2 [2/2] [UU]

unused devices: <none>


When the synchronization is ready add the array to /etc/mdadm/mdadm.conf by typing:
mdadm --detail --scan >> /etc/mdadm/mdadm.conf

Edit /etc/mdadm/mdadm.conf and put your mailaddress. Also comment out old arrays:
# mdadm.conf
#
# Please refer to mdadm.conf(5) for information about this file.
#

# by default (built-in), scan all partitions (/proc/partitions) and all
# containers for MD superblocks. alternatively, specify devices to scan, using
# wildcards if desired.
#DEVICE partitions containers

# auto-create devices with Debian standard permissions
CREATE owner=root group=disk mode=0660 auto=yes

# automatically tag new arrays as belonging to the local system
HOMEHOST <system>

# instruct the monitoring daemon where to send mail alerts
MAILADDR Your.Name@isp.org

# definitions of existing MD arrays
#ARRAY /dev/md/0 metadata=1.2 UUID=ae2235f0:110a54e7:6540e885:863f829b name=ohlala:0

# This file was auto-generated on Sun, 29 Apr 2012 08:54:32 +0200
# by mkconf $Id$
ARRAY /dev/md/0 metadata=1.2 name=ohlala:0 UUID=ae2235f0:110a54e7:6540e885:863f829b
ARRAY /dev/md/1 metadata=1.2 name=ohlala:1 UUID=0e8cb4ce:a09d1148:5b289d1b:9ae61d2b


After reboot cat /proc/mdstat. If you get an ouput similar to this below try
mdadm --stop /dev/md127, mdadm --assemble /dev/md1 and update-initramfs -u. Reboot and check again.

md127 : active (auto-read-only) raid1 sdd4[1] sdb4[0]
40751284 blocks super 1.2 [2/2] [UU]


Create the data array
Create new partitions on the data disks. Type is Linux RAID (fd00)

root@ohlala:~# gdisk /dev/sdc
GPT fdisk (gdisk) version 0.8.1

Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): n
Partition number (1-128, default 1):
First sector (34-3907029134, default = 34) or {+-}size{KMGTP}:
Information: Moved requested sector from 34 to 2048 in
order to align on 2048-sector boundaries.
Use 'l' on the experts' menu to adjust alignment
Last sector (2048-3907029134, default = 3907029134) or {+-}size{KMGTP}:
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): fd00
Changed type of partition to 'Linux RAID'

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT).
The operation has completed successfully.
root@ohlala:~#


And create the array:
root@ohlala:~# ls -al /dev/disk/by-id/
drwxr-xr-x 2 root root 880 Sep 23 08:09 .
drwxr-xr-x 8 root root 160 Sep 23 08:05 ..
lrwxrwxrwx 1 root root   9 Sep 23 08:08 ata-ST2000DL003-9VT166_5YD7JNXT -> ../../sdf
lrwxrwxrwx 1 root root  10 Sep 23 08:08 ata-ST2000DL003-9VT166_5YD7JNXT-part1 -> ../../sdf1
lrwxrwxrwx 1 root root   9 Sep 23 08:07 ata-ST2000DL003-9VT166_5YD7SM2A -> ../../sdc
lrwxrwxrwx 1 root root  10 Sep 23 08:07 ata-ST2000DL003-9VT166_5YD7SM2A-part1 -> ../../sdc1
lrwxrwxrwx 1 root root   9 Sep 23 08:07 ata-ST2000DL003-9VT166_5YD7SMPJ -> ../../sdd
lrwxrwxrwx 1 root root  10 Sep 23 08:07 ata-ST2000DL003-9VT166_5YD7SMPJ-part1 -> ../../sdd1
lrwxrwxrwx 1 root root   9 Sep 23 08:06 ata-ST2000DL003-9VT166_5YD8AVDH -> ../../sda
lrwxrwxrwx 1 root root  10 Sep 23 08:05 ata-ST2000DL003-9VT166_5YD8AVDH-part1 -> ../../sda1
lrwxrwxrwx 1 root root   9 Sep 23 08:09 ata-ST2000DL003-9VT166_5YD9XR2F -> ../../sdh
lrwxrwxrwx 1 root root  10 Sep 23 08:09 ata-ST2000DL003-9VT166_5YD9XR2F-part1 -> ../../sdh1
lrwxrwxrwx 1 root root   9 Sep 23 08:06 ata-ST2000DL003-9VT166_5YDA0P1H -> ../../sdb
lrwxrwxrwx 1 root root  10 Sep 23 08:06 ata-ST2000DL003-9VT166_5YDA0P1H-part1 -> ../../sdb1
root@ohlala:~#
 
mdadm --verbose --create /dev/md2 --chunk=256 --level=5 --raid-devices=3 /dev/sda1 /dev/sdc1 /dev/sde1 --spare-devices=1 /dev/sdf1

It may not succeed:
root@ohlala:~# mdadm --verbose --create /dev/md2 --chunk=256 --level=5 --raid-devices=3 /dev/sda1 /dev/sdc1 /dev/sde1 --spare-devices=1 /dev/sdf1
mdadm: layout defaults to left-symmetric
mdadm: layout defaults to left-symmetric
mdadm: layout defaults to left-symmetric
mdadm: layout defaults to left-symmetric
mdadm: layout defaults to left-symmetric
mdadm: size set to 1953512192K
mdadm: Defaulting to version 1.2 metadata
mdadm: ADD_NEW_DISK for /dev/sda1 failed: Device or resource busy
root@ohlala:~#


but cat /proc/mdstat shows that something is going on. Try to add missing disks.
md2 : active raid5 sdc1[1] sda1[0]
3907024384 blocks super 1.2 level 5, 256k chunk, algorithm 2 [3/2] [UU_]

root@ohlala:~# mdadm --add /dev/md2 /dev/sde1
mdadm: added /dev/sde1
root@ohlala:~# mdadm --add /dev/md2 /dev/sdf1
mdadm: added /dev/sdf1
root@ohlala:~#


And the rebuilding starts (watch it by typing watch -d cat /proc/mdstat);
Every 2.0s: cat /proc/mdstat                                                  Sun Apr 29 10:22:09 2012

Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md2 : active raid5 sdf1[4](S) sde1[3] sdc1[1] sda1[0]
3907024384 blocks super 1.2 level 5, 256k chunk, algorithm 2 [3/2] [UU_]
[>....................]  recovery =  0.1% (2641812/1953512192) finish=927.3min speed=35059K/sec

md0 : active raid1 sdd2[1] sdb2[0]
9764529 blocks super 1.2 [2/2] [UU]

md1 : active raid1 sdd4[1] sdb4[0]
40751284 blocks super 1.2 [2/2] [UU]

unused devices: <none>


As soon as rebuildning is done.
root@ohlala:~# mdadm --detail --scan >> /etc/mdadm/mdadm.conf
root@ohlala:~# update-initramfs -u


While the data array is scrubbing we continue with setting up LVM.

Part 6 - Set up LVM


Build a home server - part 4

Software installation
apt-get install git build-essential dkms linux-headers-`uname -r` bridge-utils virt-manager acpid smartmontools drbd8-utils gdisk sysstat lvm2 xorg pm-utils ssmtp

Configure Smartmontools
Start by edit /etc/default/smartmontools. Just uncomment the line "#start_smartd=yes". Continue with editing /etc//smartd.conf. I want to be informed by e-mail, so first I configured ssmtp. My ISP requires only valid mailaccounts. Start by edit /etc/ssmtp/ssmtp.conf:
#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=Your.Name@YourISP.org

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=mailout.YourISP.org

# Where will the mail seem to come from?
rewriteDomain=YourISP.com

# The full hostname
hostname=ohlala.vusir.local

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES


Edit /etc/ssmtp/revaliases:
# sSMTP aliases
#
# Format:       local_account:outgoing_address:mailhub
#
# Example: root:your_login@your.domain:mailhub.your.domain[:port]
# where [:port] is an optional port number that defaults to 25.
root:Your.Name@YourISP.org:mailout.YourISP.org


Test your setting:
echo test | mail -s "testing ssmtp setup" Your.Name@isp.org

List the devices you want to monitor:
root@ohlala:~# ls -l /dev/disk/by-id/
total 0
lrwxrwxrwx 1 root root  9 Apr 28 07:43 lrwxrwxrwx 1 root root   9 Sep 23 06:41 ata-ST2000DL003-9VT166_5YD7JNXT -> ../../sdf
lrwxrwxrwx 1 root root   9 Sep 23 06:41 ata-ST2000DL003-9VT166_5YD7SM2A -> ../../sdc
lrwxrwxrwx 1 root root   9 Sep 23 06:41 ata-ST2000DL003-9VT166_5YD7SMPJ -> ../../sdd
lrwxrwxrwx 1 root root   9 Sep 23 06:41 ata-ST2000DL003-9VT166_5YD8AVDH -> ../../sda
lrwxrwxrwx 1 root root   9 Sep 23 06:41 ata-ST2000DL003-9VT166_5YD9XR2F -> ../../sdh
lrwxrwxrwx 1 root root   9 Sep 23 06:41 ata-ST2000DL003-9VT166_5YDA0P1H -> ../../sdb
l
root@ohlala:~#


My /etc//smartd.conf:
/dev/disk/by-id/ata-ST2000DL003-9VT166_5YD7JNXT -m Your.Name@isp.org -M exec /usr/share/smartmontools/smartd-runner

/dev/disk/by-id/ata-ST2000DL003-9VT166_5YD7JNXT -a -d sat -o on -S on -s (S/../.././02|L/../../6/03) -m Your.Name@isp.org -M exec /usr/share/smartmontools/smartd-runner
/dev/disk/by-id/ata-ST2000DL003-9VT166_5YD7SMPJ -a -d sat -o on -S on -s (S/../.././02|L/../../6/03) -m Your.Name@isp.org -M exec /usr/share/smartmontools/smartd-runner
/dev/disk/by-id/ata-ST2000DL003-9VT166_5YD8AVDH -a -d sat -o on -S on -s (S/../.././02|L/../../6/03) -m Your.Name@isp.org -M exec /usr/share/smartmontools/smartd-runner
/dev/disk/by-id/ata-ST2000DL003-9VT166_5YD9VCKA -a -d sat -o on -S on -s (S/../.././02|L/../../6/03) -m Your.Name@isp.org -M exec /usr/share/smartmontools/smartd-runner
/dev/disk/by-id/ata-ST2000DL003-9VT166_5YD9XR2F -a -d sat -o on -S on -s (S/../.././02|L/../../6/03) -m Your.Name@isp.org -M exec /usr/share/smartmontools/smartd-runner
/dev/disk/by-id/ata-ST2000DL003-9VT166_5YDA0P1H -a -d sat -o on -S on -s (S/../.././02|L/../../6/03) -m Your.Name@isp.org -M exec /usr/share/smartmontools/smartd-runner


Start smartmontools:
/etc/init.d/smartmontools start

The first line in /etc/smartd.conf is just sending a testmail when smartmontools starts.


Still Saturday. Turning off the server and do other fun stuff!

Part 5 - Create Flashcache and data arrays


Build a home server - part 3

Post OS installation tasks
Aah! Saturday morning and everyone are asleep. A perfect time to spoil a perfect morning with doing the boring stuff. It is time to enumarate the hard disks and set up monitoring. Bad times will arrive. Disks are going bad at some point. It is important that you know which disk to replace.

  • Shutdown the server and remove the SATA cables attached to the data disks.
  • Power up and log on to the server as root. List the devices. You will get an out similar to this:

root@ohlala:~# ls -l /dev/disk/by-path/
total 0
lrwxrwxrwx 1 root root  9 Apr 28 05:51 pci-0000:00:1f.2-scsi-5:0:0:0 -> ../../sda
lrwxrwxrwx 1 root root  9 Apr 28 05:51 pci-0000:01:00.0-scsi-0:0:0:0 -> ../../sdb
root@ohlala:~# ls -l /dev/disk/by-id/
total 0
lrwxrwxrwx 1 root root  9 Apr 28 05:51 ata-INTEL_SSDSC2CW060A3_CVCV1534059E060AGN -> ../../sdb
lrwxrwxrwx 1 root root  9 Apr 28 05:51 ata-TEAM_XS1_SSD_TEAM-2SA110214008 -> ../../sda
root@ohlala:~#

  • Mark. Power off. Attach a another SATA cable. Boot. List. Repeat.
  • And no. This is not fun!

A listing with one of the data disks attached:

root@ohlala:~# ls -l /dev/disk/by-path/
total 0
lrwxrwxrwx 1 root root  9 Apr 28 06:39 pci-0000:00:1f.2-scsi-0:0:0:0 -> ../../sda
lrwxrwxrwx 1 root root  9 Apr 28 06:39 pci-0000:00:1f.2-scsi-5:0:0:0 -> ../../sdb
lrwxrwxrwx 1 root root  9 Apr 28 06:39 pci-0000:01:00.0-scsi-0:0:0:0 -> ../../sdc
root@ohlala:~# ls -l /dev/disk/by-id/
total 0
lrwxrwxrwx 1 root root  9 Apr 28 06:39 ata-INTEL_SSDSC2CW060A3_CVCV1534059E060AGN -> ../../sdc
lrwxrwxrwx 1 root root  9 Apr 28 06:39 ata-ST2000DL003-9VT166_5YD7JNXT -> ../../sda
lrwxrwxrwx 1 root root  9 Apr 28 06:39 ata-TEAM_XS1_SSD_TEAM-2SA110214008 -> ../../sdb
lrwxrwxrwx 1 root root  9 Apr 28 06:39 md-name-ohlala:0 -> ../../md0
root@ohlala:~#


Note the highlighted parts and how the paths have changed after a new disk has been attached. This is important to know and remember: the path /dev/sdX will change.



Update OS

apt-get update && apt-get upgrade

 

Part 4 - Configure basic monitoring.




Build a home server - part 2

Installation
The hardware is now assembled and it is time to install an operating system. My choice is Ubuntu and the only reason is that I am used to it. As version 12.04 was about to be released I started with the beta. Worked fine!

I am using the two 60 GB SSD disks as mirrored root. I partitioned the disks as follows:

gdisk /dev/sdd:
Number Start (sector) End (sector) Size Code Name
1 34 195346 95.4 MiB EF00 EFI_boot
2 195347 19726597 9.3 GiB FD00
3 19728384 36505599 8.0 GiB 8200
4 36505600 117229567 38.5 GiB FD00

The motherboard supports EFI, so partition 1 is formatted for EFI boot.
Partition 2 is a RAID partition.
Partition 3 is a swap partition
Partition 4 is a RAID partition for the future Flashcache block device.

OS installation is pretty straight forward. Create a RAID 1 array (/dev/md0) from partition 2 of the two disks and use it for the root partition. Later during installation I just chose to install OpenSSH server, so that I can sit in my sofa and do the remaining configuration.

Post OS installation task: sudo passwd root

Part 3 - Post OS installation tasks


Build a home server - part 1


Preface
So, you are in the need of a new server? This blogg will not help you with choosing the right hardware but propose to you a perfectly viable solution for a SOHO-server. The concept is not constricted to the small wallet but is expandable to your needs and choice.

 

When I embarked this journey I only had a few things in mind that I wanted to accomplish:

  1. Buy me a new, more silent home server.
  2. Install an Active Directory 2008 R2.
  3. Install a file server (Linux) that presents a shared resources with NFSv4 and CIFS using AD as the authentication source.

 

Instead of just these three quite simple goals this evolved beyond my imagination. I soon realised that I have to configure a virtualization host, learn more about the inner workings of Linux, software RAID, LVM and so on... Great fun though!

 

I did also realize that this configuration is a perfect server solution for the small business. If you are about to deploy a new server for your business or even looking for a solution to productify and support, this might be just what you are looking for. One thing, if you are using this, private or in business, please post a "I used this!" and with a few words tell us your plans here. I would appreciate it. A lot.

 

And a special thank you to all of you open source wizards that have taken time to program, realize and make all the great software publically available. I am mighty impressed of your work! Thank you.

 

Being a leacher for years it is now time for me to contribute to the common. I hope you find this blogg useful. This recepie is a compilation from various resources on the Internet.

Hardware
I am not amused with choosing hardware. I find it quite boring, so imagine my surprise when I realized that this part actually was fun. This was also the first time I ever built myself a computer. I searched the Internet for advice on choosing hardware and found Thomas Jansson's blogg. I ripped his setup but chose a cheaper motherboard because the one I wanted was out of stock and a less powerful CPU but more RAM. In retrospective I would follow his advice and buy a new, more silent CPU fan. If you are building a server for a small office, consider a chassi that has room for hot swapping hard drives.

My setup:

Hard disk: SEAGATE BARRACUDA GREEN 2TB 5900RPM SATA/600 64MB x4
Chassis: LIAN LI PC-Q08B BLACK ALU MINI-ITX NO PSU
Memory: KINGSTON DDR3 HYPERX 8GB 1600MHZ CL9 (2X4GB)
CPU: INTEL CORE I5 2400 3.10GHZ 6MB S-1155
PSU: COOLER MASTER SILENT PRO M ATX12V 2.3 500W
Motherboard: ASUS P8H61-I B3 H61 S-1155 MINI-ITX
SATA card: Silicon Image, Inc. SiI 3132 Serial ATA Raid II Controller
SSD:
60 GB
x2

 

One of the 2 TB disks and one of the SSD disks are attached to the SATA card.


Software
There were certain techniques I wanted to learn more about; software RAID, LVM and DRBD. During my searches I also found Facebook/Flashcahe and later on I found Arno Tölls et al version for Debian. I already had a 60 GB SSD disk in my laptop which I immediately janked out. More thinking rendered buying one more, so that I could create a mirrored root and Flashcache. By now you understand that the choice of operating system was Linux and the Ubuntu distribution version 12.04.

More ideas, more software
I am a Windows Systems Administrator by trade and Active Directory is my primary experties. One goal with this server is to install and configure an Active Directory and a Linux file server presenting resources with Samba and NFSv4 using Kerberos for authentication. That is the reason for the amount of RAM - virtualization with KVM.

Part 2 - the first take. Installation

 

The new approach
I failed with my first try. It is a pity.

Back to the drawing board. In the new approach I am going to use FreeBSD and Oracle ZFS (the open sourced).

But first things first. I wanted to use Ubuntu as the hosts OS and ZFS. How to combine? First I found ZFS-fuse. But never really liked it. Don't ask why. I don't know. Later I found ZFS on Linux, which I found more, how should I put it, tasteful. I downloaded it, compiled it and tried it. Worked fine. Great stuff! But I do not want to compile and remember all the details. What now? Gladly I found a PPA for ZFS. But the combination, Ubuntu and ZFS, did not work as good as I wanted and expected. Again, don't ask. It just did not appeal. Later, on several forums and blogposts, I found that FreeBSD had incorporated the latest version of ZFS in their version 9.0 and other blogposts described, more or less detailed, how to make a mirrored ZFS-root. FreeBSD started to grow on me and I tested it out. Conclusion? Great Stuff!

 

With the original design I wanted to run the file server as a virtual guest. That was also my approach when I started to look at FreeBSD. Later on I found out about Jails. A facility where you can contain a server, say a file server, without compromising the host. With using Jails I am hoping that I can exploit all the good stuff that ZFS offers (znapshots, zfs send/receive...) within the jailed server. It would be really great if I could present what Microsoft calls Previous version to the client. No matter if the client runs Linux or Windows.

So the new approach is FreeBSD and ZFS.

 

Part 2 - second take. Installation.


 

 


Configure your router for a local DNS domain.

Prerequisites
I have got an old ASUS WL-500gP router. One of the first things I did was to install firmware from OpenWRT. An "out-of-the-box" installation with DNSMasq which has served me well. OpenWRT is a really good product. No doubt about it! Thank you all that have been working with the realization of OpenWRT router software.

But if you want to do more sofisticated stuff like mounting home directories on your home server using the servers name instead of IP address or even configure an Active Directory, you will need a DNS. Kerberos does not function without a DNS. This post will inform you how to configure OpenWRT to serve your home computers with DHCP and dynamic DNS.

The plan is to use two nameservers; one for the forward lookup zone and one for the reverse zone. To accomplish that we start out with configuring the router with both zones. Later on, after Samba4 is installed and configured, we move the forward zone to the servers name server and let the routers nameserver act as a slave for the forward zone. And vice versa. The DHCP server will update the reverse zone with RR:s and the domaincontroller will feed the forward zone.

Install required packages.

1. Install the following packages; dhcp-server, bind-server, bind-check and bind-rndc. Uninstall dnsmasq.

Start with configuring the DHCP server.

2. Edit /etc/dhcpd.conf:

authoritative;

ddns-updates on;
ddns-update-style interim;
#ddns-update-style none;
update-static-leases on;
allow unknown-clients;
use-host-decl-names on;

include "/etc/rndc.key";

zone 1.168.192.in-addr.arpa. {
        primary 192.168.1.1;
        key "rndc-key";
}

option ntp-servers 192.168.1.1;

default-lease-time 43200;
max-lease-time 86400;

subnet 192.168.1.0 netmask 255.255.255.0 {
        option subnet-mask 255.255.255.0;
        option domain-name-servers 192.168.1.1, 192.168.1.10;
        option routers 192.168.1.1;
        option broadcast-address 192.168.1.255;
        range 192.168.1.101 192.168.1.200;

        option domain-name "vusir.local";
        ddns-rev-domainname "in-addr.arpa.";

        zone 1.168.192.in-addr.arpa. {
                primary 192.168.1.1;
                key "rndc-key";
        }

}

3. Generate a key for dhcpd and named to use: /usr/sbin/rndc-confgen -a. This generates the key file /etc/rndc.key.

4. Start the daemon: /etc/init.d/dhcpd start and check for errors.

5. Check that your computer is being assigned an IP adress: ipconfig /renew.

Continue with configuring BIND.

6. Copy /etc/bind/named.conf.example: cp /etc/bind/named.conf.example /etc/bind/named.conf.

7. Edit /etc/bind/named.conf and add your DNS domains:

// This is the primary configuration file for the BIND DNS server named.
options {
directory "/tmp";

// If your ISP provided one or more IP addresses for stable
// nameservers, you probably want to use them as forwarders.
// Uncomment the following block, and insert the addresses replacing
// the all-0's placeholder.

forwarders {
  208.67.222.222; // OpenDNS, primary
  208.67.222.220; // OpenDNS, secondary
};

allow-query {
  192.168.1.0/24;
  127.0.0.1;
};

allow-transfer {
  192.168.1.0/24;
  127.0.0.1;
};

auth-nxdomain no; # conform to RFC1035
};

// RNDC-key
include "/etc/rndc.key";
controls {
  inet 127.0.0.1 allow {
    localhost;
  }
  keys {
    rndc-key;
  };
};

zone "vusir.local" {
    type master;
    file "/etc/bind/db.vusir.local";
    allow-transfer { any; };
//  masters { 192.168.1.3; };
};

zone "1.168.192.in-addr.arpa" {
    type master;
    file "/etc/bind/db.192.168.1";
    allow-update {
      key "rndc-key";
    };
    notify yes;
};

// prime the server with knowledge of the root servers
zone "." {
  type hint;
  file "/etc/bind/db.root";
};

// be authoritative for the localhost forward and reverse zones, and for
// broadcast zones as per RFC 1912
zone "localhost" {
  type master;
  file "/etc/bind/db.local";
};

zone "localhost" {
  type master;
  file "/etc/bind/db.local";
};

zone "127.in-addr.arpa" {
  type master;
  file "/etc/bind/db.127";
};

zone "0.in-addr.arpa" {
  type master;
  file "/etc/bind/db.0";
};

zone "255.in-addr.arpa" {
  type master;
  file "/etc/bind/db.255";
};


8. Check configuration file: named-checkconf /etc/bind/named.conf. No output means correct file.

9. Edit zone files; /etc/bind/db.vusir.local and /etc/bind/db.192.168.1.

vi /etc/bind/db.vusir.local:
$ORIGIN .
$TTL 3600       ; 1 hour
vusir.local             IN SOA  ojoj.vusir.local. hostmaster.vusir.local. (
                                1         ; serial
                                900        ; refresh (15 minutes)
                                600        ; retry (10 minutes)
                                86400      ; expire (1 day)
                                0          ; minimum (0 seconds)
                                )
$ORIGIN vusir.local.
                        NS      ohlala.vusir.local.
                        NS      ojoj.vusir.local.

ojoj                    A       192.168.1.1
ohlala                  A       192.168.1.3

vi /etc/bind/db.192.168.1:
$ORIGIN .
$TTL 3600       ; 1 hour
1.168.192.in-addr.arpa  IN SOA  ojoj.vusir.local. hostmaster.vusir.local. (
                                1          ; serial
                                900        ; refresh (15 minutes)
                                600        ; retry (10 minutes)
                                86400      ; expire (1 day)
                                0          ; minimum (0 seconds)
                                )
                        NS      ohlala.vusir.local.
                        NS      ojoj.vusir.local.
$ORIGIN 1.168.192.in-addr.arpa.
1                       PTR     ojoj.vusir.local.
3                       PTR     ohlala.vusir.local.


10. Check the zone files.
root@ojoj:~# named-checkzone vusir.local /etc/bind/db.vusir.local
zone vusir.local/IN: loaded serial 6
OK
root@ojoj:~# named-checkzone 1.168.192.in-addr.arpa /etc/bind/db.192.168.1
zone 1.168.192.in-addr.arpa/IN: loaded serial 7
OK
root@ojoj:~#

11. Start name server: /etc/init.d/named start

12. And test.
C:\ nslookup -type=NS vusir.local
Server:  ojoj.vusir.local
Address:  192.168.1.1

vusir.local       nameserver = ojoj.vusir.local
ojoj.vusir.local  internet address = 192.168.1.1

13. Restart dhcpd and named:

/etc/init.d/dhcpd restart
/etc/init.d/named restart

14. Done!

When Samba is installed and configured to serve the name server with computer names we change the following:

15. In /etc/bind/named.conf we change the following part:
zone "vusir.local" {
        type slave;
        file "/etc/bind/db.vusir.local";
        allow-transfer { 192.168.1.0/24; };
// <-Remove       masters { 192.168.1.3; };
};

16. Restart named on the router: /etc/init.d/named restart

17. And restart named on the server: /etc/init.d/bind9 restart

18. And test.
C:\ nslookup -type=NS vusir.local
Server:  ojoj.vusir.local
Address:  192.168.1.1

vusir.local         nameserver = ohlala.vusir.local
vusir.local         nameserver = ojoj.vusir.local
ohlala.vusir.local  internet address = 192.168.1.3
ojoj.vusir.local    internet address = 192.168.1.1

19. Done!

RSS 2.0