Skip to content

Instantly share code, notes, and snippets.

@aeris
Created February 20, 2012 23:22
Show Gist options
  • Save aeris/1872233 to your computer and use it in GitHub Desktop.
Save aeris/1872233 to your computer and use it in GitHub Desktop.
Debian setup for OVH
# Partitionning
fdisk /dev/sda (n p 1, a 1, t 1 fd, w)
sfdisk -d /dev/sda | sfdisk /dev/sdb
# RAID 1
mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1 --assume-clean
# LVM
pvcreate /dev/md0
vgcreate debian /dev/md0
lvcreate -n root -L 10G debian
lvcreate -n boot -L 100M debian
lvcreate -n var -L 20G debian
lvcreate -n tmp -L 10G debian
lvcreate -n swap -L 20G debian
lvcreate -n home -l 461546 debian
# Formatting
mkfs.ext4 /dev/mapper/debian-root -L debian-root
mkfs.ext4 /dev/mapper/debian-boot -L debian-boot
mkfs.ext4 /dev/mapper/debian-var -L debian-var
mkfs.ext4 /dev/mapper/debian-tmp -L debian-tmp
mkfs.ext4 /dev/mapper/debian-home -L debian-home
mkswap /dev/mapper/debian-swap -L debian-swap
# Mount all needs
mount /dev/mapper/debian-root /mnt
mkdir -p /mnt/{boot,var,tmp,home,proc,sys,dev}
mount /dev/mapper/debian-boot /mnt/boot
mount /dev/mapper/debian-var /mnt/var
mount /dev/mapper/debian-tmp /mnt/tmp
mount /dev/mapper/debian-home /mnt/home
mount -o bind /proc /mnt/proc
mount -o bind /sys /mnt/sys
mount -o bind /dev /mnt/dev
# Autoconfigure RAID
mkdir -p /mnt/etc/mdadm
/usr/share/mdadm/mkconf > /mnt/etc/mdadm/mdadm.conf
# Bootstrap Debian Stable
debootstrap --arch=amd64 squeeze /mnt ftp://ftp.fr.debian.org/debian/
# Chroot on new Debian
chroot /mnt
# Modify apt and upgrade the system
cat > /etc/apt/sources.list <<EOF
deb ftp://ftp.fr.debian.org/debian/ stable main contrib non-free
deb-src ftp://ftp.fr.debian.org/debian/ stable main contrib non-free
deb ftp://ftp.fr.debian.org/debian/ stable-updates main contrib non-free
deb-src ftp://ftp.fr.debian.org/debian/ stable-updates main contrib non-free
deb ftp://security.debian.org/debian-security/ stable/updates main contrib non-free
deb-src ftp://security.debian.org/debian-security/ stable/updates main contrib non-free
EOF
apt-get update && apt-get dist-upgrade
# Configure network
vim /etc/network/interfaces
cat > /etc/resolv.conf <<EOF
nameserver 127.0.0.1
nameserver 213.186.33.99
EOF
echo "hostname" > /etc/hostname
hostname -F /etc/hostname
# Configure mount point
cat > /etc/fstab <<EOF
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
/dev/debian/root / ext4 errors=remount-ro 1 1
/dev/debian/boot /boot ext4 defaults 1 2
/dev/debian/var /var ext4 defaults 1 2
/dev/debian/tmp /tmp ext4 defaults 1 2
/dev/debian/home /home ext4 defaults 1 2
/dev/debian/swap none swap swap 0 0
EOF
# Verify here if /proc /sys /dev are still mounted
# Install standard packages
tasksel install standard
apt-get -y autoremove --purge wamerican exim4 exim4-base exim4-config exim4-daemon-light
apt-get -y install locales localepurge postfix less lvm2 mdadm openssh-server zsh bind9
rm -f /var/lib/mdadm/CONF-UNCHECKED
# Install kernel and bootloader
apt-get install grub2 linux-image-amd64
# Stop all started services
service atd stop
service nfs-common stop
service postfix stop
service bind9 stop
service mdadm stop
service --status-all | grep +
# Leave chroot
exit
# Clean and reboot
umount /mnt/{boot,var,home,tmp}
umount /mnt/{proc,dev,sys}
reboot
@wokayme
Copy link

wokayme commented Nov 9, 2015

thank you a lot for it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment