setup RAID 10

February 14, 2009
By randall

<div id=“dw”>

host.cipar.net (192.168.1.1)

The base for this setup is Debian Etch dom0, we will use the 64 bits edition to make use of the little extra speed advantage. We only need a minimal install to start with.

Debian install media

The most used method for a Linux installation is using the cd method, but just in case you are unlucky like me and you have a motherboard that does not like IDE cd drives i have added the step for an usb installation.

make a debian installation cd

We will use the 64 bits netinstall iso for debian etch 4.0 to install the base system wich is a +- 145Mb download.

$ wget http://cdimage.debian.org/debian-cd/4.0_r2/amd64/iso-cd/debian-40r2-amd64-netinst.iso

once we have the .iso we need to burn it to cd.

# nice --18 wodim -eject -v speed=2 dev=/dev/cdrom -data -pad debian-40r2-amd64-netinst.iso

The cd cover is marked as “host.cipar.net” Debian Etch 4.0_r2 AMD 64

make a debian installation usb

To download the installer we do as follows

$ wget http://ftp.nl.debian.org/debian/dists/etch/main/installer-amd64/current/images/hd-media/boot.img.gz

and we will also need the same iso file as when making an installation cd

$ wget http://cdimage.debian.org/debian-cd/4.0_r2/amd64/iso-cd/debian-40r2-amd64-netinst.iso

The exact mountpoint of the usb can be found with

$ fdisk -l

Assuming your usb is mounted as /dev/sda we can extract the boot.img.gz to the usb stick.

$ zcat boot.img.gz &gt; /dev/sda

Then mount the usb.

# mount /dev/sda /mnt

when this is done simply copy the .iso to the same usb disk

# cp debian-40r2-amd64-netinst.iso /mnt

and then unmount the usb stick

# umount /mnt

base install

Once we have the installation cd we

# apt-get install openssh-server
system preparation
deb http://security.debian.org/ etch/updates main contrib
deb-src http://security.debian.org/ etch/updates main contrib
deb http://www.backports.org/debian etch-backports main contrib non-free
deb http://debian.apt-get.eu/debian/ etch main contrib non-free
apt-get install debian-backports-keyring

replacing disfuctioning Marvel ethernet controller

There were problems in the past with the sky2 driver and it still seems to act up once in a while.
to replace it and to have sure the new card is detected as eth0 i did the following afterwards since it was running fine the first two weeks or so.

i disabled the first LAN card in the bios.
removed the rule set (could have simply changed it as well, as i had to any way because the firewire popped up as eth1)

# rm /etc/udev/rules.d/z25_persistent-net.rules

after a reboot it was automatically regenerated

# This file was automatically generated by the /lib/udev/write_net_rules
# program, probably run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single line.
# MAC addresses must be written in lowercase.

# PCI device 0x8086:0x100c (e1000)
SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:02:b3:91:64:d0", NAME="eth0"

# Firewire device 0011d800016be1a3 (ohci1394)
SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:11:d8:00:01:6b:e1:a3", NAME="eth2"

# PCI device 0x11ab:0x4364 (sky2)
SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="00:1d:60:33:1b:dc", NAME="eth1"
# nano /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
hwaddress ether 00:02:b3:91:64:d0
        address 212.123.252.242
        netmask 255.255.255.0
        network 212.123.252.0
        broadcast 212.123.252.255
        gateway 212.123.252.1
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 192.168.0.1
        dns-search cipar.net

auto eth1
iface eth1 inet static
hwaddress ether 00:1D:60:33:1B:DC
        address 192.168.0.1
        netmask 255.255.255.0
        broadcast 192.168.0.255
        network 192.168.0.0

auto dummy0
iface dummy0 inet static
    address 192.168.1.1
    netmask 255.255.255.0

setup RAID 10

With thanks to Falko Timme on who's article this was based on
http://www.howtoforge.com/software-raid1-grub-boot-debian-etch

After the base install we can log in via ssh to set up the RAID, the end result should become like this

  • RAID1 /dev/md0 (/dev/sdc1, /dev/sdd1, /dev/sde1 and /dev/sdf1): /boot, ext3;
  • RAID10 /dev/md1 (/dev/sdc3, /dev/sdd3, /dev/sde3 and /dev/sdf3): /root, ext3;
  • RAID10 /dev/md2 (/dev/sdc5, /dev/sdd5, /dev/sde5 and /dev/sdf5): swap
  • RAID10 /dev/md3 (/dev/sdc6, /dev/sdd6, /dev/sde6 and /dev/sdf6): LVM

I think we could have done this during the base installation a lot easier (memo to me: figure out how), but this approach at least keeps the base install as simple as possible so that a more experienced admin can pick up the dirty work from a remote location.

  • Aftertought!!!!!

It might even have been easier still to install the initial install on one of the Terrabyte disks and then create the 4 disk RAID10 array in one go, anyway, i did have some fun doing this ;)

Here we can see what happened during the base install:
To get an overview of the disk space available to the running system

# df -h
host:~# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sdc3             4.5G  446M  3.9G  11% /
tmpfs                 4.0G     0  4.0G   0% /lib/init/rw
udev                   10M   76K   10M   1% /dev
tmpfs                 4.0G     0  4.0G   0% /dev/shm
/dev/sdc1              92M   13M   74M  15% /boot

To get an overview of all the available disks and partitions

# fdisk -l
host:~# fdisk -l

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *           1          12       96358+  83  Linux
/dev/sdc2             609       60801   483500272+   5  Extended
/dev/sdc3              13         608     4787370   83  Linux
/dev/sdc5             609         669      489951   82  Linux swap / Solaris
/dev/sdc6             670       60801   483010258+  8e  Linux LVM

Partition table entries are not in disk order

Disk /dev/sdd: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

Disk /dev/sde: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

Disk /dev/sdf: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

Installing mdadm

http://manpages.songshu.org/manpages/lenny/en/man8/mdadm.8.html

The most important tool for setting up RAID is mdadm. Let's install it like this:

# apt-get install initramfs-tools mdadm

You will be asked the following question:

MD arrays needed for the root filesystem: ←- all

Afterwards, we load a few kernel modules (to avoid a reboot):

# modprobe md
# modprobe linear
# modprobe multipath
# modprobe raid0
# modprobe raid1
# modprobe raid5
# modprobe raid6
# modprobe raid10

Now run

# cat /proc/mdstat

The output should look as follows:

host:~# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
unused devices: &lt;none&gt;

Preparing /dev/sdd, /dev/sde and /dev/sdf

To create the arrays on our already running system, we must prepare the /dev/sdd, /dev/sde and /dev/sdf hard drive for RAID, then copy the contents of our /dev/sdc hard drive to it, and finally add /dev/sdc to the RAID array.

First, we copy the partition table from /dev/sdc to the others so that all disks have exactly the same layout:

http://manpages.songshu.org/manpages/lenny/en/man8/sfdisk.8.html

# sfdisk -d /dev/sdc | sfdisk /dev/sdd
# sfdisk -d /dev/sdc | sfdisk /dev/sde
# sfdisk -d /dev/sdc | sfdisk /dev/sdf

