Server install & setup

Howto setup an server with RAID and LVM. The preferred OS is Debian Sarge. The new hardware will replace an old server with the same software installed. The only difference will be support for RAID, LVM and dual cpu (new kernel with support for SATA has to be compiled as well). As soon as the OS is installed all data will be transferred, MySQL, Apache and Samba fired up.

As the Debian Sarge installer doesn't support SATA drives with kernel 2.6 I'm using the INSERT Rescue CD to boot into the system and setup the disks. The following steps are done in the rescue system.


This is the hardware we deal with:

P4 D 3.0 Ghz (Dual Core)
2 GB Ram
2 x 1000 Mbit Intel Ethernet Card
1 x 100 Mbit Intel Ethernet Card
3 x 320 GB SATA harddrive


Preferred disk layout:

mount pointspacefile system
/ 500 MB ext3
/boot 100 MB ext2
/tmp 1 GB xfs
/usr 5 GB xfs
/var 5 GB xfs
/data rest xfs


partitionsizepartition type
sda1 1 GB 82 (swap)
sda2 100 MB fd (software raid)
sda3 rest fd (software raid)

copy disk layout to the other two disks (sdb, sdc) - CAUTION: this will permanently erase all data on sdb and sdc!

sfdisk -d /dev/sda | sfdisk /dev/sdb
sfdisk -d /dev/sda | sfdisk /dev/sdc

Software Raid

raid deviceraid levelpartitionsmount point
md0 1 sda2 sdb2 /boot
md1 5 sda3 sdb3 sdc3 none, see LVM
# Create raid 1 for /boot:
mdadm --create --verbose /dev/md0 --level=1 --raid-devices=3 /dev/sda2 /dev/sdb2 /dev/sdc2
# Create Filesystem:
mkfs.ext2 /dev/md0

# create raid 5:
mdadm --create --verbose /dev/md1 --level=5 --chunk=128 --raid-devices=3 /dev/sda3 /dev/sdb3 /dev/sdc3
# watch the raid initializing ...
watch cat /proc/mdstat


volume groupdevice
vg00 /dev/md1
# create physical volume
pvcreate /dev/md1

# create volume group
vgcreate vg00 /dev/md1

# create the logical volumes
lvcreate -L500 -n root vg00
lvcreate -L 5G -n usr vg00
lvcreate -L 5G -n var vg00
lvcreate -L 1G -n tmp vg00
lvcreate -L 100G -n data vg00

# create filesystem
mkfs.ext3 /dev/vg00/root
mkfs.xfs /dev/vg00/usr
mkfs.xfs /dev/vg00/var
mkfs.xfs /dev/vg00/tmp
mkfs.xfs /dev/vg00/data


# prepare directory structure

mkdir /target
mount /dev/vg00/root /target
cd /target
mkdir --parent boot usr home var tmp

mount /dev/md0 /target/boot
mount /dev/vg00/usr /target/usr
mount /dev/vg00/var /target/var
mount /dev/vg00/tmp /target/tmp

# get debootstrap
cd /target/tmp
ar x debootstrap_0.2.45-0.2_i386.deb
mkdir /target/tmp/bootstrap
cd bootstrap
tar xfvz ../data.tar.gz
ln -s /target/tmp/bootstrap/usr/lib/debootstrap/ /usr/lib/

# install base system:
/target/tmp/bootstrap/usr/sbin/debootstrap --arch i386 sarge /target/

OK, the base system is installed, now we have things to tune …

# chroot into the new installation
chroot /target
mount /proc

vi /etc/apt/sources.list
# add:
deb sarge main
deb sarge/updates  main
deb sarge/updates  contrib non-free

vi /etc/resolv.conf
# add the appropriate entries to get access to the internet DNS

vi /etc/fstab

# /etc/fstab: static file system information.
# <file system> <mount point>   <type>  <options>                       <dump>  <pass>
proc            /proc           proc    defaults                        0       0
/dev/sda1       none            swap    sw                              0       0
/dev/sdb1       none            swap    sw                              0       0
/dev/sdc1       none            swap    sw                              0       0
/dev/md0        /boot           ext2    noatime,nodev,nosuid,noexec     0       2
/dev/vg00/root  /               ext3    defaults,errors=remount-ro      0       1
/dev/vg00/data  /data           xfs     defaults,noatime                0       2
/dev/vg00/usr   /usr            xfs     defaults,noatime,nodev          0       2
/dev/vg00/var   /var            xfs     defaults                        0       2
/dev/vg00/tmp   /tmp            xfs     nodev,sosuid                    0       2
/dev/hda        /media/cdrom0   iso9660 ro,user,noauto                  0       0
/dev/fd0        /media/floppy0  auto    rw,user,noauto,sync             0       0

As I am going to upgrade an existing server, I'm going to clone the package selections.

# Old server: save package selection to file:
dpkg --get-selections '*' > ~/dpkg_pakete

# transfer dpkg_pakete to this system
dpkg --set-selections < ~/dpkg_pakete
# install the missing packages
apt-get dselect-upgrade

Kernel & Bootloader

As the standard debian 2.6.8 kernel doesn't support SATA harddrives, there's still some work todo. I'm going to build the latest 2.6.x kernel from

apt-get install kernel-package libncurses5-dev fakeroot
cd /usr/src
tar xjf linux-
cd linux-

# create your kernel config (make menuconfig)

REVISION=$(date +%Y%m%d.%H%M)
make-kpkg --rootcmd fakeroot clean
make-kpkg --rootcmd fakeroot --revision $REVISION --append-to-version -lisa kernel-image

# "--append-to-version -lisa" is optional and helpful if you compile a kernel for a special machine (lisa)
# uname -nr will show something like this: lisa
howto/server_setup.txt · Last modified: 2012-12 by tb
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 ipv6 ready