You are here: Home / Debian GNU/Linux / System / OVH / Setup of a OVH dedicated server

Setup of a OVH dedicated server

by Pierre-Yves Landuré last modified Jan 31, 2014 06:40

This howto present various enhancements to apply immediately after the activation / installation of a OVH dedicated server.

This howto is tested on :

  • Debian 4.0 Etch
  • Debian 6.0 Squeeze

This howto works with any OVH dedicated server ordered with the following settings :

  • Operating System : Debian 6.0 Squeeze raw.
  • Langage : English


Initial setup

Make sure the character encoding used by the system is UTF-8 :

echo "en_US ISO-8859-1
en_US.UTF-8 UTF-8" > '/etc/locale.gen'
command sed -i -e 's/^LANG=.*/LANG=en_US.UTF-8/' '/etc/default/locale'
command sed -i -e 's/^LANG=.*/LANG=en_US/' '/etc/environment'
command locale-gen

Install the latest upgrades :

command apt-get update
command apt-get upgrade

Install a Mail transport agent :

command apt-get install exim4

Restart the system to activate any kernel upgrade :

command reboot

System setup

Follow these howtos:

Hardening security

Follow these howtos:


Follow this howto:

Partition reorganization

By default, the partitions are:

  • / (11 Go): The root partition, where the operating system is stored.
  • /home (??? Go): The rest of available storage.

This howto install a LVM volume on the (unused) /home partition. LVM ease greatly the available storage space management and offer a bunch of functionnalities (quotas, etc...) easing a server management. LVM is recommanded to setup Xen DomUs.

Before installing LVM, apply a fix preventing some installation problems :

if [ -e '/sbin/update-modules.modutils' ]; then
  command cp '/sbin/update-modules.modutils' '/sbin/update-modules.modutils.back'
  echo '#!/bin/sh -e
exit 0' > '/sbin/update-modules.modutils'

Install LVM:

command apt-get install lvm2

Detect the partition to be used by LVM :

LVM_DEV="$(command cat '/etc/fstab' \
| command grep '/home' \
| command cut --fields=1)"

Unmount /home:

command umount '/home'

Delete /home from fstab file:

command sed -i -e '/\/home/d' '/etc/fstab'

Create the LVM physical volume :

command pvcreate "${LVM_DEV}"

Create a volume group containing the created physical volume. Provide the volume group name :


Note: "vhd1" stands for "Virtual Hard Drive 1".

Create the volume group :

command vgcreate "${VG_NAME}" "${LVM_DEV}"

Display volume groups statuses:

command vgdisplay

Create 3 logical volumes :

  • /var (20 Go) to have sufficient space for logs.
  • /tmp (1 Go) to have a isolated temporary folder.
  • /home (10 Go) to have a /home partition for users files.
command lvcreate -n var -L 10g "${VG_NAME}"
command lvcreate -n tmp -L 1g "${VG_NAME}"
command lvcreate -n home -L 10g "${VG_NAME}"

Format the partitions with ext4 if possible (ext3 otherwise) :

if [ -e '/sbin/mkfs.ext4' ]; then
command mkfs.ext4 "/dev/${VG_NAME}/var" command mkfs.ext4 "/dev/${VG_NAME}/tmp" command mkfs.ext4 "/dev/${VG_NAME}/home"
command mkfs.ext3 "/dev/${VG_NAME}/var" command mkfs.ext3 "/dev/${VG_NAME}/tmp" command mkfs.ext3 "/dev/${VG_NAME}/home"

Add the partitions configuration to fstab file :

echo "/dev/${VG_NAME}/var   /var    ${FS_TYPE}    defaults                0       2
/dev/${VG_NAME}/tmp   /tmp    ${FS_TYPE}    defaults                0       2
/dev/${VG_NAME}/home  /home   ${FS_TYPE}    defaults                0       2" >> '/etc/fstab'

Initialize the contents of /var partition :

command mount -t "${FS_TYPE}" "/dev/${VG_NAME}/var" "/mnt"
command cp -a "/var/"* "/mnt"
command umount "/mnt"

Mount the new partitions :

command mount "/var"
command mount "/tmp"
command mount "/home"

Adjust the temporary folder rights :

command chmod go+w "/tmp"
command chmod o+t "/tmp"

If no error was raised, reboot the system :

command reboot

Installing Grub (optional)

If another kernel than the one provided by OVH is needed (experts only !), install Grub :

command apt-get install grub-pc mdadm initramfs-tools

Install the Grub Master Boot Record (MBR):

command grub-install "/dev/sda"
command update-grub