The output should be something as follows:

host:~# sfdisk -d /dev/sdc | sfdisk /dev/sde
Checking that no-one is using this disk right now ...
OK

Disk /dev/sde: 60801 cylinders, 255 heads, 63 sectors/track
Old situation:
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sde1          0       -       0          0    0  Empty
/dev/sde2          0       -       0          0    0  Empty
/dev/sde3          0       -       0          0    0  Empty
/dev/sde4          0       -       0          0    0  Empty
New situation:
Units = sectors of 512 bytes, counting from 0

   Device Boot    Start       End   #sectors  Id  System
/dev/sde1   *        63    192779     192717  83  Linux
/dev/sde2       9767520 976768064  967000545   5  Extended
/dev/sde3        192780   9767519    9574740  83  Linux
/dev/sde4             0         -          0   0  Empty
/dev/sde5       9767583  10747484     979902  82  Linux swap / Solaris
/dev/sde6      10747548 976768064  966020517  8e  Linux LVM
Successfully wrote the new partition table

Re-reading the partition table ...

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes:  dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)

The command
http://manpages.songshu.org/manpages/lenny/en/man8/fdisk.8.html

# fdisk -l

should now show that all 4 HDDs have the same layout:

host:~# fdisk -l

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *           1          12       96358+  83  Linux
/dev/sdc2             609       60801   483500272+   5  Extended
/dev/sdc3              13         608     4787370   83  Linux
/dev/sdc5             609         669      489951   82  Linux swap / Solaris
/dev/sdc6             670       60801   483010258+  8e  Linux LVM

Partition table entries are not in disk order

Disk /dev/sdd: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1   *           1          12       96358+  83  Linux
/dev/sdd2             609       60801   483500272+   5  Extended
/dev/sdd3              13         608     4787370   83  Linux
/dev/sdd5             609         669      489951   82  Linux swap / Solaris
/dev/sdd6             670       60801   483010258+  8e  Linux LVM

Partition table entries are not in disk order

Disk /dev/sde: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1   *           1          12       96358+  83  Linux
/dev/sde2             609       60801   483500272+   5  Extended
/dev/sde3              13         608     4787370   83  Linux
/dev/sde5             609         669      489951   82  Linux swap / Solaris
/dev/sde6             670       60801   483010258+  8e  Linux LVM

Partition table entries are not in disk order

Disk /dev/sdf: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1   *           1          12       96358+  83  Linux
/dev/sdf2             609       60801   483500272+   5  Extended
/dev/sdf3              13         608     4787370   83  Linux
/dev/sdf5             609         669      489951   82  Linux swap / Solaris
/dev/sdf6             670       60801   483010258+  8e  Linux LVM

Partition table entries are not in disk order

Next we must change the partition type of our three partitions on /dev/sdd, /dev/sde and /dev/sdf drives to Linux raid autodetect:

# fdisk /dev/sdd
host1:~# fdisk /dev/sdd

Command (m for help): &lt;-- m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): &lt;-- t
Partition number (1-6): &lt;-- 1
Hex code (type L to list codes): &lt;-- L

 0  Empty           1e  Hidden W95 FAT1 80  Old Minix       be  Solaris boot
 1  FAT12           24  NEC DOS         81  Minix / old Lin bf  Solaris
 2  XENIX root      39  Plan 9          82  Linux swap / So c1  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  83  Linux           c4  DRDOS/sec (FAT-
 4  FAT16 &lt;32M      40  Venix 80286     84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
 5  Extended        41  PPC PReP Boot   85  Linux extended  c7  Syrinx
 6  FAT16           42  SFS             86  NTFS volume set da  Non-FS data
 7  HPFS/NTFS       4d  QNX4.x          87  NTFS volume set db  CP/M / CTOS / .
 8  AIX             4e  QNX4.x 2nd part 88  Linux plaintext de  Dell Utility
 9  AIX bootable    4f  QNX4.x 3rd part 8e  Linux LVM       df  BootIt
 a  OS/2 Boot Manag 50  OnTrack DM      93  Amoeba          e1  DOS access
 b  W95 FAT32       51  OnTrack DM6 Aux 94  Amoeba BBT      e3  DOS R/O
 c  W95 FAT32 (LBA) 52  CP/M            9f  BSD/OS          e4  SpeedStor
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a0  IBM Thinkpad hi eb  BeOS fs
 f  W95 Ext'd (LBA) 54  OnTrackDM6      a5  FreeBSD         ee  EFI GPT
10  OPUS            55  EZ-Drive        a6  OpenBSD         ef  EFI (FAT-12/16/
11  Hidden FAT12    56  Golden Bow      a7  NeXTSTEP        f0  Linux/PA-RISC b
12  Compaq diagnost 5c  Priam Edisk     a8  Darwin UFS      f1  SpeedStor
14  Hidden FAT16 &lt;3 61  SpeedStor       a9  NetBSD          f4  SpeedStor
16  Hidden FAT16    63  GNU HURD or Sys ab  Darwin boot     f2  DOS secondary
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fd  Linux raid auto
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fe  LANstep
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid ff  BBT
1c  Hidden W95 FAT3 75  PC/IX
Hex code (type L to list codes): &lt;-- fd
Changed system type of partition 1 to fd (Linux raid autodetect)

Command (m for help): &lt;-- t
Partition number (1-6): &lt;-- 1
Hex code (type L to list codes): &lt;-- fd
Changed system type of partition 2 to fd (Linux raid autodetect)

Command (m for help): &lt;-- t
Partition number (1-5): &lt;-- 3
Hex code (type L to list codes): &lt;-- fd
Changed system type of partition 3 to fd (Linux raid autodetect)

Command (m for help): &lt;-- t
Partition number (1-4): &lt;-- 5
Hex code (type L to list codes): &lt;-- fd
Changed system type of partition 3 to fd (Linux raid autodetect)
Command (m for help): &lt;-- w
The partition table has been altered!

Command (m for help): &lt;-- t
Partition number (1-3): &lt;-- 6
Hex code (type L to list codes): &lt;-- fd
Changed system type of partition 3 to fd (Linux raid autodetect)

Calling ioctl() to re-read partition table.
Syncing disks.

To make sure that there are no remains from previous RAID installations on the disks, we run the following commands:

# mdadm --zero-superblock /dev/sdc1
# mdadm --zero-superblock /dev/sdc3
# mdadm --zero-superblock /dev/sdc5
# mdadm --zero-superblock /dev/sdc6

# mdadm --zero-superblock /dev/sdd1
# mdadm --zero-superblock /dev/sdd3
# mdadm --zero-superblock /dev/sdd5
# mdadm --zero-superblock /dev/sdd6

# mdadm --zero-superblock /dev/sde1
# mdadm --zero-superblock /dev/sde3
# mdadm --zero-superblock /dev/sde5
# mdadm --zero-superblock /dev/sde6

# mdadm --zero-superblock /dev/sdf1
# mdadm --zero-superblock /dev/sdf3
# mdadm --zero-superblock /dev/sdf5
# mdadm --zero-superblock /dev/sdf6

If there are no remains from previous RAID installations, each of the above commands will throw an error like this one (which is nothing to worry about):

host:~# mdadm --zero-superblock /dev/sdd1
mdadm: Unrecognised md component device - /dev/sdd1

Otherwise the commands will not display anything at all.

Creating Our RAID Arrays

Now let's create our RAID arrays

# mdadm --create /dev/md0 --level=1 --raid-disks=4 missing /dev/sdd1 /dev/sde1 /dev/sdf1
# mdadm --create /dev/md1 --level=10 --raid-disks=4 missing /dev/sdd3 /dev/sde3 /dev/sdf3
# mdadm --create /dev/md2 --level=10 --raid-disks=4 missing /dev/sdd5 /dev/sde5 /dev/sdf5
# mdadm --create /dev/md3 --level=10 --raid-disks=4 missing /dev/sdd6 /dev/sde6 /dev/sdf6

The command

# cat /proc/mdstat

should now show that you have three degraded RAID arrays ([_U] or [U_] means that an array is degraded while [UU] for raid1 and [UUUU] for raid10 means that the array is ok):

host:~# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md3 : active raid10 sdf6[3] sde6[2] sdd6[1]
      966020352 blocks 64K chunks 2 near-copies [4/3] [_UUU]
        resync=DELAYED

md0 : active raid1 sdf1[3] sde1[2] sdd1[1]
      96256 blocks [4/3] [_UUU]

md2 : active raid10 sdf5[3] sde5[2] sdd5[1]
      979712 blocks 64K chunks 2 near-copies [4/3] [_UUU]
        resync=DELAYED

md1 : active raid10 sdf3[3] sde3[2] sdd3[1]
      9574528 blocks 64K chunks 2 near-copies [4/3] [_UUU]
      [==============&gt;......]  resync = 74.2% (7110976/9574528) finish=0.2min speed=198246K/sec

unused devices: &lt;none&gt;

Next we create filesystems on our RAID arrays (ext3 on /dev/md0 and /dev/md2 and swap on /dev/md1):

# mkfs.ext3 /dev/md0
# mkfs.ext3 /dev/md1
# mkswap /dev/md2

Next we must adjust /etc/mdadm/mdadm.conf (which doesn't contain any information about our new RAID arrays yet) to the new situation:

# cp /etc/mdadm/mdadm.conf /etc/mdadm/mdadm.conf_orig
# mdadm --examine --scan &gt;&gt; /etc/mdadm/mdadm.conf

Display the contents of the file:

# cat /etc/mdadm/mdadm.conf

At the bottom of the file you should now see details about our three (degraded) RAID arrays:

host:~# cat /etc/mdadm/mdadm.conf
# mdadm.conf
#
# Please refer to mdadm.conf(5) for information about this file.
#

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

# 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 &lt;system&gt;

# instruct the monitoring daemon where to send mail alerts
MAILADDR root

# This file was auto-generated on Thu, 31 Jan 2008 15:05:41 +0100
# by mkconf $Id: mkconf 261 2006-11-09 13:32:35Z madduck $
ARRAY /dev/md1 level=raid10 num-devices=4 UUID=b309ee1e:3f9f428e:f41cdd86:04e94251
ARRAY /dev/md2 level=raid10 num-devices=4 UUID=b00323c1:df97cefe:f41cdd86:04e94251
ARRAY /dev/md0 level=raid1 num-devices=4 UUID=724e4049:df159d74:f41cdd86:04e94251
ARRAY /dev/md1 level=raid10 num-devices=4 UUID=5bc34c17:5085803f:f41cdd86:04e94251
ARRAY /dev/md2 level=raid10 num-devices=4 UUID=ff1da358:1dc77a2f:f41cdd86:04e94251
ARRAY /dev/md3 level=raid10 num-devices=4 UUID=ca928896:05e930e6:f41cdd86:04e94251

Adjusting The System To RAID

Now let's mount /dev/md0 and /dev/md2 (we don't need to mount the swap array /dev/md1):

# mkdir /mnt/md0
# mkdir /mnt/md1
# mount /dev/md0 /mnt/md0
# mount /dev/md1 /mnt/md1

You should now find both arrays in the output of

# mount
host:~# mount
/dev/sdc3 on / type ext3 (rw,errors=remount-ro)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
procbususb on /proc/bus/usb type usbfs (rw)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
/dev/sdc1 on /boot type ext3 (rw)
/dev/md0 on /mnt/md0 type ext3 (rw)
/dev/md1 on /mnt/md1 type ext3 (rw)

Next we modify /etc/fstab. Replace /dev/sdc1 with /dev/md0, /dev/sdc3 with /dev/md1, /dev/sdc5 with /dev/md2 so that the file looks as follows:

# nano /etc/fstab
# /etc/fstab: static file system information.
#
# &lt;file system&gt; &lt;mount point&gt;   &lt;type&gt;  &lt;options&gt;       &lt;dump&gt;  &lt;pass&gt;
proc            /proc           proc    defaults        0       0
/dev/md1       /               ext3    defaults,errors=remount-ro 0       1
/dev/md0       /boot           ext3    defaults        0       2
/dev/md2       none            swap    sw              0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto  0       0

Next replace /dev/sdc1 with /dev/md0 and /dev/sdc3 with /dev/md1 and /de in /etc/mtab:

# nano /etc/mtab
/dev/md1 / ext3 rw,errors=remount-ro 0 0
tmpfs /lib/init/rw tmpfs rw,nosuid,mode=0755 0 0
proc /proc proc rw,noexec,nosuid,nodev 0 0
sysfs /sys sysfs rw,noexec,nosuid,nodev 0 0
procbususb /proc/bus/usb usbfs rw 0 0
udev /dev tmpfs rw,mode=0755 0 0
tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0
devpts /dev/pts devpts rw,noexec,nosuid,gid=5,mode=620 0 0
/dev/md0 /boot ext3 rw 0 0
/dev/md0 /mnt/md0 ext3 rw 0 0
/dev/md1 /mnt/md1 ext3 rw 0 0

Now up to the GRUB boot loader. Open /boot/grub/menu.lst and add fallback 1 right after default 0:

# nano /boot/grub/menu.lst
default         0
fallback        1
fallback        2
fallback        3

This makes that if the first kernel (counting starts with 0, so the first kernel is 0) fails to boot, kernel #2 will be booted.

In the same file, go to the bottom where you should find some kernel stanzas. Copy the first of them and paste the stanza before the first existing stanza; replace root=/dev/sdc3 with root=/dev/md1 and root (hd0,0) with root (hd1,0):

## ## End Default Options ##

title           Debian GNU/Linux, kernel 2.6.18-5-amd64
root            (hd1,0)
kernel          /vmlinuz-2.6.18-5-amd64 root=/dev/md1 ro
initrd          /initrd.img-2.6.18-5-amd64
savedefault

title           Debian GNU/Linux, kernel 2.6.18-5-amd64
root            (hd0,0)
kernel          /vmlinuz-2.6.18-5-amd64 root=/dev/sdc3 ro
initrd          /initrd.img-2.6.18-5-amd64
savedefault

title           Debian GNU/Linux, kernel 2.6.18-5-amd64 (single-user mode)
root            (hd2,0)
kernel          /vmlinuz-2.6.18-5-amd64 root=/dev/sdc3 ro single
initrd          /initrd.img-2.6.18-5-amd64
savedefault

### END DEBIAN AUTOMAGIC KERNELS LIST

root (hd1,0) refers to /dev/sdd which is already part of our RAID arrays. We will reboot the system in a few moments; the system will then try to boot from our (still degraded) RAID arrays; if it fails, it will boot from /dev/sdc (→ fallback 1).

Next we adjust our ramdisk to the new situation:

# update-initramfs -u

Now we copy the contents of /dev/sda1 and /dev/sda3 to /dev/md0 and /dev/md2 (which are mounted on /mnt/md0 and /mnt/md2):

# cp -dpRx / /mnt/md1
# cd /boot
# cp -dpRx . /mnt/md0

Preparing GRUB (Part 1)

Afterwards we must install the GRUB bootloader on the drives:

# grub

On the GRUB shell, type in the following commands:

# root (hd3,0)

grub> root (hd0,0)
Filesystem type is ext2fs, partition type 0×83

grub>
</code>

# setup (hd3)
grub&gt; setup (hd0)
 Checking if "/boot/grub/stage1" exists... no
 Checking if "/grub/stage1" exists... yes
 Checking if "/grub/stage2" exists... yes
 Checking if "/grub/e2fs_stage1_5" exists... yes
 Running "embed /grub/e2fs_stage1_5 (hd0)"...  15 sectors are embedded.
succeeded
 Running "install /grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/grub/stage2 /grub/menu.lst"... succeeded
Done.

grub&gt;

root (hd4,0)

grub&gt; root (hd1,0)
 Filesystem type is ext2fs, partition type 0xfd

grub&gt;

setup (hd4)

grub&gt; setup (hd1)
 Checking if "/boot/grub/stage1" exists... no
 Checking if "/grub/stage1" exists... yes
 Checking if "/grub/stage2" exists... yes
 Checking if "/grub/e2fs_stage1_5" exists... yes
 Running "embed /grub/e2fs_stage1_5 (hd1)"...  15 sectors are embedded.
succeeded
 Running "install /grub/stage1 (hd1) (hd1)1+15 p (hd1,0)/grub/stage2 /grub/menu.lst"... succeeded
Done.

grub&gt;

root (hd5,0)

grub&gt; root (hd5,0)
 Filesystem type is ext2fs, partition type 0x83

grub&gt;

setup (hd5)

grub&gt; setup (hd5)
 Checking if "/boot/grub/stage1" exists... no
 Checking if "/grub/stage1" exists... yes
 Checking if "/grub/stage2" exists... yes
 Checking if "/grub/e2fs_stage1_5" exists... yes
 Running "embed /grub/e2fs_stage1_5 (hd0)"...  15 sectors are embedded.
succeeded
 Running "install /grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/grub/stage2 /grub/menu.lst"... succeeded
Done.

grub&gt;

root (hd6,0)

grub&gt; root (hd6,0)
 Filesystem type is ext2fs, partition type 0xfd

grub&gt;

setup (hd6)

grub&gt; setup (hd6)
 Checking if "/boot/grub/stage1" exists... no
 Checking if "/grub/stage1" exists... yes
 Checking if "/grub/stage2" exists... yes
 Checking if "/grub/e2fs_stage1_5" exists... yes
 Running "embed /grub/e2fs_stage1_5 (hd1)"...  15 sectors are embedded.
succeeded
 Running "install /grub/stage1 (hd1) (hd1)1+15 p (hd1,0)/grub/stage2 /grub/menu.lst"... succeeded
Done.

grub&gt;
quit

Now, back on the normal shell, we reboot the system and hope that it boots ok from our RAID arrays:

reboot

Preparing /dev/sdc

If all goes well, you should now find /dev/md0 and /dev/md2 in the output of

# df -h
host:~# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/md1              9.0G  458M  8.1G   6% /
tmpfs                 4.0G     0  4.0G   0% /lib/init/rw
udev                   10M  136K  9.9M   2% /dev
tmpfs                 4.0G     0  4.0G   0% /dev/shm
/dev/md0               92M   18M   69M  21% /boot

The output of

# cat /proc/mdstat

should be as follows:

host:~# cat /proc/mdstat
Personalities : [raid1] [raid10]
md3 : active raid10 sdd6[1] sdf6[3] sde6[2]
      966020352 blocks 64K chunks 2 near-copies [4/3] [_UUU]

md0 : active raid1 sdd1[1] sdf1[3] sde1[2]
      96256 blocks [4/3] [_UUU]

md2 : active raid10 sdd5[1] sdf5[3] sde5[2]
      979712 blocks 64K chunks 2 near-copies [4/3] [_UUU]

md1 : active raid10 sdd3[1] sdf3[3] sde3[2]
      9574528 blocks 64K chunks 2 near-copies [4/3] [_UUU]

unused devices: &lt;none&gt;

Now we must change the partition types of our three partitions on /dev/sdc to Linux raid autodetect as well:

# fdisk /dev/sdc
host:~# fdisk /dev/sdc

Command (m for help): &lt;-- t
Partition number (1-6): &lt;-- 1
Hex code (type L to list codes): &lt;-- fd
Changed system type of partition 1 to fd (Linux raid autodetect)

Command (m for help): &lt;-- t
Partition number (1-6): &lt;-- 3
Hex code (type L to list codes): &lt;-- fd
Changed system type of partition 2 to fd (Linux raid autodetect)

Command (m for help): &lt;-- t
Partition number (1-6): &lt;-- 5
Hex code (type L to list codes): &lt;-- fd
Changed system type of partition 3 to fd (Linux raid autodetect)

Command (m for help): &lt;-- t
Partition number (1-6): &lt;-- 6
Hex code (type L to list codes): &lt;-- fd
Changed system type of partition 3 to fd (Linux raid autodetect)

Command (m for help): &lt;-- w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

Now we can add /dev/sdc1, /dev/sdc3, /dev/sdc5 and /dev/sdc6 to the respective RAID arrays:

# mdadm --add /dev/md0 /dev/sdc1
# mdadm --add /dev/md1 /dev/sdc3
# mdadm --add /dev/md2 /dev/sdc5
# mdadm --add /dev/md2 /dev/sdc6

Now take a look at

# cat /proc/mdstat
host:~# cat /proc/mdstat
Personalities : [raid1] [raid10]
md3 : active raid10 sdc6[4] sdd6[1] sdf6[3] sde6[2]
      966020352 blocks 64K chunks 2 near-copies [4/3] [_UUU]
      [&gt;....................]  recovery =  1.2% (5975552/483010176) finish=123.1min speed=64582K/sec

md0 : active raid1 sdc1[0] sdd1[1] sdf1[3] sde1[2]
      96256 blocks [4/4] [UUUU]

md2 : active raid10 sdc5[0] sdd5[1] sdf5[3] sde5[2]
      979712 blocks 64K chunks 2 near-copies [4/4] [UUUU]

md1 : active raid10 sdc3[0] sdd3[1] sdf3[3] sde3[2]
      9574528 blocks 64K chunks 2 near-copies [4/4] [UUUU]

unused devices: &lt;none&gt;

(You can run

# watch cat /proc/mdstat

to get an ongoing output of the process. To leave watch, press CTRL+C.)

Wait until the synchronization has finished, the output should then look like this:

host:~# cat /proc/mdstat
Personalities : [raid1] [raid10]
md3 : active raid10 sdc6[0] sdd6[1] sdf6[3] sde6[2]
      966020352 blocks 64K chunks 2 near-copies [4/4] [UUUU]

md0 : active raid1 sdc1[0] sdd1[1] sdf1[3] sde1[2]
      96256 blocks [4/4] [UUUU]

md2 : active raid10 sdc5[0] sdd5[1] sdf5[3] sde5[2]
      979712 blocks 64K chunks 2 near-copies [4/4] [UUUU]

md1 : active raid10 sdc3[0] sdd3[1] sdf3[3] sde3[2]
      9574528 blocks 64K chunks 2 near-copies [4/4] [UUUU]

unused devices: &lt;none&gt;

Then adjust /etc/mdadm/mdadm.conf to the new situation:

# cp /etc/mdadm/mdadm.conf_orig /etc/mdadm/mdadm.conf
# mdadm --examine --scan &gt;&gt; /etc/mdadm/mdadm.conf

/etc/mdadm/mdadm.conf should now look something like this:

# cat /etc/mdadm/mdadm.conf
# mdadm.conf
#
# Please refer to mdadm.conf(5) for information about this file.
#

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

# 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 &lt;system&gt;

# instruct the monitoring daemon where to send mail alerts
MAILADDR root

# definitions of existing MD arrays

# This file was auto-generated on Thu, 31 Jan 2008 15:05:41 +0100
# by mkconf $Id: mkconf 261 2006-11-09 13:32:35Z madduck $
ARRAY /dev/md0 level=raid1 num-devices=4 UUID=724e4049:df159d74:f41cdd86:04e94251
ARRAY /dev/md1 level=raid10 num-devices=4 UUID=a43048f6:f9759799:0d2aba67:9fb5aef3
ARRAY /dev/md2 level=raid10 num-devices=4 UUID=af1886bd:8acb329c:0d2aba67:9fb5aef3
ARRAY /dev/md3 level=raid10 num-devices=4 UUID=ca928896:05e930e6:f41cdd86:04e94251

Preparing GRUB (Part 2)

We are almost done now. Now we must modify /boot/grub/menu.lst again. Right now it is configured to boot from /dev/sdd (hd1,0). Of course, we still want the system to be able to boot in case /dev/sdd fails. Therefore we copy the first kernel stanza (which contains hd1), paste it below and replace hd1 with hd0. Furthermore we comment out all other kernel stanzas so that it looks as follows:

# nano /boot/grub/menu.lst
## ## End Default Options ##

title           Debian GNU/Linux, kernel 2.6.18-5-amd64
root            (hd3,0)
kernel          /vmlinuz-2.6.18-5-amd64 root=/dev/md1 ro
initrd          /initrd.img-2.6.18-5-amd64
savedefault

title           Debian GNU/Linux, kernel 2.6.18-5-amd64
root            (hd2,0)
kernel          /vmlinuz-2.6.18-5-amd64 root=/dev/md1 ro
initrd          /initrd.img-2.6.18-5-amd64
savedefault

title           Debian GNU/Linux, kernel 2.6.18-5-amd64
root            (hd1,0)
kernel          /vmlinuz-2.6.18-5-amd64 root=/dev/md1 ro
initrd          /initrd.img-2.6.18-5-amd64
savedefault

title           Debian GNU/Linux, kernel 2.6.18-5-amd64
root            (hd0,0)
kernel          /vmlinuz-2.6.18-5-amd64 root=/dev/md1 ro
initrd          /initrd.img-2.6.18-5-amd64
savedefault

title           Debian GNU/Linux, kernel 2.6.18-5-amd64
root            (hd0,0)
kernel          /vmlinuz-2.6.18-5-amd64 root=/dev/sdc3 ro
initrd          /initrd.img-2.6.18-5-amd64
savedefault

title           Debian GNU/Linux, kernel 2.6.18-5-amd64 (single-user mode)
root            (hd2,0)
kernel          /vmlinuz-2.6.18-5-amd64 root=/dev/sdc3 ro single
initrd          /initrd.img-2.6.18-5-amd64
savedefault

### END DEBIAN AUTOMAGIC KERNELS LIST

In the same file, there's a kopt line; replace /dev/sdc3 with /dev/md2 (don't remove the # at the beginning of the line!):

# kopt=root=/dev/md1 ro

Afterwards, update your ramdisk:

# update-initramfs -u

… and reboot the system:

# reboot

It should boot without problems.

Pffffff!!!!!

We still need to add the two terrabyte disks sda and sdb to a new raid1 array for our back-up storage

# fdisk /dev/sda
host:~# fdisk /dev/sda

The number of cylinders for this disk is set to 121601.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-121601, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-121601, default 121601):
Using default value 121601

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): fd
Changed system type of partition 1 to fd (Linux raid autodetect)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
# mdadm --create /dev/md4 --level=1 --raid-disks=2 /dev/sda1 /dev/sdb1
# cp /etc/mdadm/mdadm.conf_orig /etc/mdadm/mdadm.conf
# mdadm --examine --scan &gt;&gt; /etc/mdadm/mdadm.conf
apt-get install lvm2
host:/home# fdisk /dev/md4

The number of cylinders for this disk is set to 121600.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): l

 0  Empty           1e  Hidden W95 FAT1 80  Old Minix       be  Solaris boot
 1  FAT12           24  NEC DOS         81  Minix / old Lin bf  Solaris
 2  XENIX root      39  Plan 9          82  Linux swap / So c1  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  83  Linux           c4  DRDOS/sec (FAT-
 4  FAT16 &lt;32M      40  Venix 80286     84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
 5  Extended        41  PPC PReP Boot   85  Linux extended  c7  Syrinx
 6  FAT16           42  SFS             86  NTFS volume set da  Non-FS data
 7  HPFS/NTFS       4d  QNX4.x          87  NTFS volume set db  CP/M / CTOS / .
 8  AIX             4e  QNX4.x 2nd part 88  Linux plaintext de  Dell Utility
 9  AIX bootable    4f  QNX4.x 3rd part 8e  Linux LVM       df  BootIt
 a  OS/2 Boot Manag 50  OnTrack DM      93  Amoeba          e1  DOS access
 b  W95 FAT32       51  OnTrack DM6 Aux 94  Amoeba BBT      e3  DOS R/O
 c  W95 FAT32 (LBA) 52  CP/M            9f  BSD/OS          e4  SpeedStor
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a0  IBM Thinkpad hi eb  BeOS fs
 f  W95 Ext'd (LBA) 54  OnTrackDM6      a5  FreeBSD         ee  EFI GPT
10  OPUS            55  EZ-Drive        a6  OpenBSD         ef  EFI (FAT-12/16/
11  Hidden FAT12    56  Golden Bow      a7  NeXTSTEP        f0  Linux/PA-RISC b
12  Compaq diagnost 5c  Priam Edisk     a8  Darwin UFS      f1  SpeedStor
14  Hidden FAT16 &lt;3 61  SpeedStor       a9  NetBSD          f4  SpeedStor
16  Hidden FAT16    63  GNU HURD or Sys ab  Darwin boot     f2  DOS secondary
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fd  Linux raid auto
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fe  LANstep
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid ff  BBT
1c  Hidden W95 FAT3 75  PC/IX
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
# vgcreate backup /dev/md4
# vgcreate xen /dev/md3

Vserver installation

We will use the vserver kernel from backports.

# apt-get install vserver-debiantools util-vserver
# apt-get install -t etch-backports linux-image-2.6.22-3-vserver-amd64

We set up the network interfaces, eth0 is for the internet, eth1 is for the LAN and dummy0 is for the DMZ

# nano /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
        address RED-ENVELOPE
        netmask RED-ENVELOPE
        network RED-ENVELOPE
        broadcast RED-ENVELOPE
        gateway RED-ENVELOPE
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers RED-ENVELOPE
        dns-search cipar.net

auto eth1
iface eth1 inet static
        address 192.168.0.1
        netmask 255.255.255.0
        broadcast 192.168.0.255
        network 192.168.0.0

auto dummy0
iface dummy0 inet static
    address 192.168.1.1
    netmask 255.255.255.0

To bring up the interfaces

# ifup dumm0

There seem to be some old functions being depreciated in the new version from backports that produce some error when starting a new Vserver.
To fix this we use a patch from Christian Schenk

# cd /usr/local/sbin
# wget http://data.christianschenk.org/upgrading-vserver-from-20-to-22/set-context.sh

To make it executable

# chmod a+x set-context.sh

We can use this script before starting a new Vserver for the first time by calling this script with the name of the new server.

# ./set-context.sh name-of-server

(the script content looks like this

#!/bin/sh

test ! $# = 1 &amp;&amp; echo "Usage: $0 [vservername]" &amp;&amp; exit 1

NAME=$1
VSERVER_CONFIG="/etc/vservers/$NAME"
test ! -d $VSERVER_CONFIG &amp;&amp; echo "ERROR: $VSERVER_CONFIG doesn't exist" &amp;&amp; exit 1

LAST_CTX=`find /etc/vservers/ -name context | xargs -L1 cat | sort -n | tail -1`
NEXT_CTX=`expr $LAST_CTX + 1`

#
# valid static contexts are between 2 and 49151 (daniel_hozac on IRC)
#
test $NEXT_CTX = 1 &amp;&amp; NEXT_CTX=2
test $NEXT_CTX -gt 49151 &amp;&amp; echo "ERROR: Maximum number of contexts reached" &amp;&amp; exit 1

echo $NEXT_CTX &gt; $VSERVER_CONFIG/context

shorewall

http://manpages.songshu.org/manpages/lenny/en/man8/shorewall.8.html

Shorewall will arrange our routing and security settings between the network interfaces.

# apt-get install shorewall
# apt-get install shorewall-doc
# cp /usr/share/doc/shorewall/default-config/modules /etc/shorewall/
# cp /usr/share/doc/shorewall/default-config/zones /etc/shorewall/
# cp /usr/share/doc/shorewall/default-config/policy /etc/shorewall/
# cp /usr/share/doc/shorewall/default-config/interfaces /etc/shorewall/
# cp /usr/share/doc/shorewall/default-config/rules /etc/shorewall/
# cp /usr/share/shorewall/macro.* /etc/shorewall/
# nano /etc/shorewall/zones

We set up the following zones

#ZONE   TYPE            OPTIONS         IN                      OUT
#                                       OPTIONS                 OPTIONS
fw      firewall
net     ipv4
loc     ipv4
dmz     ipv4
#LAST LINE - ADD YOUR ENTRIES ABOVE THIS ONE - DO NOT REMOVE
# nano /etc/shorewall/policy

We set up the following

loc        net         ACCEPT
net        all         DROP        info
all        all         REJECT      info

!!!!!!!!!THiS WILL LOCK YOU OUT!!!!!!!!!!!!!!!
check http://songshu.org/doku/doku.php?id=the_network for the actual rules applied
And set up our network interfaces

# nano /etc/shorewall/interfaces
#ZONE   INTERFACE       BROADCAST       OPTIONS
net     eth0            detect          tcpflags,dhcp,routefilter,norfc1918,nosmurfs,logmartians
loc     eth1            detect          tcpflags,detectnets,nosmurfs
dmz     dummy0          detect
# nano /etc/default/shorewall

change

startup=0
to
startup=1
# nano /etc/shorewall/shorewall.conf

change

IP_FORWARDING=Keep
to
IP_FORWARDING=On

monitoring

For the host system we want to set up some automatic monitoring so we receive emails about hard disk status, raid status, UPS etc…

postfix

http://manpages.songshu.org/manpages/lenny/en/man1/postfix.1.html

To receive emails we need something to send them so we install postfix

# apt-get install postfix

–> we choose “satelite system” here

--&gt; we choose host.cipar.net
--&gt; all mails are send to smtp.cipar.net

We need all the mail sent to the root account to be sent to an external account.

# nano /etc/aliases

here we add the following

root:   myname@mydomain.org
# newaliases

monitoring tools

http://manpages.songshu.org/manpages/lenny/en/man1/monit.1.html

# apt-get install monit syslog-ng watchdog apcupsd mailx smartmontools

monit

S.M.A.R.T.

http://manpages.songshu.org/manpages/lenny/en/man8/smartctl.8.html

# nano /etc/default/smartmontools

change the value to “yes”

# uncomment to start smartd on system startup
start_smartd=yes

to check if your hard disk(s) support SMART

# smartctl -i -d ata /dev/sda

To enable SMART on SATA drives

# smartctl -s on -d ata /dev/sda

check the SMART Health Status

# smartctl -H /dev/sda

We need to change some values to make sure it works with our SATA disks

# nano /etc/smartd.conf

first comment out the device scan so it looks like this:

#DEVICESCAN -m root -M exec /usr/share/smartmontools/smartd-runner

Then we manually add our ata type disks, start a selftest for every disk on sunday at 13:00 and send the error reporting message to root and if there is an error report reminders should be sent daily.

/dev/sda -a -d ata -s L/../../7/01 -m root -M daily
/dev/sdb -a -d ata -s L/../../7/01 -m root -M daily
/dev/sdc -a -d ata -s L/../../7/01 -m root -M daily
/dev/sdd -a -d ata -s L/../../7/01 -m root -M daily
/dev/sde -a -d ata -s L/../../7/01 -m root -M daily
/dev/sdf -a -d ata -s L/../../7/01 -m root -M daily

To start smart:

# /etc/init.d/smartmontools start

APC UPS

http://manpages.songshu.org/manpages/lenny/en/man8/apcupsd.8.html

# nano /etc/apcupsd/apcupsd.conf

change

  • UPSCABLE smart to UPSCABLE usb

and

  • DEVICE /dev/ttyS0 to DEVICE /dev/usb/hiddev0

and change

  • UPSTYPE apcsmart to #UPSTYPE usb

the final file will look as follows

## apcupsd.conf v1.1 ##
#
#  for apcupsd release 3.12.4 (19 August 2006) - debian
#
# "apcupsd" POSIX config file

#
# ========= General configuration parameters ============
#

# UPSNAME xxx
#   Use this to give your UPS a name in log files and such. This
#   is particulary useful if you have multiple UPSes. This does not
#   set the EEPROM. It should be 8 characters or less.
#UPSNAME

# UPSCABLE &lt;cable&gt;
#   Defines the type of cable connecting the UPS to your computer.
#
#   Possible generic choices for &lt;cable&gt; are:
#     simple, smart, ether, usb
#
#   Or a specific cable model number may be used:
#     940-0119A, 940-0127A, 940-0128A, 940-0020B,
#     940-0020C, 940-0023A, 940-0024B, 940-0024C,
#     940-1524C, 940-0024G, 940-0095A, 940-0095B,
#     940-0095C, M-04-02-2000
#
#UPSCABLE smart
UPSCABLE usb
# To get apcupsd to work, in addition to defining the cable
# above, you must also define a UPSTYPE, which corresponds to
# the type of UPS you have (see the Description for more details).
# You must also specify a DEVICE, sometimes referred to as a port.
# For USB UPSes, please leave the DEVICE directive blank. For
# other UPS types, you must specify an appropriate port or address.
#
# UPSTYPE   DEVICE           Description
# apcsmart  /dev/tty**       Newer serial character device,
#                            appropriate for SmartUPS models using
#                            a serial cable (not USB).
#
#usb       &lt;BLANK&gt;          Most new UPSes are USB.
#                            A blank DEVICE setting enables
#                            autodetection, which is th best choice
#                            for most installations.
#
# net       hostname:port    Network link to a master apcupsd
#                            through apcupsd's Network Information
#                            Server. This is used if you don't have
#                            a UPS directly connected to your computer.
#
# snmp      hostname:port:vendor:community
#                            SNMP Network link to an SNMP-enabled
#                            UPS device. Vendor is the MIB used by
#                            the UPS device: can be "APC", "APC_NOTRAP"
#                            or "RFC" where APC is the powernet MIB,
#                            "APC_NOTRAP" is powernet with SNMP trap
#                            catching disabled, and RFC is the IETF's
#                            rfc1628 UPS-MIB. Port is usually 161.
#                            Community is "private".
#
# dumb      /dev/tty**       Old serial character device for use
#                            with simple-signaling UPSes.
#
#UPSTYPE apcsmart
UPSTYPE usb
#DEVICE /dev/ttyS0
DEVICE /dev/usb/hiddev0

# LOCKFILE &lt;path to lockfile&gt;
#   Path for device lock file.
LOCKFILE /var/lock

#
# ======== Configuration parameters used during power failures ==========
#

# The ONBATTERYDELAY is the time in seconds from when a power failure
#   is detected until we react to it with an onbattery event.
#
#   This means that, apccontrol will be called with the powerout argument
#   immediately when a power failure is detected.  However, the
#   onbattery argument is passed to apccontrol only after the
#   ONBATTERYDELAY time.  If you don't want to be annoyed by short
#   powerfailures, make sure that apccontrol powerout does nothing
#   i.e. comment out the wall.
ONBATTERYDELAY 6

#
# Note: BATTERYLEVEL, MINUTES, and TIMEOUT work in conjunction, so
# the first that occurs will cause the initation of a shutdown.
#

# If during a power failure, the remaining battery percentage
# (as reported by the UPS) is below or equal to BATTERYLEVEL,
# apcupsd will initiate a system shutdown.
BATTERYLEVEL 5

# If during a power failure, the remaining runtime in minutes
# (as calculated internally by the UPS) is below or equal to MINUTES,
# apcupsd, will initiate a system shutdown.
MINUTES 3

# If during a power failure, the UPS has run on batteries for TIMEOUT
# many seconds or longer, apcupsd will initiate a system shutdown.
# A value of 0 disables this timer.
#
#  Note, if you have a Smart UPS, you will most likely want to disable
#    this timer by setting it to zero. That way, you UPS will continue
#    on batteries until either the % charge remaing drops to or below BATTERYLEVEL,
#    or the remaining battery runtime drops to or below MINUTES.  Of course,
#    if you are testing, setting this to 60 causes a quick system shutdown
#    if you pull the power plug.
#  If you have an older dumb UPS, you will want to set this to less than
#    the time you know you can run on batteries.
TIMEOUT 0

#  Time in seconds between annoying users to signoff prior to
#  system shutdown. 0 disables.
ANNOY 300

# Initial delay after power failure before warning users to get
# off the system.
ANNOYDELAY 60

# The condition which determines when users are prevented from
# logging in during a power failure.
# NOLOGON &lt;string&gt; [ disable | timeout | percent | minutes | always ]
NOLOGON disable

# If KILLDELAY is non-zero, apcupsd will continue running after a
# shutdown has been requested, and after the specified time in
# seconds attempt to kill the power. This is for use on systems
# where apcupsd cannot regain control after a shutdown.
# KILLDELAY &lt;seconds&gt;  0 disables
KILLDELAY 0

#
# ==== Configuration statements for Network Information Server ====
#

# NETSERVER [ on | off ] on enables, off disables the network
#  information server. If netstatus is on, a network information
#  server process will be started for serving the STATUS and
#  EVENT data over the network (used by CGI programs).
NETSERVER on

# NISIP &lt;dotted notation ip address&gt;
#  IP address on which NIS server will listen for incoming connections.
#  Default value is 0.0.0.0 that means any incoming request will be
#  serviced but if you want it to listen to a single subnet you can
#  set it up to that subnet address, for example 192.168.10.0
#  Additionally you can listen for a single IP like 192.168.10.1
NISIP 127.0.0.1

# NISPORT &lt;port&gt; default is 3551 as registered with the IANA
#  port to use for sending STATUS and EVENTS data over the network.
#  It is not used unless NETSERVER is on. If you change this port,
#  you will need to change the corresponding value in the cgi directory
#  and rebuild the cgi programs.
NISPORT 3551

# If you want the last few EVENTS to be available over the network
# by the network information server, you must define an EVENTSFILE.
EVENTSFILE /var/log/apcupsd.events

# EVENTSFILEMAX &lt;kilobytes&gt;
#  By default, the size of the EVENTSFILE will be not be allowed to exceed
#  10 kilobytes.  When the file grows beyond this limit, older EVENTS will
#  be removed from the beginning of the file (first in first out).  The
#  parameter EVENTSFILEMAX can be set to a different kilobyte value, or set
#  to zero to allow the EVENTSFILE to grow without limit.
EVENTSFILEMAX 10

#
# ========== Configuration statements used if sharing =============
#            a UPS and controlling it via the network

# The configuration statements below are used if you want to share one
# UPS to power multiple machines and have them communicate by the network.
# Most of these items are for Master/Slave mode only, however NETTIME is
# also used for Client/Server NIS networking with the net driver.

# NETTIME &lt;int&gt;
#   Interval (in seconds) at which the slave or client polls the master
#   or server. This is applicable to BOTH master/slave and client/server
#   (NIS) networking.
#NETTIME 100

#
# Remaining items are for Master/Slave networking ONLY
#

# UPSCLASS [ standalone | shareslave | sharemaster | netslave | netmaster ]
#   Normally standalone unless you share a UPS with multiple machines.
#
UPSCLASS standalone

# UPSMODE [ disable | share | net | sharenet ]
#   Unless you want to share the UPS (power multiple machines),
#   this should be disable.
UPSMODE disable

# NETPORT &lt;int&gt;
#   Port on which master/slave networking communicates.
#NETPORT 6544

# MASTER &lt;machine-name&gt;
#   IP address of the master. Only applicable on slaves.
#MASTER

# SLAVE &lt;machine-name&gt;
#   IP address(es) of the slave(s). Only applicable on master.
#SLAVE slave1
#SLAVE slave2

# USERMAGIC &lt;string&gt;
#   Magic string use by slaves to identify themselves. Only applicable
#   on slaves.
#USERMAGIC

#
# ===== Configuration statements to control apcupsd system logging ========
#

# Time interval in seconds between writing the STATUS file; 0 disables
STATTIME 0

# Location of STATUS file (written to only if STATTIME is non-zero)
STATFILE /var/log/apcupsd.status

# LOGSTATS [ on | off ] on enables, off disables
# Note! This generates a lot of output, so if
#       you turn this on, be sure that the
#       file defined in syslog.conf for LOG_NOTICE is a named pipe.
#  You probably do not want this on.
LOGSTATS off

# Time interval in seconds between writing the DATA records to
#   the log file. 0 disables.
DATATIME 0

# FACILITY defines the logging facility (class) for logging to syslog.
#          If not specified, it defaults to "daemon". This is useful
#          if you want to separate the data logged by apcupsd from other
#          programs.
#FACILITY DAEMON

#
# ========== Configuration statements used in updating the UPS EPROM =========
#

#
# These statements are used only by apctest when choosing "Set EEPROM with conf
# file values" from the EEPROM menu. THESE STATEMENTS HAVE NO EFFECT ON APCUPSD.
#

# UPS name, max 8 characters
#UPSNAME UPS_IDEN

# Battery date - 8 characters
#BATTDATE mm/dd/yy

# Sensitivity to line voltage quality (H cause faster transfer to batteries)
# SENSITIVITY H M L        (default = H)
#SENSITIVITY H

# UPS delay after power return (seconds)
# WAKEUP 000 060 180 300   (default = 0)
#WAKEUP 60

# UPS Grace period after request to power off (seconds)
# SLEEP 020 180 300 600    (default = 20)
#SLEEP 180

# Low line voltage causing transfer to batteries
# The permitted values depend on your model as defined by last letter
#  of FIRMWARE or APCMODEL. Some representative values are:
#    D 106 103 100 097
#    M 177 172 168 182
#    A 092 090 088 086
#    I 208 204 200 196     (default = 0 =&gt; not valid)
#LOTRANSFER  208

# High line voltage causing transfer to batteries
# The permitted values depend on your model as defined by last letter
#  of FIRMWARE or APCMODEL. Some representative values are:
#    D 127 130 133 136
#    M 229 234 239 224
#    A 108 110 112 114
#    I 253 257 261 265     (default = 0 =&gt; not valid)
#HITRANSFER 253

# Battery change needed to restore power
# RETURNCHARGE 00 15 50 90 (default = 15)
#RETURNCHARGE 15

# Alarm delay
# 0 = zero delay after pwr fail, T = power fail + 30 sec, L = low battery, N = never
# BEEPSTATE 0 T L N        (default = 0)
#BEEPSTATE T

# Low battery warning delay in minutes
# LOWBATT 02 05 07 10      (default = 02)
#LOWBATT 2

# UPS Output voltage when running on batteries
# The permitted values depend on your model as defined by last letter
#  of FIRMWARE or APCMODEL. Some representative values are:
#    D 115
#    M 208
#    A 100
#    I 230 240 220 225     (default = 0 =&gt; not valid)
#OUTPUTVOLTS 230

# Self test interval in hours 336=2 weeks, 168=1 week, ON=at power on
# SELFTEST 336 168 ON OFF  (default = 336)
#SELFTEST 336

# mdadm –monitor –scan –daemonise

host:/var/mail# cat /proc/mdstat
Personalities : [raid1] [raid10]
md3 : active raid10 sdc6[0] sdf6[3] sde6[2] sdd6[4](F)

    966020352 blocks 64K chunks 2 near-copies [4/3] [U_UU]

md2 : active raid10 sdc5[0] sdf5[3] sde5[2] sdd5[4](F)

    979712 blocks 64K chunks 2 near-copies [4/3] [U_UU]

md1 : active raid10 sdc3[0] sdf3[3] sde3[2] sdd3[4](F)

    9574528 blocks 64K chunks 2 near-copies [4/3] [U_UU]

md0 : active raid1 sdc1[0] sdf1[3] sde1[2] sdd1[4](F)

    96256 blocks [4/3] [U_UU]

# mdadm –fail /dev/md0 /dev/sdd1
# mdadm –fail /dev/md1 /dev/sdd3
# mdadm –fail /dev/md2 /dev/sdd5
# mdadm –fail /dev/md3 /dev/sdd6

# mdadm –remove /dev/md0 /dev/sdd1
# mdadm –remove /dev/md1 /dev/sdd3
# mdadm –remove /dev/md2 /dev/sdd5
# mdadm –remove /dev/md3 /dev/sdd6

# shutdown -h now

# sfdisk -d /dev/sdc | sfdisk /dev/sdd

# mdadm –add /dev/md0 /dev/sdd1
# mdadm –add /dev/md1 /dev/sdd3
# mdadm –add /dev/md2 /dev/sdd5
# mdadm –add /dev/md3 /dev/sdd6

http://manpages.songshu.org/manpages/lenny/en/man8/dnsmasq.8.html

# apt-get install dnsmasq
nano /etc/dnsmasq.conf
listen-address=192.168.1.1
dhcp-range=192.168.0.50,192.168.0.150,12h
dhcp-option=42,0.0.0.0

</div>

Tags: , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Links

Calendar

    September 2010
    M T W T F S S
    « Mar    
     12345
    6789101112
    13141516171819
    20212223242526
    27282930